Hi Matt,
Here is something that might do what you want:
temp = systemfunc("ls *.grb")
if (any(temp.eq."test.grb")) then
print("File found, reading in")
a = addfile("test.grb","r")
else
print("File not found, exiting")
exit
end if
Adam
> Delivered-To: asphilli AT ucar.edu
> Delivered-To: ncl-talk AT ucar.edu
> Date: Fri, 11 Apr 2003 14:52:14 -0400
> From: Matt Fearon <matthew.fearon AT unh.edu>
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2)
Gecko/20021120 Netscape/7.01
> X-Accept-Language: en-us, en
> MIME-Version: 1.0
> To: ncl-talk AT ucar.edu
> Content-Transfer-Encoding: 7bit
> Subject: testing if files exist
> X-BeenThere: ncl-talk AT ucar.edu
> X-Mailman-Version: 2.0.13
> List-Help: <mailto:ncl-talk-request AT ucar.edu?subject=help>
> List-Post: <mailto:ncl-talk AT ucar.edu>
> List-Subscribe: <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>,
<mailto:ncl-talk-request AT ucar.edu?subject=subscribe>
> List-Id: NCAR Command Language User Group <ncl-talk.ucar.edu>
> List-Unsubscribe: <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>,
<mailto:ncl-talk-request AT ucar.edu?subject=unsubscribe>
> X-Spam-Status: No, hits=-3.2 required=5.0
tests=NOSPAM_INC,SPAM_PHRASE_01_02,USER_AGENT,
USER_AGENT_MOZILLA_UA,X_ACCEPT_LANG version=2.41
> X-Spam-Level:
>
> 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
-------------------------------------------------------------
Adam Phillips email: asphilli AT ucar.edu
Climate and Global Dynamics Division tel: (303) 497-1726
National Center for Atmospheric Research fax: (303) 497-1333
P.O. Box 3000
Boulder, CO 80307-3000 http://www.cgd.ucar.edu/~asphilli
_______________________________________________
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