> I am trying to use an external Fortran 90 routine to read in an ASCII table
> of mixed integers, strings and floats. One of the columns of the table is a
> string. I am not sure how this array of strings should be defined in the f90,
> the wrapper, and the ncl script.
>
> (There was a similar question in the ncl-talk list on Mon Aug 01 2005, but I
> could not find an answer...)
Hi Andrea,
In this case, you can use NCL .. let the file sample.table contain
20040812 00 LGAK 37.89 23.74 2.00 24.88 25.25
20040812 00 LGAM 37.94 23.71 9.00 24.54 26.50
20040812 00 LGDE 38.12 23.78 274.00 21.78 18.75
20040812 00 LGEK 37.97 23.72 74.00 24.30 24.00
20040812 00 LGGU 37.99 23.78 162.00 22.46 21.75
20040812 00 LGKT 38.14 23.95 212.00 21.39 21.75
The following is untested. I may have miscounted the columns
for the character variables.
good luck
D
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
diri = "./"
fili = "sample.table"
nRow = numAsciiRow(diri+fili) ; number of rows
nCol = 7 ; number of columns with numbers
tabf = asciiread(diri+fili, (/nRow,nCol/) , "float")
yyyyymmdd = floattointeger( tabf(:,0) )
ihr = floattointeger( tabf(:,1) )
x2d = tabf(:,2:)
print(x2d)
tabs = asciiread(diri+fili, -1, "string")
tabc = stringtochar(tabs)
id = chartostring( tabc(:,16:19) ) ; columns may be off
print(id)
end
--------------
If the table has header lines, use readAsciiTable
http://www.ncl.ucar.edu/Document/Functions/Contributed/readAsciiTable.shtml
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Nov 17 2005 - 15:47:14 MST
This archive was generated by hypermail 2.2.0 : Thu Nov 17 2005 - 19:15:42 MST