[gradsusr] Running the same command over multiple files

James T. Potemra jimp at hawaii.edu
Fri Dec 10 13:14:05 EST 2010


Shay:

Let's say your ctl files are of the form sample1.ctl, sample2.ctl, 
sample3.ctl... sample9.ctl.  The
script would look something like

i = 1
while ( i <= 9 )
  'open sample'%i
  'd u'
  'd v'
  'reinit'
  i = i + 1
endwhile

Note that if you don't "reinit" you'll have to specify the variable from 
each ctl file (e.g.,
instead of just 'd u' it would be 'd u.1' for the first file, 'd u.2' 
for the second, and so on.
Also, without a reinit you could run out of memory.  Also, you might 
have to add some
if/then lines for cases like "sample01.ctl", e.g., "open sample0'%i" if 
i is less than 10.
Hope that works.

Jim

PS there are some good doc pages on the grads site for commands like 
"reinit" and
for the scripting language.

shay barner wrote:
> Thanks Tatiana,
>
> But the problem is I have around 700 files to open...
> How can I use a script to open all the files in a loop?
>
> Thanks in advance!
>
>
> On Fri, Dec 10, 2010 at 5:57 PM, Tatiana.Gonzalez 
> <Tatiana.Gonzalez at noaa.gov <mailto:Tatiana.Gonzalez at noaa.gov>> wrote:
>
>     Shay,
>     It's easier if you do it in a grad script.
>     http://www.iges.org/grads/gadoc/script.html
>
>     *open file1
>     'open .file1.ctl'
>     *open file2
>     'open .file2.ctl'
>     *open file3
>     'open .file3.ctl'
>     d u
>     d v
>     d u.2   //this handles file 2 etc
>     d v.2
>     d u.3
>     d v.3
>     you can also use a loop to open all the files, but if you only
>     have a few this will work
>
>     Tatiana
>
>
>     On 12/10/2010 10:13 AM, shay barner wrote:
>>     Hi!
>>
>>     I have multiple ctl files (700!) and I want to run the same
>>     command over all these files.
>>
>>     For each file I want to run:
>>     open filename
>>     d u
>>     d v
>>
>>     I am not very experienced with Linux and Grads...
>>     how can I do this in a sctipt? What are the commands?
>>
>>     Thanks!
>>     Shay.
>>
>>
>>     _______________________________________________
>>     gradsusr mailing list
>>     gradsusr at gradsusr.org <mailto:gradsusr at gradsusr.org>
>>     http://gradsusr.org/mailman/listinfo/gradsusr
>>       
>
>
>
>     _______________________________________________
>     gradsusr mailing list
>     gradsusr at gradsusr.org <mailto:gradsusr at gradsusr.org>
>     http://gradsusr.org/mailman/listinfo/gradsusr
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>   



More information about the gradsusr mailing list