Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NC_STRING #274

Closed
bzah opened this issue Aug 7, 2023 · 6 comments
Closed

Support NC_STRING #274

bzah opened this issue Aug 7, 2023 · 6 comments

Comments

@bzah
Copy link

bzah commented Aug 7, 2023

Hi,

We use some of the latest netCDF4 features in the dataset we produce.
However, when running a nco command such as:

ncks -O fcil1c_rrad.nc tmp.nc

, we get warnings like:

ncks: WARNING "grid_mapping" attribute for variable /data/ir_123/measured/pixel_quality is type NC_STRING, not NC_CHAR. 
This violates the CF convention for allowed datatypes (http://cfconventions.org/cf-conventions/cf-conventions.html#_data_types). 
Therefore nco_xtr_cf_var_add() will skip this attribute. If you want CF to support NC_STRING attributes, please tell CF and CC: NCO.

But, when we go click on the CF conventions linked, we can read that strings should be supported:

Data variables must be one of the following data types: string, char, byte, unsigned byte, short, unsigned short, int, unsigned int, int64, unsigned int64, float or real, and double (which are all the netCDF external data types

Here is an example of the dataset that produce the error: fcil1c_rrad.zip

Would it be possible for nco to support NC_STRING type ?

Side notes:
The link to UCAR's datatype from CF convention is dead, you may want to look at the code of netCDF C here for reference: https://docs.unidata.ucar.edu/netcdf-c/current/netcdf_8h_source.html

@czender
Copy link
Member

czender commented Aug 7, 2023

This is a reasonable suggestion that I will put on the TODO list. The NCO warning message is out-of-date, since it was written before CF allowed NC_STRING. Now that CF allows netCDF4 types, we should fix NCO to support them. I will post again when progress has been made.

@bzah
Copy link
Author

bzah commented Aug 8, 2023

Great, thank you.

@czender
Copy link
Member

czender commented Aug 15, 2023

I have made some progress. The current snapshot has better NC_STRING support that resolves your immediate issue. However, better NC_STRING is still needed since there's a lot of code that only works for NC_CHAR. If you have the ability to build and test the main branch, any feedback would be helpful. Here's the result of the command that originally error'd out for you:

zender@spectral:~/Downloads$ ncks -O fcil1c_rrad.nc tmp.nc
ncks: WARNING File contains 12 user-defined types (UDTs) (i.e., compound, enum, opaque, or vlen) used to define 42 non-atomic variables and their attributes. NCO currently ignores variables and attributes with UDTs by default, although some preliminary features can be accessed with the --udt flag. Nevertheless, most ncks features will only work for atomic variables.
zender@spectral:~/Downloads$ 

@bzah
Copy link
Author

bzah commented Aug 16, 2023

I tried to compile nco, but I faced a few issues. TBH, I haven't compiled a C project in a while, so I'm probably missing something.
With cmake, it requires to run as sudo in order to write in /usr/local, but when running it it elevated, it gives me

CMake Error at CMakeLists.txt:1017 (add_dependencies):
  The dependency target "data" of target "check" does not exist.

I also tried the ./configure; make; make install; but no luck either. It also needs to write to /usr/local and when I run sudo make I get this error:

test -f ncap_lex.c || /bin/bash ../../autobld/ylwrap ncap_lex.l lex.nco_yy.c ncap_lex.c -- :  -Pnco_yy
make[3]: *** [Makefile:1125: ncap_lex.c] Error 1
make[3]: Leaving directory '/home/bzah/workspace/nco/src/nco'
make[2]: *** [Makefile:382: all-recursive] Error 1
make[2]: Leaving directory '/home/bzah/workspace/nco/src'
make[1]: *** [Makefile:449: all-recursive] Error 1
make[1]: Leaving directory '/home/bzah/workspace/nco'
make: *** [Makefile:381: all] Error 2

edit: I'm running these commands on a Ubuntu 23.04

@czender
Copy link
Member

czender commented Aug 16, 2023

This should build/install NCO in your home directory.

cd ~/nco/cmake
cmake .. -DCMAKE_INSTALL_PREFIX=${HOME}
make install

Try also make data if you still receive the error above.

@bzah
Copy link
Author

bzah commented Sep 18, 2023

Hi, I was not able to compile nco before, but I just tried with nco 5.1.8 and it works smoothly.
Thanks @czender for working and maintaining nco.

@bzah bzah closed this as completed Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants