[Thread Prev][Thread Next][Index]

Re: [ferret_users] Size of an array in a crooked case



Hi Patrick,
Thank you for mentioning that.  Both of these were introduced way back in Ferret v5.3,

http://ferret.pmel.noaa.gov/static/Documentation/Release_Notes/v53.html, which says,
 
  • Function SPAWN executes a Unix system command and returns the result in a string array.
  •  
  • The syntax "SPAWN:"command" allows the output of a Unix command to be mixed with other strings. For example,

  •         LET a = {"first.nc", SPAWN:"ls *.nc","last.nc"}
     
As you note, the size of the string array is available from the SPAWN( ) function but not with the command. This is a difference between the way Ferret handles the result of a function, and the constant-array _expression_ using the curly braces.

Ansley

On 9/30/2014 1:37 AM, Patrick Brockmann wrote:
Hi,

Have a look to this thread.
http://www.pmel.noaa.gov/maillists/tmap/ferret_users/fu_2014/msg00255.html

So should be
yes? say `Liste_LMDZ[i=@ngd]`


Patrick

Hi again,

An additionnal comment on how to achieve this data count.
You can use the SPAWN:"command" inside a string array definition
but also use the SPAWN function.

I have noticed that their behaviour is not similar.
Here is a example:

yes? let a={spawn: "ls *.shp"}
yes? say `a,return=size`
2000
---> so use of @NGD is needed
yes? say `a[i=@ngd]`
4

yes? let a=spawn("ls *.shp")
yes? say `a,return=size`
4

For this reason, I prefer to use the SPAWN function as in the following example

yes? let listfiles=SPAWN("ls *.nc")
yes? repeat/name=N/range=1:`listfiles,return=size` ( \
...?       def sym N=`N` ;\
...?       list listfiles[i=($N)] ;\
...?       use "`listfiles[i=($N)]`";\
...? )


Regards
Patrick



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

Privacy Policy | Disclaimer | Accessibility Statement