[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UDUNITS #LTB-717744]: ut_read_xml() behavior



Charlie,

> I found a flaw in my previous code where I passed an empty
> string ("") rather than a NULL to ut_read_xml().
> When I pass the NULL then the installed database is used and
> the UDUNITS2_XML_PATH is searched if specified.
> 
> > What does the above do on your system?
> 
> I tested your commands and get the same behavior.
> So the udunits2 executable works as expected.
> The behavior when linked to ncks operator, however, does not.
> However, there's lots of verbosity I do not understand.
> ncks is built with netCDF4 and is linked to the libudunits2.so.
> 
> Compile nco_lmt.c with
> 
> ut_sys=ut_read_xml(NULL);
> 
> and run and get
> 
> address@hidden:~$ unset UDUNITS2_XML_PATH
> address@hidden:~$ which ncks
> /home/zender/bin/LINUX/ncks
> address@hidden:~$ ldd `which ncks`
> linux-gate.so.1 =>  (0xffffe000)
> libhdf5.so.1 => /usr/local/netcdf4/lib/libhdf5.so.1 (0x4001d000)
> libhdf5_hl.so.0 => /usr/local/netcdf4/lib/libhdf5_hl.so.0
> (0x4051c000)
> libudunits2.so.0 => /usr/local/lib/libudunits2.so.0 (0x4054c000)
> libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x40593000)
> libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x405ba000)
> libz.so.1 => /usr/lib/libz.so.1 (0x406fb000)
> /lib/ld-linux.so.2 (0x40000000)
> address@hidden:~$ ncks -O -D 0 -C -H -v wvl -d wvl,'0.4 micron','0.7
> micron' -s '%3.1e' ~/nco/data/in.nc
> Definition of "kt" in "/usr/local/share/udunits2-common.xml", line 80,
> overrides prefixed-unit "1000000 kilogram"
> Definition of "microns" in "/usr/local/share/udunits2-common.xml", line
> 290, overrides prefixed-unit "1e-15 second"
> Definition of "ft" in "/usr/local/share/udunits2-common.xml", line 387,
> overrides prefixed-unit "1e-12 kilogram"
> Definition of "yd" in "/usr/local/share/udunits2-common.xml", line 395,
> overrides prefixed-unit "8.64e-20 second"
> Definition of "pt" in "/usr/local/share/udunits2-common.xml", line 616,
> overrides prefixed-unit "1e-09 kilogram"
> Definition of "at" in "/usr/local/share/udunits2-common.xml", line 1013,
> overrides prefixed-unit "1e-15 kilogram"
> Definition of "ph" in "/usr/local/share/udunits2-common.xml", line 1531,
> overrides prefixed-unit "3.6e-09 second"
> Definition of "nt" in "/usr/local/share/udunits2-common.xml", line 1538,
> overrides prefixed-unit "1e-06 kilogram"
> Definition of "kt" in "/usr/local/share/udunits2-common.xml", line 80,
> overrides prefixed-unit "1000000 kilogram"
> Definition of "microns" in "/usr/local/share/udunits2-common.xml", line
> 290, overrides prefixed-unit "1e-15 second"
> Definition of "ft" in "/usr/local/share/udunits2-common.xml", line 387,
> overrides prefixed-unit "1e-12 kilogram"
> Definition of "yd" in "/usr/local/share/udunits2-common.xml", line 395,
> overrides prefixed-unit "8.64e-20 second"
> Definition of "pt" in "/usr/local/share/udunits2-common.xml", line 616,
> overrides prefixed-unit "1e-09 kilogram"
> Definition of "at" in "/usr/local/share/udunits2-common.xml", line 1013,
> overrides prefixed-unit "1e-15 kilogram"
> Definition of "ph" in "/usr/local/share/udunits2-common.xml", line 1531,
> overrides prefixed-unit "3.6e-09 second"
> Definition of "nt" in "/usr/local/share/udunits2-common.xml", line 1538,
> overrides prefixed-unit "1e-06 kilogram"
> 5.0e-07
> 
> That 5.0e-07 is the right answer, which is good.
> But how do I lose the verbosity about "overrides prefixed-unit"?

Printing "override" messages to the standard error stream is
the default for the UDUNITS-2 library.  You can override the
default like this:

ut_set_error_message_handler(ut_ignore);
unitSystem = ut_read_xml(NULL);
ut_set_error_message_handler(ut_write_to_stderr);

> Thanks,
> Charlie
> --
> Charlie Zender, Department of Earth System Science, UC Irvine
> Visiting LGGE until 20080715: Voice: 011+33+476+824236
> Laboratoire de Glaciologie et Geophysique de l'Environnement
> BP 96, 54 rue Moliere, 38402 Saint Martin d'Heres Cedex, France

Regards,
Steve Emmerson

Ticket Details
===================
Ticket ID: LTB-717744
Department: Support UDUNITS
Priority: Emergency
Status: Closed


NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.