You should change your signature to
void test_func(float a[], int arraylength);
Not only are you passing the wrong datatype, you are also reading more memory, then you passed in, which accounts for the garbage.
real
is 4 bytes and double
is 8 bytes, so you are reading twice as much memory beyond your array limit as you passed in which will cause undefined behaviour.
Another good idea would be to pass the length of the array as well. I don't know how this is in Fortran
, but in C
you are just reading a pointer, without any information how long that array is.