bes Updated for version 3.20.13
HDF5CFFloat64.cc
Go to the documentation of this file.
1// This file is part of hdf5_handler: an HDF5 file handler for the OPeNDAP
2// data server.
3
4// Copyright (c) 2011-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
32
33#include "config_hdf5.h"
34
35#include <libdap/InternalErr.h>
36#include "HDF5CFFloat64.h"
37#include <BESDebug.h>
38#include "h5common.h"
39
40using namespace std;
41using namespace libdap;
42
43HDF5CFFloat64::HDF5CFFloat64(const string &n, const string &d):Float64(n, d)
44{
45}
46
47HDF5CFFloat64::HDF5CFFloat64(const string &n, const string &d,const string &d_f) : Float64(n, d),filename(d_f)
48{
49}
50
51BaseType *HDF5CFFloat64::ptr_duplicate()
52{
53 return new HDF5CFFloat64(*this);
54}
55
56bool HDF5CFFloat64::read()
57{
58 BESDEBUG("h5","Coming to HDF5CFFloat64 read "<<endl);
59
60 if (read_p())
61 return true;
62
63 hid_t file_id = H5Fopen(filename.c_str(),H5F_ACC_RDONLY,H5P_DEFAULT);
64 if(file_id < 0) {
65 throw InternalErr(__FILE__,__LINE__, "Fail to obtain the HDF5 file ID .");
66 }
67
68 hid_t dset_id = -1;
69 dset_id = H5Dopen2(file_id,dataset().c_str(),H5P_DEFAULT);
70
71 if(dset_id < 0) {
72 H5Fclose(file_id);
73 throw InternalErr(__FILE__,__LINE__, "Fail to obtain the dataset .");
74 }
75
76 try {
77 dods_float64 buf;
78
79 get_data(dset_id, (void *) &buf);
80
81 set_read_p(true);
82 set_value(buf);
83
84 // Release the handles.
85 if (H5Dclose(dset_id) < 0) {
86 throw InternalErr(__FILE__, __LINE__, "Unable to close the dset.");
87 }
88 H5Fclose(file_id);
89 }
90 catch(...) {
91 H5Dclose(dset_id);
92 H5Fclose(file_id);
93 throw;
94 }
95
96 return true;
97
98}
This class provides a way to map HDF5 64-bit floating-point(double) to DAP 64-bit floating-point for ...
void get_data(hid_t dset, void *buf)
Definition: h5common.cc:50