[ncl-talk] Fortran 90 extension with wrapit

Marston Ward marston.johnston at gu.se
Fri Dec 1 11:00:56 MST 2017


Hi Mary,

I’m running into the issue where the dimensions are switched between NCL and FORTRAN.
For example, when I pass a 2D variable: GBIN(NLAT,NLON) to the fortran subroutine, I have to switch the dimensions to GBIN(NLON,NLAT).
My question is, how do I handle a 3D array which is declared B(M,N,Z) in NCL? I suspect that Z and M switches places in the fortran script?
This is assuming WRAPIT can handle higher dimensions than 2. I could not find an example in the docs.

Cheers,
/M

Marston S. Ward

On 1 Dec 2017, 16:45 +0100, Mary Haley <haley at ucar.edu>, wrote:
Hi Marston,

A tip: you can add the "-d" option to WRAPIT to get some really verbose output. This helped me see that it was this step that was causing the warning:


wrapit77 < binning_statsF90.stub > WRAPIT.c

I took a look at binning_statsF90.stub and saw two issues.

[1] There are certain rules about a stub file used with WRAPIT. One is that the "C NCLFORTSTART" and "C NCLEND" lines must start in the first column:

C NCLFORTSTART
       subroutine bin_stats(sf,nlat,nlon,missing,tb_bins,ntb_bins,
. . .
C NCLEND


[2] The "+" continuation character is starting in column 7. These have to be in column 6. This is a Fortran 77 rule. To fix, simply remove one space before the "+":

C NCLFORTSTART
       subroutine bin_stats(sf,nlat,nlon,missing,tb_bins,ntb_bins,
     +     ntb_binsc,lat_bins,nlat_bins,nlat_binsc,gbin,lsm,
     +     lat2d,outbin,outbin2)
       integer j,tb,la,jl,jk
       integer nlat_bins,ntb_bins,nlat_binsc,ntb_binsc
       integer tb_bins(ntb_bins)
       integer lat_bins(nlat_bins)
       integer nlat,nlon,sf
       real    missing
       real    gbin(nlat,nlon),lsm(nlat,nlon),lat2d(nlat,nlon)
       real    outbin(sf,ntb_binsc),
     + outbin2(sf,nlat_binsc,ntb_binsc)
C NCLEND

--Mary

On Fri, Dec 1, 2017 at 5:59 AM, Marston Ward <marston.johnston at gu.se<mailto:marston.johnston at gu.se>> wrote:
Hi,

I’ve written a F90 routine to do some heavy calculations within NCL.
I’ve followed the instructions on how to write the “stub” file: https://www.ncl.ucar.edu/Document/Tools/WRAPIT.shtml#FixingCommonProblems,
how to make sure there are no stray characters in code, as well as made sure the routine compiles as a standalone.
However, when I run WRAPIT -in  stubfile myfile.F90 I get the following, despite that the SO file is created. I’ve not yet check the SO file but wanted to
check with the NCL experts with experience in F90 routines and WRAPIT.
My files are attached and here is the error message when compiling (which is not much to go on):

$ WRAPIT -in binning_statsF90.stub binning_stats.F90

WRAPIT Version: 120209
/software/apps/comp_wrapper/intel/ifort
A syntax error occurred while parsing:
COMPILING binning_stats.F90
LINKING
END WRAPIT

Would appreciate some thoughts on what’s going on. Just to reiterate a bit. I’ve gone through the trouble shooting part of the doc and made sure I’ve not made some mistakes that WRAPIT can’t handle, but fortran can.

/M

Marston S. Ward

_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu>
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/20171201/35dd3a8b/attachment.html>


More information about the ncl-talk mailing list