[ncl-talk] 回复: Re: call Fortran in NCL

Dennis Shea shea at ucar.edu
Mon Dec 8 22:16:20 MST 2014


I think you have a hidden  illegal character.
There is a 'dos' character. Use dos2unix to eliminate the character.

ot there

%> WRAPIT getlatlon.stub

WRAPIT Version: 120209
A syntax error occurred while parsing:
LINKING
END WRAPIT

 %> dos2unix getlatlon.stub

dos2unix: converting file getlatlon.stub to Unix format ...

%> WRAPIT getlatlon.stub

WRAPIT Version: 120209
LINKING
END WRAPIT

+++++++++++++++
I do not know why you are reading in fortran.
It is easy in NCL
++++++++++++++++

  diri = "./"
  fili = "station.txt"

  ncol = 2
  nrow = numAsciiRow(diri+fili)  ; determine # or rows

  latlon = asciiread(diri+fili, (/nrow,ncol/), "float")
  lat    = latlon(:,0)
  lon    = latlon(:,1)

  print(lat+"  "+lon)



On Mon, Dec 8, 2014 at 8:22 PM, 易路 <dg1225033 at smail.nju.edu.cn> wrote:

>
> ----- 转发邮件 -----
> 发件人: 易路 <dg1225033 at smail.nju.edu.cn>
> 收件人: Dennis Shea <shea at ucar.edu>
> 已发送邮件: Tue, 09 Dec 2014 11:21:15 +0800 (CST)
> 主题: 回复: Re: [ncl-talk] call Fortran in NCL
>
> Thanks very much for your remind of statements must starting in column 7,
> but it still show error:
>
> A syntax error occurred while parsing:
> COMPILING getlatlon.f90
> END WRAPIT
>
> would you please help me check it again? Thanks a lot!
>
> ----- 原始邮件 -----
> 发件人: Dennis Shea <shea at ucar.edu>
> 收件人: 易路 <dg1225033 at smail.nju.edu.cn>
> 抄送: ncl-talk at ucar.edu
> 已发送邮件: Tue, 09 Dec 2014 01:25:12 +0800 (CST)
> 主题: Re: [ncl-talk] call Fortran in NCL
>
> 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/c0db0253/attachment.html 


More information about the ncl-talk mailing list