Re: wrapit / cd

From: Saji Njarackalazhikam Hameed <saji_at_nyahnyahspammersnyahnyah>
Date: Thu, 1 Nov 2007 23:21:58 +0900

Mike,

Why not run NCL using a script (csh,bash,ruby etc) and run
different instances of NCL?

for example in ruby:

# -------- %< start of ruby code -------

#!/usr/bin/ruby

directories=%w(dir1 dir2 dir3 dir4)

for dir in directories do
  Dir.chdir(dir)
  ans=system("wrapit file.F")
  exit if ans==false # Abort if we did not succeed in compiling
  system("ncl file.ncl")
end

# -------- %< end of ruby code -------

saji
  

* Michael Notaro <mnotaro_at_wisc.edu> [2007-11-01 09:25:39 -0500]:

> Thanks. I know how to loop through the directory names and even change
> directories,
> but how do I execute wrapit from each of those directories?
>
> If I use system(cd ...) and then on the next line, execute wrapit, it will
> not run the .so file
> in that directory since the system command is temporary.
>
> Mike
>
>
> On Oct 31, 2007, at 5:24 PM, Rick Grubin wrote:
>
>> Hi Mike
>>
>>> Is there any way in NCL to change to directory A, use wrapit to run a
>>> fortran file there, change to directory B, use wrapit to run a fortran
>>> file there, and so on?
>>>
>>> I want to loop through a list of directory-name strings in NCL, change to
>>> those directories, and use wrapit to run fortran programs in those
>>> directories. But system("cd ...") apparently only temporarily changes
>>> directory if that makes sense, meaning once NCL gets to the next line, it
>>> no longer is in that directory.
>>
>> The 'system()' function executes its command argument in a subshell,
>> meaning that whatever command you wish to run is a separate process from
>> your NCL session. Once it's done executing, you're "right back where you
>> started" so to speak. This is how the Unix 'system' function operates.
>>
>> If your list of directory name strings is representative of a flat file
>> structure -- all directories have the same root -- then you should be able
>> to loop without difficult using 'system(cd ...)' by iterating over your
>> list of strings.
>>
>> If your list of directory name strings is a tree structure -- each
>> directory is a subdirectory of the previous -- then you'll need to build a
>> directory name string as you go, concatenating strings to be able to
>> change directory to successive levels down.
>>
>> Example #2 at:
>> http://www.ncl.ucar.edu/Document/Functions/Built-in/system.shtml should
>> give you an idea of how to do this, where you'd build a new directory name
>> each time instead of a new filename as in the example.
>>
>> If I didn't completely understand your question, could you please explain
>> a bit more?
>>
>> -Rick.
>> ----
>> Rick Grubin NCAR/TDD/CISL/VETS
>> Visualization + Enabling Technologies
>> grubin_at_ucar.edu 303.497.1832
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
Saji N. Hameed
APEC Climate Center          				+82 51 668 7470
National Pension Corporation Busan Building 12F         
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705			saji_at_apcc21.net
KOREA
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Nov 01 2007 - 08:21:58 MDT

This archive was generated by hypermail 2.2.0 : Fri Nov 02 2007 - 10:04:33 MDT