<div dir="ltr"><div class="gmail_default" style="font-size:small">The problem is that the file has &quot;invisible&quot; ^M characters at the end of every line. These are carriage return characters that are sometimes carried over from Window/DOS systems.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">From the UNIX command line, you can use &quot;cat -v&quot; to see if your file has these invisible characters:</div><div class="gmail_default"><div class="gmail_default" style="font-size:12.8px"><p class="gmail-m_963428865849121580gmail-p1" style="font-size:small"><span class="gmail-m_963428865849121580gmail-s1"><font face="monospace, monospace">cat -v dale_test.f</font></span></p><p class="gmail-m_963428865849121580gmail-p1"><font face="monospace, monospace">C NCLFORTSTART^M<br>       subroutine ES (t,h,w,r,buio,ffmo,^M<br>      1                       xisio,fwio,dmco,dco)^M</font></p><p class="gmail-m_963428865849121580gmail-p1"><font face="monospace, monospace"> . . .</font></p><p class="gmail-m_963428865849121580gmail-p1"><font face="monospace, monospace">c^M<br></font><span style="font-family:monospace,monospace">       enddo^M<br></span><span style="font-family:monospace,monospace">       enddo^M<br></span><span style="font-family:monospace,monospace">       return^M<br></span><span style="font-family:monospace,monospace">    end^M</span></p></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Unfortunately, WRAPIT can&#39;t handle these characters.</div><br>If you have the &quot;dos2unix&quot; command on your machine, then you use it to fix the file:<br><br><font face="monospace, monospace">  dos2unix dale_test.f<br>  WRAPIT dale_test.f<br></font><br>If you don&#39;t have &quot;dos2unix&quot;, then you can try the UNIX &quot;tr&quot; command:</div><div class="gmail_default"><br><div class="gmail_default" style="font-size:12.8px"><font face="monospace, monospace">  tr -d &#39;\r&#39; &lt; dale_test.f &gt; dale_test_fix.f<br></font></div><div class="gmail_default" style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:small">  WRAPIT dale_test_fix.f</span><br style="font-family:monospace,monospace;font-size:small"></div><div class="gmail_default" style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:small"><br></span></div><div class="gmail_default" style="font-size:12.8px"><br></div><div class="gmail_default" style="font-size:12.8px">The documentation on WRAPIT does mention this issue, but it only mentioned the &quot;dos2unix&quot; command. I added the &quot;tr&quot; information to it as well:</div><div class="gmail_default" style="font-size:12.8px"><br></div><div class="gmail_default"><span style="font-size:12.8px"><a href="http://www.ncl.ucar.edu/Document/Tools/WRAPIT.shtml#FixingCommonProblems">http://www.ncl.ucar.edu/Document/Tools/WRAPIT.shtml#FixingCommonProblems</a></span><br></div><div class="gmail_default"><span style="font-size:12.8px"><br></span></div><div class="gmail_default"><span style="font-size:12.8px">--Mary</span></div><div class="gmail_default"><span style="font-size:12.8px"><br></span></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 13, 2017 at 9:41 AM, Alan Brammer <span dir="ltr">&lt;<a href="mailto:abrammer@albany.edu" target="_blank">abrammer@albany.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">It would be substantially easier to send the actual file along with demo NCL lines to call the fortran code.   <div><br></div><div>I just fixed about 6 errors related to spacing and the fact that you didn’t close the do loops or end the subroutine.  These were probably copy/paste errors based on your WRAPIT -d output. </div><div><br></div><div>After fixing the compiler errors, I can get the code to be called and subsequently segfault cause I passed it a bunch of missing data.  fortran code without copy paste errors attached.  It’s not clear, to me at least, where the error actually lies. </div><div><br></div><div><br></div><div><br></div><div><div><div>&gt;ncl</div><div>ncl 0&gt; external ex1 &quot;./dale_test.so&quot;</div><div>ncl 1&gt; x = new(183, float)</div><div>ncl 2&gt; ex1::ES(x,x,x,x,x,x,x,x,x,x)</div><div>Segmentation fault (core dumped)</div></div></div><div><br></div><div>Also Dennis wil have meant </div><div><span class="m_7012914035213712829Apple-tab-span" style="white-space:pre-wrap">        </span>gcc --version</div><div><br></div><div><br><div></div></div></div><br><div style="word-wrap:break-word"><div><div></div><div><br></div><div><br></div><div><br></div><div><br><div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><span class="m_-172440093099944557Apple-style-span" style="border-collapse:separate;color:rgb(0,0,0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;border-spacing:0px"><div style="word-wrap:break-word">##############################<br>Alan Brammer,<div>Post-Doc Researcher</div><div><br></div><div>Department of Atmospheric and Environmental Sciences,<br>University at Albany, State University of New York, Albany, NY, 12222<div><a href="mailto:abrammer@albany.edu" target="_blank">abrammer@albany.edu</a><br>##############################</div></div></div></span></div></div>
</div>
<br><div><blockquote type="cite"><div>On 12 Mar 2017, at 23:00, dale zuri &lt;<a href="mailto:dalezuri@gmail.com" target="_blank">dalezuri@gmail.com</a>&gt; wrote:</div><br class="m_-172440093099944557Apple-interchange-newline"><div><div dir="ltr"><div>Hi,<br><br>Please find here a program and other informations as well.<br><br></div><div>Thanks in advance.<br> <br></div><div>C NCLFORTSTART<br>      subroutine ES (t,h,w,r,buio,ffmo,<br>     1                       xisio,fwio,dmco,dco)<br>C        integer tlen<br>      dimension t(183),h(183)<br>      dimension w(183),r(183)<br>      dimension ffmo(183),xisio(183)<br>      dimension fwio(183),dmco(183)<br>      dimension buio(183),dco(183)<br>C        integer indate,yr,mon,day,hr<br>C        character*10 timez<br>C NCLEND<br>C        write(timez,&#39;(i10)&#39;) indate<br>C        read(timez,&#39;(i4,3i2)&#39;) yr,mon,day,hr<br><br><br>      call canada(t,h,w,r,buio,ffmo,<wbr>xisio,<br>     1           fwio,dmco,dco)<br><br>      return<br>      end<br><br>cccccccccccccccccccccccccccccc<wbr>cccccccccccccccccccccccccccc<br>      subroutine canada(t,h,w,r,buio,ffmo,<wbr>xisio,<br>     1           fwio,dmco,dco)<br><br>   dimension lmon(12), el(12), fl(12)<br>      dimension t(183),h(183),w(183),r(183)<br>      dimension tin(183),hin(183),win(183),<wbr>rin(183)<br>      dimension ffmc(183),dmc(183),dc(183)<br>     1          ,xisi(183),bui(183),fwi(183),<wbr>dsr(183)<br>      dimension ffmo(183),dmco(183),dco(183),<wbr>buio(183)<br>      dimension fwio(183),xisio(183)<br>c data statement<br>      data lmon / 31,28,21,30,31,30,31,31,30,31,<wbr>30,31/<br>      data el /6.5,7.5,9.0,12.8,13.9,13.9,<wbr>12.4,10.9,9.4,8.0,7.0,<br>     1         6.0/<br>      data fl /-1.6,-1.6,-1.6,.9,3.8,5.8,6.<wbr>4,5.0,2.4,.4,-1.6,<br>     1         -1.6/<br>c<br>c&amp;&amp; enter in the inital values here<br>c 3 fuel moisture codes, initialize<br>       ffmo(1) =85.5<br>       dmco(1)=6.0<br>       dco(1)=15.0<br><br>c keep track of julian day<br>            iday=90<br>c start on april 1 and go to september 30 <br>        do im=4,9<br>        do jday=1,lmon(im)<br>            iday = iday +1<br>c move the data from the array to the variable for the calculation on a given day<br>            t = tin(iday)<br>            h = hin(iday)<br>            w = win(iday)<br>            r = rin(iday)<br>c<br>c  convert m/s to km/hr<br>c      w(i,j) = w(i,j)*3.6<br>c<br>c     FINE FUEL MOISTURE CODE<br>c<br>      wmo = 147.2*(101-ffmo(iday))/(59.5+<wbr>ffmo(iday))<br>      if(r(iday)&gt;0.5) then<br>        ra=r(iday)-0.5<br>        if (ra.lt.0.1) ra = 0.1<br>        if(wmo.gt.150) then<br>          wmo= wmo+ 42.5*ra*exp(-100.0/(251-wmo))*<wbr>(1.0-exp(-6.93/ra))<br>     1      +0.0015*(wmo-150)*(wmo-150)*<wbr>sqrt(ra)<br>        else<br>          wmo=wmo+42.5*ra*exp(-100.0/(<wbr>251-wmo))*(1.0-exp(-6.93/ra))<br>        endif<br>      endif<br>      if (wmo.gt.250.) wmo = 250.<br>      ed=0.942 * h(iday)**0.679 +<br>     1          (11.0*exp((h(iday)-100.0)/10.<wbr>0)) +<br>     1    0.18 * (21.1-t(iday)) * (1.0-1.0/exp(h(iday)*0.115))<br>      ew=0.618 * h(iday)**0.753 +<br>     1       (10.0*exp((h(iday)-100.0)/10.<wbr>0)) +<br>     1    0.18 * (21.1-t(iday)) * (1.0-1.0/exp(h(iday)*0.115))<br>      if(wmo.lt.ed.and.wmo.lt.ew) then<br>        z = 0.424 * ( 1.0 - ((100.0-h(iday))/100.0)**1.7 ) +<br>     1     0.0694 * sqrt(w(iday)) * (1.0 -<br>     1  ((100.0-h(iday))/100.0)**8.0 )<br>        x = z * 0.581 * exp(0.0365*t(iday))<br>        wm = ew-(ew-wmo) / (10.0**x)<br>      elseif (wmo.gt.ed) then<br>        z = 0.424 * ( 1.0 - (h(iday)/100.)**1.7 ) + 0.0694 *<br>     1    sqrt(w(iday)) * ( 1 - (h(iday)/100)**8.0 )<br>        x = z * 0.581 * exp(0.0365*t(iday))<br>        wm = ed + ( wmo - ed) / (10.0**x)<br>      else<br> wm = wmo<br>      endif<br>      if (wm.lt.0.) wm = 0.0<br>      ffmc(iday) = 59.5 * (250.0 - wm) / (147.2 + wm)<br>      if (ffmc(iday).gt.101.0) ffmc(iday) = 101.0<br>      if (ffmc(iday).lt.0.) ffmc(iday) = 0.<br>c<br>c     DUFF MOISTURE CODE<br>c<br>      t1=t(iday)<br>      if (t(iday).lt.-1.1) t1 = -1.1<br>      rk = 1.894 * (t1 + 1.1) * (100.0 - h(iday)) * el(im) * 0.0001<br>      if(r(iday).le.1.5) then<br>        pr = dmco(iday)<br>      else<br>        ra = r(iday)<br>        rw = 0.92 * ra - 1.27<br>        wmi = 20.0 + 280.0 / exp(0.023 * dmco(iday))<br>        if(dmco(iday).le.33) then<br>          b = 100.0 / (0.5 + 0.3 * dmco(iday))<br>        elseif (dmco(iday).le.65) then<br>          b = 14.0 - 1.3 * log(dmco(iday))<br>        else<br>          b = 6.2 * log(dmco(iday)) - 17.2<br>        endif<br>        wmr = wmi + 1000.0 * rw / (48.77 + b * rw)<br>        pr = 43.43 * (5.6348 - log(wmr-20))<br>      endif<br>      if (pr.lt.0.) pr = 0.<br>      dmc(iday) = pr + rk<br>      if (dmc(iday).lt.0.) dmc(iday) = 0.<br>c<br>c     DROUGHT CODE<br><br>      t2 = t(iday)<br>      if (t(iday).lt.-2.8) t2 = -2.81<br>      pe = (.36 * (t2 + 2.8) + fl(mon)) / 2.0<br>      if (pe.lt.0.) pe = 0.0<br>c the fix for winter negative DC change<br>      if(r(iday).le.2.801) then<br>        dr = dco(iday)<br>      else<br>       ra = r(iday)<br>       rw = 0.83 * ra - 1.27<br>       smi = 800 * exp(-dco(iday) / 400)<br>       qr = smi + 3.937 * rw<br>       dr = 400 * log(800 / qr)<br>       if (dr.lt.0.) dr = 0.<br>      endif<br>      v = 0.36 * (t2 + 2.8) + fl(im)<br>      if (v.lt.0.) v = 0.<br>      dc(iday) = dr + v * 0.5<br>      if (dc(iday).lt.0.) dc(iday)=0.<br>c<br>c     INITIAL SPREAD INDEX<br>c<br>      fm = 147.2 * (101.0 - ffmc(iday)) / (59.5 + ffmc(iday))<br>      sf = 19.115 * exp(-0.1386 * fm) * (1.0 + fm**5.31 / 4.93e07)<br>      xisi(iday) = sf * exp(0.05039 * w(iday))<br>c<br>c     BUILD UP INDEX<br>c<br>      if(dmc(iday).eq.0.and.dc(iday)<wbr>.eq.0.) then<br>        bui(iday)=0<br>      elseif (dmc(iday).le.0.4*dc(iday)) then<br>        bui(iday) = 0.8 * dc(iday) * dmc(iday)<br>    1    / (dmc(iday) + 0.4 * dc(iday))<br>      else<br>        bui(iday) = dmc(iday) - (1 - 0.8 * dc(iday)<br>     1   / (dmc(iday) + 0.4 *<br>     1    dc(iday))) * (0.92 + (0.0114 * dmc(iday))** 1.7)<br>      endif<br>      if (bui(iday).lt.0.) bui(iday) = 0.0<br>c<br>c     FIRE WEATHER INDEX AND DSR<br>c<br>      if(bui(iday).gt.80.) then<br>        bb = 0.1 * xisi(iday) *<br>     1    (1000.0 / (25.0 + 108.64 / exp(0.023*bui(iday))))<br>      else<br>        bb = 0.1 * xisi(iday) * (0.626 * bui(iday)**0.809 + 2.0)<br>      endif<br>      if (bb.le.1.) then<br>        fwi(iday) = bb<br>      else<br>        fwi(iday) = exp(2.72 * (0.434 * log(bb))**0.647 )<br>      endif<br>      dsr(iday) = 0.0272 * fwi(iday)**1.77<br>c<br>      ffmo(iday)=ffmc(iday)<br>      dmco(iday)=dmc(iday)<br>      dco(iday)=dc(iday)<br>      buio(iday)=bui(iday)<br>      fwio(iday)=fwi(iday)<br>      xisio(iday)=xisi(iday)<br>c<br>       enddo<br><br><br>uname -av<br>Darwin Dale.local 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_<wbr>X86_64 x86_64<br></div>ncl -V<br><div><br>6.3.0<br>gxx --version<br>gxx: Command not found.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 12, 2017 at 6:02 AM, Dennis Shea <span dir="ltr">&lt;<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>Well, I think you would have to send the fortran code: newcffi_singlegrid.f<br><br></div>Also, the output from the following.<br><br></div>%&gt; ncl -V<br></div>%&gt; gxx--version<br></div>%&gt; uname -a<br><br>=====<br></div>Further, based on a previous email, where you wrote &quot;new to NCL&quot;, I suggest that you invest looking at NCL tutorial at:<br>   <a href="http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/" target="_blank">http://www.ncl.ucar.edu/Docume<wbr>nt/Manuals/NCL_User_Guide/</a><br><br></div>Yes, it will take some time BUT you will learn NCL.<br><br></div>Good luck<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-172440093099944557h5">On Sat, Mar 11, 2017 at 7:21 PM, dale zuri <span dir="ltr">&lt;<a href="mailto:dalezuri@gmail.com" target="_blank">dalezuri@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-172440093099944557h5"><div dir="ltr"><div><div>Hi,<br></div>WRAPIT didn&#39;t give any error. But, when I run ncl code, I get below printed warning. And also printed the WRAPIT -d output. <br><br></div><div>Please, help me to fix this bug?<br></div><div>Thank you,<br></div><div>Dale<br></div><div><br>;;;;;;;;;;;;;;;;;;;;;;;;;;;<br><br>warning:An error occurred loading the external file ./newcffi_singlegrid.so, file not loaded<br>dlopen(./newcffi_singlegrid.so<wbr>, 2): Symbol not found: _hin_<br>  Referenced from: ./newcffi_singlegrid.so<br>  Expected in: flat namespace<br> in ./newcffi_singlegrid.so<br>warning:error at line 9 in file canadafire_FWItestZeikcomp.ncl<br><br>fatal:syntax error: line 43 in file canadafire_FWItestZeikcomp.ncl before or near : <br>EX:<br>--^<br><br>fatal:error in statement<br>fatal:Syntax Error in block, block not executed<br><br></div>Output of WRAPIT -d<br>COMPILING newcffi_singlegrid.f<br>gfortran -m64 -fPIC -v -c -fno-second-underscore newcffi_singlegrid.f<br>Using built-in specs.<br>COLLECT_GCC=gfortran<br>Target: x86_64-apple-darwin15.6.0<br>Configured with: ../gcc-6.2.0/configure --enable-languages=c++,fortran --with-gmp=/usr/local<br>Thread model: posix<br>gcc version 6.2.0 (GCC) <br>COLLECT_GCC_OPTIONS=&#39;-m64&#39; &#39;-fPIC&#39; &#39;-v&#39; &#39;-c&#39; &#39;-fno-second-underscore&#39; &#39;-mmacosx-version-min=10.12.3&#39; &#39;-mtune=core2&#39;<br> /usr/local/libexec/gcc/x86_64<wbr>-apple-darwin15.6.0/6.2.0/f951 newcffi_singlegrid.f -ffixed-form -fPIC -quiet -dumpbase newcffi_singlegrid.f -m64 -mmacosx-version-min=10.12.3 -mtune=core2 -auxbase newcffi_singlegrid -version -fPIC -fno-second-underscore -fintrinsic-modules-path /usr/local/lib/gcc/x86_64-appl<wbr>e-darwin15.6.0/6.2.0/finclude -o /var/folders/60/qx8g2gvj169741<wbr>yy29b3h0hm0000gn/T//ccLtfHN9.s<br>GNU Fortran (GCC) version 6.2.0 (x86_64-apple-darwin15.6.0)<br>    compiled by GNU C version 6.2.0, GMP version 6.0.0, MPFR version 3.1.2-p10, MPC version 1.0.2, isl version none<br>GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072<br>GNU Fortran2008 (GCC) version 6.2.0 (x86_64-apple-darwin15.6.0)<br>    compiled by GNU C version 6.2.0, GMP version 6.0.0, MPFR version 3.1.2-p10, MPC version 1.0.2, isl version none<br>GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072<br>COLLECT_GCC_OPTIONS=&#39;-m64&#39; &#39;-fPIC&#39; &#39;-v&#39; &#39;-c&#39; &#39;-fno-second-underscore&#39; &#39;-mmacosx-version-min=10.12.3&#39; &#39;-mtune=core2&#39;<br> as -arch x86_64 -force_cpusubtype_ALL -o newcffi_singlegrid.o /var/folders/60/qx8g2gvj169741<wbr>yy29b3h0hm0000gn/T//ccLtfHN9.s<br>COMPILER_PATH=/usr/local/libex<wbr>ec/gcc/x86_64-apple-darwin15.6<wbr>.0/6.2.0/:/usr/local/libexec/g<wbr>cc/x86_64-apple-darwin15.6.0/6<wbr>.2.0/:/usr/local/libexec/gcc/x<wbr>86_64-apple-darwin15.6.0/:/usr<wbr>/local/lib/gcc/x86_64-apple-<wbr>darwin15.6.0/6.2.0/:/usr/<wbr>local/lib/gcc/x86_64-apple-<wbr>darwin15.6.0/<br>LIBRARY_PATH=/usr/local/lib/gc<wbr>c/x86_64-apple-darwin15.6.0/6.<wbr>2.0/:/usr/local/lib/gcc/x86_64<wbr>-apple-darwin15.6.0/6.2.0/../.<wbr>./../<br>COLLECT_GCC_OPTIONS=&#39;-m64&#39; &#39;-fPIC&#39; &#39;-v&#39; &#39;-c&#39; &#39;-fno-second-underscore&#39; &#39;-mmacosx-version-min=10.12.3&#39; &#39;-mtune=core2&#39;<br>SHARED OBJECT NAME (SharedObj): newcffi_singlegrid.so<br>LINKER SUFFIX (ld_suffix): WRAPIT.o newcffi_singlegrid.o -o newcffi_singlegrid.so<br> <br>LINKING<br>gcc -m64 -bundle -flat_namespace -undefined suppress WRAPIT.o newcffi_singlegrid.o -o newcffi_singlegrid.so -lgfortran<br>END WRAPIT<br><br><br><div>Thank you<br></div><div><br><br><br></div></div>
<br></div></div>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">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/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
______________________________<wbr>_________________<br>ncl-talk mailing list<br><a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>List instructions, subscriber options, unsubscribe:<br><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br></div></blockquote></div><br></div></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>