[Thread Prev][Thread Next][Index]

Re: [ferret_users] test_opendap() on file not in ./



Hi Marco,
The TEST_OPENDAP function checks the existence and status of the file or url but does not take into account the paths named in the environment variable FER_DATA. So for a file, it checks only the local directory, and returns the code for file-not-found. The USE command does search the paths in FER_DATA.

One test from the Ferret command line for existence of a file would be to set MODE IGNORE_ERROR, try to  open the file, and then check the symbol FER_LAST_ERROR:
set mode ignore
use levitus_climatology
if ($FER_LAST_ERROR"0|*>1") THEN
   say file error: ($FER_LAST_ERROR)
   cancel symbol fer_last_error
else
   ...
endif

cancel mode ignore
There is also the Unix command-line tool Fdata:
> Fdata levitus_climatology
* * * * * * * * in /home/users/tmap/ferret/linux/fer_dsets/data
-rwxr-xr-x. 1 tmap oerdnewp 10373712 Oct 20  2010 levitus_climatology.cdf

> Fdata nofile.nc
No files matching 'nofile.nc' were found
Another option might be to do something with Ferret's SPAWN command to run Fdata and check the result.

-Ansley

On 2/23/2016 6:19 AM, Marco van Hulten wrote:
Hello,

I would like to use test_opendap() on a local file that is in
${FER_DATA} but not in the current directory:

    yes? say `test_opendap("levitus_climatology.cdf")`
    2

The return code 2 should mean the file does not exist.  However,

    yes? use "levitus_climatology.cdf"
    yes? sh data
         currently SET data sets:
        1> /usr/local/install/ferret-6.9.6/data/levitus_climatology.cdf
        (default) name     title                             I
        J         K         L         M         N TEMP
        TEMPERATURE                      1:360     1:180
        1:20      ...       ...       ... SALT
        SALINITY                         1:360     1:180
        1:20      ...       ...       ...

If I put the file in the current directory (where I start Ferret),
test_opendap() returns zero (no error).

Is this a bug?

Is there another way to gracefully test the existence and sanity of a
NetCDF file in Ferret?

Marco



[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement