[Thread Prev][Thread Next][Index]

Re: [ferret_users] placing the attribute name (a string) into a file's name

Thank you for the help, Ansley.


On Thu, Apr 20, 2017 at 9:44 AM, Ansley C. Manke <ansley.b.manke@xxxxxxxx> wrote:
Hi Paul,
Here's a syntax for naming your file:

yes? let station = ..station_name
yes? let filename = "`station`.dat"
 !-> DEFINE VARIABLE filename = "Acapulco.dat"

Or just,

yes? list/file="`station`.dat" ...

We don't have all the flexibility in writing string variables to ascii text files that one might want.  But because you want to write the same string to all the records in this LIST command, we can set it up using the LIST/FORMAT= , doing something like this

yes? list/file=`filename`/format=(F8.4, " `station`")
 !-> list/file=Acapulco.dat/format=(f8.4, " Acapulco") ssh

and the file will have

 1.1234 Acapulco
 1.2345 Acapulco
 1.3456 Acapulco
 1.4444 Acapulco

Another option would be to use /precision=  instead of /format= . This will be needed if station is a string variable that's changing along with the numeric variables you're writing; but gives less control over the exact format.

   list/file=`filename`/norow/precision=6 ssh, station

which gives you,

  1.12340 "Acapulco"
  1.23450 "Acapulco"
  1.34560 "Acapulco"
  1.44440 "Acapulco"

On 4/19/2017 6:14 PM, Paul Goddard wrote:

I am having trouble with how to use strings;....and how to word my question, so I will provide an annotated example:

My data contains an attribute for station_name

Yes?   let station = ..station_name
Yes?   list/nohead station

I would like to use this string, "Acapulco" in two ways:
1\  I want to insert the string into the name of a file, such that when I am using a repeat loop
     the program will do something like:

Yes? list/format=(2f8.4)/file = `station`.dat  SSH
      !-> list/format=(2f8.4)/file =Acapulco.dat SSH

2\  I also want the string to become a variable so that when I save my data file, one of the columns says Acapulco and next to it will be the SSH value.... so something like:

Yes? list/format=(2f8.4)/file = `station`.dat `station`,SSH
      !-> list/format=(2f8.4)/file = Acapulco.dat Acapulco,SSH

Thanks in advance,

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

Privacy Policy | Disclaimer | Accessibility Statement