Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
@@ -53,7 +53,7 @@ inline bool write_array(hid_t a_loc,const std::string& a_name,
cpt = ::H5Pcreate(H5P_DATASET_CREATE);
if(cpt<0) return false;
if(a_chunked) {
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
::H5Pclose(cpt);
return false;
}
@@ -64,7 +64,7 @@ inline bool write_array(hid_t a_loc,const std::string& a_name,
return false;
}
} else {
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
::H5Pclose(cpt);
return false;
}
@@ -87,9 +87,9 @@ inline bool write_array(hid_t a_loc,const std::string& a_name,
if(a_chunked) {
hsize_t mx_dims[1];
mx_dims[0] = H5S_UNLIMITED; //extendable.
file_space = ::H5Screate_simple(1,dims,mx_dims);
file_space = ::H5Screate_simple(1,dims,mx_dims);
} else {
file_space = ::H5Screate_simple(1,dims,NULL);
file_space = ::H5Screate_simple(1,dims,NULL);
}
if(file_space<0) {if(cpt>=0) ::H5Pclose(cpt);return false;}
dataset = tools_H5Dcreate(a_loc,a_name.c_str(),a_file_type,file_space,cpt);
@@ -98,7 +98,7 @@ inline bool write_array(hid_t a_loc,const std::string& a_name,
if(dataset<0) return false;}
if(H5Dwrite(dataset,a_mem_type,H5S_ALL,H5S_ALL,H5P_DEFAULT,a_array)<0) {
::H5Dclose(dataset);
::H5Dclose(dataset);
return false;
}
::H5Dclose(dataset);
@@ -116,7 +116,7 @@ inline bool write_vlen(hid_t a_loc,const std::string& a_name,
cpt = ::H5Pcreate(H5P_DATASET_CREATE);
if(cpt<0) return false;
if(a_chunked) {
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
::H5Pclose(cpt);
return false;
}
@@ -127,7 +127,7 @@ inline bool write_vlen(hid_t a_loc,const std::string& a_name,
return false;
}
} else {
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
::H5Pclose(cpt);
return false;
}
@@ -150,9 +150,9 @@ inline bool write_vlen(hid_t a_loc,const std::string& a_name,
if(a_chunked) {
hsize_t mx_dims[1];
mx_dims[0] = H5S_UNLIMITED; //extendable.
file_space = ::H5Screate_simple(1,dims,mx_dims);
file_space = ::H5Screate_simple(1,dims,mx_dims);
} else {
file_space = ::H5Screate_simple(1,dims,NULL);
file_space = ::H5Screate_simple(1,dims,NULL);
}
if(file_space<0) {if(cpt>=0) ::H5Pclose(cpt);return false;}
@@ -165,14 +165,14 @@ inline bool write_vlen(hid_t a_loc,const std::string& a_name,
if(dataset<0) return false;}
hid_t mem_type = ::H5Tvlen_create(a_mem_type);
hvl_t wdata[1];
wdata[0].len = a_size;
wdata[0].p = (void*)a_array;
if(H5Dwrite(dataset,mem_type,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata)<0) {
::H5Tclose(mem_type);
::H5Dclose(dataset);
::H5Dclose(dataset);
return false;
}
::H5Tclose(mem_type);
@@ -200,7 +200,7 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
cpt = ::H5Pcreate(H5P_DATASET_CREATE);
if(cpt<0) return false;
if(a_chunked) {
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
::H5Pclose(cpt);
return false;
}
@@ -212,7 +212,7 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
return false;
}
} else {
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
::H5Pclose(cpt);
return false;
}
@@ -235,7 +235,7 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
if(a_create) {
hsize_t dims[1];
dims[0] = a_size;
file_space = ::H5Screate_simple(1,dims,NULL);
file_space = ::H5Screate_simple(1,dims,NULL);
if(file_space<0) {
if(cpt>=0) ::H5Pclose(cpt);
return false;
@@ -265,9 +265,9 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
return false;
}
file_space = H5Dget_space(dataset);
file_space = H5Dget_space(dataset);
if(file_space<0) {
::H5Dclose(dataset);
::H5Dclose(dataset);
if(cpt>=0) ::H5Pclose(cpt);
return false;
}
@@ -278,7 +278,7 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
count[0] = number;
if(H5Sselect_hyperslab(file_space,H5S_SELECT_SET,offset,NULL,count,NULL)<0) {
::H5Sclose(file_space);
::H5Dclose(dataset);
::H5Dclose(dataset);
if(cpt>=0) ::H5Pclose(cpt);
return false;
}}
@@ -287,7 +287,7 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
hsize_t dims[1];
dims[0] = number;
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
if(mem_space<0) {
::H5Sclose(file_space);
::H5Dclose(dataset);
@@ -297,7 +297,7 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
if(H5Dwrite(dataset,a_mem_type,mem_space,file_space,H5P_DEFAULT,a_array)<0) {
::H5Sclose(file_space);
::H5Dclose(dataset);
::H5Dclose(dataset);
if(cpt>=0) ::H5Pclose(cpt);
return false;
}
@@ -314,8 +314,8 @@ inline bool write_append_array_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid
unsigned int a_number,const T a_array[]) {
hsize_t old_size = 0;
{hid_t dataspace = H5Dget_space(a_dataset);
if(dataspace<0) return false;
{hid_t dataspace = H5Dget_space(a_dataset);
if(dataspace<0) return false;
hsize_t dims[1];
if(H5Sget_simple_extent_dims(dataspace,dims,NULL)<0) {
::H5Sclose(dataspace);
@@ -329,7 +329,7 @@ inline bool write_append_array_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid
// if(H5Dextend(dataset,exts)<0) {
if(H5Dset_extent(a_dataset,exts)<0) return false;}
hid_t file_space = H5Dget_space(a_dataset);
hid_t file_space = H5Dget_space(a_dataset);
if(file_space<0) return false;
{hsize_t offset[1];
@@ -343,7 +343,7 @@ inline bool write_append_array_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid
hsize_t dims[1];
dims[0] = a_number;
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
if(mem_space<0) {
::H5Sclose(file_space);
return false;
@@ -366,8 +366,8 @@ inline bool write_append_vlen_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid_
unsigned int a_number,const T a_array[]) {
hsize_t old_size = 0;
{hid_t dataspace = H5Dget_space(a_dataset);
if(dataspace<0) return false;
{hid_t dataspace = H5Dget_space(a_dataset);
if(dataspace<0) return false;
hsize_t dims[1];
if(H5Sget_simple_extent_dims(dataspace,dims,NULL)<0) {
::H5Sclose(dataspace);
@@ -381,7 +381,7 @@ inline bool write_append_vlen_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid_
// if(H5Dextend(dataset,exts)<0) {
if(H5Dset_extent(a_dataset,exts)<0) return false;}
hid_t file_space = H5Dget_space(a_dataset);
hid_t file_space = H5Dget_space(a_dataset);
if(file_space<0) return false;
{hsize_t offset[1];
@@ -395,18 +395,18 @@ inline bool write_append_vlen_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid_
hsize_t dims[1];
dims[0] = 1;
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
if(mem_space<0) {
::H5Sclose(file_space);
return false;
}
hid_t mem_type = ::H5Tvlen_create(a_mem_type);
hvl_t wdata[1];
wdata[0].len = a_number;
wdata[0].p = (void*)a_array;
if(H5Dwrite(a_dataset,mem_type,mem_space,file_space,H5P_DEFAULT,wdata)<0) {
::H5Tclose(mem_type);
::H5Sclose(mem_space);
@@ -427,7 +427,7 @@ inline bool write_append_array(hid_t a_loc,const std::string& a_name,hid_t a_fil
hid_t dataset = tools_H5Dopen(a_loc,a_name.c_str());
if(dataset<0) return false;
bool status = write_append_array_dataset(dataset,a_file_type,a_mem_type,a_number,a_array);
::H5Dclose(dataset);
::H5Dclose(dataset);
return status;
}
@@ -443,7 +443,7 @@ inline bool write_array_struct(
){
hsize_t dims[1];
dims[0] = a_size;
hid_t dataspace = ::H5Screate_simple(1,dims,NULL);
hid_t dataspace = ::H5Screate_simple(1,dims,NULL);
if(dataspace<0) return false;
hid_t dataset = tools_H5Dcreate(a_loc,a_name.c_str(),a_create_type,dataspace,H5P_DEFAULT);
@@ -453,12 +453,12 @@ inline bool write_array_struct(
}
if(H5Dwrite(dataset,aWriteType,H5S_ALL,H5S_ALL,H5P_DEFAULT,a_array)<0) {
::H5Dclose(dataset);
::H5Dclose(dataset);
::H5Sclose(dataspace);
return false;
}
::H5Dclose(dataset);
::H5Dclose(dataset);
::H5Sclose(dataspace);
return true;
@@ -476,7 +476,7 @@ inline bool read_scalar(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,T
return false;
}
hid_t mem_space = ::H5Screate(H5S_SCALAR);
hid_t mem_space = ::H5Screate(H5S_SCALAR);
if(mem_space<0) {
::H5Sclose(file_space);
::H5Dclose(dataset);
@@ -550,7 +550,7 @@ inline bool read_array(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,un
return true; //It is ok.
}
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
if(mem_space<0) {
::H5Sclose(file_space);
::H5Dclose(dataset);
@@ -631,8 +631,8 @@ inline bool read_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,uns
a_array = 0;
return false;
}
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
if(mem_space<0) {
::H5Sclose(file_space);
::H5Dclose(dataset);
@@ -666,9 +666,9 @@ inline bool read_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,uns
for(hsize_t index=0;index<len;index++,pos++,_data++) *pos = *_data;
}
a_size = len;
::H5Dvlen_reclaim(mem_type,mem_space,H5P_DEFAULT,rdata);
::H5Tclose(mem_type);
::H5Sclose(mem_space);
::H5Sclose(file_space);
@@ -734,7 +734,7 @@ inline bool read_sub_array(hid_t a_loc,const std::string& a_name,hid_t a_mem_typ
}
// abcdef
// 012345
// 012345
int remain = sz-a_offset;
if(remain<=0) {
::H5Sclose(file_space);
@@ -743,7 +743,7 @@ inline bool read_sub_array(hid_t a_loc,const std::string& a_name,hid_t a_mem_typ
a_array = 0;
return a_number?false:true;
}
int number = (int(a_number)<=remain) ? int(a_number) : remain;
if(number<=0) {
::H5Sclose(file_space);
@@ -766,7 +766,7 @@ inline bool read_sub_array(hid_t a_loc,const std::string& a_name,hid_t a_mem_typ
}}
dims[0] = number;
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
if(mem_space<0) {
::H5Sclose(file_space);
::H5Dclose(dataset);
@@ -850,7 +850,7 @@ inline bool read_sub_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type
}
// abcdef
// 012345
// 012345
int remain = sz-a_offset;
if(remain<=0) {
::H5Sclose(file_space);
@@ -859,7 +859,7 @@ inline bool read_sub_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type
a_array = 0;
return false;
}
{hsize_t offset[1];
offset[0] = a_offset;
hsize_t count[1];
@@ -873,7 +873,7 @@ inline bool read_sub_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type
}}
dims[0] = 1;
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
if(mem_space<0) {
::H5Sclose(file_space);
::H5Dclose(dataset);
@@ -907,9 +907,9 @@ inline bool read_sub_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type
for(hsize_t index=0;index<len;index++,pos++,_data++) *pos = *_data;
}
a_size = len;
::H5Dvlen_reclaim(mem_type,mem_space,H5P_DEFAULT,rdata);
::H5Tclose(mem_type);
::H5Sclose(mem_space);
::H5Sclose(file_space);
@@ -994,7 +994,7 @@ inline bool read_array_struct(
return false;
}}
hid_t memspace = ::H5Screate_simple(dimn,dims,NULL);
hid_t memspace = ::H5Screate_simple(dimn,dims,NULL);
if(memspace<0) {
delete [] dims;
::H5Sclose(dataspace);
@@ -1064,7 +1064,7 @@ inline bool read_struct(hid_t a_loc,const std::string& a_name,hid_t aReadType,T&
::H5Dclose(dataset);
return true;
}
template <class TYPE>
inline bool write_scalar(hid_t a_loc,const std::string& a_name,const TYPE& aData) {
hid_t scalar = ::H5Screate(H5S_SCALAR);
@@ -1076,7 +1076,7 @@ inline bool write_scalar(hid_t a_loc,const std::string& a_name,const TYPE& aData
return false;
}
if(H5Pset_layout(compact,H5D_COMPACT)<0) {
if(H5Pset_layout(compact,H5D_COMPACT)<0) {
::H5Pclose(compact);
::H5Sclose(scalar);
return false;
@@ -1088,22 +1088,22 @@ inline bool write_scalar(hid_t a_loc,const std::string& a_name,const TYPE& aData
::H5Sclose(scalar);
return false;
}
if(::H5Dwrite(dataset,to_T_mem_type(TYPE()),H5S_ALL,H5S_ALL,H5P_DEFAULT,&aData)<0) {
::H5Pclose(compact);
::H5Sclose(scalar);
::H5Dclose(dataset);
::H5Dclose(dataset);
return false;
}
::H5Pclose(compact);
::H5Sclose(scalar);
::H5Dclose(dataset);
::H5Dclose(dataset);
return true;
}
template <class T>
inline bool write_struct(hid_t a_loc,const std::string& a_name,
inline bool write_struct(hid_t a_loc,const std::string& a_name,
hid_t a_create_type,hid_t aWriteType,const T& aData) {
hid_t scalar = ::H5Screate(H5S_SCALAR);
if(scalar<0) return false;
@@ -1114,7 +1114,7 @@ inline bool write_struct(hid_t a_loc,const std::string& a_name,
return false;
}
if(H5Pset_layout(compact,H5D_COMPACT)<0) {
if(H5Pset_layout(compact,H5D_COMPACT)<0) {
::H5Pclose(compact);
::H5Sclose(scalar);
return false;
@@ -1130,13 +1130,13 @@ inline bool write_struct(hid_t a_loc,const std::string& a_name,
if(H5Dwrite(dataset,aWriteType,H5S_ALL,H5S_ALL,H5P_DEFAULT,&aData)<0) {
::H5Pclose(compact);
::H5Sclose(scalar);
::H5Dclose(dataset);
::H5Dclose(dataset);
return false;
}
::H5Pclose(compact);
::H5Sclose(scalar);
::H5Dclose(dataset);
::H5Dclose(dataset);
return true;
}
@@ -1288,7 +1288,7 @@ inline bool write_scalar_atb(hid_t aDS,const std::string& a_name,const TYPE& aDa
if(has_attr==1) {
if(H5Adelete(aDS,a_name.c_str())<0) return false;
}
hid_t scalar = ::H5Screate(H5S_SCALAR);
if(scalar<0) return false;
@@ -1297,16 +1297,16 @@ inline bool write_scalar_atb(hid_t aDS,const std::string& a_name,const TYPE& aDa
::H5Sclose(scalar);
return false;
}
if(H5Awrite(aid,to_T_mem_type(TYPE()),&aData)<0) {
::H5Sclose(scalar);
::H5Aclose(aid);
return false;
}
::H5Sclose(scalar);
::H5Aclose(aid);
return true;
}
@@ -1321,7 +1321,7 @@ namespace hdf5 {
inline bool write_strings(hid_t a_loc,const std::string& a_name,
size_t a_number,const char** a_strings,
unsigned int a_chunked = 0,unsigned int a_compress = 0) {
size_t sz;char* buffer;
size_t sz;char* buffer;
if(!tools::strings2buf(a_number,a_strings,sz,buffer)) return false;
sz--;
bool status = hdf5::write_array<char>(a_loc,a_name,to_T_file_type(char()),to_T_mem_type(char()),
@@ -1333,7 +1333,7 @@ inline bool write_strings(hid_t a_loc,const std::string& a_name,
inline bool write_strings(hid_t a_loc,const std::string& a_name,
const std::vector<std::string>& a_strings,
unsigned int a_chunked = 0,unsigned int a_compress = 0) {
size_t sz;char* buffer;
size_t sz;char* buffer;
if(!tools::strings2buf(a_strings,sz,buffer)) return false;
sz--;
bool status = hdf5::write_array<char>(a_loc,a_name,to_T_file_type(char()),to_T_mem_type(char()),
@@ -1343,7 +1343,7 @@ inline bool write_strings(hid_t a_loc,const std::string& a_name,
}
inline bool write_append_strings(hid_t a_loc,const std::string& a_name,size_t a_number,const char** a_strings) {
size_t sz;char* buffer;
size_t sz;char* buffer;
if(!tools::strings2buf(a_number,a_strings,sz,buffer)) return false;
sz--;
bool status = hdf5::write_append_array<char>(a_loc,a_name,to_T_file_type(char()),to_T_mem_type(char()),(unsigned int)sz,buffer);
@@ -1352,7 +1352,7 @@ inline bool write_append_strings(hid_t a_loc,const std::string& a_name,size_t a_
}
inline bool write_append_strings(hid_t a_loc,const std::string& a_name,const std::vector<std::string>& a_strings) {
size_t sz;char* buffer;
size_t sz;char* buffer;
if(!tools::strings2buf(a_strings,sz,buffer)) return false;
sz--;
bool status = hdf5::write_append_array<char>(a_loc,a_name,to_T_file_type(char()),to_T_mem_type(char()),(unsigned int)sz,buffer);