[ncl-talk] call Fortran in NCL

Dennis Shea shea at ucar.edu
Mon Dec 8 10:25:12 MST 2014


Remember f77 requires that statements must start in column 7.

Your SUBROUTINE statement started befor column 7.
I've made a 2nd stub file to illustrate how to include
a more general CHARACTER declaration.

===> foo.stub

C NCLFORTSTART
      SUBROUTINE getlatlon (infile,nx,ny,ii,iilat,iilon)
       CHARACTER*80 infile
        INTEGER  nx,ny,ii
        REAL iilat,iilon
C NCLEND
C NCLFORTSTART
      SUBROUTINE getlatlon1(infile,nx,ny,ii,iilat,iilon)
       CHARACTER*(*) infile
        INTEGER  nx,ny,ii
        REAL iilat,iilon
C NCLEND

=====

WRAPIT foo.stub

WRAPIT Version: 120209
LINKING
END WRAPIT



On Mon, Dec 8, 2014 at 9:06 AM, 易路 <dg1225033 at smail.nju.edu.cn> wrote:

> 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
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141208/e9732be6/attachment.html 


More information about the ncl-talk mailing list