Re: addfile question

From: David Ian Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Mon, 4 Jun 2007 13:27:39 -0600

Hi Matt,

There is no general facility in NCL currently for responding to errors
in the way you would like.
It is something that is on our to-do list however, and hopefully we can
make time for it fairly soon.

I should point out that this particular message does not necessarily
mean that the file is unusable.
This message only means that NCL found what looked like a valid GRIB
record (it found an instance of the characters
"GRIB", which indicates the start of a GRIB record), but from that
point to the the end of the file is less than what the record
itself indicates should be its size. There could be many valid GRIB
records before this point is reached, and the file could
be mostly correct.

If no valid records were found in the file then NCL will return a
missing value for the file variable. To check for this
case you can use the construct:

if (ismissing(f)) then
  ; skip to next file
end if

If there were some good records, then you will need to check to see if
the file contains the variables you want,
probably using getfilevarnames. However, note that it is still
possible that some records of the variable could be
missing (either because of file corruption or because that's just the
way the file was written, NCL has no way to
tell the difference). When a record is missing, a warning about it is
issued, and if you try to access those elements of
the variable, you will get missing values.

We definitely are aware that NCL's behavior is not ideal in regard to
error handling, and we hope we can correct
this before too long.
  -dave

On Jun 1, 2007, at 11:22 AM, Matt Fearon wrote:

> Dear NCL Users:
>
> When I use addfile on a particular grib file, ie,
> f=addfile(test.grb,"r"), I receive the following error message:
>
> fatal:Premature end-of-file, file appears to be truncated
>
> I realize this is a problem with the file. However, is there an easy
> method to check for this error so my script
> will not crash. I would like to be able to skip such files. I have
> tried the following, but have been
> unsuccessful;
>
> if (any(f.eq."fatal")) then
> print("file truncated, skip to next file")
> end if
>
> Any suggestions would be greatly appreciated.
> thanks,
> Matt
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jun 04 2007 - 13:27:39 MDT

This archive was generated by hypermail 2.2.0 : Tue Jun 05 2007 - 16:18:21 MDT