Re: systemfunc returning an integer

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu Feb 16 2012 - 14:07:39 MST

Hi Joe,
Until the fix gets put in, you can try using isfilepresent:

dir = "/d1/fieldData/CoSPA_INIT_CASES/ncf/MCS_grid/20100603/"
dir_check = isfilepresent(dir)
if (dir_check) then ; dir_check = True or False
     print(systemfunc("ls "+dir))
end if
Adam

On 02/16/2012 01:52 PM, Joe Grim wrote:
> Hi,
>
> I am trying to use the systemfunc function in order to check if a
> directory exists. The NCL documentation
> (http://www.ncl.ucar.edu/Document/Functions/Built-in/systemfunc.shtml)
> says that the returned array should be of type string. However, I keep
> getting it of type integer. What I am ultimately trying to do is see if
> the directory exists, and if not, create it.
>
> Here is the code snippet:
> dir_check = systemfunc("ls
> /d1/fieldData/CoSPA_INIT_CASES/ncf/MCS_grid/20100603/")
> print(dir_check)
>
> And the relevant output:
> ls: cannot access /d1/fieldData/CoSPA_INIT_CASES/ncf/MCS_grid/20100603/:
> No such file or directory
>
>
> Variable: dir_check
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : -2147483647
> (0) -2147483647
>
> It looks to me like if it returns an error message, it decides to return
> it as an integer with a missing value. Is this the way it should be?
> The problem is that I am trying to test for a string.
>
> Thanks for your help.
>
> Joe Grim

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Feb 16 14:07:51 2012

This archive was generated by hypermail 2.1.8 : Fri Feb 17 2012 - 08:50:10 MST