<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><font size="4" face="Times" class="">Dear NCL team, </font><div class=""><font size="4" face="Times" class="">Greetings. </font></div><div class=""><font size="4" face="Times" class=""><br class=""></font></div><div class=""><font size="4" face="Times" class="">I have a shell script that does the following : Read from a text file which has a list of dates (yyyyddmm) format and times. For example, the first column in the text represents the date and the second the time. </font></div><div class=""><div style="margin: 0px; font-size: 16px; line-height: normal; background-color: rgb(237, 234, 212);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class="">20121030 13 73.34 51.77 -21.57</font></span></div></div><div style="margin: 0px; font-size: 16px; line-height: normal; background-color: rgb(237, 234, 212);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="font-size: large;" class=""><font face="Times" class=""><br class=""></font></span></span></div><div style="margin: 0px; line-height: normal; background-color: rgb(237, 234, 212);" class=""><font face="Times" class=""><span style="font-size: 16px; font-variant-ligatures: no-common-ligatures;" class=""><span style="font-size: large;" class="">My shell script reads in the first and second column and stores those values and passes off as arguments to my NCL script. My NCL script reads the first argument as the filename and the second as time. I use this time as an index in several of my arrays in my NCL script since my variable </span></span><font size="4" class="">dimensions are time x lev x lat x lon. </font></font></div><div style="margin: 0px; line-height: normal; background-color: rgb(237, 234, 212);" class=""><font size="4" face="Times" class="">The problem here is that shell reads these values as strings and I am unable to get it as an integer, which is compulsory if I want to use it as an array index. Please see the below error. </font></div><div style="margin: 0px; line-height: normal; background-color: rgb(237, 234, 212);" class=""><font size="4" face="Times" class="">Can one of you please guide me as to how I pass this value as an integer? </font></div><div style="margin: 0px; line-height: normal; background-color: rgb(237, 234, 212);" class=""><br class=""></div><div style="margin: 0px; line-height: normal; background-color: rgb(237, 234, 212);" class=""><font face="Times" size="4" class="">Many thanks, </font></div><div style="margin: 0px; line-height: normal; background-color: rgb(237, 234, 212);" class=""><font face="Times" size="4" class="">Prashanth </font></div><div style="margin: 0px; line-height: normal; background-color: rgb(237, 234, 212);" class=""><font face="Times" size="4" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; background-color: rgb(237, 234, 212);" class=""><font face="Times" size="4" class="">Error: </font></div><div style="margin: 0px; line-height: normal; background-color: rgb(237, 234, 212);" class=""><div style="margin: 0px; font-size: 16px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class=""><font color="#ff2600" class="">fatal:Illegal subscript. Subscripts must be integer when not using coordinate index</font>ing</font></span></div><div style="margin: 0px; font-size: 16px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class=""><br class=""></font></span></div><div style="margin: 0px; line-height: normal;" class=""><font face="Times" class=""><b class=""><u class=""><font size="3" class="">My code (I’m attaching the entire code in case you want to have a look, but I am pasting the necessary portions here) : </font></u></b></font></div><div style="margin: 0px; font-size: 16px; line-height: normal;" class=""><font face="Times" class=""><br class=""></font></div><div style="margin: 0px; font-size: 16px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class="">#!bin/bash</font></span></div><div style="margin: 0px; line-height: normal;" class=""><font face="Times" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">file</span><span style="font-variant-ligatures: no-common-ligatures;" class="">=</span><span style="font-variant-ligatures: no-common-ligatures;" class="">"</span><span style="font-variant-ligatures: no-common-ligatures" class="">/scratch/conte/s/sbhalach/DATA/RI_compute/CatRW2030.txt</span><span style="font-variant-ligatures: no-common-ligatures;" class="">"</span></font></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class="">while read f1 f2 f3 f4;</font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class="">do</font></span></div><div style="margin: 0px; line-height: normal; min-height: 19px;" class=""><font face="Times" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Times" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">export</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> dirname=</span><span style="font-variant-ligatures: no-common-ligatures;" class="">$(</span><span style="font-variant-ligatures: no-common-ligatures" class="">echo</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">$f1)</span><span style="font-variant-ligatures: no-common-ligatures;" class="">00post</span></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Times" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">echo</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">$dirname</span></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Times" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">cd</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">$dirname</span></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Times" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> <font color="#ff2600" class=""> </font></span><font color="#ff2600" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">export</span><span style="font-variant-ligatures: no-common-ligatures" class=""> filename=</span><span style="font-variant-ligatures: no-common-ligatures;" class="">${f1}</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.nc</span></font></font></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" color="#ff2600" class=""> export time=$f2</font></span></div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class="">#*************************************************************************</font></span></div><div style="margin: 0px; line-height: normal;" class=""><font face="Times" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> cat </span><span style="font-variant-ligatures: no-common-ligatures;" class="">></span><span style="font-variant-ligatures: no-common-ligatures" class=""> varcalc.ncl </span><span style="font-variant-ligatures: no-common-ligatures;" class=""><< EOF</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span></font></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class="">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; </font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class="">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; </font></span></div><div style="margin: 0px; line-height: normal; min-height: 19px;" class=""><font face="Times" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Times" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> load "</span><span style="font-variant-ligatures: no-common-ligatures;" class="">$NCARG_ROOT</span><span style="font-variant-ligatures: no-common-ligatures" class="">/lib/ncarg/nclscripts/csm/contributed.ncl"</span></font></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class=""> load "/scratch/lustreD/s/sbhalach/DATA/func_center.ncl"</font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class=""> load "/scratch/lustreD/s/sbhalach/DATA/func_rtheta.ncl"</font></span></div><div style="margin: 0px; line-height: normal; min-height: 19px;" class=""><font face="Times" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class=""> a = addfile(filename,"r")</font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class=""> u10 = a->u10</font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class=""> v10 = a->v10</font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class=""> slp = a->slp</font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class=""> u = a->u</font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class=""> v = a->v</font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><font face="Times" class="">allvars = new((/40/),float)</font></span></div></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class=""><br class=""></font></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><font face="Times" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">slpsub = slp(<font color="#ff2600" class="">time</font>,0,:,:) </span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">; <font color="#ff2600" class=""><b class="">Note that the time here is taken as string and hence the error. I obviously tried the toint() and strongpoint() functions but then the function only returns missing values. </b></font></span></div><div style="margin: 0px; line-height: normal;" class="">.</div><div style="margin: 0px; line-height: normal;" class="">.</div><div style="margin: 0px; line-height: normal;" class="">. </div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">;;;;;;;;;;;;;;;;;;;;;; Write to a netcdf file ;;;;;;;;;;;;;;;;;;</span></div><div style="margin: 0px; line-height: normal; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> system("rm -f </span><span style="font-variant-ligatures: no-common-ligatures" class="">$f1_$f2_allvars.nc</span><span style="font-variant-ligatures: no-common-ligatures;" class="">")</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> ncdf = addfile("</span><span style="font-variant-ligatures: no-common-ligatures;" class="">$f1_$f2_allvars.nc</span><span style="font-variant-ligatures: no-common-ligatures" class="">","c")</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> ncdf->allvars = allvars</span></div><p style="margin: 0px; line-height: normal; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">EOF</span></div><div style="margin: 0px; line-height: normal; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">#*************************************************************************</span></div><div style="margin: 0px; line-height: normal; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> <b class=""><font color="#ff2600" class="">ncl </font></b></span><b class=""><font color="#ff2600" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">-n</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">'</span><span style="font-variant-ligatures: no-common-ligatures" class="">filename = "$filename"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">'</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">'</span><span style="font-variant-ligatures: no-common-ligatures" class="">time = "$time"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">'</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> varcalc.ncl</span></font></b></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">mv</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">$f1_$f2_allvars.nc</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> ../</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">cd</span><span style="font-variant-ligatures: no-common-ligatures" class=""> ../</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">done</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class=""><"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">$file</span><span style="font-variant-ligatures: no-common-ligatures" class="">”</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span></div></span></div></font></span></div></div></div></body></html>