[Thread Prev][Thread Next][Index]

Re: [ferret_users] How to define a variable holding directory path?

Hi -
When you use the symbol to point to the entire path including the file name, it needs to have the quote marks. So when the script adds the file name, then the incoming path symbol needs to not have quotes around it. Also Ferret parses the / as a syntax element, I think this is what makes this a bit tricky. 

Define the path symbol without quotation marks, and without the last slash:
define symbol dirname = /home/myhome/var/data/month
Then pass it into the script, maybe also with other arguments such as a month number
define symbol nmoth = `m`
if `m lt 10` then define symbol nmonth = 0`m`
go use_data ($dirname)  ($nmonth)
inside the script give the path, then the last slash, and then append the filename which might contain other symbols.
   use "($1)/sst_($2).nc"
This would open up the file /home/myhome/var/data/month/sst_01.nc .  All of this works with remote dataset URL's too,
define symbol pathname = http://ferret.pmel.noaa.gov/thredds/dodsC/data/PMEL

To make the script more readable, it's a nice idea to define a meaningful symbol inside the script rather than just referring to ($1) and ($2).  The Documentation on Writing Go Tools discusses this further.

C. Shaji wrote:
Hello All,
I would like to define a variable holding a directory path and then use it
as an argument in calling program and pass it to the main programto use it
there. Can somebody suggest me the correct format to do this?

For eg. in the calling program
define symbol dirname = "?DATA/...../month"

Thanks in advance,
C. Shaji


[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement