Re: ascii (cnl88)

From: Chad Herman <the.chad.herman_at_nyahnyahspammersnyahnyah>
Date: Sun Oct 09 2011 - 12:32:13 MDT

cnl88,

Your error message can be reproduced with the following code snippet:

x = new((/2,5/), float)
y = new((/2,6/), float)
x = y

NCL, unlike many interpreted languages, doesn't permit dynamic
reassignment of an array variable's dimensions. If you want to
(referring to the above example) copy y into x, you must first
"delete(x)" and *then* assign "x = y". You can automate this deletion
with the following:

if( isdefined("x") )then
  delete(x)
end if

As to your question about reading in floats and strings, that's not an
easy solution. Where are the strings? At the top (header)? If so, you
can read the header in with readAsciiHead and read the rest with
readAsciiTable. If it's more complicated (like floats and strings
interspersed), then I would recommend writing a Fortran subroutine to
handle the text reading.

Regards,

Chad

On 10/09/2011 02:00 PM, ncl-talk-request@ucar.edu wrote:
> Message: 1
> Date: Sun, 9 Oct 2011 22:30:27 +0800 (CST)
> From: cnl88<cnl88@163.com>
> Subject: ascii
> To:"ncl-talk@ucar.edu" <ncl-talk@ucar.edu>
> Message-ID:<2b8c3f91.c0f9.132e9178d35.Coremail.cnl88@163.com>
> Content-Type: text/plain; charset="gbk"
>
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "/usr/local/ncl/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
> load "/usr/local/ncl/lib/ncarg/nclscripts/csm/contributed.ncl"
> ;************************************************
> begin
> I=12428
> K=6
> z= asciiread("./20110411.txt",(/12428,6/),"float")
> p = z(:,1) ;alt
> t = z(:,2);nox
>
> l = z(:,3) ; so2
> velocity =z(:,4) ;o3
> time = z(:,0)
>
> CO = z(:,5)
>
> p = new ( (/I,K/), typeof(CO) )
> p(:,0) = z(:,0)
> p(:,1) = z(:,1)
> p(:,2) = z(:,2)
> p(:,3) = z(:,3)
> p(:,4) = z(:,4)
> p(:,5) = z(:,5)
>
> fmtx = "6f10.6"
> opt = True
>
> opt@fout = fon
> write_matrix (p,fmtx, opt)
>
> end
>
> I have two questions.One is the error!the other is that how can i read the data which include float and string! hope for your help!
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20111009/0e598b7d/attachment.html
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: ??1.png
> Type: image/png
> Size: 2329 bytes
> Desc: not available
> Url :http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20111009/0e598b7d/attachment.png
>
> ------------------------------
>
> _______________________________________________

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Oct 9 12:32:24 2011

This archive was generated by hypermail 2.1.8 : Mon Oct 10 2011 - 11:43:35 MDT