Re: strings questions]

From: Kate Hedstrom <kate_at_nyahnyahspammersnyahnyah>
Date: Wed, 20 Sep 2006 15:55:51 -0800

Forgot to cc the list:
----- Forwarded message from Kate Hedstrom <> -----

> I think Kate's first question is about creating a NetCDF scalar
> variable, which you can do
> one of two ways -- both of which are documented (perhaps too obscurely)
> in the example
> section of the 'filevardef'. Either way you use the special pre-defined
> dimension name "ncl_scalar".
> Here is one way:
> spherical = new(1,"character")
> spherical!0 = "ncl_scalar"
> spherical = integertocharacter(1) ; 1 for True -- 0 for False
> spherical_at_long_name = "Grid type logical switch"
> ncid->spherical = spherical
> The other way is to use 'filevardef' to create the scalar variable
> directly in the file.
> filevardef(ncid, "spherical","character","ncl_scalar")
> ncld->spherical = integertocharacter(1)
> ncid->spherical_at_long_name = "Grid type logical switch"
> Note that if you look at this file in NCL it will appear as if there is
> a dimension named "ncl_scalar",
> but in an ncdump of the file the dimension will not appear, so the
> variable *is* a true NetCDF scalar.

Yes, David understood my question. However, I want the thing to have
a value of either "T" or "F". Here is what I tried:

    172 sflag = new(1,"character")
    173 str = stringtochar("F")
    174 sflag = str(0)
fatal:Assignment type mismatch, right hand side can't be coerced to type of left hand side
fatal:Execute: Error occurred at or near line 175 in file grid_cdf.ncl

> NetCDF3 doesn't care what the unlimited dimension is called or what it
> represents. The limitations for
> unlimited dimensions are (1) that there can only be one of them and (2)
> that it is the leftmost (slowest changing)
> dimension for every variable that uses it.
> The error you are getting has nothing to do with the unlimited
> dimension. The line it is complaining
> about is the assignment to "str", which is a result of NCL's fussy
> assignment constraints. "str" has been defined
> to be 80 characters but the character array assigned is shorter than 80
> characters.
> One way around this would be to modify the code as follows:
> filedimdef(ncid, "bath", -1, True)
> filedimdef(ncid, "stringlen", 80, False)
> dims = (/ "bath", "stringlen" /)
> filevardef(ncid, "bath_history", "character", dims)
> str = "Flat bottom"
> len = dimsizes(stringtochar(str))
> ncid->bath_history(0,0:len-1) = stringtochar(str)
> fileAtt = True
> fileAtt_at_bath_history_0 = "Flat bottom"
> fileattdef(ncid, fileAtt)

Yes, this worked!

> What is your application for the inverse map projection? You are
> correct that there is no interface to a grid based
> inverse map projection in NCL although you can do it point by point.
> -dave

The ROMS ocean model operates on an orthogonal curvilinear grid. Our
grid generation software operates using flat (complex plane) geometry.
I've been finding the domain boundary by projecting the coastline
onto a flat surface, choosing a boundary, making the grid in the
flat coordinate system, then doing the inverse map transform to find
the lat,lon of all the gridpoints. I need to know the lat,lon for
interpolating the bathymetry, initial conditions, and so on, also
for recomputing the grid metrics for the globe - gc_latlon looks
perfect for that. I've been doing this all with old Fortran codes,
but no one else wants to use them. What they really want is even
more of a gui wrapper that calls the grid generation program too.


Kate Hedstr´┐Żm       Arctic Region Supercomputing Center       University of Alaska, Fairbanks
Phone: 907-450-8678
----- End forwarded message -----
ncl-talk mailing list
Received on Wed Sep 20 2006 - 17:55:51 MDT

This archive was generated by hypermail 2.2.0 : Mon Sep 25 2006 - 11:45:07 MDT