[ncl-talk] unable to pass an argument to NCL code

Geeta Geeta geetag54 at yahoo.com
Wed Mar 18 10:11:59 MDT 2020


 Thanks Rick. 
it worked

Geeta.

     On Wednesday, 18 March, 2020, 06:53:55 pm IST, Rick Brownrigg <brownrig at ucar.edu> wrote:  
 
 Hi,
I think you need to escape the quotes at the shell level. Something like this seems to work:
# This simply echos the names of the files is current directory, from both the shell and then as passed into NCL
for i in *; do echo $i ncl name_of_file=\"$i\" foo.ncldone
foo.ncl: print(name_of_file)

Rick


 
On Wed, Mar 18, 2020 at 5:46 AM Geeta Geeta via ncl-talk <ncl-talk at ucar.edu> wrote:

Hi.

I have to run My ncl code for large number of days having same data format
(example, -rw-r----- 1 aditya aditya 38874040 Jul  9  2018 02apr2008.ua.nc
-rwx--x--x 1 aditya aditya 38874040 Jul 10  2018 03mar2006.ua.nc
-rwx--x--x 1 aditya aditya 38874040 Jul 10  2018 05apr2009.ua.nc
-rwx--x--x 1 aditya aditya 38874040 Jul 10  2018 05mar2005.ua.nc)

I have written a small script that will pass on the argument 02apr2008.ua.nc,  03mar2006.ua.nc..... to the NCL code.


The script (ATTACHED) is reading partcular files and assigning to the variable $myvar which goes as input to the code.

for i in $(ls ?????????.ua.nc); do
echo  $i
myvar=$i
echo $myvar

First few lines of the code are

SPLIT_FILE   =    str_split(name_of_file,".")
                     print(SPLIT_FILE)

name_of_file variable will be passed on by shell script. 
But variables are not being passed correctly. 
 the output is .

Variable: SPLIT_FILE
Type: string
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:   [1]
Coordinates: 
(0)     $myvar


Variable: storms_file
Type: string
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:   [1]
Coordinates: 
(0)     dcc.$myvar.txt
fatal:["FileSupport.c":3973]:($myvar) has no file extension, can't determine type of file to open
Segmentation fault (core dumped)


2. I tried to pass argument on the command line and it runs well. 
aditya at agniilap:~/geeta/ncl/Plotecmf$ ../bin/ncl 'name_of_file="02apr2008.ua.nc"' ecmf.v5.ua.ncl

I have to run this script in batch mode as large number of days are there. 

thanks

Geeta._______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200318/da702b94/attachment.html>


More information about the ncl-talk mailing list