<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>
<body>
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">
Hi Mary,
<div><br>
</div>
<div>I’m running into the issue where the dimensions are switched between NCL and FORTRAN.</div>
<div>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).</div>
<div>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?</div>
<div>This is assuming WRAPIT can handle higher dimensions than 2. I could not find an example in the docs.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>/M  </div>
</div>
<div name="messageSignatureSection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">
<br>
<p class="MsoNormal"><b><i>Marston S. Ward</i></b><br>
</p>
</div>
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">
<br>
On 1 Dec 2017, 16:45 +0100, Mary Haley <haley@ucar.edu>, wrote:<br>
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #1abc9c;">
<div dir="ltr">
<div class="gmail_default" style="font-size:small">Hi Marston,</div>
<div class="gmail_default" style="font-size:small"><br>
</div>
<div class="gmail_default" style="font-size:small">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:</div>
<div class="gmail_default" style="font-size:small"><br>
</div>
<div class="gmail_default" style="font-size:small">
<p class="gmail-p1"><span class="gmail-s1">wrapit77 < binning_statsF90.stub > WRAPIT.c</span></p>
<p class="gmail-p1">I took a look at binning_statsF90.stub and saw two issues.</p>
</div>
<div class="gmail_default" style="font-size:small">[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:</div>
<div class="gmail_default" style="font-size:small"><br>
</div>
<div class="gmail_default" style="font-size:small">
<div class="gmail_default"><font face="monospace, monospace">C NCLFORTSTART</font></div>
<div class="gmail_default"><font face="monospace, monospace">       subroutine bin_stats(sf,nlat,nlon,missing,tb_bins,ntb_bins,</font></div>
<div class="gmail_default"><font face="monospace, monospace">. . .</font></div>
<div class="gmail_default"><font face="monospace, monospace">C NCLEND</font></div>
<div class="gmail_default"><br>
</div>
</div>
<div class="gmail_default" style="font-size:small"><br>
</div>
<div class="gmail_default" style="font-size:small">[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 "+":</div>
<div class="gmail_default" style="font-size:small"><br>
</div>
<div class="gmail_default">
<div class="gmail_default"><font face="monospace, monospace">C NCLFORTSTART</font></div>
<div class="gmail_default"><font face="monospace, monospace">       subroutine bin_stats(sf,nlat,nlon,missing,tb_bins,ntb_bins,</font></div>
<div class="gmail_default"><font face="monospace, monospace">     +     ntb_binsc,lat_bins,nlat_bins,nlat_binsc,gbin,lsm,</font></div>
<div class="gmail_default"><font face="monospace, monospace">     + <span style="white-space:pre">
</span>    lat2d,outbin,outbin2)</font></div>
<div class="gmail_default"><font face="monospace, monospace">       integer j,tb,la,jl,jk</font></div>
<div class="gmail_default"><font face="monospace, monospace">       integer nlat_bins,ntb_bins,nlat_binsc,ntb_binsc</font></div>
<div class="gmail_default"><font face="monospace, monospace">       integer tb_bins(ntb_bins)</font></div>
<div class="gmail_default"><font face="monospace, monospace">       integer lat_bins(nlat_bins)</font></div>
<div class="gmail_default"><font face="monospace, monospace">       integer nlat,nlon,sf</font></div>
<div class="gmail_default"><font face="monospace, monospace">       real    missing</font></div>
<div class="gmail_default"><font face="monospace, monospace">       real    gbin(nlat,nlon),lsm(nlat,nlon),lat2d(nlat,nlon)</font></div>
<div class="gmail_default"><font face="monospace, monospace">       real    outbin(sf,ntb_binsc),</font></div>
<div class="gmail_default"><font face="monospace, monospace">     + outbin2(sf,nlat_binsc,ntb_binsc)</font></div>
<div class="gmail_default"><font face="monospace, monospace">C NCLEND</font></div>
<div class="gmail_default"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default"><font face="arial, helvetica, sans-serif">--Mary</font></div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Dec 1, 2017 at 5:59 AM, Marston Ward <span dir="ltr">
<<a href="mailto:marston.johnston@gu.se" target="_blank">marston.johnston@gu.se</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;">
<div>
<div name="messageBodySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif">
Hi,
<div><br>
</div>
<div>I’ve written a F90 routine to do some heavy calculations within NCL.</div>
<div>I’ve followed the instructions on how to write the “stub” file: <a href="https://www.ncl.ucar.edu/Document/Tools/WRAPIT.shtml#FixingCommonProblems" target="_blank">https://www.ncl.ucar.<wbr>edu/Document/Tools/WRAPIT.<wbr>shtml#FixingCommonProblems</a>, </div>
<div>how to make sure there are no stray characters in code, as well as made sure the routine compiles as a standalone.</div>
<div>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</div>
<div>check with the NCL experts with experience in F90 routines and WRAPIT.</div>
<div>My files are attached and here is the error message when compiling (which is not much to go on):<br>
</div>
<div><br>
</div>
<div>
<div>$ WRAPIT -in binning_statsF90.stub binning_stats.F90</div>
<div><br>
</div>
<div>WRAPIT Version: 120209</div>
<div>/software/apps/comp_wrapper/<wbr>intel/ifort</div>
<div>A syntax error occurred while parsing:</div>
<div>COMPILING binning_stats.F90</div>
<div>LINKING</div>
<div>END WRAPIT</div>
<div><br>
</div>
</div>
<div>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. </div>
<div><br>
</div>
<div>/M</div>
</div>
<div name="messageSignatureSection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif">
<br>
<p class="MsoNormal"><b><i>Marston S. Ward</i></b><br>
</p>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</blockquote>
</div>
</body>
</html>