Re: Strange problem using FORTRAN code in NCL

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon, 5 Oct 2009 07:33:45 -0600

You are defining "ai" to be integer in your Fortran program, but in
the NCL code, you are defining "var" to be a float, and trying to
pass this
to your Fortran routine as the "ai" array.

Try making "var" an integer:

    var = new((/180,360/),int)

--Mary

On Oct 3, 2009, at 1:45 PM, eddycarl wrote:

> Sorry, I have found the problem. It is due to the "stop" statement
> in the fortran code.
> But, I still have problem reading the correct data value. Now, I
> can get correct value of "lat" and "lon". However, the value of the
> 2d array "var", which is printed by NCL, is totally wrong (while,
> the value printed out by fortran code is correct!). So, I doubt
> whether NCL has bugs in tranfering 2d array from FORTRAN to NCL?
> Thanks for your attention!
>
> >Send ncl-talk mailing list submissions to > ncl-talk_at_ucar.edu >
> >To subscribe or unsubscribe via the World Wide Web, visit > http://
> mailman.ucar.edu/mailman/listinfo/ncl-talk >or, via email, send a
> message with subject or body 'help' to > ncl-talk-request_at_ucar.edu
> > >You can reach the person managing the list at > ncl-talk-
> owner_at_ucar.edu > >When replying, please edit your Subject line so
> it is more specific >than "Re: Contents of ncl-talk digest..." > >
> >Today's Topics: > > 1. Re: intel-mac binary 32 or 64 bit? (Jamie
> Scott) > 2. Re: intel-mac binary 32 or 64 bit? (Wei Huang) > 3.
> "Height" axis label on left in gsn_csm_pres_hgt > (Oswald
> Jason Lobo) > 4. Strange problem using FORTRAN code in NCL
> (eddycarl) > >
> >---------------------------------------------------------------------
> - > >Message: 1 >Date: Fri, 02 Oct 2009 15:39:22 -0600 >From: Jamie
> Scott <James.D.Scott_at_noaa.gov> >Subject: Re: intel-mac
> binary 32 or 64 bit? >To: Wei Huang <huangwei_at_ucar.edu>, ncl-
> talk_at_ucar.edu >Message-ID:
> <A4573765-54A2-461C-9A26-1E70B34F2885_at_noaa.gov> >Content-Type: text/
> plain; charset="us-ascii" > >Doesn't seem to be any limit to
> memory. Also "top" indicates I have >3.3GB available. > >>
> cputime unlimited >> filesize unlimited >> datasize
> 6144 kbytes >> stacksize 8192 kbytes >> coredumpsize 0 kbytes >>
> memoryuse unlimited >> descriptors 256 >> memorylocked
> unlimited >> maxproc 266 > > >-Jamie >On Oct 2, 2009, at 3:32
> PM, Wei Huang wrote: > >> Jamie, >> >> Your Mac has 8G memory, does
> not mean your NCL can use all of them. >> You may have other
> program running, such as your dock, web browser, >> finder, etc.
> >> For example, I have firefox running, which takes about 150M. >>
> >> Also, there may be per process limit on your mac, and you may >>
> use "limit" command to see if there is a limit on each process. >>
> >> Thanks, >> >> Wei Huang >> huangwei_at_ucar.edu >> VETS/CISL >>
> National Center for Atmospheric Research >> P.O. Box 3000 (1850
> Table Mesa Dr.) >> Boulder, CO 80307-3000 USA >> (303) 497-8924 >>
> >> >> >> >> >> On Oct 2, 2009, at 3:10 PM, Jamie Scott wrote: >>
> >>> I'm running the latest ncl binary for the intel-mac
> (downloaded >>> ncl_ncarg-5.1.1.MacOS_i386_9.7.0.tar from ESG),
> >>> and I'm unable to allocate more than 3.5GB before getting a
> malloc >>> error. I was allocating 200mb variables to see where
> >>> the limit was. >>> >>>> ncl(46785) malloc: *** mmap
> (size=200003584) failed (error code=12) >>>> *** error: can't
> allocate region >>>> *** set a breakpoint in malloc_error_break to
> debug >>>> fatal:NclMalloc Failed:[errno=12] >>>> fatal:New: could
> not create new array:[errno=12] >>>> br> >>> >>> So it appears this
> binary is 32-bit instead of 64. Is this the >>> case or is there
> something else wrong? If so, is it possible to >>> make a 64-bit
> binary? >>> >>> I'm using mac OS X 10.58 on and intel-mac with 8GB
> memory. >>> Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT
> 2009; >>> root:xnu-1228.15.4~1/RELEASE_I386 i386 i386 >>> >>> >>>
> Thanks, >>> >>> Jamie Scott >>>
> _______________________________________________ >>> ncl-talk
> mailing list >>> 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/20091002/13516713/attachment.html >
> >------------------------------ > >Message: 2 >Date: Fri, 2 Oct
> 2009 16:30:43 -0600 >From: Wei Huang <huangwei_at_ucar.edu> >Subject:
> Re: [ncl-talk] intel-mac binary 32 or 64 bit? >To: Jamie Scott
> <James.D.Scott_at_noaa.gov> >Cc: ncl-talk_at_ucar.edu >Message-ID:
> <0F305E77-1805-4CD7-9A67-57E7097FA38C_at_ucar.edu> >Content-Type: text/
> plain; charset="us-ascii" > >Jamie > >It seems that NCL binary for
> Mac Intel is now 32-bit. >There should be a way to build it in 64-
> bit. >As half of the NCL team will be traveling the next 3 weeks,
> >so that will take us longer to look at this. > >Thanks, > >Wei
> Huang >huangwei_at_ucar.edu >VETS/CISL >National Center for
> Atmospheric Research >P.O. Box 3000 (1850 Table Mesa Dr.) >Boulder,
> CO 80307-3000 USA >(303) 497-8924 > > > > > >On Oct 2, 2009, at
> 3:39 PM, Jamie Scott wrote: > >> Doesn't seem to be any limit to
> memory. Also "top" indicates I have >> 3.3GB available. >> >>>
> cputime unlimited >>> filesize unlimited >>> datasize
> 6144 kbytes >>> stacksize 8192 kbytes >>> coredumpsize 0 kbytes
> >>> memoryuse unlimited >>> descriptors 256 >>> memorylocked
> unlimited< /font>maxproc 266 >> >> >> -Jamie >> On Oct 2,
> 2009, at 3:32 PM, Wei Huang wrote: >> >>> Jamie, >>> >>> Your Mac
> has 8G memory, does not mean your NCL can use all of them. >>> You
> may have other program running, such as your dock, web browser,
> >>> finder, etc. >>> For example, I have firefox running, which
> takes about 150M. >>> >>> Also, there may be per process limit on
> your mac, and you may >>> use "limit" command to see if there is a
> limit on each process. >>> >>> Thanks, >>> >>> Wei Huang >>>
> huangwei_at_ucar.edu >>> VETS/CISL >>> National Center for Atmospheric
> Research >>> P.O. Box 3000 (1850 Table Mesa Dr.) >>> Boulder, CO
> 80307-3000 USA >>> (303) 497-8924 >>> >>> >>> >>> >>> >>> On Oct 2,
> 2009, at 3:10 PM, Jamie Scott wrote: >>> >>>> I'm running the
> latest ncl binary for the intel-ma c (downl >>>>
> g-5.1.1.MacOS_i386_9.7.0.tar from ESG), >>>> and I'm unable to
> allocate more than 3.5GB before getting a malloc >>>> error. I
> was allocating 200mb variables to see where >>>> the limit was.
> >>>> >>>>> ncl(46785) malloc: *** mmap(size=200003584) failed
> (error code=12) >>>>> *** error: can't allocate region >>>>> ***
> set a breakpoint in malloc_error_break to debug >>>>>
> fatal:NclMalloc Failed:[errno=12] >>>>> fatal:New: could not create
> new array:[errno=12] >>>>> br> >>>> >>>> So it appears this binary
> is 32-bit instead of 64. & nbsp;Is >>>> something else wrong? If
> so, is it possible to make a 64-bit >>>> binary? >>>> >>>> I'm
> using mac OS X 10.58 on and intel-mac with 8GB memory. >>>> Darwin
> Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; >>>>
> root:xnu-1228.15.4~1/RELEASE_I386 i386 i386 >>>> >>>> >>>> Thanks,
> >>>> >>>> Jamie Scott >>>>
> _______________________________________________ >>>> ncl-talk
> mailing list >>>> 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/20091002/fe21336b/attachment.html >
> >------------------------------ > >Message: 3 >Date: Sat, 3 Oct
> 2009 18:38:22 +0530 >From: Oswald Jason Lobo <ojlobo_at_gmail.com>
> >Subject: "Height" axis label on left in
> gsn_csm_pres_hgt >To: ncl-talk_at_ucar.edu >Message-ID: >
> <f1db919c0910030608n3b5b33bax652cefa333f991ff_at_mail.gmail.com>
> >Content-Type: text/plain; charset="iso-8859-1" > >Hi, > > > I'm
> trying to put "Height(Km)" on the left Y axis along with the
> >tickmarks using gsn_csm_pres_hgt. At present the default is the
> right Y >axis. Is there any way i can put "Height(Km)" on both the
> axis? Also i'm not >able to change the font of the "Height(Km)"
> label. > > >Thanks. >-------------- next part -------------- >An
> HTML attachment was scrubbed... >URL: http://mailman.ucar.edu/
> pipermail/ncl-talk/attachments/20091003/bbbe64f3/attachment.html >
> >------------------------------ > >Message: 4 >Date: Sun, 4 Oct
> 2009 00:12:55 +0800 (CST) >From: eddycarl <eddycarl_at_126.com>
> >Subject: Strange problem using FORTRAN code in NCL >To:
> ncl-talk <ncl-talk_at_ucar.edu> >Message-ID: >
> <8531955.116541254586375684.JavaMail.coremail_at_bj126app67.126.com>
> >Content-Type: text/plain; charset="gbk" > >Hi there, >I have a
> problem using a FORTRAN 77 code to read ASCII data into NCL to
> plot. The data I try to read is TOMS OMI aerosol index and the
> FORTRAN 77 code is provided at TOMS ftp site. I followed the steps
> in http://www.ncl.ucar.edu/Document/Tools/WRAPIT.shtml to write
> special wrapper text, run WRAPIT and load the shared object and
> call the routine. This seems to be good. But when I run my NCL
> script, it didn't show ANY result (However, it is supposed to print
> the information of the the data (for the "print(var)" command)
> which is read in, and a plot). NO error information is shown,
> either. When I add a "write" statement in the fortran code (as you
> can find in my f code), the data can be shown on the commandline
> when I run NCL. But still, there is NO result from NCL. I think
> this indicated that the f subrountine can be called by NCL, but
> there is some problem in transfering data array into NCL. I am
> wondering if anyone can help to solve this problem? Thanks! >BW: I
> used NCL Version 5.1.1 on Linux X86_64 platform. I have tested the
> ex.f and ex.ncl at WRAPIT webpage. And it can be run successfully.
> > >The fortran code to read the data: (This code is OK to run
> separately. And it needs a string as filename input) >c this
> program reads the daily gridded data for real-time OMI >c data
> for January 31, 2007. variables lat and lon contain the >c
> latitudes and longitudes of the center of each of the grid
> >c cells in the array AI. >
> >C NCLFORTSTART > subroutine read_aersl_omi(fname,lat,lon,ai)
> > character*80 header
> > integer*4 ai
> > real*4 lat(180), lon(360)
> > character*(*) fname >
> dimension ai(360,180) >C
> NCLEND > >c calculate latitudes and
> longitudes
> >c >
> dlat = 1.0 > do 10
> i=1,180 > lat(i) = -89.5
> + (i-1)*dlat >10
> continue > dlon =
> 1.0 > do 20
> i=1,360 > lon(i) = -179.5 +
> (i-1)*dlon >20
> continue
> >c >c open the
> input file
> >c >cc open
> (1,file='L3_aersl_omi_20051231.txt',status='old')
> > open(1,file=fname,status='old')
> >c
> >c read in the header lines
> >c >
> read(1,'(a80)') header > read
> (1,'(a80)') header > read
> (1,'(a80)') header
> >c >c read
> in the data into the array ozone
> >c > do 30
> i=1,180 > read(1,'(1x,25i3)')
> (ai(j,i),j=1,360) >30
> continue
> >c
> >c close the input file
> >c
> > close(1)
> >c >c
> process/print the ai data >c write(*,*)
> ai > stop >
> end > >Part of the NCL code I used: >; read multiple files >
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" > load
> "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" > load
> "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" > external
> OMI "./read_aersl_omi.so" ; fortran shared object produced by
> WRAPIT > begin > fname = "L3_aersl_omi_20051230.txt"
> > lat = new(180,float) > lon = new(360,float) >
> var = new((/180,360/),float) > > OMI::read_aersl_omi
> (fname,lat,lon,var) > print(lat) > print(lon) >
> print(var) >; ... ... following codes to plot the data > end
> >-------------- next part -------------- >An HTML attachment was
> scrubbed... >URL: http://mailman.ucar.edu/pipermail/ncl-talk/
> attachments/20091004/72fdf49e/attachment.html >
> >------------------------------ >
> >_______________________________________________ >ncl-talk mailing
> list >ncl-talk@ucar.edu >http://mailman.ucar.edu/mailman/listinfo/
> ncl-talk > > >End of ncl-talk Digest, Vol 71, Issue 6
> >***************************************
>
>
> 网易邮箱用户购物独享现金返还
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Oct 05 2009 - 07:33:45 MDT

This archive was generated by hypermail 2.2.0 : Mon Oct 05 2009 - 13:28:34 MDT