OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
cdl_utils.h
Go to the documentation of this file.
1 #include <stdint.h>
2 #include <iostream>
3 #include <fstream>
4 
5 #define PBUFFER_SIZE 32768
6 
7 using namespace std;
8 
9 class ncdfFile {
10  int ncid;
11 
12  int ngrps;
13  int gid[10];
14 
15  int ndims;
16  int dimid[1000];
17 
18 public:
19  ncdfFile();
20  ~ncdfFile();
21 
22  int cdlCreate(char* l1_filename, char* cdl_filename, int32_t numScans);
23 
24  int cdlCreateDim(char* l1_filename, char* cdl_filename, const char** dim_names, size_t* dim_size, size_t n_dims, size_t numScans);
25 
26  int parseDims(string dimString, int *numDims, int *varDims);
27 
28  int getGid(const char *grpName);
29  int getNcid();
30  int close();
31 };
32 
33 inline
34 int expandEnvVar(string *sValue) {
35  if ((*sValue).find_first_of("$") == string::npos) return 0;
36  string::size_type posEndIdx = (*sValue).find_first_of("/");
37  if (posEndIdx == string::npos) return 0;
38  char *envVar_str = getenv((*sValue).substr(1, posEndIdx - 1).c_str());
39  if (envVar_str == 0x0) {
40  printf("Environment variable: %s not defined.\n", envVar_str);
41  exit(1);
42  }
43  *sValue = envVar_str + (*sValue).substr(posEndIdx);
44 
45  return 0;
46 }
int parseDims(int ncid, int ndims, string dimString, int *numDims, int *dimid, int *varDims)
int expandEnvVar(string *sValue)
Definition: cdl_utils.h:34