I'm writing a code with Fortran 90 and now I need to use the special functions in the*amos Fotran 77 library(http://www.netlib.org/amos/). Now I found a module interface for those routines(https://github.com/certik/fortran-utils/blob/master/src/amos.f90).
My question is: how can I combine them and use them in my Fortran 90 program and how to compile them correctly?
I have been struggling for this for one whole day and still could not figure it out.
The following is my test code:
PROGRAM TEST_ZBESI
USE set_precisions
USE amos
IMPLICIT NONE
INTEGER :: n, i, nz, ierr
!double precision :: zr,zi, cyr(5), cyi(5)
REAL(kind=DBL) :: zr, zi, cyr(5), cyi(5)
n=5
zr=1.0_DBL
zi=2.0_DBL
call ZBESI(zr,zi,0.0_DBL,1,n,cyr,cyi,nz,ierr)
print *,' '
do i=1, n
write(*,10) i-1, cyr(i)
write(*,11) i-1, cyi(i)
end do
print *,' NZ=', NZ
print *,' Error code:', ierr
print *,' '
10 format(' zr(',I1,') = ',F10.6)
11 format(' zi(',I1,') = ',F10.6)
END PROGRAM TEST_ZBESI
The result I got is the following:
zr(0) = 0.000000
zi(0) = 0.000000
zr(1) = 0.000000
zi(1) = 0.000000
zr(2) = 0.000000
zi(2) = 0.000000
zr(3) = 0.000000
zi(3) = 0.000000
zr(4) = 0.000000
zi(4) = 0.000000
NZ= 0
Error code: 4
It seems I could not get the correct answer no matter how.
I tried to convert the ZBESI.f Fortran 77 code to Fortran 90 code by hand. But the code is so long and it was a disaster.