Re: testing if files exist

From: Dave Brown (dbrown AT XXXXXX)
Date: Fri Apr 11 2003 - 13:34:10 MDT


There's nothing built in to NCL but you could use the shell:

testfile = "test.grb"
t = systemfunc("sh -c 'if test -f " + testfile + "; then echo 1; else echo 0; fi'")
if (t .eq. 1) then
        f = addfile ... etc.

Not very pretty, I guess, but I think it works.
 -dave

On Fri, 11 Apr 2003, Matt Fearon wrote:

> dear ncl users:
>
> is there a way to test if a file exists and print that result? for example,
> if i have the following statements where "test.grb" doesn't exist
>
> f=addfile("test.grb","r")
> print(f)
>
> with this, i receive a fatal error, but "f" still prints a missing value. is
> there a way to check if "test.grb" exists before i use addfile?
> suggestions are much appreciated.
> thank you,
> 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



This archive was generated by hypermail 2b29 : Fri Apr 11 2003 - 13:49:06 MDT