[ncl-talk] Substitute, not overwrite all variables
David Brown
dbrown at ucar.edu
Fri Dec 30 11:57:51 MST 2016
You need to change these lines:
if(isfilepresent(filename)) then
system("/bin/rm " + filename)
end if
f = addfile(filename,"c")
This is removing the file if it exists and the open a new file. You
can simply replace these lines with
f = addfile(filename,"w")
which opens an existing file with write access.
Hope that helps.
-dave
On Fri, Dec 30, 2016 at 6:09 AM, Barry Lynn <barry.h.lynn at gmail.com> wrote:
> Hello:
>
> I found this wonderful program on an e-mail exchange.
>
> I have attached my version.
>
> https://www.ncl.ucar.edu/Support/talk_archives/2011/0619.html
>
> (how to replace a variable in a variable in an ncl file).
>
> However, as set up, this overwrites the old wrfinput_d02, rather than just
> replacing the modified variable.
>
> Also, when I read this variable in the new wrfinput_d02.nc file (now just
> three variables), it is missing coordinate information (below), although I
> seem to add this information before writing it.
>
> If someone could explain how to replace a single variable, rather than to
> overwrite the whole file that would be great (and to add coordinate
> information).
>
> Thank you
>
> float L_OBS ( ncl0, ncl1, ncl2 )
> lon2d : <ARRAY of 39204 elements>
> lat2d : <ARRAY of 39204 elements>
> _FillValue : 9.96921e+36
>
> float xlat ( south_north, west_east )
> coordinates : XLONG XLAT
> stagger :
> units : degree_north
> description : LATITUDE, SOUTH IS NEGATIVE
> MemoryOrder : XY
> FieldType : 104
>
>
> --
> Barry H. Lynn, Ph.D
> Senior Lecturer,
> The Institute of the Earth Science,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> C.E.O, Weather It Is, LTD
> Weather and Climate Focus
> http://weather-it-is.com
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
> US 914 432 3108
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
More information about the ncl-talk
mailing list