Re: use of times = wrf_user_list_times(a)

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon, 11 Aug 2008 09:43:44 -0600 (MDT)

On Fri, 8 Aug 2008, [KOI8-R] Гузий Саша wrote:

> Dear list,
>
>
> I use ncl function from wrf "wrf_user_list_times":
>
> a = addfile(fileName,"r") ; open netcdf file
> times = wrf_user_list_times(a) ; get dates
>
> then i create array of data, and need to save it to ascii file.
> how can i include times(0) in the file name?

You can use the special "+" operator which allows you to concatenate
strings. For example:

    fileName = "name" + times(0)
    asciiwrite(fileName, result)

However, if the "times(0)" string has spaces in it, then this
may not be an ideal string to use in a file name.

> And it would be great if there were some functions to manipulate
> strings, like, taking substring, for example.

NCL is limited in the area of string subselection. We do have some
functions for handling strings, like "indStrSubset":

   http://www.ncl.ucar.edu/Document/Functions/Contributed/indStrSubset.shtml

Also, you can subscript strings if you first convert them to character
arrays:

   str = "I have more than eight characters"
   cstr = stringtochar(str) ; Convert to character array
   substr = chartostring(cstr(1:8)) ; Subscript and convert back to string
   print("substr = '" + substr + "'")

The "substr" string will be equal to " have mo".

I will add something to the new FAQ for this kind of question.

You can see a list of string manipulation routines at:

   http://www.ncl.ucar.edu/Document/Functions/string.shtml

--Mary

> Tried fortran style str(1:8) didn't work.
>
> Thank you in advance.
>
> best regards,
> Guziy Alex.
>

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Aug 11 2008 - 09:43:44 MDT

This archive was generated by hypermail 2.2.0 : Mon Aug 11 2008 - 10:00:53 MDT