Re: opening the files

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Mar 27 2013 - 16:28:35 MDT

Even better ...

   month = sprinti("%0.2i", i) ; fill with leading zeros

For fun, try

   MONTH = sprinti("%0.2i", ispan(1,12,1))
   print(MONTH)

On 3/27/13 4:06 PM, Michael Notaro wrote:
> Something like this should work.
>
> do iy=1979,2010
> do im=0,11
>
> if (im.le.8) then
> month="0"+(im+1)
> else
> month=""+(im+1)
> end if
>
> a=addfile("era.cice.h."+iy+"-"+month+".nc","r")
>
> end do
> end do
>
>
>
> On 03/27/13, Alexander Semenov wrote:
>> Hi,
>>
>> I have a question.
>>
>>
>> I am reading a bunch of files like this
>>
>>
>> year = 1979
>> month = 01
>>
>> files = systemfunc("ls era.cice.h."+year+"-"+month+".nc")
>>
>>
>> With that notion I believe ncl will loop through the files, but the program crashes because month in the output file has 2 digits and not 1. So, when the code reads the data it reads: era.cice.h.1979-1.nc(http://era.cice.h.1979-1.nc) which is incorrect, it needs to be era.cice.h.1979-01.nc(http://era.cice.h.1979-01.nc)
>>
>>
>> I tried to fix it with the if statement but I got confused with syntaxis. Could you help me please with this?
>>
>>
>> Thanks,
>> Alex
> _______________________________________________
> 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 Wed Mar 27 16:28:39 2013

This archive was generated by hypermail 2.1.8 : Tue Apr 02 2013 - 21:23:48 MDT