bes  Updated for version 3.20.10
h5cfdap.cc
Go to the documentation of this file.
1 // This file is part of hdf5_handler a HDF5 file handler for the OPeNDAP
2 // data server.
3 
4 // Copyright (c) 2007-2016 The HDF Group, Inc. and OPeNDAP, Inc.
5 //
6 // This is free software; you can redistribute it and/or modify it under the
7 // terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 2.1 of the License, or (at your
9 // option) any later version.
10 //
11 // This software is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //
20 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
21 // You can contact The HDF Group, Inc. at 1800 South Oak Street,
22 // Suite 203, Champaign, IL 61820
23 
33 
34 #include <libdap/InternalErr.h>
35 #include <BESDebug.h>
36 #include <libdap/mime_util.h>
37 #include "config_hdf5.h"
38 #include "h5cfdap.h"
39 
40 using namespace std;
41 using namespace libdap;
42 
43 void read_cfdds(DDS&,const string&,hid_t);
44 void read_cfdas(DAS&, const string&,hid_t);
45 void read_cfdmr(DMR*, const string&,hid_t);
46 
47 void read_cfdds(DDS & dds, const string &filename,hid_t myfile_id) {
48 
49  BESDEBUG("h5","Coming to CF DDS read function read_cfdds "<<endl);
50 
51  // Set the DDS name be the file name
52  dds.set_dataset_name(name_path(filename));
53 
54  hid_t fileid = myfile_id;
55  H5CFModule moduletype;
56 
57 #if 0
58  fileid = H5Fopen(filename.c_str(),H5F_ACC_RDONLY,H5P_DEFAULT);
59  if (fileid < 0) {
60  string msg =
61  "h5_cf_dds handler: Cannot open the HDF5 file ";
62  msg += filename;
63  throw InternalErr(__FILE__, __LINE__, msg);
64  }
65 #endif
66 
67  moduletype = check_module(fileid);
68  if (moduletype == HDF_EOS5) {
69  map_eos5_cfdds(dds,fileid, filename);
70  }
71  else { // handle HDF5 general product
72  map_gmh5_cfdds(dds,fileid, filename);
73 
74  }
75 
76 }
77 
78 void read_cfdas(DAS & das, const string &filename,hid_t myfile_id) {
79 
80  BESDEBUG("h5","Coming to CF DAS read function read_cfdas "<<endl);
81  hid_t fileid = myfile_id;
82  H5CFModule moduletype;
83 
84 #if 0
85  fileid = H5Fopen(filename.c_str(),H5F_ACC_RDONLY,H5P_DEFAULT);
86  if (fileid < 0) {
87  string msg =
88  "h5_cf_das handler: Cannot open the HDF5 file ";
89  msg += filename;
90  throw InternalErr(__FILE__, __LINE__, msg);
91  }
92 #endif
93 
94  moduletype = check_module(fileid);
95  if (moduletype == HDF_EOS5) {
96  map_eos5_cfdas(das,fileid, filename);
97  }
98  else { // handle HDF5 general product
99  map_gmh5_cfdas(das,fileid, filename);
100  }
101 
102 }
103 
104 void read_cfdmr(DMR* dmr, const string &filename,hid_t fileid) {
105 
106  BESDEBUG("h5","Coming to CF DMR read function read_cfdmr "<<endl);
107  H5CFModule moduletype;
108  dmr->set_name(name_path(filename));
109  dmr->set_filename(name_path(filename));
110  D4Group *d4_root = dmr->root();
111  moduletype = check_module(fileid);
112  if (moduletype == HDF_EOS5)
113  map_eos5_cfdmr(d4_root,fileid, filename);
114  else // handle HDF5 general product
115  map_gmh5_cfdmr(d4_root,fileid, filename);
116 
117  BESDEBUG("h5","Coming to CF DMR read function read_cfdmr "<<endl);
118 
119  return;
120 
121 }
The main wrapper of headers of the HDF5 OPeNDAP handler for the CF option.