[ncl-talk] "Final" answer: Passing numbers to NCL scripts (08 --> 8)

Barry Lynn barry.h.lynn at gmail.com
Wed Aug 29 00:31:16 MDT 2018


As noted before, I wanted to pass numbers, like "08" to an NCL script.

However, if I call the NCL script with "08" it ends up being an "8" on the
"inside."

Even if I specify month1 = ""08," it gets written in the systems call as
"8."

Here is the solution.

ncl ./parse_tau_obs.ncl year1=18 month1=8 day1=28

  i = day1

  j = month1

  k = year1

  myFiles = systemfunc("ls -l weather_it_is_telav_20"+sprinti("%0.2i",
k)+sprinti("%0.2i", j)+sprinti("%0.2i", i)+"*csv")

  print(myFiles)

The 0.2i converts the parameters to two digits within the systems call.

Barry
On Wed, Aug 29, 2018 at 9:12 AM Barry Lynn <barry.h.lynn at gmail.com> wrote:

> Actually, the problem is that in the delimiter "month1", even if I specify
> it as "08" instead of passing it, it is written out as "8" in the following
> line.
>
> myFiles = systemfunc("ls -l
> weather_it_is_telav_20"+year1+month1+day1+"*csv")
>
>
> I found this information in the help pages
>
> (https://www.ncl.ucar.edu/Document/Functions/Built-in/sprinti.shtml)
>
>
> Even if the number is passed as "8" instead of "08," it gets converted to
> "08" using the format statement below.
>
>
> i = month1
>
>   print( sprinti("%0.2i", i) )   ;
>
>
> Also, if I pass "18" it remains as 18.
>
>
> So, I am set.
>
>
> Thank you
>
> On Wed, Aug 29, 2018 at 8:43 AM Barry Lynn <barry.h.lynn at gmail.com> wrote:
>
>> Hi:
>>
>> I am wondering how I might pass the number 08 as is, instead of finding
>> it to be equal to "8" within the scriipt.
>>
>> ncl ./parse_tau_obs.ncl year1=18 month1=08 day1=28
>>
>> --
>> Barry H. Lynn, Ph.D
>> Senior Associate Scientist, Lecturer,
>> The Institute of the Earth Science,
>> The Hebrew University of Jerusalem,
>> Givat Ram, Jerusalem 91904, Israel
>> Tel: 972 547 231 170
>> Fax: (972)-25662581
>>
>> C.E.O, Weather It Is, LTD
>> Weather and Climate Focus
>> http://weather-it-is.com
>> Jerusalem, Israel
>> Local: 02 930 9525
>> Cell: 054 7 231 170
>> Int-IS: x972 2 930 9525
>>
>>
>
> --
> Barry H. Lynn, Ph.D
> Senior Associate Scientist, Lecturer,
> The Institute of the Earth Science,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> C.E.O, Weather It Is, LTD
> Weather and Climate Focus
> http://weather-it-is.com
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
>
>

-- 
Barry H. Lynn, Ph.D
Senior Associate Scientist, Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180829/60a14855/attachment.html>


More information about the ncl-talk mailing list