1 /* 2 This file is part of CDO. CDO is a collection of Operators to manipulate and analyse Climate model Data. 3 4 Author: Uwe Schulzweida 5 6 */ 7 #ifndef GRIDDES_H 8 #define GRIDDES_H 9 10 #include <vector> 11 #include <string> 12 #include <cdi.h> 13 14 constexpr double undef_grid_value = 9.e20; 15 16 struct // GridDesciption 17 #ifdef WARN_UNUSED 18 [[gnu::warn_unused]] 19 #endif 20 GridDesciption 21 { 22 std::vector<int> mask; 23 std::vector<double> xvals; 24 std::vector<double> yvals; 25 std::vector<double> xbounds; 26 std::vector<double> ybounds; 27 std::vector<double> area; 28 std::vector<int> reducedPoints; 29 double xfirst = undef_grid_value, yfirst = undef_grid_value; 30 double xlast = undef_grid_value, ylast = undef_grid_value; 31 double xinc = undef_grid_value, yinc = undef_grid_value; 32 double xpole = 0.0, ypole = 0.0, angle = 0.0; // rotated north pole 33 int scanningMode = 64; 34 /* 35 scanningMode = 128 * iScansNegatively + 64 * jScansPositively + 32 * jPointsAreConsecutive; 36 64 = 128 * 0 + 64 * 1 + 32 * 0 37 00 = 128 * 0 + 64 * 0 + 32 * 0 38 96 = 128 * 0 + 64 * 1 + 32 * 1 39 Default implicit scanning mode is 64: i and j scan positively, i points are consecutive (row-major) 40 */ 41 double a = 0.0; 42 int isRotated = 0; // true for rotated grids 43 int datatype = CDI_UNDEFID; 44 int type = CDI_UNDEFID; 45 int ntr = 0; 46 int nvertex = 0; 47 size_t size = 0; 48 size_t xsize = 0; 49 size_t ysize = 0; 50 int numLPE = 0; 51 int lcomplex = 1; 52 bool genBounds = false; 53 int nd = 0, ni = 0, ni2 = 0, ni3 = 0; 54 int number = 0, position = 0; 55 unsigned char uuid[CDI_UUID_SIZE] = { 0 }; 56 char path[16384] = { 0 }; 57 char xname[CDI_MAX_NAME] = { 0 }; 58 char xlongname[CDI_MAX_NAME] = { 0 }; 59 char xunits[CDI_MAX_NAME] = { 0 }; 60 char xdimname[CDI_MAX_NAME] = { 0 }; 61 char yname[CDI_MAX_NAME] = { 0 }; 62 char ylongname[CDI_MAX_NAME] = { 0 }; 63 char yunits[CDI_MAX_NAME] = { 0 }; 64 char ydimname[CDI_MAX_NAME] = { 0 }; 65 char vdimname[CDI_MAX_NAME] = { 0 }; 66 }; 67 68 int grid_define(GridDesciption &grid); 69 70 int gird_from_nc_file(const char *gridfile); 71 int grid_from_h5_file(const char *gridfile); 72 int grid_from_name(const char *gridname); 73 74 void write_n_cgrid(const char *gridfile, int gridID, int *imask); 75 76 int cdo_define_grid(const std::string &gridfile); 77 78 int grid_read(FILE *gfp, const char *dname); // TODO: Find better place for this 79 80 int cdo_cdf_openread(const char *filename); 81 void cdo_cdf_close(int nc_file_id); 82 void cdo_set_grids(const char *gridarg); 83 84 void gaussian_latitudes_in_degrees(std::vector<double> &lats, std::vector<double> &lat_bounds, size_t nlat); 85 86 #endif /* GRIDDES_H */ 87