Re: writing ascii file

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Tue, 14 Oct 2008 17:25:15 -0600

Agnes,

The string "missing" is the default value of each element in "data"
before anything is written to that array. So this is a symptom of
your program not completely filling "data".

I suspect that you have a discrepancy between the values of npts and
dim. Try these debugging statements:

Before "do i=0,dim-1":
    print (dim)

Before asciiwrite:
    print (data)

Quick fix to output only the valid part of data:
    asciiwrite (filo , data(0:dim-1))

Dave Allured
CU/CIRES Climate Diagnostics Center (CDC)
http://cires.colorado.edu/science/centers/cdc/
NOAA/ESRL/PSD, Climate Analysis Branch (CAB)
http://www.cdc.noaa.gov/

Agnes Lim wrote:
> Hi
>
> I am writing an ascii file using the following code segments
> Output average values
> diro = "/tank/alim/WRF/stats/03062400/"
> filo = diro+"average"
>
> no_vars=6
>
> npts=26*6
>
> data = new(npts, "string")
>
> npts=-1
>
> do i=0,dim-1
> npts=npts+1
> data(npts) = sprinti("%6d", lev_p(i))
> data(npts) = data(npts)+sprintf("%8.5f", average_u_ctrl(i))
> data(npts) = data(npts)+sprintf("%8.5f", average_u_da(i))
> data(npts) = data(npts)+sprintf("%8.5f", average_v_ctrl(i))
> data(npts) = data(npts)+sprintf("%8.5f", average_v_da(i))
> data(npts) = data(npts)+sprintf("%8.4f", average_ghgt_ctrl(i))
> data(npts) = data(npts)+sprintf("%8.4f", average_ghgt_da(i))
> end do
>
> asciiwrite (filo , data)
>
> The output file basically contains what i wanted but towards the end of
> what i asked it to write, it appended the word missing.
> Following is the segment of the file
> 950 0.55090-0.70421 0.55090-9.22972 -3.6016 -1.8250
> 975 0.10978-0.14815 0.10978-8.28661 -2.8962 -0.6138
> 1000-999.00000-999.00000-999.00000-999.00000-999.0000-999.0000
> missing
> missing
> missing
> missing
> missing
>
> How do i rectify this?
>
> Thanks
> Agnes
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Oct 14 2008 - 17:25:15 MDT

This archive was generated by hypermail 2.2.0 : Fri Oct 17 2008 - 10:06:33 MDT