Hi Dennis and David,
Thanks for your suggestions. I learn a lot. The way suggested by David work well.
-- Best wishes Guanhuan Wen At 2014-03-15 00:58:04,"Dennis Shea" <shea@ucar.edu> wrote: >The following NCL script could be used to invoke another NCL script. >It shows two slight variations of a sample system command. > >;===== Simulate the following in NCL============ >;; #!/bin/bash >;; season=(JJA DJF MAM) >;; for ((k=0; k<${#season[@]}; k=k+1)) >;; do >;; ncl 'se="${season[${k}]}"' test.ncl >;; done > > dq = str_get_dq() ; double quote (") as a string > > season = (/"JJA", "DJF", "MAM" /) > do k=0,dimsizes(season)-1 > CMD = "ncl 'se="+dq+season(k)+dq+"' test.ncl" > ;CMD = "ncl 'se="+dq+season(k)+dq+"' test.ncl >&! out.test."+k > print(""+CMD) > system(CMD) > end do >;========================================= >The explicit creation of the 'CMD' variable was done so that you >could print the created string. It could be done directly via > > do k=0,dimsizes(season)-1 > system("ncl 'se="+dq+season(k)+dq+"' test.ncl") > end do >++++++++++++++++++++++++++++++++++++++++++++ >A trivial test.ncl script would be: > >begin > print("test.ncl : season="+se) >end > > >++++++++++++++++++++++++++++++++++++++++++++ >Maybe somebody from the Python world would illustrate how >one would invoke the NCL script via Python. > > > > >On 3/14/14, 9:16 AM, David B. Reusch wrote: >> I think you just need additional single quotes (') on the call to ncl. >> The first goes before the "$" and the second goes after the "}". At >> least this is what I would do in csh and I'm assuming it's the same in >> bash. The way it is now, the shell is not substituting the season >> variable. >> >> Hope this helps, >> Dave >> >> wen said the following on 3/14/2014 7:53 AM: >>> Hi Dennis, >>> Thanks for you help. I write linux-shell-script to pass parameter of >>> type of string. It do not work. Do you know why? Following is the >>> linux-shell-script. >>> >>> #!/bin/bash >>> season=(JJA DJF MAM) >>> for ((k=0; k<${#season[@]}; k=k+1)) >>> do >>> ncl 'se="${season[${k}]}"' test.ncl >>> done >>> >>> >>> >>> >>> -- >>> ?? >>> ??? >>> >>> At 2014-03-14 21:23:55,"Dennis Shea" <shea@ucar.edu> wrote: >>> >Please read: >>> > http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclCLO.shtml >>> > >>> >There are many examples. >>> > >>> > >>> >%>ncl 'fil="sample.nc"' ys=1979 ye=2005 ex=0 lgen=1 minpre=0.1 lgex=2 >>> >maxpre=3 day_int_amo_annual.ncl >>> > >>> >On 3/14/14, 6:54 AM, wen wrote: >>> >> Hi all, I run a ncl script by passing parameter as following. I >>> found it work well when the type of parameter is numerical type. >>> However, it did not work when the type of parameter is string. Could >>> ncl pass parameter of type of string? If anyone know that , please >>> tell me. Thank you! >>> >> ncl ys=1979 ye=2005 ex=0 lgen=1 minpre=0.1 lgex=2 maxpre=3 >>> day_int_amo_annual.ncl >>> >> >>> >> >>> >> >>> >> >>> >> >>> >> -- >>> >> >>> >> Best wishes >>> >> Guanhuan Wen >>> >> >>> >> >>> >> >>> >> _______________________________________________ >>> >> ncl-talk mailing list >>> >> List instructions, subscriber options, unsubscribe: >>> >> http://mailman.ucar.edu/mailman/listinfo/ncl-talk >>> >> >>> >>> >>> >>> >>> _______________________________________________ >>> ncl-talk mailing list >>> List instructions, subscriber options, unsubscribe: >>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk >> >> >> >> _______________________________________________ >> ncl-talk mailing list >> List instructions, subscriber options, unsubscribe: >> http://mailman.ucar.edu/mailman/listinfo/ncl-talk >>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Mar 14 19:54:13 2014
This archive was generated by hypermail 2.1.8 : Fri Mar 21 2014 - 15:49:21 MDT