I'm trying to call routines in the SHTOOLS library (written in fortran 95) from C. For example, one routine is:
subroutine PreCompute(lmax, zero, w, plx, wisdom_file, norm, csphase, cnorm)
integer, intent(in) :: lmax
real*8, intent(out) :: zero), w)
real*8, intent(out), optional :: plx,
integer, intent(in), optional :: norm, csphase, cnorm
character(*), intent(in), optional :: wisdom_file
if (size(zero) < lmax+1) then
print*, "Error --- PreCompute"
...
Now when I call from C, I use the standard:
int lmax;
double *zero = malloc(...);
precompute_(&lmax, zero, ...)
but apparantly fortran 95 needs to know the size of the 'zero' array since it checks size(zero) etc. Needless to say, this check fails since it doesn't have size information on 'zero'.
My question is, how do you properly pass arrays to fortran 95? How do you specify these size/dimension parameters in the call?
subroutine PreCompute(lmax, zero, w, plx, wisdom_file, norm, csphase, cnorm)
integer, intent(in) :: lmax
real*8, intent(out) :: zero), w)
real*8, intent(out), optional :: plx,
integer, intent(in), optional :: norm, csphase, cnorm
character(*), intent(in), optional :: wisdom_file
if (size(zero) < lmax+1) then
print*, "Error --- PreCompute"
...
Now when I call from C, I use the standard:
int lmax;
double *zero = malloc(...);
precompute_(&lmax, zero, ...)
but apparantly fortran 95 needs to know the size of the 'zero' array since it checks size(zero) etc. Needless to say, this check fails since it doesn't have size information on 'zero'.
My question is, how do you properly pass arrays to fortran 95? How do you specify these size/dimension parameters in the call?