UW-Hydro / VIC

The Variable Infiltration Capacity (VIC) Macroscale Hydrologic Model
http://vic.readthedocs.io
MIT License
259 stars 385 forks source link

Question about nc_vars and nc_var in nc_file_struct #874

Open itzetoile opened 5 years ago

itzetoile commented 5 years ago

Hi there,

I need to add extra variables to the output netcdf file and I came across something I do not understand. In drivers/shared_image/src/vic_write.c, the structure nc_hist_file is written as it contains a structure named nc_vars, example:

ndims = nc_hist_file->nc_vars[k].nc_dims

But in the definition of the nc_hist_file structure in the header file nc_var has only one dimension.

I would like to be able to use the full nc_vars structure in vic_run.c, but don't know how, as it does not seem to be fully defined anywhere. I tried to print the nc_dimids of one variable in vic_run.c without any success. What I have now, but of course it does not work, since nc_hist_file only contains nc_var (an not the full structure of nc_vars), is:

extern nc_file_struct *nc_hist_files;

.... printf("nc_dims of var 2 in vic_run is %d\n", nc_hist_files->nc_vars[2].nc_dims);

How could I pass the nc_vars structure to vic_run.c and why is not the full nc_vars structure saved in nc_file_struct?

Thank you, I hope I menaged to explain the problem properly :)

Itzel

Feature Requests

jhamman commented 4 years ago

@itzetoile - have you seen this page in the VIC documentation: https://vic.readthedocs.io/en/master/Documentation/Drivers/Image/OutputFormatting/

If you are just trying to add additional output variables to your netCDF output file, you shouldn't need to change any of the VIC code, just lines in your global parameter file.