Hi,
I'm trying to write a netcdf4 file that I created with CDL and ncgen.
The problem is that when I try to add an attribute to the file, I get
the following error:
Write the scale and offset...
NCID = 196608 GRPID = 196610 VARID = 0
Error: NetCDF: Variable not found
I've tried with and with entering the define mode and both have failed.
I would love some help with solving this problem. There seem to be
little in the manual on NETCDF4.
Sincerely,
/Marston
The function to add attributes to the variables:
static void AddAtt(struct data *Var, int grpid, int id, int root_grp) {
int stat;
const double scale_factor[1] = {Var->scale_factor};
const double add_offset[1] = {Var->add_offset};
if(DEBUG) {
printf("Write the scale and offset...\n");
printf("NCID = %d GRPID = %d VARID = %d\n",root_grp,grpid,id);
}
// enter define mode
stat = nc_redef (root_grp);
check_err(stat,__LINE__,__FILE__);
stat =
nc_put_att_double(grpid,id,"scale_factor",NC_DOUBLE,1,scale_factor);
check_err(stat,__LINE__,__FILE__);
stat = nc_put_att_double(grpid,id,"add_offset",NC_DOUBLE,1,add_offset);
check_err(stat,__LINE__,__FILE__);
// leave define mode
stat = nc_enddef (root_grp);
check_err(stat,__LINE__,__FILE__);
return;
}
The setup function for the file generating the netcdf file:
static void SetupNC(struct GL *g, struct NODE *vlist) {// create output file
int stat; // return status
int ncid; // netCDF id
// group ids
int root_grp;
int Geolocation_grp;
int Data_3D_grp;
int Data_2D_grp;
// dimension ids
int Geolocation_lon_dim;
int Geolocation_lat_dim;
int Geolocation_level_dim;
int Data_3D_lon_dim;
int Data_3D_lat_dim;
int Data_3D_level_dim;
int Data_2D_lon_dim;
int Data_2D_lat_dim;
// dimension lengths
size_t Geolocation_lon_len = g->nlon;
size_t Geolocation_lat_len = g->nlat;
size_t Geolocation_level_len = g->nlev;
size_t Data_3D_lon_len = g->nlon;
size_t Data_3D_lat_len = g->nlat;
size_t Data_3D_level_len = g->nlev;
size_t Data_2D_lon_len = g->nlon;
size_t Data_2D_lat_len = g->nlat;
// variable ids
int Geolocation_level_id;
int Geolocation_lon_id;
int Geolocation_lat_id;
int Data_3D_T_id;
int Data_3D_Q_id;
int Data_3D_GMH_id;
int Data_3D_P_id;
int Data_3D_PV_id;
int Data_3D_PT_id;
int Data_3D_GPH_id;
int Data_3D_O3_id;
int Data_3D_CIWC_id;
int Data_3D_CLWC_id;
int Data_3D_U_id;
int Data_3D_V_id;
int Data_2D_SP_id;
int Data_2D_T2M_id;
int Data_2D_TCW_id;
int Data_2D_TCWV_id;
int Data_2D_TCO3_id;
int Data_2D_MSL_id;
int Data_2D_Z_id;
int Data_2D_U10M_id;
int Data_2D_V10M_id;
int Data_2D_SKT_id;
// rank (number of dimensions) for each variable
# define RANK_Geolocation_level 1
# define RANK_Geolocation_lon 1
# define RANK_Geolocation_lat 1
# define RANK_Data_3D_T 3
# define RANK_Data_3D_Q 3
# define RANK_Data_3D_GMH 3
# define RANK_Data_3D_P 3
# define RANK_Data_3D_PV 3
# define RANK_Data_3D_PT 3
# define RANK_Data_3D_GPH 3
# define RANK_Data_3D_O3 3
# define RANK_Data_3D_CIWC 3
# define RANK_Data_3D_CLWC 3
# define RANK_Data_3D_U 2
# define RANK_Data_3D_V 3
# define RANK_Data_2D_SP 2
# define RANK_Data_2D_T2M 2
# define RANK_Data_2D_TCW 2
# define RANK_Data_2D_TCWV 2
# define RANK_Data_2D_TCO3 2
# define RANK_Data_2D_MSL 2
# define RANK_Data_2D_Z 2
# define RANK_Data_2D_U10M 2
# define RANK_Data_2D_V10M 2
# define RANK_Data_2D_SKT 2
// variable shapes
int Geolocation_level_dims[RANK_Geolocation_level];
int Geolocation_lon_dims[RANK_Geolocation_lon];
int Geolocation_lat_dims[RANK_Geolocation_lat];
int Data_3D_T_dims[RANK_Data_3D_T];
int Data_3D_Q_dims[RANK_Data_3D_Q];
int Data_3D_GMH_dims[RANK_Data_3D_GMH];
int Data_3D_P_dims[RANK_Data_3D_P];
int Data_3D_PV_dims[RANK_Data_3D_PV];
int Data_3D_PT_dims[RANK_Data_3D_PT];
int Data_3D_GPH_dims[RANK_Data_3D_GPH];
int Data_3D_O3_dims[RANK_Data_3D_O3];
int Data_3D_CIWC_dims[RANK_Data_3D_CIWC];
int Data_3D_CLWC_dims[RANK_Data_3D_CLWC];
int Data_3D_U_dims[RANK_Data_3D_U];
int Data_3D_V_dims[RANK_Data_3D_V];
int Data_2D_SP_dims[RANK_Data_2D_SP];
int Data_2D_T2M_dims[RANK_Data_2D_T2M];
int Data_2D_TCW_dims[RANK_Data_2D_TCW];
int Data_2D_TCWV_dims[RANK_Data_2D_TCWV];
int Data_2D_TCO3_dims[RANK_Data_2D_TCO3];
int Data_2D_MSL_dims[RANK_Data_2D_MSL];
int Data_2D_Z_dims[RANK_Data_2D_Z];
int Data_2D_U10M_dims[RANK_Data_2D_U10M];
int Data_2D_V10M_dims[RANK_Data_2D_V10M];
int Data_2D_SKT_dims[RANK_Data_2D_SKT];
// enter define mode
stat = nc_create(g->outfile, NC_CLOBBER|NC_NETCDF4, &ncid);
check_err(stat,__LINE__,__FILE__);
root_grp = ncid;
stat = nc_def_grp(root_grp, "Geolocation", &Geolocation_grp);
check_err(stat,__LINE__,__FILE__);
stat = nc_def_grp(root_grp, "Data_3D", &Data_3D_grp);
check_err(stat,__LINE__,__FILE__);
stat = nc_def_grp(root_grp, "Data_2D", &Data_2D_grp);
check_err(stat,__LINE__,__FILE__);
// define dimensions
stat = nc_def_dim(Geolocation_grp, "lon", Geolocation_lon_len,
&Geolocation_lon_dim);
check_err(stat,__LINE__,__FILE__);
stat = nc_def_dim(Geolocation_grp, "lat", Geolocation_lat_len,
&Geolocation_lat_dim);
check_err(stat,__LINE__,__FILE__);
stat = nc_def_dim(Geolocation_grp, "level", Geolocation_level_len,
&Geolocation_level_dim);
check_err(stat,__LINE__,__FILE__);
stat = nc_def_dim(Data_3D_grp, "lon", Data_3D_lon_len, &Data_3D_lon_dim);
check_err(stat,__LINE__,__FILE__);
stat = nc_def_dim(Data_3D_grp, "lat", Data_3D_lat_len, &Data_3D_lat_dim);
check_err(stat,__LINE__,__FILE__);
stat = nc_def_dim(Data_3D_grp, "level", Data_3D_level_len,
&Data_3D_level_dim);
check_err(stat,__LINE__,__FILE__);
stat = nc_def_dim(Data_2D_grp, "lon", Data_2D_lon_len, &Data_2D_lon_dim);
check_err(stat,__LINE__,__FILE__);
stat = nc_def_dim(Data_2D_grp, "lat", Data_2D_lat_len, &Data_2D_lat_dim);
check_err(stat,__LINE__,__FILE__);
// define variables
Geolocation_level_dims[0] = Geolocation_level_dim;
stat = nc_def_var(Geolocation_grp, "level", NC_FLOAT,
RANK_Geolocation_level, Geolocation_level_dims, &Geolocation_level_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Geolocation_level_id,"level");
Geolocation_lon_dims[0] = Geolocation_lon_dim;
stat = nc_def_var(Geolocation_grp, "lon", NC_FLOAT,
RANK_Geolocation_lon, Geolocation_lon_dims, &Geolocation_lon_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Geolocation_lon_id,"lon");
Geolocation_lat_dims[0] = Geolocation_lat_dim;
stat = nc_def_var(Geolocation_grp, "lat", NC_FLOAT,
RANK_Geolocation_lat, Geolocation_lat_dims, &Geolocation_lat_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Geolocation_lat_id,"lat");
Data_3D_T_dims[0] = Data_3D_lon_dim;
Data_3D_T_dims[1] = Data_3D_lat_dim;
Data_3D_T_dims[2] = Data_3D_level_dim;
stat = nc_def_var(Data_3D_grp, "T", NC_SHORT, RANK_Data_3D_T,
Data_3D_T_dims, &Data_3D_T_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_3D_T_id,"T");
Data_3D_Q_dims[0] = Data_3D_lon_dim;
Data_3D_Q_dims[1] = Data_3D_lat_dim;
Data_3D_Q_dims[2] = Data_3D_level_dim;
stat = nc_def_var(Data_3D_grp, "Q", NC_FLOAT, RANK_Data_3D_Q,
Data_3D_Q_dims, &Data_3D_Q_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_3D_Q_id,"Q");
Data_3D_GMH_dims[0] = Data_3D_lon_dim;
Data_3D_GMH_dims[1] = Data_3D_lat_dim;
Data_3D_GMH_dims[2] = Data_3D_level_dim;
stat = nc_def_var(Data_3D_grp, "GMH", NC_SHORT, RANK_Data_3D_GMH,
Data_3D_GMH_dims, &Data_3D_GMH_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_3D_GMH_id,"GMH");
Data_3D_P_dims[0] = Data_3D_lon_dim;
Data_3D_P_dims[1] = Data_3D_lat_dim;
Data_3D_P_dims[2] = Data_3D_level_dim;
stat = nc_def_var(Data_3D_grp, "P", NC_SHORT, RANK_Data_3D_P,
Data_3D_P_dims, &Data_3D_P_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_3D_P_id,"P");
Data_3D_PV_dims[0] = Data_3D_lon_dim;
Data_3D_PV_dims[1] = Data_3D_lat_dim;
Data_3D_PV_dims[2] = Data_3D_level_dim;
stat = nc_def_var(Data_3D_grp, "PV", NC_FLOAT, RANK_Data_3D_PV,
Data_3D_PV_dims, &Data_3D_PV_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_3D_PV_id,"PV");
Data_3D_PT_dims[0] = Data_3D_lon_dim;
Data_3D_PT_dims[1] = Data_3D_lat_dim;
Data_3D_PT_dims[2] = Data_3D_level_dim;
stat = nc_def_var(Data_3D_grp, "PT", NC_SHORT, RANK_Data_3D_PT,
Data_3D_PT_dims, &Data_3D_PT_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_3D_PT_id,"PT");
Data_3D_GPH_dims[0] = Data_3D_lon_dim;
Data_3D_GPH_dims[1] = Data_3D_lat_dim;
Data_3D_GPH_dims[2] = Data_3D_level_dim;
stat = nc_def_var(Data_3D_grp, "GPH", NC_SHORT, RANK_Data_3D_GPH,
Data_3D_GPH_dims, &Data_3D_GPH_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_3D_GPH_id,"GPH");
Data_3D_O3_dims[0] = Data_3D_lon_dim;
Data_3D_O3_dims[1] = Data_3D_lat_dim;
Data_3D_O3_dims[2] = Data_3D_level_dim;
stat = nc_def_var(Data_3D_grp, "O3", NC_FLOAT, RANK_Data_3D_O3,
Data_3D_O3_dims, &Data_3D_O3_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_3D_O3_id,"O3");
Data_3D_CIWC_dims[0] = Data_3D_lon_dim;
Data_3D_CIWC_dims[1] = Data_3D_lat_dim;
Data_3D_CIWC_dims[2] = Data_3D_level_dim;
stat = nc_def_var(Data_3D_grp, "CIWC", NC_FLOAT, RANK_Data_3D_CIWC,
Data_3D_CIWC_dims, &Data_3D_CIWC_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_3D_CIWC_id,"CIWC");
Data_3D_CLWC_dims[0] = Data_3D_lon_dim;
Data_3D_CLWC_dims[1] = Data_3D_lat_dim;
Data_3D_CLWC_dims[2] = Data_3D_level_dim;
stat = nc_def_var(Data_3D_grp, "CLWC", NC_FLOAT, RANK_Data_3D_CLWC,
Data_3D_CLWC_dims, &Data_3D_CLWC_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_3D_CLWC_id,"CLWC");
Data_3D_U_dims[0] = Data_3D_lon_dim;
Data_3D_U_dims[1] = Data_3D_lat_dim;
stat = nc_def_var(Data_3D_grp, "U", NC_SHORT, RANK_Data_3D_U,
Data_3D_U_dims, &Data_3D_U_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_3D_U_id,"U");
Data_3D_V_dims[0] = Data_3D_lon_dim;
Data_3D_V_dims[1] = Data_3D_lat_dim;
Data_3D_V_dims[2] = Data_3D_level_dim;
stat = nc_def_var(Data_3D_grp, "V", NC_SHORT, RANK_Data_3D_V,
Data_3D_V_dims, &Data_3D_V_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_3D_V_id,"V");
Data_2D_SP_dims[0] = Data_2D_lon_dim;
Data_2D_SP_dims[1] = Data_2D_lat_dim;
stat = nc_def_var(Data_2D_grp, "SP", NC_SHORT, RANK_Data_2D_SP,
Data_2D_SP_dims, &Data_2D_SP_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_2D_SP_id,"SP");
Data_2D_T2M_dims[0] = Data_2D_lon_dim;
Data_2D_T2M_dims[1] = Data_2D_lat_dim;
stat = nc_def_var(Data_2D_grp, "T2M", NC_SHORT, RANK_Data_2D_T2M,
Data_2D_T2M_dims, &Data_2D_T2M_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_2D_T2M_id,"T2M");
Data_2D_TCW_dims[0] = Data_2D_lon_dim;
Data_2D_TCW_dims[1] = Data_2D_lat_dim;
stat = nc_def_var(Data_2D_grp, "TCW", NC_SHORT, RANK_Data_2D_TCW,
Data_2D_TCW_dims, &Data_2D_TCW_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_2D_TCW_id,"TCW");
Data_2D_TCWV_dims[0] = Data_2D_lon_dim;
Data_2D_TCWV_dims[1] = Data_2D_lat_dim;
stat = nc_def_var(Data_2D_grp, "TCWV", NC_SHORT, RANK_Data_2D_TCWV,
Data_2D_TCWV_dims, &Data_2D_TCWV_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_2D_TCWV_id,"TCWV");
Data_2D_TCO3_dims[0] = Data_2D_lon_dim;
Data_2D_TCO3_dims[1] = Data_2D_lat_dim;
stat = nc_def_var(Data_2D_grp, "TCO3", NC_SHORT, RANK_Data_2D_TCO3,
Data_2D_TCO3_dims, &Data_2D_TCO3_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_2D_TCO3_id,"TCO3");
Data_2D_MSL_dims[0] = Data_2D_lon_dim;
Data_2D_MSL_dims[1] = Data_2D_lat_dim;
stat = nc_def_var(Data_2D_grp, "MSL", NC_SHORT, RANK_Data_2D_MSL,
Data_2D_MSL_dims, &Data_2D_MSL_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_2D_MSL_id,"MSL");
Data_2D_Z_dims[0] = Data_2D_lon_dim;
Data_2D_Z_dims[1] = Data_2D_lat_dim;
stat = nc_def_var(Data_2D_grp, "Z", NC_SHORT, RANK_Data_2D_Z,
Data_2D_Z_dims, &Data_2D_Z_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_2D_Z_id,"Z");
Data_2D_U10M_dims[0] = Data_2D_lon_dim;
Data_2D_U10M_dims[1] = Data_2D_lat_dim;
stat = nc_def_var(Data_2D_grp, "U10M", NC_SHORT, RANK_Data_2D_U10M,
Data_2D_U10M_dims, &Data_2D_U10M_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_2D_U10M_id,"U10M");
Data_2D_V10M_dims[0] = Data_2D_lon_dim;
Data_2D_V10M_dims[1] = Data_2D_lat_dim;
stat = nc_def_var(Data_2D_grp, "V10M", NC_SHORT, RANK_Data_2D_V10M,
Data_2D_V10M_dims, &Data_2D_V10M_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_2D_V10M_id,"V10M");
Data_2D_SKT_dims[0] = Data_2D_lon_dim;
Data_2D_SKT_dims[1] = Data_2D_lat_dim;
stat = nc_def_var(Data_2D_grp, "SKT", NC_SHORT, RANK_Data_2D_SKT,
Data_2D_SKT_dims, &Data_2D_SKT_id);
check_err(stat,__LINE__,__FILE__);
append_node(vlist,Data_2D_SKT_id,"SKT");
if(DEBUG) printf("Checking the nc vlist!\n");
count_list(vlist);
// assign global attributes
{ // University
stat = nc_put_att_text(root_grp, NC_GLOBAL, "University", 33,
"Chalmers University of Technology");
check_err(stat,__LINE__,__FILE__);
}
{ // Institude
stat = nc_put_att_text(root_grp, NC_GLOBAL, "Institude", 36, "Earth
and Space Sciences Institution");
check_err(stat,__LINE__,__FILE__);
}
{ // Title
stat = nc_put_att_text(root_grp, NC_GLOBAL, "Title", 54, "Basic
data for Odin processing and other research uses");
check_err(stat,__LINE__,__FILE__);
}
{ // Source
stat = nc_put_att_text(root_grp, NC_GLOBAL, "Source", 14, "ECMWF
Analysis");
check_err(stat,__LINE__,__FILE__);
}
{ // History
stat = nc_put_att_text(root_grp, NC_GLOBAL, "History", 44, "Created
for GEM group by M. S. Johnston 2011");
check_err(stat,__LINE__,__FILE__);
}
{ // Convention
stat = nc_put_att_text(root_grp, NC_GLOBAL, "Convention", 40, "Data
is stored in 64 bit NETCDF-4 format");
check_err(stat,__LINE__,__FILE__);
}
{ // Missing
stat = nc_put_att_text(root_grp, NC_GLOBAL, "Missing", 37, "Error
in data field is shown as -9999");
check_err(stat,__LINE__,__FILE__);
}
{ // Packing
stat = nc_put_att_text(root_grp, NC_GLOBAL, "Packing", 38, "Data is
stored with a scale_factor and add_offset");
check_err(stat,__LINE__,__FILE__);
}
{ // Resolution
stat = nc_put_att_text(root_grp, NC_GLOBAL, "Resolution", 39, "Data
is stored on a 1 x 1 degree grid");
check_err(stat,__LINE__,__FILE__);
}
{ // Data order
stat = nc_put_att_text(root_grp, NC_GLOBAL, "Data order", 39, "Data
is ordered TOA first; Lowest level last");
check_err(stat,__LINE__,__FILE__);
}
// assign per-variable attributes
{ // long_name
stat = nc_put_att_text(Geolocation_grp, Geolocation_level_id,
"long_name", 6, "Levels");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const float Geolocation_level_FillValue_att[1] = {-999} ;
stat = nc_put_att_float(Geolocation_grp, Geolocation_level_id,
"_FillValue", NC_FLOAT, 1, Geolocation_level_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // long_name
stat = nc_put_att_text(Geolocation_grp, Geolocation_lon_id,
"long_name", 9, "longitude");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const float Geolocation_lon_FillValue_att[1] = {-999} ;
stat = nc_put_att_float(Geolocation_grp, Geolocation_lon_id,
"_FillValue", NC_FLOAT, 1, Geolocation_lon_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Geolocation_grp, Geolocation_lon_id,
"units", 12, "degrees_east");
check_err(stat,__LINE__,__FILE__);
}
{ // lat_name
stat = nc_put_att_text(Geolocation_grp, Geolocation_lat_id,
"lat_name", 8, "latitude");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const float Geolocation_lat_FillValue_att[1] = {-999} ;
stat = nc_put_att_float(Geolocation_grp, Geolocation_lat_id,
"_FillValue", NC_FLOAT, 1, Geolocation_lat_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Geolocation_grp, Geolocation_lat_id,
"units", 13, "degrees_north");
check_err(stat,__LINE__,__FILE__);
}
{ // T_name
stat = nc_put_att_text(Data_3D_grp, Data_3D_T_id, "T_name", 11,
"Temperature");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_3D_T_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_3D_grp, Data_3D_T_id, "_FillValue",
NC_SHORT, 1, Data_3D_T_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_3D_grp, Data_3D_T_id, "units", 1, "K");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_3D_T_code_att[1] = {130} ;
stat = nc_put_att_short(Data_3D_grp, Data_3D_T_id, "code",
NC_SHORT, 1, Data_3D_T_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // Q_name
stat = nc_put_att_text(Data_3D_grp, Data_3D_Q_id, "Q_name", 17,
"Specific Humidity");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const float Data_3D_Q_FillValue_att[1] = {-999} ;
stat = nc_put_att_float(Data_3D_grp, Data_3D_Q_id, "_FillValue",
NC_FLOAT, 1, Data_3D_Q_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_3D_grp, Data_3D_Q_id, "units", 5, "kg/kg");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const float Data_3D_Q_code_att[1] = {130} ;
stat = nc_put_att_float(Data_3D_grp, Data_3D_Q_id, "code",
NC_FLOAT, 1, Data_3D_Q_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // GMH_name
stat = nc_put_att_text(Data_3D_grp, Data_3D_GMH_id, "GMH_name", 16,
"Geometric Height");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_3D_GMH_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_3D_grp, Data_3D_GMH_id, "_FillValue",
NC_SHORT, 1, Data_3D_GMH_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_3D_grp, Data_3D_GMH_id, "units", 1, "m");
check_err(stat,__LINE__,__FILE__);
}
{ // P_name
stat = nc_put_att_text(Data_3D_grp, Data_3D_P_id, "P_name", 8,
"Pressure");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_3D_P_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_3D_grp, Data_3D_P_id, "_FillValue",
NC_SHORT, 1, Data_3D_P_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_3D_grp, Data_3D_P_id, "units", 2, "Pa");
check_err(stat,__LINE__,__FILE__);
}
{ // PV_name
stat = nc_put_att_text(Data_3D_grp, Data_3D_PV_id, "PV_name", 19,
"Potential Vorticity");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const float Data_3D_PV_FillValue_att[1] = {-999} ;
stat = nc_put_att_float(Data_3D_grp, Data_3D_PV_id, "_FillValue",
NC_FLOAT, 1, Data_3D_PV_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_3D_grp, Data_3D_PV_id, "units", 32,
"10**-6 K m**2 kg**-1 s**-1 (PVU)");
check_err(stat,__LINE__,__FILE__);
}
{ // PT_name
stat = nc_put_att_text(Data_3D_grp, Data_3D_PT_id, "PT_name", 21,
"Potential Temperature");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_3D_PT_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_3D_grp, Data_3D_PT_id, "_FillValue",
NC_SHORT, 1, Data_3D_PT_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_3D_grp, Data_3D_PT_id, "units", 1, "K");
check_err(stat,__LINE__,__FILE__);
}
{ // GPH_name
stat = nc_put_att_text(Data_3D_grp, Data_3D_GPH_id, "GPH_name", 19,
"Geopotential height");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_3D_GPH_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_3D_grp, Data_3D_GPH_id, "_FillValue",
NC_SHORT, 1, Data_3D_GPH_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_3D_grp, Data_3D_GPH_id, "units", 10,
"m**2 s**-2");
check_err(stat,__LINE__,__FILE__);
}
{ // O3_name
stat = nc_put_att_text(Data_3D_grp, Data_3D_O3_id, "O3_name", 23,
"Ozone mass mixing ratio");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const float Data_3D_O3_FillValue_att[1] = {-999} ;
stat = nc_put_att_float(Data_3D_grp, Data_3D_O3_id, "_FillValue",
NC_FLOAT, 1, Data_3D_O3_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_3D_grp, Data_3D_O3_id, "units", 9, "kg
kg**-1");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const float Data_3D_O3_code_att[1] = {203} ;
stat = nc_put_att_float(Data_3D_grp, Data_3D_O3_id, "code",
NC_FLOAT, 1, Data_3D_O3_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // CIWC_name
stat = nc_put_att_text(Data_3D_grp, Data_3D_CIWC_id, "CIWC_name",
23, "Cloud Ice Water Content");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const float Data_3D_CIWC_FillValue_att[1] = {-999} ;
stat = nc_put_att_float(Data_3D_grp, Data_3D_CIWC_id, "_FillValue",
NC_FLOAT, 1, Data_3D_CIWC_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_3D_grp, Data_3D_CIWC_id, "units", 9,
"kg kg**-1");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const float Data_3D_CIWC_code_att[1] = {247} ;
stat = nc_put_att_float(Data_3D_grp, Data_3D_CIWC_id, "code",
NC_FLOAT, 1, Data_3D_CIWC_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // CLWC_name
stat = nc_put_att_text(Data_3D_grp, Data_3D_CLWC_id, "CLWC_name",
26, "Cloud Liquid Water Content");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const float Data_3D_CLWC_FillValue_att[1] = {-999} ;
stat = nc_put_att_float(Data_3D_grp, Data_3D_CLWC_id, "_FillValue",
NC_FLOAT, 1, Data_3D_CLWC_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_3D_grp, Data_3D_CLWC_id, "units", 9,
"kg kg**-1");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const float Data_3D_CLWC_code_att[1] = {248} ;
stat = nc_put_att_float(Data_3D_grp, Data_3D_CLWC_id, "code",
NC_FLOAT, 1, Data_3D_CLWC_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // U_name
stat = nc_put_att_text(Data_3D_grp, Data_3D_U_id, "U_name", 16, "U
wind component");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_3D_U_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_3D_grp, Data_3D_U_id, "_FillValue",
NC_SHORT, 1, Data_3D_U_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_3D_grp, Data_3D_U_id, "units", 7, "m
s**-1");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_3D_U_code_att[1] = {131} ;
stat = nc_put_att_short(Data_3D_grp, Data_3D_U_id, "code",
NC_SHORT, 1, Data_3D_U_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // V_name
stat = nc_put_att_text(Data_3D_grp, Data_3D_V_id, "V_name", 16, "V
wind component");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_3D_V_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_3D_grp, Data_3D_V_id, "_FillValue",
NC_SHORT, 1, Data_3D_V_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_3D_grp, Data_3D_V_id, "units", 7, "m
s**-1");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_3D_V_code_att[1] = {132} ;
stat = nc_put_att_short(Data_3D_grp, Data_3D_V_id, "code",
NC_SHORT, 1, Data_3D_V_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // SP_name
stat = nc_put_att_text(Data_2D_grp, Data_2D_SP_id, "SP_name", 16,
"Surface Pressure");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_2D_SP_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_SP_id, "_FillValue",
NC_SHORT, 1, Data_2D_SP_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_2D_grp, Data_2D_SP_id, "units", 2, "Pa");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_2D_SP_code_att[1] = {134} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_SP_id, "code",
NC_SHORT, 1, Data_2D_SP_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // T2M_name
stat = nc_put_att_text(Data_2D_grp, Data_2D_T2M_id, "T2M_name", 15,
"2 m Temperature");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_2D_T2M_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_T2M_id, "_FillValue",
NC_SHORT, 1, Data_2D_T2M_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_2D_grp, Data_2D_T2M_id, "units", 1, "K");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_2D_T2M_code_att[1] = {167} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_T2M_id, "code",
NC_SHORT, 1, Data_2D_T2M_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // TCW_name
stat = nc_put_att_text(Data_2D_grp, Data_2D_TCW_id, "TCW_name", 18,
"Total Column Water");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_2D_TCW_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_TCW_id, "_FillValue",
NC_SHORT, 1, Data_2D_TCW_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_2D_grp, Data_2D_TCW_id, "units", 8, "kg
m**-2");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_2D_TCW_code_att[1] = {136} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_TCW_id, "code",
NC_SHORT, 1, Data_2D_TCW_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // TCWV_name
stat = nc_put_att_text(Data_2D_grp, Data_2D_TCWV_id, "TCWV_name",
25, "Total Column Water Vapour");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_2D_TCWV_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_TCWV_id, "_FillValue",
NC_SHORT, 1, Data_2D_TCWV_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_2D_grp, Data_2D_TCWV_id, "units", 8,
"kg m**-2");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_2D_TCWV_code_att[1] = {137} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_TCWV_id, "code",
NC_SHORT, 1, Data_2D_TCWV_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // TCO3_name
stat = nc_put_att_text(Data_2D_grp, Data_2D_TCO3_id, "TCO3_name",
18, "Total Column Ozone");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_2D_TCO3_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_TCO3_id, "_FillValue",
NC_SHORT, 1, Data_2D_TCO3_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_2D_grp, Data_2D_TCO3_id, "units", 8,
"kg m**-2");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_2D_TCO3_code_att[1] = {206} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_TCO3_id, "code",
NC_SHORT, 1, Data_2D_TCO3_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // MSL_name
stat = nc_put_att_text(Data_2D_grp, Data_2D_MSL_id, "MSL_name", 23,
"Mean Sea-Level Pressure");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_2D_MSL_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_MSL_id, "_FillValue",
NC_SHORT, 1, Data_2D_MSL_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_2D_grp, Data_2D_MSL_id, "units", 8, "kg
m**-2");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_2D_MSL_code_att[1] = {151} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_MSL_id, "code",
NC_SHORT, 1, Data_2D_MSL_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // Z_name
stat = nc_put_att_text(Data_2D_grp, Data_2D_Z_id, "Z_name", 12,
"Geopotential");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_2D_Z_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_Z_id, "_FillValue",
NC_SHORT, 1, Data_2D_Z_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_2D_grp, Data_2D_Z_id, "units", 10,
"m**2 s**-2");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_2D_Z_code_att[1] = {129} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_Z_id, "code",
NC_SHORT, 1, Data_2D_Z_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // U10M_name
stat = nc_put_att_text(Data_2D_grp, Data_2D_U10M_id, "U10M_name",
26, "U Wind component 10 meters");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_2D_U10M_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_U10M_id, "_FillValue",
NC_SHORT, 1, Data_2D_U10M_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_2D_grp, Data_2D_U10M_id, "units", 7, "m
s**-2");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_2D_U10M_code_att[1] = {165} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_U10M_id, "code",
NC_SHORT, 1, Data_2D_U10M_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // V10M_name
stat = nc_put_att_text(Data_2D_grp, Data_2D_V10M_id, "V10M_name",
26, "V Wind component 10 meters");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_2D_V10M_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_V10M_id, "_FillValue",
NC_SHORT, 1, Data_2D_V10M_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_2D_grp, Data_2D_V10M_id, "units", 7, "m
s**-2");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_2D_V10M_code_att[1] = {166} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_V10M_id, "code",
NC_SHORT, 1, Data_2D_V10M_code_att);
check_err(stat,__LINE__,__FILE__);
}
{ // SKT_name
stat = nc_put_att_text(Data_2D_grp, Data_2D_SKT_id, "SKT_name", 16,
"Skin Temperature");
check_err(stat,__LINE__,__FILE__);
}
{ // _FillValue
static const short Data_2D_SKT_FillValue_att[1] = {-999} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_SKT_id, "_FillValue",
NC_SHORT, 1, Data_2D_SKT_FillValue_att);
check_err(stat,__LINE__,__FILE__);
}
{ // units
stat = nc_put_att_text(Data_2D_grp, Data_2D_SKT_id, "units", 1, "K");
check_err(stat,__LINE__,__FILE__);
}
{ // code
static const short Data_2D_SKT_code_att[1] = {235} ;
stat = nc_put_att_short(Data_2D_grp, Data_2D_SKT_id, "code",
NC_SHORT, 1, Data_2D_SKT_code_att);
check_err(stat,__LINE__,__FILE__);
}
if(DEBUG) {
printf("DEBUG SETUPNC: NCID %d GLID %d 3DID %d 2DID
%d\n",root_grp,Geolocation_grp,Data_3D_grp,Data_2D_grp);
}
// Save the group ids
g->oncid = root_grp;
g->gl_grp = Geolocation_grp;
g->d3d_grp = Data_3D_grp;
g->d2d_grp = Data_2D_grp;
// leave define mode
stat = nc_enddef (root_grp);
check_err(stat,__LINE__,__FILE__);
return;
}
On 01/24/2011 12:56 PM, siavash ghiasvand wrote:
When I tried to compile netcdf-3.6.2 on an openSUSE 11.2, I got two
errors which said: "*** was not declared in this scope"
The solution is simple just add the line below:
include "string.h"
To these files:
netcdf-3.6.2/examples/CXX/sfc_pres_temp_rd.cpp
netcdf-3.6.2/cxx/ncvalues.cpp
-----------------
Sincerely yours,
Siavash Ghiasvand
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Marston S. Johnston e-mail: marston@xxxxxxxxxxx ~
~ Doctoral Student Earth and Space Sciences ~
~ Chalmers Univeristy of Technology http://www.chalmers.se ~
~ Gothenburg Tel. (46) 31 772 2235 ~
~ Sweden Skype ID marston.johnston ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~