Results 1 to 3 of 3
Hey guys,
I'm having issues using some of the Fortran 90 Numerical Recipe modules. Specifically I just wanted to try use the hello_bessel program on page 936. The code for ...
- 06-21-2011 #1Just Joined!
- Join Date
- Apr 2010
- Posts
- 15
Problems with Fortran 90 NR
Hey guys,
I'm having issues using some of the Fortran 90 Numerical Recipe modules. Specifically I just wanted to try use the hello_bessel program on page 936. The code for the program is as follows:
the nr module is very long but the flmoon and the bessj0 interfaces look like this:Code:PROGRAM hello_bessel USE nrtype USE nr, ONLY: flmoon, bessj0 IMPLICIT NONE INTEGER(I4B) :: n=200,nph=2,jd REAL(SP) :: x,frac,ans call flmoon(n,nph,jd,frac) x=jd**0.24_sp ans=bessj0(x) write(*,*) 'Hello, Bessel: ', ans END PROGRAM
Code:INTERFACE SUBROUTINE flmoon(n,nph,jd,frac) USE nrtype INTEGER(I4B), INTENT(IN) :: n,nph INTEGER(I4B), INTENT(OUT) :: jd REAL(SP), INTENT(OUT) :: frac END SUBROUTINE flmoon END INTERFACEWhen I try and compile I've tried a number of different commands but I'm pretty sure the right way to do it would be to do:Code:INTERFACE bessj0 FUNCTION bessj0_s(x) USE nrtype REAL(SP), INTENT(IN) :: x REAL(SP) :: bessj0_s END FUNCTION bessj0_s !BL FUNCTION bessj0_v(x) USE nrtype REAL(SP), DIMENSION(:), INTENT(IN) :: x REAL(SP), DIMENSION(size(x)) :: bessj0_v END FUNCTION bessj0_v END INTERFACE
But whenever I do that I get:Code:ifort nrtype.f90 nr.f90 hello_bessel.f90
Code:/tmp/ifortzYtJmW.o(.text+0x2f): In function `MAIN__': : undefined reference to `flmoon_' /tmp/ifortzYtJmW.o(.text+0x54): In function `MAIN__': : undefined reference to `bessj0_s_'
Any suggestions on where I'm going wrong?
- 06-23-2011 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
I'm not familiar with ifort - is that an Intel compiler? Usually I and my physicist wife use the gnu f77 compiler. Have you tried that?
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-24-2011 #3Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
I created stub routines for flmoon, and bessj0_[sv] based on the interfaces. Here is a driver script that shows the high points:
producing:Code:#!/usr/bin/env bash # @(#) s1 Demonstrate compile with ifort, link, stub, execute. # Utility functions: print-as-echo, print-line-with-visual-space, debug. # export PATH="/usr/local/bin:/usr/bin:/bin" pe() { for _i;do printf "%s" "$_i";done; printf "\n"; } pl() { pe;pe "-----" ;pe "$*"; } db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; } db() { : ; } C=$HOME/bin/context && [ -f $C ] && $C version ifort rm -f *.o *.mod a.out pl " Source files present:" ls *.f90 pl " Sample stub, flmoon.f90:" cat flmoon.f90 pl " Compile, link:" ifort nrtype.f90 nr.f90 hello_bessel.f90 bessj0_s.f90 bessj0_v.f90 flmoon.f90 pl " Results:" ./a.out # Cleanup. rm -f *.o *.mod a.out exit 0
So if your results are missing routines, how is my procedure different from yours? Perhaps that mine included the compile of flmoon, etc? ... cheers, drlCode:% ./s1 Environment: LC_ALL = C, LANG = C (Versions displayed with local utility "version") OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64 Distribution : Debian GNU/Linux 5.0.8 (lenny) GNU bash 3.2.39 ifort (IFORT) 11.1 20090827 ----- Source files present: bessj0_s.f90 bessj0_v.f90 flmoon.f90 hello_bessel.f90 nr.f90 nrtype.f90 ----- Sample stub, flmoon.f90: SUBROUTINE flmoon(n,nph,jd,frac) USE nrtype INTEGER(I4B), INTENT(IN) :: n,nph INTEGER(I4B), INTENT(OUT) :: jd REAL(SP), INTENT(OUT) :: frac jd =0 frac = 0.0 END SUBROUTINE flmoon ----- Compile, link: ----- Results: Hello, Bessel: 0.000000000000000E+000
Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )


Reply With Quote