資源簡介
hdf5,安裝netcdf所需安裝的包之一,版本為1.8.11,適用于linux64位系統(tǒng)(32位未知)
代碼片段和文件信息
/*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*
?*?Copyright?by?The?HDF?Group.???????????????????????????????????????????????*
?*?Copyright?by?the?Board?of?Trustees?of?the?University?of?Illinois.?????????*
?*?All?rights?reserved.??????????????????????????????????????????????????????*
?*???????????????????????????????????????????????????????????????????????????*
?*?This?file?is?part?of?HDF5.??The?full?HDF5?copyright?notice?including?????*
?*?terms?governing?use?modification?and?redistribution?is?contained?in????*
?*?the?files?COPYING?and?Copyright.html.??COPYING?can?be?found?at?the?root???*
?*?of?the?source?code?distribution?tree;?Copyright.html?can?be?found?at?the??*
?*?root?level?of?an?installed?copy?of?the?electronic?HDF5?document?set?and???*
?*?is?linked?from?the?top-level?documents?page.??It?can?also?be?found?at?????*
?*?http://hdfgroup.org/HDF5/doc/Copyright.html.??If?you?do?not?have??????????*
?*?access?to?either?file?you?may?request?a?copy?from?help@hdfgroup.org.?????*
?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*?*/
/*
?*???This?example?shows?how?to?read?data?from?a?chunked?dataset.
?*???We?will?read?from?the?file?created?by?extend.cpp
?*/
#ifdef?OLD_HEADER_FILENAME
#include?
#else
#include?
#endif
#include?
#ifndef?H5_NO_NAMESPACE
#ifndef?H5_NO_STD
????using?std::cout;
????using?std::endl;
#endif??//?H5_NO_STD
#endif
#include?“H5Cpp.h“
#ifndef?H5_NO_NAMESPACE
????using?namespace?H5;
#endif
const?H5std_string?FILE_NAME(?“SDSextendible.h5“?);
const?H5std_string?DATASET_NAME(?“ExtendibleArray“?);
const?int??????NX?=?10;
const?int??????NY?=?5;
const?int??????RANK?=?2;
const?int??????RANKC?=?1;
int?main?(void)
{
????hsize_t i?j;
????//?Try?block?to?detect?exceptions?raised?by?any?of?the?calls?inside?it
????try
????{
/*
?*?Turn?off?the?auto-printing?when?failure?occurs?so?that?we?can
?*?handle?the?errors?appropriately
?*/
Exception::dontPrint();
/*
?*?Open?the?file?and?the?dataset.
?*/
H5File?file(?FILE_NAME?H5F_ACC_RDONLY?);
DataSet?dataset?=?file.openDataSet(?DATASET_NAME?);
/*
?*?Get?filespace?for?rank?and?dimension
?*/
DataSpace?filespace?=?dataset.getSpace();
/*
?*?Get?number?of?dimensions?in?the?file?dataspace
?*/
int?rank?=?filespace.getSimpleExtentNdims();
/*
?*?Get?and?print?the?dimension?sizes?of?the?file?dataspace
?*/
hsize_t?dims[2];? //?dataset?dimensions
rank?=?filespace.getSimpleExtentDims(?dims?);
cout?<“dataset?rank?=?“?< ?????<(unsigned?long)(dims[0])?<“?x?“
?????<(unsigned?long)(dims[1])?<
/*
?*?Define?the?memory?space?to?read?dataset.
?*/
DataSpace?mspace1(RANK?dims);
/*
?*?Read?dataset?back?and?display.
?*/
int?data_out[NX][NY];??//?buffer?for?dataset?to?be?read
dataset.read(?data_out?PredType::NATIVE_INT?mspace1?filespace?);
cout?<“\n“;
cout?<“Dataset:?\n“;
for?(j?=?0;?j? {
????for?(i?=?0;?i?
評(píng)論
共有 條評(píng)論