Re: extract variables from grib: Segmentation fault

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Apr 13 2012 - 16:20:39 MDT

There's not enough information to go on here, as I don't know where it's seg faulting.

Uou can try to determine the location of the seg fault by commenting out the "begin" and "end", and then running ncl with the "-x" option:

   ncl -x yourfile.ncl

This will echo every line as it is executed, so you can see where it fails.

One possibility is that you have exceeded some large file limit, in which case you might need to call this before calling addfile to open the output file:

   setfileoption("nc","Format","LargeFile")

The other possibility is that there's some conflicting coordinate information between rain, precip, and snow.

What does a printVarSummary of all three of these variables report?

   printVarSummary(precip)
   etc.

You should remove the output file before you open it with addfile:

  outfilename = "output_precip_"+year+"_"+startday3+"_"+endday3+".nc"
  system("rm -f " + outfilename)
  outfile = addfile(outfilename,"c")
>
--Mary

On Apr 13, 2012, at 3:39 PM, Guo Zhang wrote:

> Hi,
>
> I'm trying extract variables from grib data. When I just output precip, it works pretty well. But when I added ' outfile->rain = rain
> outfile->snow = snow' , I got error: Segmentation fault. How can I fix it? Thanks.
>
> Guo
>
> The part of my script is like this:
>
> precip = new((endday-startday+1)*8,float)
> gribfiles = systemfunc("ls /d1/zhangg/GLDAS/*A"+year+day3+"*.grb")
> do ihr = 0,7
> print("Starting: "+gribfiles(ihr))
> gribfile = addfile(gribfiles(ihr), "r")
> rain = gribfile->Rainf_GDS0_SFC(416,1174)
> snow = gribfile->Snowf_GDS0_SFC(416,1174)
> precip((iday-startday)*8+ihr) = rain + snow
> end do
> delete(gribfiles)
>
> outfile = addfile("output_precip_"+year+"_"+startday3+"_"+endday3+".nc", "c")
> outfile->precip = precip
> outfile->rain = rain
> outfile->snow = snow
> _______________________________________________
> 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 Fri Apr 13 16:20:48 2012

This archive was generated by hypermail 2.1.8 : Fri Apr 20 2012 - 16:21:18 MDT