Re: formatting output ascii files

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Thu, 29 Mar 2007 12:23:50 -0600

Eva, Mateus--

There is an easier way. sprinti supports controls for minimum field
width and leading zeros. Either of these methods will work:

print (sprinti ("temp.%.3i", 78) + sprinti (".%.2i", 9))
(0) temp.078.09

print (sprinti ("temp.%03i", 78) + sprinti (".%02i", 9))
(0) temp.078.09

Try "man sprintf" on your Unix or Linux system for more
documentation. NCL sprinti is alleged to do formatting similar to
the standard C function sprintf.

--Dave A.
CU/CIRES Climate Diagnostics Center (CDC)
NOAA/ESRL/PSD, Climate Analysis Branch (CAB)

Mateus da Silva Teixeira wrote:
> Eva,
>
> I think that with some IFs you can do it easily! For example:
>
> do i=1,100
> if (i.lt10) then
> suffix1 = "00"
> end if
> if (i.ge.10.and.lt.100) then
> suffix1 = "0"
> end if
> fileName = "temp."+suffix1+"."+suffix2
> end do
>
> If suffix2 should have same control, add more IFs
> I hope it helps you!
>
> Mateus
>
> EVA SALGADO SANCHEZ escreveu:
>>
>> Dear all,
>>
>> I'm new user to NCL. I've been playing around and looking through the
>> documentation and I didn't find a way to name an output file in the
>> way I need it. I read data from a grib file and extract the value of a
>> variable (array) into an ascii output file (no problem). I use
>> write_matrix and can name the different ascii output files like:
>>
>> temp.1.45
>> temp.10.45
>> temp.100.45
>>
>> (the sample values 1, 10, 100 are read from another variable of the
>> grib file)
>>
>> but I would like them to be
>>
>> temp.001.45
>> temp.010.45
>> temp.100.45
>>
>>
>> Is it possible to do it directly with ncl? (NCAR Command Language
>> Version 4.2.0.a034)
>>
>> Thank you in advance for any possible help,
>>
>> Eva
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Mar 29 2007 - 12:23:50 MDT

This archive was generated by hypermail 2.2.0 : Sun Apr 01 2007 - 11:52:47 MDT