<div dir="ltr"><div><div>If you are learning NCL, Please see some documentation and tutorials at<br><br><a href="http://www.ncl.ucar.edu">http://www.ncl.ucar.edu</a><br><br></div>CLick 'Suoort', then click 'Manuals'<br><br></div>See the two tutorials created by DKRZ<br><br><br><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 9, 2014 at 3:40 AM, 易路 <span dir="ltr"><<a href="mailto:dg1225033@smail.nju.edu.cn" target="_blank">dg1225033@smail.nju.edu.cn</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
Thank you very much the Fortran code can be called , after eliminating the possible "dos" characters using “dos2unix”!<br>
<br>
And it is very right and simple to replace the frotran calling by using asciiread, I did not know that method before.<br>
<br>
Thanks very much for reminding of the application of "asciiread", and I also learned the use of "asciiwrite","numAsciiCol","numAsciiRow". Thank you very much!!<br>
<span class=""><br>
----- 原始邮件 -----<br>
发件人: Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>><br>
收件人: 易路 <<a href="mailto:dg1225033@smail.nju.edu.cn">dg1225033@smail.nju.edu.cn</a>><br>
抄送: <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
</span>已发送邮件: Tue, 09 Dec 2014 13:16:20 +0800 (CST)<br>
主题: Re: 回复: Re: [ncl-talk] call Fortran in NCL<br>
<div class="HOEnZb"><div class="h5"><br>
I think you have a hidden illegal character.<br>
There is a 'dos' character. Use dos2unix to eliminate the character.<br>
<br>
ot there<br>
<br>
%> WRAPIT getlatlon.stub<br>
<br>
WRAPIT Version: 120209<br>
A syntax error occurred while parsing:<br>
LINKING<br>
END WRAPIT<br>
<br>
%> dos2unix getlatlon.stub<br>
<br>
dos2unix: converting file getlatlon.stub to Unix format ...<br>
<br>
%> WRAPIT getlatlon.stub<br>
<br>
WRAPIT Version: 120209<br>
LINKING<br>
END WRAPIT<br>
<br>
+++++++++++++++<br>
I do not know why you are reading in fortran.<br>
It is easy in NCL<br>
++++++++++++++++<br>
<br>
diri = "./"<br>
fili = "station.txt"<br>
<br>
ncol = 2<br>
nrow = numAsciiRow(diri+fili) ; determine # or rows<br>
<br>
latlon = asciiread(diri+fili, (/nrow,ncol/), "float")<br>
lat = latlon(:,0)<br>
lon = latlon(:,1)<br>
<br>
print(lat+" "+lon)<br>
<br>
<br>
<br>
On Mon, Dec 8, 2014 at 8:22 PM, 易路 <<a href="mailto:dg1225033@smail.nju.edu.cn">dg1225033@smail.nju.edu.cn</a>> wrote:<br>
<br>
><br>
> ----- 转发邮件 -----<br>
> 发件人: 易路 <<a href="mailto:dg1225033@smail.nju.edu.cn">dg1225033@smail.nju.edu.cn</a>><br>
> 收件人: Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>><br>
> 已发送邮件: Tue, 09 Dec 2014 11:21:15 +0800 (CST)<br>
> 主题: 回复: Re: [ncl-talk] call Fortran in NCL<br>
><br>
> Thanks very much for your remind of statements must starting in column 7,<br>
> but it still show error:<br>
><br>
> A syntax error occurred while parsing:<br>
> COMPILING getlatlon.f90<br>
> END WRAPIT<br>
><br>
> would you please help me check it again? Thanks a lot!<br>
><br>
> ----- 原始邮件 -----<br>
> 发件人: Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>><br>
> 收件人: 易路 <<a href="mailto:dg1225033@smail.nju.edu.cn">dg1225033@smail.nju.edu.cn</a>><br>
> 抄送: <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
> 已发送邮件: Tue, 09 Dec 2014 01:25:12 +0800 (CST)<br>
> 主题: Re: [ncl-talk] call Fortran in NCL<br>
><br>
> Remember f77 requires that statements must start in column 7.<br>
><br>
> Your SUBROUTINE statement started befor column 7.<br>
> I've made a 2nd stub file to illustrate how to include<br>
> a more general CHARACTER declaration.<br>
><br>
> ===> foo.stub<br>
><br>
> C NCLFORTSTART<br>
> SUBROUTINE getlatlon (infile,nx,ny,ii,iilat,iilon)<br>
> CHARACTER*80 infile<br>
> INTEGER nx,ny,ii<br>
> REAL iilat,iilon<br>
> C NCLEND<br>
> C NCLFORTSTART<br>
> SUBROUTINE getlatlon1(infile,nx,ny,ii,iilat,iilon)<br>
> CHARACTER*(*) infile<br>
> INTEGER nx,ny,ii<br>
> REAL iilat,iilon<br>
> C NCLEND<br>
><br>
> =====<br>
><br>
> WRAPIT foo.stub<br>
><br>
> WRAPIT Version: 120209<br>
> LINKING<br>
> END WRAPIT<br>
><br>
><br>
><br>
> On Mon, Dec 8, 2014 at 9:06 AM, 易路 <<a href="mailto:dg1225033@smail.nju.edu.cn">dg1225033@smail.nju.edu.cn</a>> wrote:<br>
><br>
> > Hi all,<br>
> > I want to call Fortran in NCL to read in data, but it shows errors while<br>
> > run WRAPIT, would you please help me find out the resons?<br>
> ><br>
> > error1 ,while WRAPTI getlatlon.stub getlatlon.f90,shows:<br>
> > A syntax error occurred while parsing:<br>
> > LINKING<br>
> > END WRAPIT<br>
> ><br>
> > erro2, while run ncl getlatlon.ncl<br>
> ><br>
> > warning:Could not find Init() in external file ./getlatlon.so, file<br>
> > not loaded<br>
> > warning:error at line 2 in file getlatlon.ncl<br>
> ><br>
> > fatal:syntax error: line 10 in file getlatlon.ncl before or near :<br>
> > GETLATLON_SO:<br>
> > ----------------^<br>
> ><br>
> > fatal:error in statement<br>
> > fatal:Syntax Error in block, block not executed<br>
> > fatal:error at line 16 in file getlatlon.ncl<br>
> > ***********fortran program**************<br>
> > subroutine getlatlon (infile,nx,ny,ii,iilat,iilon)<br>
> > implicit none<br>
> > character*80 infile<br>
> > integer:: nx,ny,ii,i,j<br>
> > real:: iilat, iilon<br>
> > real,allocatable::latlon(:,:)<br>
> ><br>
> > open(10,file=infile,status='old')<br>
> ><br>
> > allocate(latlon(nx,ny))<br>
> > do j=1,ny<br>
> > read(10,*)(latlon(i,j),i=1,nx)<br>
> > end do<br>
> ><br>
> > iilat=latlon(1,ii)<br>
> > iilon=latlon(2,ii)<br>
> ><br>
> > close(10)<br>
> > return<br>
> > end subroutine<br>
> > *************************stub file************************<br>
> > C NCLFORTSTART<br>
> > SUBROUTINE getlatlon (infile,nx,ny,ii,iilat,iilon)<br>
> > CHARACTER*80 infile<br>
> > INTEGER nx,ny,ii<br>
> > REAL iilat,iilon<br>
> > C NCLEND<br>
> ><br>
> > ********************NCL file********************************<br>
> ><br>
> > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>
> > external GETLATLON_SO "./getlatlon.so"<br>
> ><br>
> > begin<br>
> > infile ="./station.txt"<br>
> > nx=2<br>
> > ny=60<br>
> > do ii=1,ny<br>
> ><br>
> > GETLATLON_SO::getlatlon(infile,nx,ny,ii,iilat,iilon)<br>
> > print(iilat)<br>
> > print(iilon)<br>
> ><br>
> > end do<br>
> ><br>
> > end<br>
> > _______________________________________________<br>
> > ncl-talk mailing list<br>
> > List instructions, subscriber options, unsubscribe:<br>
> > <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
> ><br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>