[ncl-talk] call Fortran in NCL

易路 dg1225033 at smail.nju.edu.cn
Mon Dec 8 09:06:10 MST 2014


Hi all,
I want to call Fortran in NCL to read in data, but it shows errors while run WRAPIT, would you please help me find out the resons? 

error1 ,while WRAPTI getlatlon.stub getlatlon.f90,shows:
        A syntax error occurred while parsing:
        LINKING
        END WRAPIT

erro2, while run ncl getlatlon.ncl

      warning:Could not find Init() in external file ./getlatlon.so, file not loaded
      warning:error at line 2 in file getlatlon.ncl

      fatal:syntax error: line 10 in file getlatlon.ncl before or near : 
       GETLATLON_SO:
   ----------------^

fatal:error in statement
fatal:Syntax Error in block, block not executed
fatal:error at line 16 in file getlatlon.ncl
***********fortran program**************
subroutine getlatlon (infile,nx,ny,ii,iilat,iilon)
implicit none
character*80 infile
integer:: nx,ny,ii,i,j
real:: iilat, iilon
real,allocatable::latlon(:,:)

open(10,file=infile,status='old')

allocate(latlon(nx,ny))
do j=1,ny
   read(10,*)(latlon(i,j),i=1,nx)
end do

iilat=latlon(1,ii)
iilon=latlon(2,ii)

close(10)
return
end subroutine
*************************stub file************************
C NCLFORTSTART
    SUBROUTINE getlatlon (infile,nx,ny,ii,iilat,iilon) 
       CHARACTER*80 infile
	INTEGER  nx,ny,ii
	REAL iilat,iilon
C NCLEND

********************NCL file********************************

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
external GETLATLON_SO "./getlatlon.so"

begin
infile ="./station.txt"
nx=2
ny=60
do ii=1,ny

    GETLATLON_SO::getlatlon(infile,nx,ny,ii,iilat,iilon)
    print(iilat)
    print(iilon)

end do 

end 


More information about the ncl-talk mailing list