#include <iostream>#include <string>#include <vector>#include <netcdf.h>#include <nco_utl.hh>#include <nco_var.hh>Include dependency graph for nco_att.hh:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| int | nco_put_att (const int &nc_id, const int &var_id, const std::string &att_nm, const size_t &att_sz, const float *const &att_val, const nc_type &att_typ=NC_FLOAT) |
| int | nco_put_att (const int &nc_id, const int &var_id, const std::string &att_nm, const float &att_val, const nc_type &att_typ=NC_FLOAT) |
| int | nco_put_att (const int &nc_id, const int &var_id, const std::string &att_nm, const size_t &att_sz, const double *const &att_val, const nc_type &att_typ=NC_DOUBLE) |
| int | nco_put_att (const int &nc_id, const int &var_id, const std::string &att_nm, const double &att_val, const nc_type &att_typ=NC_DOUBLE) |
| int | nco_put_att (const int &nc_id, const int &var_id, const std::string &att_nm, const size_t &att_sz, const int *const &att_val, const nc_type &att_typ=NC_INT) |
| int | nco_put_att (const int &nc_id, const int &var_id, const std::string &att_nm, const int &att_val, const nc_type &att_typ=NC_INT) |
| int | nco_put_att (const int &nc_id, const int &var_id, const std::string &att_nm, const size_t &att_sz, const short *const &att_val, const nc_type &att_typ=NC_SHORT) |
| int | nco_put_att (const int &nc_id, const int &var_id, const std::string &att_nm, const short &att_val, const nc_type &att_typ=NC_SHORT) |
| int | nco_put_att (const int &nc_id, const int &var_id, const std::string &att_nm, const size_t &att_sz, const long *const &att_val, const nc_type &att_typ=NC_INT) |
| int | nco_put_att (const int &nc_id, const int &var_id, const std::string &att_nm, const long &att_val, const nc_type &att_typ=NC_INT) |
| int | nco_put_att (const int &nc_id, const int &var_id, const std::string &att_nm, const std::string &att_val) |
| int | nco_put_att (const int &nc_id, const std::string &var_nm, const std::string &att_nm, const std::string &att_val) |
| int | nco_put_att (const int &nc_id, const int &var_id, const std::string &att_nm, const std::vector< double > &att_val, const nc_type &att_typ=NC_DOUBLE) |
| int | nco_inq_att (const int &nc_id, const int &var_id, const std::string &att_nm, nc_type &att_typ, size_t &att_sz, const int &rcd_opt=NC_NOERR) |
| int | nco_inq_attid (const int &nc_id, const int &var_id, const std::string &att_nm, int &att_id, const int &rcd_opt=NC_NOERR) |
| int | nco_inq_attid (const int &nc_id, const std::string &var_nm, const std::string &att_nm, int &att_id, const int &rcd_opt=NC_NOERR) |
| int | nco_inq_attid (const int &nc_id, const int &var_id, const std::string &att_nm) |
| int | nco_inq_attid (const int &nc_id, const std::string &var_nm, const std::string &att_nm) |
| int | nco_inq_attname (const int &nc_id, const int &var_id, const int &att_id, std::string &att_nm, const int &rcd_opt=NC_NOERR) |
| std::string | nco_inq_attname (const int &nc_id, const int &var_id, const int &att_id) |
| std::string | nco_inq_attname (const int &nc_id, const std::string &var_nm, const int &att_id) |
| int | nco_inq_atttype (const int &nc_id, const int &var_id, const std::string &att_nm, nc_type &att_typ, const int &rcd_opt=NC_NOERR) |
| nc_type | nco_inq_atttype (const int &nc_id, const std::string &var_nm, const std::string &att_nm) |
| int | nco_inq_attlen (const int &nc_id, const int &var_id, const std::string &att_nm, size_t &att_sz, const int &rcd_opt=NC_NOERR) |
| size_t | nco_inq_attlen (const int &nc_id, const int &var_id, const std::string &att_nm) |
| size_t | nco_inq_attlen (const int &nc_id, const int &var_id, const int &att_id) |
| size_t | nco_inq_attlen (const int &nc_id, const std::string &var_nm, const std::string &att_nm) |
| int | nco_get_att (const int &nc_id, const int &var_id, const std::string &att_nm, std::string &att_val) |
| int | nco_get_att (const int &nc_id, const int &var_id, const std::string &att_nm, float *&att_val) |
| int | nco_get_att (const int &nc_id, const int &var_id, const std::string &att_nm, double *&att_val) |
| template<class typ_ntr> | |
| int | nco_get_att (const int &nc_id, const std::string &var_nm, const std::string &att_nm, typ_ntr &att_val) |
| template<class typ_ntr> | |
| typ_ntr | nco_get_att (const int &nc_id, const int &var_id, const std::string &att_nm) |
| template<class typ_ntr> | |
| typ_ntr | nco_get_att (const int &nc_id, const std::string &var_nm, const std::string &att_nm) |
|
||||||||||||||||||||
|
Definition at line 379 of file nco_att.hh. References nco_get_att(), and nco_inq_varid(). 00382 { 00383 // Purpose: Wrapper for nco_get_att() 00384 00385 // 20050109 Prototype nco_inq_varid() to satisfy g++ 3.4 finickiness described above 00386 int // O [id] Variable ID 00387 nco_inq_varid // [fnc] Inquire variable ID 00388 (const int &nc_id, // I [enm] netCDF file ID 00389 const std::string &var_nm); // I [sng] Variable name 00390 00391 typ_ntr att_val; // O [frc] Attribute value 00392 int rcd=nco_get_att(nc_id,nco_inq_varid(nc_id,var_nm),att_nm,att_val); 00393 return att_val; 00394 } // end nco_get_att<typ_ntr>()
|
|
||||||||||||||||||||
|
Definition at line 359 of file nco_att.hh. References nco_get_att(). 00362 { 00363 // Purpose: Wrapper for nco_get_att() 00364 typ_ntr att_val; // O [frc] Attribute value 00365 int rcd=nco_get_att(nc_id,var_id,att_nm,att_val); 00366 return att_val; 00367 } // end nco_get_att<typ_ntr>()
|
|
||||||||||||||||||||||||
|
Definition at line 318 of file nco_att.hh. References nco_get_att(), and nco_inq_varid(). 00322 { 00323 /* 20050109 Unless nco_inq_varid() prototype appears here, g++ 3.4 produces 00324 "./nco_att.hh:369: error: there are no arguments to `nco_inq_varid' that depend on a template parameter, so a declaration of `nco_inq_varid' must be available 00325 ./nco_att.hh:369: error: (if you use `-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)" 00326 when compiling nco_var.cc 00327 Unclear why this nco_inq_varid() template must be here and in nco_var.hh 00328 Probably g++ 3.4 is finicky and does not allow circular prototype references 00329 Eliminating this additional nco_inq_varid() reference may require adding 00330 .hh files to eliminate circular references. 00331 Hence must weigh complexity of multiple (three) nco_inq_varid() prototypes 00332 (master prototype in nco_var.hh and two local prototypes in overloaded 00333 nco_get_att() functions in nco_att.hh) against complexity of finer-grained 00334 (more) .hh files. 00335 On balance, I prefer fewer files 00336 There are currently only two redundant nco_inq_varid() prototypes 00337 If this number grows appreciably then we should re-visit this decision */ 00338 00339 int // O [id] Variable ID 00340 nco_inq_varid // [fnc] Inquire variable ID 00341 (const int &nc_id, // I [enm] netCDF file ID 00342 const std::string &var_nm); // I [sng] Variable name 00343 00344 // Purpose: Wrapper for nc_get_att() 00345 int rcd=nco_get_att(nc_id,nco_inq_varid(nc_id,var_nm),att_nm,att_val); 00346 return rcd; 00347 } // end nco_get_att<typ_ntr>()
|
|
||||||||||||||||||||
|
Definition at line 478 of file nco_att.cc. References nc_get_att_double, NC_NOERR, nco_err_exit(), and nco_inq_attlen(). 00482 { 00483 // Purpose: Wrapper for nc_get_att_double() 00484 size_t att_sz=nco_inq_attlen(nc_id,var_id,att_nm); 00485 // Allocate space for variable: User is responsible for freeing space 00486 att_val=new double[att_sz]; 00487 int rcd=nc_get_att_double(nc_id,var_id,att_nm.c_str(),att_val); 00488 if(rcd != NC_NOERR) nco_err_exit(rcd,"nco_get_att<double>"); 00489 return rcd; 00490 } // end nco_get_att<double>()
|
|
||||||||||||||||||||
|
Definition at line 462 of file nco_att.cc. References nc_get_att_float, NC_NOERR, nco_err_exit(), and nco_inq_attlen(). 00466 { 00467 // Purpose: Wrapper for nc_get_att_float() 00468 size_t att_sz=nco_inq_attlen(nc_id,var_id,att_nm); 00469 // Allocate space for variable: User is responsible for freeing space 00470 att_val=new float[att_sz]; 00471 int rcd=nc_get_att_float(nc_id,var_id,att_nm.c_str(),att_val); 00472 if(rcd != NC_NOERR) nco_err_exit(rcd,"nco_get_att<float>"); 00473 return rcd; 00474 } // end nco_get_att<float>()
|
|
||||||||||||||||||||
|
Definition at line 439 of file nco_att.cc. References nc_get_att_text, NC_NOERR, nco_err_exit(), nco_inq_attlen(), and nco_wrn_prn(). 00443 { 00444 // Purpose: Wrapper for nc_get_att_text() 00445 size_t att_sz=nco_inq_attlen(nc_id,var_id,att_nm); 00446 if(att_sz == 0) nco_wrn_prn("nco_get_att<std::string> will attempt to read NC_CHAR of size zero"); 00447 // Allocate one extra byte for manual NUL-termination 00448 char *att_val_chr=new char[att_sz+1]; 00449 int rcd=nc_get_att_text(nc_id,var_id,att_nm.c_str(),att_val_chr); 00450 /* Attribute on disk may or may not be NUL-terminated 00451 In either case, NUL-terminate it before assigning it to string 00452 Otherwise, overloaded string:=(char *) assignment will not terminate */ 00453 att_val_chr[att_sz]='\0'; 00454 att_val=att_val_chr; 00455 delete []att_val_chr; 00456 if(rcd != NC_NOERR) nco_err_exit(rcd,"nco_get_att<std::string>"); 00457 return rcd; 00458 } // end nco_get_att<std::string>()
|
|
||||||||||||||||||||||||||||
|
Definition at line 225 of file nco_att.cc. References nc_inq_att, NC_NOERR, and nco_err_exit(). 00231 { 00232 /* Purpose: Wrapper for nc_inq_att() 00233 User may omit rcd_opt, or supply value of non-fatal netCDF return code */ 00234 int rcd=nc_inq_att(nc_id,var_id,att_nm.c_str(),&att_typ,&att_sz); 00235 if(rcd != NC_NOERR && rcd != rcd_opt) nco_err_exit(rcd,"nco_inq_att"); 00236 return rcd; 00237 } // end nco_inq_att()
|
|
||||||||||||||||
|
Definition at line 288 of file nco_att.cc. References nco_inq_attid(), and nco_inq_varid(). 00291 { 00292 // Purpose: Wrapper for nco_inq_attid() 00293 int att_id; // O [id] Attribute ID 00294 int rcd=nco_inq_attid(nc_id,nco_inq_varid(nc_id,var_nm),att_nm,att_id); 00295 rcd+=0; // CEWI 00296 return att_id; 00297 } // end nco_inq_attid()
|
|
||||||||||||||||
|
Definition at line 275 of file nco_att.cc. References nco_inq_attid(). 00278 { 00279 // Purpose: Wrapper for nco_inq_attid() 00280 int att_id; // O [id] Attribute ID 00281 int rcd=nco_inq_attid(nc_id,var_id,att_nm,att_id); 00282 rcd+=0; // CEWI 00283 return att_id; 00284 } // end nco_inq_attid()
|
|
||||||||||||||||||||||||
|
Definition at line 260 of file nco_att.cc. References NC_NOERR, nco_err_exit(), nco_inq_attid(), and nco_inq_varid(). 00265 { 00266 /* Purpose: Wrapper for nco_inq_attid() 00267 User may omit rcd_opt, or supply value of non-fatal netCDF return code */ 00268 int rcd=nco_inq_attid(nc_id,nco_inq_varid(nc_id,var_nm),att_nm,att_id); 00269 if(rcd != NC_NOERR && rcd != rcd_opt) nco_err_exit(rcd,"nco_inq_attid"); 00270 return rcd; 00271 } // end nco_inq_attid()
|
|
||||||||||||||||||||||||
|
Definition at line 244 of file nco_att.cc. References nc_inq_attid, NC_NOERR, nco_err_exit(), and nco_inq_varname(). 00249 { 00250 /* Purpose: Wrapper for nc_inq_attid() 00251 User may omit rcd_opt, or supply value of non-fatal netCDF return code */ 00252 int rcd=nc_inq_attid(nc_id,var_id,att_nm.c_str(),&att_id); 00253 if(rcd != NC_NOERR && rcd != rcd_opt) nco_err_exit(rcd,"nco_inq_attid","Unable to find attribute ID for attribute \""+att_nm+"\" of variable \""+nco_inq_varname(nc_id,var_id)+"\", exiting..."); 00254 if(rcd != NC_NOERR && rcd != rcd_opt) nco_err_exit(rcd,"nco_inq_attid"); 00255 return rcd; 00256 } // end nco_inq_attid()
|
|
||||||||||||||||
|
Definition at line 423 of file nco_att.cc. References nco_inq_attlen(), and nco_inq_varid(). 00426 { 00427 // Purpose: Wrapper for nco_inq_attlen(nc_inq_dimid()) 00428 size_t att_sz; // O [nbr] Attribute size 00429 int rcd=nco_inq_attlen(nc_id,nco_inq_varid(nc_id,var_nm),att_nm,att_sz); 00430 rcd+=0; // CEWI 00431 return att_sz; 00432 } // end nco_inq_attlen()
|
|
||||||||||||||||
|
Definition at line 410 of file nco_att.cc. References nco_inq_attlen(), and nco_inq_attname(). 00413 { 00414 // Purpose: Wrapper for nco_inq_attlen() 00415 size_t att_sz; // O [nbr] Attribute size 00416 int rcd=nco_inq_attlen(nc_id,var_id,nco_inq_attname(nc_id,var_id,att_id),att_sz); 00417 rcd+=0; // CEWI 00418 return att_sz; 00419 } // end nco_inq_attlen()
|
|
||||||||||||||||
|
Definition at line 397 of file nco_att.cc. References nco_inq_attlen(). 00400 { 00401 // Purpose: Wrapper for nco_inq_attlen() 00402 size_t att_sz; // O [nbr] Attribute size 00403 int rcd=nco_inq_attlen(nc_id,var_id,att_nm,att_sz); 00404 rcd+=0; // CEWI 00405 return att_sz; 00406 } // end nco_inq_attlen()
|
|
||||||||||||||||||||||||
|
Definition at line 382 of file nco_att.cc. References nc_inq_attlen, NC_NOERR, and nco_err_exit(). 00387 { 00388 /* Purpose: Wrapper for nc_inq_attlen() 00389 User may omit rcd_opt, or supply value of non-fatal netCDF return code */ 00390 int rcd=nc_inq_attlen(nc_id,var_id,att_nm.c_str(),&att_sz); 00391 if(rcd != NC_NOERR && rcd != rcd_opt) nco_err_exit(rcd,"nco_inq_attlen"); 00392 return rcd; 00393 } // end nco_inq_attlen()
|
|
||||||||||||||||
|
Definition at line 334 of file nco_att.cc. References nco_inq_attname(), and nco_inq_varid(). 00337 { 00338 // Purpose: Wrapper for nco_inq_attname() 00339 std::string att_nm; // O [id] Variable name 00340 int rcd=nco_inq_attname(nc_id,nco_inq_varid(nc_id,var_nm),att_id,att_nm); 00341 rcd+=0; // CEWI 00342 return att_nm; 00343 } // end nco_inq_attname()
|
|
||||||||||||||||
|
Definition at line 321 of file nco_att.cc. References nco_inq_attname(). 00324 { 00325 // Purpose: Wrapper for nco_inq_attname() 00326 std::string att_nm; // O [id] Variable name 00327 int rcd=nco_inq_attname(nc_id,var_id,att_id,att_nm); 00328 rcd+=0; // CEWI 00329 return att_nm; 00330 } // end nco_inq_attname()
|
|
||||||||||||||||||||||||
|
Definition at line 304 of file nco_att.cc. References nc_inq_attname, NC_MAX_NAME, NC_NOERR, and nco_err_exit(). 00309 { 00310 /* Purpose: Wrapper for nc_inq_attname() 00311 User may omit rcd_opt, or supply value of non-fatal netCDF return code */ 00312 char att_nm_chr[NC_MAX_NAME]; 00313 int rcd=nc_inq_attname(nc_id,var_id,att_id,att_nm_chr); 00314 att_nm=att_nm_chr; 00315 if(rcd != NC_NOERR && rcd != rcd_opt) nco_err_exit(rcd,"nco_inq_attname"); 00316 return rcd; 00317 } // end nco_inq_attname()
|
|
||||||||||||||||
|
Definition at line 365 of file nco_att.cc. References nco_inq_atttype(), and nco_inq_varid(). 00368 { 00369 // Purpose: Wrapper for nco_inq_atttype() 00370 nc_type att_typ; // O [enm] Variable type 00371 int rcd=nco_inq_atttype(nc_id,nco_inq_varid(nc_id,var_nm),att_nm,att_typ); 00372 rcd+=0; // CEWI 00373 return att_typ; 00374 } // end nco_inq_atttype()
|
|
||||||||||||||||||||||||
|
Definition at line 350 of file nco_att.cc. References nc_inq_atttype, NC_NOERR, and nco_err_exit(). 00355 { 00356 /* Purpose: Wrapper for nc_inq_atttype() 00357 User may omit rcd_opt, or supply value of non-fatal netCDF return code */ 00358 int rcd=nc_inq_atttype(nc_id,var_id,att_nm.c_str(),&att_typ); 00359 if(rcd != NC_NOERR && rcd != rcd_opt) nco_err_exit(rcd,"nco_inq_atttype"); 00360 return rcd; 00361 } // end nco_inq_atttype()
|
|
||||||||||||||||||||||||
|
Definition at line 207 of file nco_att.cc. References NC_NOERR, nc_put_att_double, and nco_err_exit(). 00212 { 00213 // Purpose: Wrapper for nc_put_att_double() 00214 // fxm: For some reason vector works here but valarray does not 00215 int rcd=nc_put_att_double(nc_id,var_id,att_nm.c_str(),att_typ,att_val.size(),&att_val[0]); 00216 if(rcd != NC_NOERR) nco_err_exit(rcd,"nco_put_att<std::vector<double>>"); 00217 return rcd; 00218 } // end nco_put_att<std::vector<double>>()
|
|
||||||||||||||||||||
|
Definition at line 195 of file nco_att.cc. References nco_inq_varid(), and nco_put_att(). 00199 { 00200 // Purpose: Wrapper for nco_put_att<std::string>() 00201 int rcd=nco_put_att(nc_id,nco_inq_varid(nc_id,var_nm),att_nm,att_val); 00202 return rcd; 00203 } // end nco_put_att<std::string>()
|
|
||||||||||||||||||||
|
Definition at line 182 of file nco_att.cc. References NC_NOERR, nc_put_att_text, and nco_err_exit(). 00186 { 00187 // Purpose: Wrapper for nc_put_att_text() 00188 int rcd=nc_put_att_text(nc_id,var_id,att_nm.c_str(),att_val.size(),att_val.c_str()); 00189 if(rcd != NC_NOERR) nco_err_exit(rcd,"nco_put_att<std::string>"); 00190 return rcd; 00191 } // end nco_put_att<std::string>()
|
|
||||||||||||||||||||||||
|
Definition at line 168 of file nco_att.cc. References nc_put_att_long. 00173 { 00174 // Purpose: Wrapper for nc_put_att_long() 00175 const size_t att_sz(1); 00176 int rcd=nc_put_att_long(nc_id,var_id,att_nm.c_str(),att_typ,att_sz,&(const_cast<long &>(att_val))); 00177 return rcd; 00178 } // end nco_put_att<long>()
|
|
||||||||||||||||||||||||||||
|
Definition at line 154 of file nco_att.cc. References nc_put_att_long. 00160 { 00161 // Purpose: Wrapper for nc_put_att_long() 00162 int rcd=nc_put_att_long(nc_id,var_id,att_nm.c_str(),att_typ,att_sz,att_val); 00163 return rcd; 00164 } // end nco_put_att<long>()
|
|
||||||||||||||||||||||||
|
Definition at line 140 of file nco_att.cc. References nc_put_att_short. 00145 { 00146 // Purpose: Wrapper for nc_put_att_short() 00147 const size_t att_sz(1); 00148 int rcd=nc_put_att_short(nc_id,var_id,att_nm.c_str(),att_typ,att_sz,&(const_cast<short &>(att_val))); 00149 return rcd; 00150 } // end nco_put_att<short>()
|
|
||||||||||||||||||||||||||||
|
Definition at line 126 of file nco_att.cc. References nc_put_att_short. 00132 { 00133 // Purpose: Wrapper for nc_put_att_short() 00134 int rcd=nc_put_att_short(nc_id,var_id,att_nm.c_str(),att_typ,att_sz,att_val); 00135 return rcd; 00136 } // end nco_put_att<short>()
|
|
||||||||||||||||||||||||
|
Definition at line 112 of file nco_att.cc. References nc_put_att_int. 00117 { 00118 // Purpose: Wrapper for nc_put_att_int() 00119 const size_t att_sz(1); 00120 int rcd=nc_put_att_int(nc_id,var_id,att_nm.c_str(),att_typ,att_sz,&(const_cast<int &>(att_val))); 00121 return rcd; 00122 } // end nco_put_att<int>()
|
|
||||||||||||||||||||||||||||
|
Definition at line 98 of file nco_att.cc. References nc_put_att_int. 00104 { 00105 // Purpose: Wrapper for nc_put_att_int() 00106 int rcd=nc_put_att_int(nc_id,var_id,att_nm.c_str(),att_typ,att_sz,att_val); 00107 return rcd; 00108 } // end nco_put_att<int>()
|
|
||||||||||||||||||||||||
|
Definition at line 84 of file nco_att.cc. References nc_put_att_double. 00089 { 00090 // Purpose: Wrapper for nc_put_att_double() 00091 const size_t att_sz(1); 00092 int rcd=nc_put_att_double(nc_id,var_id,att_nm.c_str(),att_typ,att_sz,&(const_cast<double &>(att_val))); 00093 return rcd; 00094 } // end nco_put_att<double>()
|
|
||||||||||||||||||||||||||||
|
Definition at line 69 of file nco_att.cc. References NC_NOERR, nc_put_att_double, and nco_err_exit(). 00075 { 00076 // Purpose: Wrapper for nc_put_att_double() 00077 int rcd=nc_put_att_double(nc_id,var_id,att_nm.c_str(),att_typ,att_sz,att_val); 00078 if(rcd != NC_NOERR) nco_err_exit(rcd,"nco_put_att<double>"); 00079 return rcd; 00080 } // end nco_put_att<double>()
|
|
||||||||||||||||||||||||
|
Definition at line 49 of file nco_att.cc. References nc_put_att_float. 00054 { 00055 // Purpose: Wrapper for nco_put_att<float>() 00056 const size_t att_sz(1); 00057 /* fxm: NB: float is the source from which all other nco_put_att<type> functions should 00058 be copied/templated, once the best method for handling single value puts is determined, 00059 that is */ 00060 // int rcd=nco_put_att(nc_id,var_id,att_nm,att_sz,&(const_cast<float &>(att_val)),att_typ); 00061 // float foo_val(att_val); 00062 // int rcd=nco_put_att(nc_id,var_id,att_nm,att_sz,&foo_val,att_typ); 00063 int rcd=nc_put_att_float(nc_id,var_id,att_nm.c_str(),att_typ,att_sz,&(const_cast<float &>(att_val))); 00064 return rcd; 00065 } // end nco_put_att<float>()
|
|
||||||||||||||||||||||||||||
|
Definition at line 34 of file nco_att.cc. References NC_NOERR, nc_put_att_float, and nco_err_exit(). 00040 { 00041 // Purpose: Wrapper for nc_put_att_float() 00042 int rcd=nc_put_att_float(nc_id,var_id,att_nm.c_str(),att_typ,att_sz,att_val); 00043 if(rcd != NC_NOERR) nco_err_exit(rcd,"nco_put_att<float>"); 00044 return rcd; 00045 } // end nco_put_att<float>()
|
1.4.4