[ncl-talk] sub: Wrapit error...
Mary Haley
haley at ucar.edu
Mon Mar 13 15:38:09 MDT 2017
The problem is that the file has "invisible" ^M characters at the end of
every line. These are carriage return characters that are sometimes carried
over from Window/DOS systems.
>From the UNIX command line, you can use "cat -v" to see if your file has
these invisible characters:
cat -v dale_test.f
C NCLFORTSTART^M
subroutine ES (t,h,w,r,buio,ffmo,^M
1 xisio,fwio,dmco,dco)^M
. . .
c^M
enddo^M
enddo^M
return^M
end^M
Unfortunately, WRAPIT can't handle these characters.
If you have the "dos2unix" command on your machine, then you use it to fix
the file:
dos2unix dale_test.f
WRAPIT dale_test.f
If you don't have "dos2unix", then you can try the UNIX "tr" command:
tr -d '\r' < dale_test.f > dale_test_fix.f
WRAPIT dale_test_fix.f
The documentation on WRAPIT does mention this issue, but it only mentioned
the "dos2unix" command. I added the "tr" information to it as well:
http://www.ncl.ucar.edu/Document/Tools/WRAPIT.shtml#FixingCommonProblems
--Mary
On Mon, Mar 13, 2017 at 9:41 AM, Alan Brammer <abrammer at albany.edu> wrote:
> It would be substantially easier to send the actual file along with demo
> NCL lines to call the fortran code.
>
> 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.
>
> 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.
>
>
>
> >ncl
> ncl 0> external ex1 "./dale_test.so"
> ncl 1> x = new(183, float)
> ncl 2> ex1::ES(x,x,x,x,x,x,x,x,x,x)
> Segmentation fault (core dumped)
>
> Also Dennis wil have meant
> gcc --version
>
>
>
>
>
>
>
> ##############################
> Alan Brammer,
> Post-Doc Researcher
>
> Department of Atmospheric and Environmental Sciences,
> University at Albany, State University of New York, Albany, NY, 12222
> abrammer at albany.edu
> ##############################
>
> On 12 Mar 2017, at 23:00, dale zuri <dalezuri at gmail.com> wrote:
>
> Hi,
>
> Please find here a program and other informations as well.
>
> Thanks in advance.
>
> C NCLFORTSTART
> subroutine ES (t,h,w,r,buio,ffmo,
> 1 xisio,fwio,dmco,dco)
> C integer tlen
> dimension t(183),h(183)
> dimension w(183),r(183)
> dimension ffmo(183),xisio(183)
> dimension fwio(183),dmco(183)
> dimension buio(183),dco(183)
> C integer indate,yr,mon,day,hr
> C character*10 timez
> C NCLEND
> C write(timez,'(i10)') indate
> C read(timez,'(i4,3i2)') yr,mon,day,hr
>
>
> call canada(t,h,w,r,buio,ffmo,xisio,
> 1 fwio,dmco,dco)
>
> return
> end
>
> cccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
> subroutine canada(t,h,w,r,buio,ffmo,xisio,
> 1 fwio,dmco,dco)
>
> dimension lmon(12), el(12), fl(12)
> dimension t(183),h(183),w(183),r(183)
> dimension tin(183),hin(183),win(183),rin(183)
> dimension ffmc(183),dmc(183),dc(183)
> 1 ,xisi(183),bui(183),fwi(183),dsr(183)
> dimension ffmo(183),dmco(183),dco(183),buio(183)
> dimension fwio(183),xisio(183)
> c data statement
> data lmon / 31,28,21,30,31,30,31,31,30,31,30,31/
> data el /6.5,7.5,9.0,12.8,13.9,13.9,12.4,10.9,9.4,8.0,7.0,
> 1 6.0/
> data fl /-1.6,-1.6,-1.6,.9,3.8,5.8,6.4,5.0,2.4,.4,-1.6,
> 1 -1.6/
> c
> c&& enter in the inital values here
> c 3 fuel moisture codes, initialize
> ffmo(1) =85.5
> dmco(1)=6.0
> dco(1)=15.0
>
> c keep track of julian day
> iday=90
> c start on april 1 and go to september 30
> do im=4,9
> do jday=1,lmon(im)
> iday = iday +1
> c move the data from the array to the variable for the calculation on a
> given day
> t = tin(iday)
> h = hin(iday)
> w = win(iday)
> r = rin(iday)
> c
> c convert m/s to km/hr
> c w(i,j) = w(i,j)*3.6
> c
> c FINE FUEL MOISTURE CODE
> c
> wmo = 147.2*(101-ffmo(iday))/(59.5+ffmo(iday))
> if(r(iday)>0.5) then
> ra=r(iday)-0.5
> if (ra.lt.0.1) ra = 0.1
> if(wmo.gt.150) then
> wmo= wmo+ 42.5*ra*exp(-100.0/(251-wmo))*(1.0-exp(-6.93/ra))
> 1 +0.0015*(wmo-150)*(wmo-150)*sqrt(ra)
> else
> wmo=wmo+42.5*ra*exp(-100.0/(251-wmo))*(1.0-exp(-6.93/ra))
> endif
> endif
> if (wmo.gt.250.) wmo = 250.
> ed=0.942 * h(iday)**0.679 +
> 1 (11.0*exp((h(iday)-100.0)/10.0)) +
> 1 0.18 * (21.1-t(iday)) * (1.0-1.0/exp(h(iday)*0.115))
> ew=0.618 * h(iday)**0.753 +
> 1 (10.0*exp((h(iday)-100.0)/10.0)) +
> 1 0.18 * (21.1-t(iday)) * (1.0-1.0/exp(h(iday)*0.115))
> if(wmo.lt.ed.and.wmo.lt.ew) then
> z = 0.424 * ( 1.0 - ((100.0-h(iday))/100.0)**1.7 ) +
> 1 0.0694 * sqrt(w(iday)) * (1.0 -
> 1 ((100.0-h(iday))/100.0)**8.0 )
> x = z * 0.581 * exp(0.0365*t(iday))
> wm = ew-(ew-wmo) / (10.0**x)
> elseif (wmo.gt.ed) then
> z = 0.424 * ( 1.0 - (h(iday)/100.)**1.7 ) + 0.0694 *
> 1 sqrt(w(iday)) * ( 1 - (h(iday)/100)**8.0 )
> x = z * 0.581 * exp(0.0365*t(iday))
> wm = ed + ( wmo - ed) / (10.0**x)
> else
> wm = wmo
> endif
> if (wm.lt.0.) wm = 0.0
> ffmc(iday) = 59.5 * (250.0 - wm) / (147.2 + wm)
> if (ffmc(iday).gt.101.0) ffmc(iday) = 101.0
> if (ffmc(iday).lt.0.) ffmc(iday) = 0.
> c
> c DUFF MOISTURE CODE
> c
> t1=t(iday)
> if (t(iday).lt.-1.1) t1 = -1.1
> rk = 1.894 * (t1 + 1.1) * (100.0 - h(iday)) * el(im) * 0.0001
> if(r(iday).le.1.5) then
> pr = dmco(iday)
> else
> ra = r(iday)
> rw = 0.92 * ra - 1.27
> wmi = 20.0 + 280.0 / exp(0.023 * dmco(iday))
> if(dmco(iday).le.33) then
> b = 100.0 / (0.5 + 0.3 * dmco(iday))
> elseif (dmco(iday).le.65) then
> b = 14.0 - 1.3 * log(dmco(iday))
> else
> b = 6.2 * log(dmco(iday)) - 17.2
> endif
> wmr = wmi + 1000.0 * rw / (48.77 + b * rw)
> pr = 43.43 * (5.6348 - log(wmr-20))
> endif
> if (pr.lt.0.) pr = 0.
> dmc(iday) = pr + rk
> if (dmc(iday).lt.0.) dmc(iday) = 0.
> c
> c DROUGHT CODE
>
> t2 = t(iday)
> if (t(iday).lt.-2.8) t2 = -2.81
> pe = (.36 * (t2 + 2.8) + fl(mon)) / 2.0
> if (pe.lt.0.) pe = 0.0
> c the fix for winter negative DC change
> if(r(iday).le.2.801) then
> dr = dco(iday)
> else
> ra = r(iday)
> rw = 0.83 * ra - 1.27
> smi = 800 * exp(-dco(iday) / 400)
> qr = smi + 3.937 * rw
> dr = 400 * log(800 / qr)
> if (dr.lt.0.) dr = 0.
> endif
> v = 0.36 * (t2 + 2.8) + fl(im)
> if (v.lt.0.) v = 0.
> dc(iday) = dr + v * 0.5
> if (dc(iday).lt.0.) dc(iday)=0.
> c
> c INITIAL SPREAD INDEX
> c
> fm = 147.2 * (101.0 - ffmc(iday)) / (59.5 + ffmc(iday))
> sf = 19.115 * exp(-0.1386 * fm) * (1.0 + fm**5.31 / 4.93e07)
> xisi(iday) = sf * exp(0.05039 * w(iday))
> c
> c BUILD UP INDEX
> c
> if(dmc(iday).eq.0.and.dc(iday).eq.0.) then
> bui(iday)=0
> elseif (dmc(iday).le.0.4*dc(iday)) then
> bui(iday) = 0.8 * dc(iday) * dmc(iday)
> 1 / (dmc(iday) + 0.4 * dc(iday))
> else
> bui(iday) = dmc(iday) - (1 - 0.8 * dc(iday)
> 1 / (dmc(iday) + 0.4 *
> 1 dc(iday))) * (0.92 + (0.0114 * dmc(iday))** 1.7)
> endif
> if (bui(iday).lt.0.) bui(iday) = 0.0
> c
> c FIRE WEATHER INDEX AND DSR
> c
> if(bui(iday).gt.80.) then
> bb = 0.1 * xisi(iday) *
> 1 (1000.0 / (25.0 + 108.64 / exp(0.023*bui(iday))))
> else
> bb = 0.1 * xisi(iday) * (0.626 * bui(iday)**0.809 + 2.0)
> endif
> if (bb.le.1.) then
> fwi(iday) = bb
> else
> fwi(iday) = exp(2.72 * (0.434 * log(bb))**0.647 )
> endif
> dsr(iday) = 0.0272 * fwi(iday)**1.77
> c
> ffmo(iday)=ffmc(iday)
> dmco(iday)=dmc(iday)
> dco(iday)=dc(iday)
> buio(iday)=bui(iday)
> fwio(iday)=fwi(iday)
> xisio(iday)=xisi(iday)
> c
> enddo
>
>
> uname -av
> 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_X86_64 x86_64
> ncl -V
>
> 6.3.0
> gxx --version
> gxx: Command not found.
>
> On Sun, Mar 12, 2017 at 6:02 AM, Dennis Shea <shea at ucar.edu> wrote:
>
>> Well, I think you would have to send the fortran code:
>> newcffi_singlegrid.f
>>
>> Also, the output from the following.
>>
>> %> ncl -V
>> %> gxx--version
>> %> uname -a
>>
>> =====
>> Further, based on a previous email, where you wrote "new to NCL", I
>> suggest that you invest looking at NCL tutorial at:
>> http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/
>>
>> Yes, it will take some time BUT you will learn NCL.
>>
>> Good luck
>>
>> On Sat, Mar 11, 2017 at 7:21 PM, dale zuri <dalezuri at gmail.com> wrote:
>>
>>> Hi,
>>> WRAPIT didn't give any error. But, when I run ncl code, I get below
>>> printed warning. And also printed the WRAPIT -d output.
>>>
>>> Please, help me to fix this bug?
>>> Thank you,
>>> Dale
>>>
>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>
>>> warning:An error occurred loading the external file
>>> ./newcffi_singlegrid.so, file not loaded
>>> dlopen(./newcffi_singlegrid.so, 2): Symbol not found: _hin_
>>> Referenced from: ./newcffi_singlegrid.so
>>> Expected in: flat namespace
>>> in ./newcffi_singlegrid.so
>>> warning:error at line 9 in file canadafire_FWItestZeikcomp.ncl
>>>
>>> fatal:syntax error: line 43 in file canadafire_FWItestZeikcomp.ncl
>>> before or near :
>>> EX:
>>> --^
>>>
>>> fatal:error in statement
>>> fatal:Syntax Error in block, block not executed
>>>
>>> Output of WRAPIT -d
>>> COMPILING newcffi_singlegrid.f
>>> gfortran -m64 -fPIC -v -c -fno-second-underscore newcffi_singlegrid.f
>>> Using built-in specs.
>>> COLLECT_GCC=gfortran
>>> Target: x86_64-apple-darwin15.6.0
>>> Configured with: ../gcc-6.2.0/configure --enable-languages=c++,fortran
>>> --with-gmp=/usr/local
>>> Thread model: posix
>>> gcc version 6.2.0 (GCC)
>>> COLLECT_GCC_OPTIONS='-m64' '-fPIC' '-v' '-c' '-fno-second-underscore'
>>> '-mmacosx-version-min=10.12.3' '-mtune=core2'
>>> /usr/local/libexec/gcc/x86_64-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-apple-darwin15.6.0/6.2.0/finclude
>>> -o /var/folders/60/qx8g2gvj169741yy29b3h0hm0000gn/T//ccLtfHN9.s
>>> GNU Fortran (GCC) version 6.2.0 (x86_64-apple-darwin15.6.0)
>>> 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
>>> GGC heuristics: --param ggc-min-expand=100 --param
>>> ggc-min-heapsize=131072
>>> GNU Fortran2008 (GCC) version 6.2.0 (x86_64-apple-darwin15.6.0)
>>> 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
>>> GGC heuristics: --param ggc-min-expand=100 --param
>>> ggc-min-heapsize=131072
>>> COLLECT_GCC_OPTIONS='-m64' '-fPIC' '-v' '-c' '-fno-second-underscore'
>>> '-mmacosx-version-min=10.12.3' '-mtune=core2'
>>> as -arch x86_64 -force_cpusubtype_ALL -o newcffi_singlegrid.o
>>> /var/folders/60/qx8g2gvj169741yy29b3h0hm0000gn/T//ccLtfHN9.s
>>> COMPILER_PATH=/usr/local/libexec/gcc/x86_64-apple-darwin15.6
>>> .0/6.2.0/:/usr/local/libexec/gcc/x86_64-apple-darwin15.6.0/6
>>> .2.0/:/usr/local/libexec/gcc/x86_64-apple-darwin15.6.0/:/usr
>>> /local/lib/gcc/x86_64-apple-darwin15.6.0/6.2.0/:/usr/
>>> local/lib/gcc/x86_64-apple-darwin15.6.0/
>>> LIBRARY_PATH=/usr/local/lib/gcc/x86_64-apple-darwin15.6.0/6.
>>> 2.0/:/usr/local/lib/gcc/x86_64-apple-darwin15.6.0/6.2.0/../../../
>>> COLLECT_GCC_OPTIONS='-m64' '-fPIC' '-v' '-c' '-fno-second-underscore'
>>> '-mmacosx-version-min=10.12.3' '-mtune=core2'
>>> SHARED OBJECT NAME (SharedObj): newcffi_singlegrid.so
>>> LINKER SUFFIX (ld_suffix): WRAPIT.o newcffi_singlegrid.o -o
>>> newcffi_singlegrid.so
>>>
>>> LINKING
>>> gcc -m64 -bundle -flat_namespace -undefined suppress WRAPIT.o
>>> newcffi_singlegrid.o -o newcffi_singlegrid.so -lgfortran
>>> END WRAPIT
>>>
>>>
>>> Thank you
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
> _______________________________________________
> ncl-talk mailing list
> 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/20170313/86e739f5/attachment.html
More information about the ncl-talk
mailing list