├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── Makefile ├── README.md ├── src ├── H5_OO_mod.f90 ├── H5_func_mod.f90 ├── Strings_Func_mod.f90 └── Types_mod.f90 └── tests ├── test_funcs.f90 └── test_objs.f90 /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | *.smod 19 | 20 | # Compiled Static libraries 21 | *.lai 22 | *.la 23 | *.a 24 | *.lib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | 31 | #dset files 32 | *.h5 33 | *.nc 34 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [Unreleased] 2 | 3 | ## [1.1.1] 2017.04.10 - Ricardo Torres 4 | ### Fixed 5 | - Bug correction in h5 funciton calls 6 | 7 | ## [1.1.0] 2017.04.07 - Ricardo Torres 8 | ### Created 9 | - Defined extendDataset to write datasets in block or extend existing datasets 10 | - Defined methods to create scales and link them to datasets 11 | - New method to verify if an attribute exists 12 | ### Changed 13 | - The datasets can now be extended in all if its dimenions instead of only the last 14 | 15 | ## [1.0.0] 2017.03.22 - Ricardo Torres 16 | ### Created 17 | - Defined 4 classes, H5Attributable, H5Group, H5File and H5Dataset 18 | - Can open and create HDF5 File, open and creat a group, read and write attributes, read, read only part and write datasets. 19 | 20 | [Unreleased]: https://github.com/rjgtorres/oo_hdf/compare/v1.1.1...HEAD 21 | [1.1.1]: https://github.com/rjgtorres/oo_hdf/compare/v1.1.0...v1.1.1 22 | [1.1.0]: https://github.com/rjgtorres/oo_hdf/compare/v1.0.0...v1.1.0 23 | [1.0.0]: https://github.com/rjgtorres/oo_hdf/compare/2abbef6...v1.0.0 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017, Ricardo Torres 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Usage: 3 | # make mod # To compile module 4 | # make # To compile all routines and link it to HDF5 libraries 5 | # make clean # to remove *.o *.exe *.mod 6 | # 7 | 8 | SRC=src/ 9 | TEST=tests/ 10 | 11 | #PROG=wrapper 12 | TEST1=test_funcs 13 | TEST2=test_objs 14 | 15 | LIST_MOD_F=\ 16 | $(SRC)Types_mod.f90\ 17 | $(SRC)Strings_Func_mod.f90\ 18 | $(SRC)H5_func_mod.f90\ 19 | $(SRC)H5_OO_mod.f90 20 | 21 | LIST_SUB_F=\ 22 | 23 | 24 | # work compilation 25 | #DIRLIBRARY_H=/usr/local/hdf5-1.8.11/hdf5 26 | 27 | #LIBRARY_HF=hdf5_fortran 28 | #LIBRARY_H=hdf5 29 | 30 | #LIB=lib 31 | #INC=include 32 | 33 | 34 | # home compilation 35 | DIRLIBRARY_H=/usr 36 | 37 | LIBRARY_HF=hdf5_serial_fortran 38 | LIBRARY_H=hdf5_serial 39 | LIBRARY_HFL=hdf5_serialhl_fortran 40 | LIBRARY_HL=hdf5_serial_hl 41 | 42 | LIB=lib/x86_64-linux-gnu 43 | INC=include/hdf5/serial/ 44 | 45 | # *.f90 -> *.o 46 | LIST_MOD_O=$(LIST_MOD_F:.f90=.o) 47 | LIST_SUB_O=$(LIST_SUB_F:.f90=.o) 48 | 49 | 50 | #Compiler 51 | FC = gfortran 52 | 53 | #options for 54 | FFLAGS= -fbounds-check -O0 -fconvert=big-endian -finit-local-zero -cpp -DLITTLE_ENDIAN -Wsurprising -ffree-line-length-none -I $(DIRLIBRARY_H)/$(INC) -I $(DIRLIBRARY_H)/$(LIB) 55 | 56 | $(TEST1).exe: $(TEST)$(TEST1).o $(LIST_MOD_O) $(LIST_SUB_O) \ 57 | $(DIRLIBRARY_H)/$(LIB)/lib$(LIBRARY_HF).a \ 58 | $(DIRLIBRARY_H)/$(LIB)/lib$(LIBRARY_H).a \ 59 | $(DIRLIBRARY_H)/$(LIB)/lib$(LIBRARY_HL).a \ 60 | $(DIRLIBRARY_H)/$(LIB)/lib$(LIBRARY_HFL).a 61 | $(FC) $(FFLAGS) $(TEST)$(TEST1).o $(LIST_MOD_O) $(LIST_SUB_O) \ 62 | -L$(DIRLIBRARY_H)/$(LIB) \ 63 | -l$(LIBRARY_HF) \ 64 | -L$(DIRLIBRARY_H)/$(LIB) \ 65 | -l$(LIBRARY_H) \ 66 | -l$(LIBRARY_HL) \ 67 | -l$(LIBRARY_HFL) \ 68 | -o $@ 69 | 70 | $(TEST2).exe: $(TEST)$(TEST2).o $(LIST_MOD_O) $(LIST_SUB_O) \ 71 | $(DIRLIBRARY_H)/$(LIB)/lib$(LIBRARY_HF).a \ 72 | $(DIRLIBRARY_H)/$(LIB)/lib$(LIBRARY_H).a \ 73 | $(DIRLIBRARY_H)/$(LIB)/lib$(LIBRARY_HL).a \ 74 | $(DIRLIBRARY_H)/$(LIB)/lib$(LIBRARY_HFL).a 75 | $(FC) $(FFLAGS) $(TEST)$(TEST2).o $(LIST_MOD_O) $(LIST_SUB_O) \ 76 | -L$(DIRLIBRARY_H)/$(LIB) \ 77 | -l$(LIBRARY_HF) \ 78 | -L$(DIRLIBRARY_H)/$(LIB) \ 79 | -l$(LIBRARY_H) \ 80 | -l$(LIBRARY_HL) \ 81 | -l$(LIBRARY_HFL) \ 82 | -o $@ 83 | 84 | # -l$(LIBRARY_HL) \ 85 | # -l$(LIBRARY_HFL) \ 86 | # $(DIRLIBRARY_H)/$(LIB)/lib$(LIBRARY_HL).a \ 87 | # $(DIRLIBRARY_H)/$(LIB)/lib$(LIBRARY_HFL).a 88 | 89 | clean: 90 | rm -f $(SRC)*.o $(TEST)*.o *.exe *.mod *.o 91 | 92 | mod: 93 | $(FC) -c $(FFLAGS) $(LIST_MOD_F) 94 | 95 | all: 96 | make clean 97 | make mod 98 | make 99 | 100 | .SUFFIXES: .f90 .o 101 | 102 | .f90.o : 103 | $(FC) -c $(FFLAGS) $*.f90 -o $*.o 104 | 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # oo_hdf 2 | Object oriented fortran HDF5 module 3 | 4 | This library aims to create a group of classes in fortran to interact with [HDF5](https://support.hdfgroup.org/HDF5/). 5 | 6 | ### Contents: 7 | This library as two main files, one with high level hdf5 routines **(H5_func_mod.f90)**, the other with classes wrapping those routines **(H5_OO_mod.f90)**. 8 | 9 | The function module was inspired, extends and has several of the functions present in [HDF5_utils](https://github.com/tiasus/HDF5_utils). 10 | 11 | The classes module has the same base structure of [mo_netcdf](https://github.com/schaefed/mo_netcdf). 12 | 13 | There are two main classes, *H5Group* and *H5Dataset*. The *H5File* is extended from the *H5Group*. All classes can read and write attributes from the *H5Attributable* class. 14 | 15 | ### Tested 16 | 17 | This library was tested with versions: 18 | - **HDF5**: 1.8.11, 1.8.16 19 | - **gfortran**: 4.8.\*, 5.4.\* 20 | 21 | The following methods have been tested in several ways, most of them in production code: 22 | - All H5File 23 | - All H5Group 24 | - All H5Attributable 25 | - All H5Dataset, but: 26 | - getDataset only integer 8, 16, 32 and real 32 up to 3 dimensions (:,:,:) 27 | - setDataset with more than 4 dimensions is not tested 28 | - getBlock with more than 2 dimensions is not tested 29 | - extendDataset was only tested with int16 array of 3 and 4 dimensions 30 | 31 | ### TODO 32 | 33 | - [ ] One example of the definition of a netCDF file with this library. 34 | - [x] A way to write blocks of arrays. 35 | - [x] A way to define more than one dimension to be extensible. 36 | - [ ] Implement more functions of the HDF5 library. 37 | 38 | ### Interface 39 | #### H5File 40 | ```fortran 41 | type(H5File) :: file 42 | 43 | file = H5File(' path of the file ', status, mode) 44 | !status can be: (OLD, O, NEW, N, REPLACE, RP), not case sensitive 45 | !mode can be: (READ, R, WRITE, W, READWRITE, RW), not case sensitive 46 | 47 | ``` 48 | 49 | ```fortran 50 | call file%closeFile() 51 | ``` 52 | #### H5Group 53 | ```fortran 54 | type(H5Group) :: newgroup 55 | type(H5Group) :: oldgroup 56 | ``` 57 | This class must always be called from an object of the same class (H5Group or H5File) 58 | ```fortran 59 | call file%setGroup('name of the new group', newgroup) 60 | call newgroup%openGroup('name of an existing group', oldgroup) 61 | call oldgroup%closeGroup() 62 | 63 | call newgroup%getNumObj(number_of_objects) 64 | ! number_of_objects is integer 32 bits, method counts the all the groups and datasets in a group 65 | 66 | call newgroup%getObjNameByIdx(idx, obj_name) 67 | ! method to retrieve the names of the objects in a group 68 | 69 | call newgroup%isDset(obj_name) 70 | ! logical method that verifies if an object is a Dataset 71 | 72 | call newgroup%isGrp(obj_name) 73 | ! logical method that verifies if an object is a Group 74 | ``` 75 | #### H5Dataset 76 | ```fortran 77 | type(H5Dataset) :: newdataset 78 | newdataset = H5Dataset('Name of the dataset', parent group) 79 | ``` 80 | Define the chunk size of the dataset: 81 | ```fortran 82 | call newdataset%setChunkSize(chunksize) 83 | ! chunksize is an integer, if not defined is by default 100 84 | ``` 85 | 86 | Define the compression level of the dataset: 87 | ```fortran 88 | call newdataset%setCompressionLevel(CompressionLevel) 89 | ! CompressionLevel is an integer that must vary between 0 and 9, if not defined is by default 9 90 | ``` 91 | Define the fill value of the dataset: 92 | ```fortran 93 | call newdataset%setFillValue(fillvalue) 94 | ! fillvalue is an integer, if not defined is by default 0 95 | ``` 96 | 97 | Define the dataset is extendable in n dimentions: 98 | ```fortran 99 | call newdataset%setExtendable(n) 100 | ! n is an integer less or equal to the dataset dimensions 101 | ! the dataset gets extended from the last rank to the start 102 | ! if newdataset has 4 dimensions (:,:,:,:) and we call newdataset%setExtendable(2), 103 | ! the last two dimensions become extendable 104 | ``` 105 | Define an empty dataset: 106 | ```fortran 107 | call newdataset%setEmpty() 108 | ``` 109 | Get the dataset rank: 110 | ```fortran 111 | call newdataset%getRank(rank) 112 | !rank is an integer 113 | ``` 114 | 115 | Get the dataset dimensions: 116 | ```fortran 117 | call newdataset%getDims(dims) 118 | !Dims must be an integer array with the dataset rank 119 | ``` 120 | 121 | Define dimension (scale) of an array 122 | ```fortran 123 | type(H5Dataset) :: dim_dset 124 | call dim_dset%setDataset(x) 125 | call dim_dset%defScale(dimension_name) 126 | !dimension_name the name you wish to attribute to the scale, it is optional 127 | ``` 128 | 129 | Link a dimension (scale) to an array 130 | ```fortran 131 | call newdataset%setScale(dim_dset,idx_dim) 132 | !dim_dset is the scale object you wish to link with your dataset 133 | !idx_dim is an integer with the rank of the dataset where you will link the scale 134 | ``` 135 | 136 | Read the entire dataset: 137 | ```fortran 138 | call newdataset%getDataset(dset_array) 139 | !dset_array can be an array of 1 to 6 dimensions 140 | !dset_array can be an integer of 32 bits or a real of 64 bits 141 | !the dataset inside the file can be of any kind lower or equal of those. 142 | ``` 143 | 144 | Read a block of a dataset: 145 | ```fortran 146 | call newdataset%getBlock(offset, shape, d_array) 147 | !offset is a one dimension integer of 64 bits array with the size of the rank of the dataset to read, 148 | !this array must have the starting points of where you will read the array 149 | ! 150 | !shape is a one dimension integer of 64 bits array with the size of the rank of the dataset to read, 151 | !this array must have the size of the portion the array you want to read 152 | ! 153 | !dset_array can be an array of 1 to 5 dimensions 154 | !dset_array can be an integer or a real of 32 bits 155 | ``` 156 | 157 | Write a Dataset: 158 | ```fortran 159 | call newdataset%setDataset(dset_array) 160 | !dset_array can be an array of 1 to 6 dimensions 161 | !dset_array can be an integer of 8, 16 or 32 bits 162 | !dset_array can be a real of 32 or 64 bits 163 | ``` 164 | 165 | Extend a Dataset: 166 | ```fortran 167 | call newdataset%extendDataset(new_size, offset, dshape, val) 168 | !dset_array can be an array of 1 to 6 dimensions 169 | !dset_array can be an integer of 8, 16 or 32 bits 170 | !dset_array can be a real of 32 or 64 bits 171 | ! 172 | !new_size is a one dimension integer of 64 bits array with the size of the rank of the dataset to write, 173 | !this array must have the new total shape of the array you want to extend 174 | ! 175 | !offset is a one dimension integer of 64 bits array with the size of the rank of the dataset to write, 176 | !this array must have the starting points of where you will start writing the array 177 | ! 178 | !dshape is a one dimension integer of 64 bits array with the size of the rank of the dataset to extend, 179 | !this array must have the size of the portion the array you want to write 180 | ! 181 | 182 | ``` 183 | 184 | #### H5Attributable 185 | This class is only accessed from an object of class H5Group or H5Dataset. 186 | 187 | Verify if an attribute exists: 188 | ```fortran 189 | if ( newdataset%Attr_exists(a_name) ) then 190 | print*,a_name//' exists' 191 | end if 192 | !Attr_exists is a logical function 193 | !a_name is the name of the attribute to check 194 | ``` 195 | Get the number of attributes of an object: 196 | ```fortran 197 | call newdataset%getNumberAttrs(number_of_attributes) 198 | !number_of_attributes is an integer of 32 bits 199 | ``` 200 | get the name of an attribute by index, the attributes names are retrived by alphabetical order 201 | ```fortran 202 | call newdataset%getAttNameByIdx(idx, a_name) 203 | !idx is an integer of 32 bits 204 | !a_name is the name of the attribute to check 205 | ``` 206 | 207 | Read an attribute: 208 | ```fortran 209 | call newdataset%getAttribute(a_name, val) 210 | call file%getAttribute(a_name, val) 211 | call newgroup%getAttribute(a_name, val) 212 | !a_name is the name of the attribute to read 213 | !val can be of type character, integer or real(32 or 64 bits) 214 | !val can be a scalar or an array of one dimension. 215 | ``` 216 | Write an attribute: 217 | ```fortran 218 | call newdataset%setAttribute(a_name, val) 219 | call file%setAttribute(a_name, val) 220 | call newgroup%setAttribute(a_name, val) 221 | !a_name is the name of the attribute to read 222 | !val can be of type character, integer or real(32 or 64 bits) 223 | !val can be a scalar or an array of one dimension. 224 | ``` 225 | 226 | ### Examples: 227 | - Write file, dataset and attribute: 228 | 229 | ```fortran 230 | 231 | type(H5File) :: f1 232 | type(H5Dataset) :: d1, d2 233 | type(H5Group) :: g1 234 | 235 | !Open a new, write only, file 236 | f1=H5File("new_test_file.h5", "N", "W") 237 | !write an attribute in / 238 | call f1%setAttribute('root_atribute',42) 239 | !initialize a dataset in / 240 | d1=H5Dataset('2d_i32',f1) 241 | !set the fillvalue of d1 dataset to -1 242 | call d1%setFillValue(-1) 243 | !define a new group in / 244 | call f1%setGroup('newgroup',g1) 245 | !initialize a dataset in group "newgroup" 246 | d2=H5Dataset('4d_r64',g1) 247 | 248 | do i=1,size(test_arr(:,1)) 249 | do j=1,size(test_arr(1,:)) 250 | test_arr(i,j)=i*j 251 | end do 252 | end do 253 | !write the contents of test_arr to d1 dataset in 8 bits precision 254 | call d1%setDataset(int(test_arr,1)) 255 | !write an attribute in d1 dataset 256 | call d1%setAttribute('dataset_atribute',int(42,2)) 257 | !write one array in double precision to d2 dataset 258 | call d2%setDataset(real([[1],[2],[4],[5]],DP)) 259 | !write an attribute in group g1 260 | call g2%setAttribute('att1', int([4,4,2,5,4,6,3,1,1,5,5,2,4,2154545,6,2,4,7,6],4)) 261 | !close hdf5 file 262 | call f1%closeFile() 263 | ``` 264 | 265 | - Read the contents of a HDF5 file: 266 | 267 | ```fortran 268 | !Open an existing, read only, file 269 | f1=H5File("new_test_file.h5", "O", "R") 270 | !read and attribute in / 271 | call f1%getAttribute('thgttg',i) 272 | !open on group in / 273 | call f1%openGroup('newgroup',g1) 274 | !initialize a dataset in / 275 | d1=H5Dataset('2d_i32',f1) 276 | !read an attribute in d1 dataset 277 | call d1%getAttribute('att1',read_a) 278 | !initialize a dataset in group "newgroup" 279 | d2=H5Dataset('4d_r64',g1) 280 | !read the contents of d2 dataset 281 | call d2%getDataset(r8_dset) 282 | !close hdf5 file 283 | call f1%closeFile() 284 | 285 | ``` 286 | -------------------------------------------------------------------------------- /src/H5_OO_mod.f90: -------------------------------------------------------------------------------- 1 | !#################################################################################################! 2 | !BSD 3-Clause License 3 | ! 4 | !Copyright (c) 2017, Ricardo Torres 5 | !All rights reserved. 6 | ! 7 | !Redistribution and use in source and binary forms, with or without 8 | !modification, are permitted provided that the following conditions are met: 9 | ! 10 | !* Redistributions of source code must retain the above copyright notice, this 11 | ! list of conditions and the following disclaimer. 12 | 13 | !* Redistributions in binary form must reproduce the above copyright notice, 14 | ! this list of conditions and the following disclaimer in the documentation 15 | ! and/or other materials provided with the distribution. 16 | 17 | !* Neither the name of the copyright holder nor the names of its 18 | ! contributors may be used to endorse or promote products derived from 19 | ! this software without specific prior written permission. 20 | ! 21 | !THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | !AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | !IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | !DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | !FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | !DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | !SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | !CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | !OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | !OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | !#################################################################################################! 32 | 33 | module H5_OO_mod 34 | use H5_Func_mod 35 | use Types_mod 36 | 37 | implicit none 38 | 39 | !#################################################################################################! 40 | type :: H5Attributable 41 | integer(I32) :: id 42 | contains 43 | 44 | procedure, public :: Attr_exists 45 | procedure, public :: getNumberAttrs 46 | procedure, public :: getAttTypeSize 47 | procedure, public :: getAttNameByIdx 48 | procedure, public :: getAttDims 49 | 50 | procedure, private :: set_Int16_Attr0 51 | procedure, private :: set_Int16_Attr1 52 | procedure, private :: set_Int32_Attr0 53 | procedure, private :: set_Int32_Attr1 54 | procedure, private :: set_Real32_Attr0 55 | procedure, private :: set_Real32_Attr1 56 | procedure, private :: set_Real64_Attr0 57 | procedure, private :: set_Real64_Attr1 58 | procedure, private :: set_Char_Attr0 59 | procedure, private :: set_Char_Attr1 60 | 61 | procedure, private :: get_Char_Attr0 62 | procedure, private :: get_Char_Attr1 63 | procedure, private :: get_Int_Attr0 64 | procedure, private :: get_Int_Attr1 65 | procedure, private :: get_Real32_Attr0 66 | procedure, private :: get_Real32_Attr1 67 | procedure, private :: get_Real64_Attr0 68 | procedure, private :: get_Real64_Attr1 69 | 70 | generic, public :: setAttribute => & 71 | set_Int16_Attr0, & 72 | set_Int16_Attr1, & 73 | set_Int32_Attr0, & 74 | set_Int32_Attr1, & 75 | set_Real32_Attr0, & 76 | set_Real32_Attr1, & 77 | set_Real64_Attr0, & 78 | set_Real64_Attr1, & 79 | set_Char_Attr0, & 80 | set_Char_Attr1 81 | 82 | generic, public :: getAttribute => & 83 | get_Char_Attr0, & 84 | get_Char_Attr1, & 85 | get_Int_Attr0, & 86 | get_Int_Attr1, & 87 | get_Real32_Attr0, & 88 | get_Real32_Attr1, & 89 | get_Real64_Attr0, & 90 | get_Real64_Attr1 91 | 92 | end type H5Attributable 93 | 94 | !#################################################################################################! 95 | type, extends(H5Attributable) :: H5Group 96 | contains 97 | procedure, public :: setGroup 98 | procedure, public :: closeGroup 99 | procedure, public :: openGroup 100 | 101 | procedure, public :: getNumObj 102 | procedure, public :: getObjNameByIdx 103 | procedure, public :: isDset 104 | procedure, public :: isGrp 105 | end type H5Group 106 | 107 | !#################################################################################################! 108 | type, extends(H5Group) :: H5File 109 | contains 110 | procedure, public :: closeFile 111 | end type H5File 112 | 113 | interface H5File 114 | procedure newH5File 115 | end interface H5File 116 | 117 | !#################################################################################################! 118 | type, extends(H5Attributable) :: H5Dataset 119 | character(len=255) :: d_name 120 | integer(kind=I32), private :: parent_id 121 | 122 | integer(kind=I32), private :: compression_level 123 | integer(kind=I32), private :: chunk_size 124 | integer(kind=I32), private :: fill_value 125 | integer(kind=I32), private :: extendable 126 | contains 127 | procedure, public :: showstatus 128 | 129 | procedure, public :: setChunkSize 130 | procedure, public :: setCompressionLevel 131 | procedure, public :: setFillValue 132 | procedure, public :: setExtendable 133 | procedure, public :: getRank 134 | procedure, public :: getDims 135 | procedure, public :: getDTypeSize ! H5T_NO_CLASS_F -1 136 | ! H5T_INTEGER_F 0 137 | ! H5T_FLOAT_F 1 138 | ! H5T_STRING_F 2 139 | ! H5T_BITFIELD_F 3 140 | ! H5T_OPAQUE_F 4 141 | ! H5T_COMPOUND_F 5 142 | ! H5T_REFERENCE_F 6 143 | ! H5T_ENUM_F 7 144 | ! H5T_VLEN_F 8 145 | ! H5T_ARRAY_F 9 146 | 147 | procedure, public :: setEmpty 148 | 149 | procedure, public :: defScale 150 | procedure, public :: setScale 151 | 152 | procedure, private :: set_Int8_1d 153 | procedure, private :: set_Int16_1d 154 | procedure, private :: set_Int32_1d 155 | procedure, private :: set_Real32_1d 156 | procedure, private :: set_Real64_1d 157 | procedure, private :: set_Int8_2d 158 | procedure, private :: set_Int16_2d 159 | procedure, private :: set_Int32_2d 160 | procedure, private :: set_Real32_2d 161 | procedure, private :: set_Real64_2d 162 | procedure, private :: set_Int8_3d 163 | procedure, private :: set_Int16_3d 164 | procedure, private :: set_Int32_3d 165 | procedure, private :: set_Real32_3d 166 | procedure, private :: set_Real64_3d 167 | procedure, private :: set_Int8_4d 168 | procedure, private :: set_Int16_4d 169 | procedure, private :: set_Int32_4d 170 | procedure, private :: set_Real32_4d 171 | procedure, private :: set_Real64_4d 172 | procedure, private :: set_Int8_5d 173 | procedure, private :: set_Int16_5d 174 | procedure, private :: set_Int32_5d 175 | procedure, private :: set_Real32_5d 176 | procedure, private :: set_Real64_5d 177 | procedure, private :: set_Int8_6d 178 | procedure, private :: set_Int16_6d 179 | procedure, private :: set_Int32_6d 180 | procedure, private :: set_Real32_6d 181 | procedure, private :: set_Real64_6d 182 | 183 | procedure, private :: get_Int_1d 184 | procedure, private :: get_Int_2d 185 | procedure, private :: get_Int_3d 186 | procedure, private :: get_Int_4d 187 | procedure, private :: get_Int_5d 188 | procedure, private :: get_Int_6d 189 | procedure, private :: get_Real32_1d 190 | procedure, private :: get_Real32_2d 191 | procedure, private :: get_Real32_3d 192 | procedure, private :: get_Real32_4d 193 | procedure, private :: get_Real32_5d 194 | procedure, private :: get_Real32_6d 195 | procedure, private :: get_Real64_1d 196 | procedure, private :: get_Real64_2d 197 | procedure, private :: get_Real64_3d 198 | procedure, private :: get_Real64_4d 199 | procedure, private :: get_Real64_5d 200 | procedure, private :: get_Real64_6d 201 | 202 | procedure, private :: get_Int_Slab1d 203 | procedure, private :: get_Int_Slab2d 204 | procedure, private :: get_Int_Slab3d 205 | procedure, private :: get_Int_Slab4d 206 | procedure, private :: get_Int_Slab5d 207 | procedure, private :: get_Real_Slab1d 208 | procedure, private :: get_Real_Slab2d 209 | procedure, private :: get_Real_Slab3d 210 | procedure, private :: get_Real_Slab4d 211 | procedure, private :: get_Real_Slab5d 212 | 213 | procedure, private :: Extend_Int8_1d 214 | procedure, private :: Extend_Int16_1d 215 | procedure, private :: Extend_Int32_1d 216 | procedure, private :: Extend_Real32_1d 217 | procedure, private :: Extend_Real64_1d 218 | procedure, private :: Extend_Int8_2d 219 | procedure, private :: Extend_Int16_2d 220 | procedure, private :: Extend_Int32_2d 221 | procedure, private :: Extend_Real32_2d 222 | 223 | procedure, private :: Extend_Real64_2d 224 | procedure, private :: Extend_Int8_3d 225 | procedure, private :: Extend_Int16_3d 226 | procedure, private :: Extend_Int32_3d 227 | procedure, private :: Extend_Real32_3d 228 | procedure, private :: Extend_Real64_3d 229 | procedure, private :: Extend_Int8_4d 230 | procedure, private :: Extend_Int16_4d 231 | procedure, private :: Extend_Int32_4d 232 | procedure, private :: Extend_Real32_4d 233 | procedure, private :: Extend_Real64_4d 234 | procedure, private :: Extend_Int8_5d 235 | procedure, private :: Extend_Int16_5d 236 | procedure, private :: Extend_Int32_5d 237 | procedure, private :: Extend_Real32_5d 238 | procedure, private :: Extend_Real64_5d 239 | procedure, private :: Extend_Int8_6d 240 | procedure, private :: Extend_Int16_6d 241 | procedure, private :: Extend_Int32_6d 242 | procedure, private :: Extend_Real32_6d 243 | procedure, private :: Extend_Real64_6d 244 | 245 | generic, public :: setDataset => & 246 | set_Int8_1d, & 247 | set_Int16_1d, & 248 | set_Int32_1d, & 249 | set_Real32_1d, & 250 | set_Real64_1d, & 251 | set_Int8_2d, & 252 | set_Int16_2d, & 253 | set_Int32_2d, & 254 | set_Real32_2d, & 255 | set_Real64_2d, & 256 | set_Int8_3d, & 257 | set_Int16_3d, & 258 | set_Int32_3d, & 259 | set_Real32_3d, & 260 | set_Real64_3d, & 261 | set_Int8_4d, & 262 | set_Int16_4d, & 263 | set_Int32_4d, & 264 | set_Real32_4d, & 265 | set_Real64_4d, & 266 | set_Int8_5d, & 267 | set_Int16_5d, & 268 | set_Int32_5d, & 269 | set_Real32_5d, & 270 | set_Real64_5d, & 271 | set_Int8_6d, & 272 | set_Int16_6d, & 273 | set_Int32_6d, & 274 | set_Real32_6d, & 275 | set_Real64_6d 276 | 277 | generic, public :: getDataset => & 278 | get_Int_1d, & 279 | get_Int_2d, & 280 | get_Int_3d, & 281 | get_Int_4d, & 282 | get_Int_5d, & 283 | get_Int_6d, & 284 | get_Real32_1d, & 285 | get_Real32_2d, & 286 | get_Real32_3d, & 287 | get_Real32_4d, & 288 | get_Real32_5d, & 289 | get_Real32_6d, & 290 | get_Real64_1d, & 291 | get_Real64_2d, & 292 | get_Real64_3d, & 293 | get_Real64_4d, & 294 | get_Real64_5d, & 295 | get_Real64_6d 296 | 297 | generic, public :: getBlock => & 298 | get_Int_Slab1d, & 299 | get_Int_Slab2d, & 300 | get_Int_Slab3d, & 301 | get_Int_Slab4d, & 302 | get_Int_Slab5d, & 303 | get_Real_Slab1d, & 304 | get_Real_Slab2d, & 305 | get_Real_Slab3d, & 306 | get_Real_Slab4d, & 307 | get_Real_Slab5d 308 | 309 | generic, public :: extendDataset => & 310 | Extend_Int8_1d, & 311 | Extend_Int16_1d, & 312 | Extend_Int32_1d, & 313 | Extend_Real32_1d, & 314 | Extend_Real64_1d, & 315 | Extend_Int8_2d, & 316 | Extend_Int16_2d, & 317 | Extend_Int32_2d, & 318 | Extend_Real32_2d, & 319 | Extend_Real64_2d, & 320 | Extend_Int8_3d, & 321 | Extend_Int16_3d, & 322 | Extend_Int32_3d, & 323 | Extend_Real32_3d, & 324 | Extend_Real64_3d, & 325 | Extend_Int8_4d, & 326 | Extend_Int16_4d, & 327 | Extend_Int32_4d, & 328 | Extend_Real32_4d, & 329 | Extend_Real64_4d, & 330 | Extend_Int8_5d, & 331 | Extend_Int16_5d, & 332 | Extend_Int32_5d, & 333 | Extend_Real32_5d, & 334 | Extend_Real64_5d, & 335 | Extend_Int8_6d, & 336 | Extend_Int16_6d, & 337 | Extend_Int32_6d, & 338 | Extend_Real32_6d, & 339 | Extend_Real64_6d 340 | 341 | 342 | 343 | 344 | end type H5Dataset 345 | 346 | interface H5Dataset 347 | procedure newH5Dataset 348 | end interface H5Dataset 349 | 350 | !#################################################################################################! 351 | 352 | contains 353 | !#################################################################################################! 354 | !###################################### Attribute Methods ########################################! 355 | !#################################################################################################! 356 | function Attr_exists(self, a_name) 357 | class(H5Attributable), intent(in) :: self 358 | character(len=*), intent (in):: a_name 359 | logical :: Attr_exists 360 | integer(kind=I32) :: error 361 | integer(kind=I32) :: dset_id 362 | 363 | select type (self) 364 | class is (H5Dataset) 365 | dset_id = open_dset(self%parent_id,self%d_name) 366 | Attr_exists = Ch_Attr_exist(dset_id,a_name) 367 | error = close_dset(dset_id) 368 | class default 369 | Attr_exists = Ch_Attr_exist(self%id,a_name) 370 | end select 371 | end function Attr_exists 372 | 373 | subroutine getAttNameByIdx(self, idx, a_name) 374 | class(H5Attributable), intent(in) :: self 375 | integer(kind=I32), intent(in) :: idx 376 | character(len=*), intent(out) :: a_name 377 | character(len=80) :: obj_name 378 | integer :: dset_id 379 | integer :: hdferr 380 | 381 | select type (self) 382 | class is (H5Dataset) 383 | dset_id = open_dset(self%parent_id,self%d_name) 384 | hdferr = get_att_name_idx(dset_id, self%d_name, idx, a_name) 385 | hdferr = close_dset(dset_id) 386 | class default 387 | hdferr = get_obj_name(self%id, obj_name) 388 | hdferr = get_att_name_idx(self%id, trim(obj_name), idx, a_name) 389 | end select 390 | end subroutine getAttNameByIdx 391 | 392 | subroutine getNumberAttrs(self, n_attrs) 393 | class(H5Attributable), intent(in) :: self 394 | integer(kind=I32), intent(out) :: n_attrs 395 | integer(kind=I32) :: error 396 | integer(kind=I32) :: dset_id 397 | 398 | select type (self) 399 | class is (H5Dataset) 400 | dset_id = open_dset(self%parent_id,self%d_name) 401 | n_attrs = number_attrs(dset_id) 402 | error = close_dset(dset_id) 403 | class default 404 | n_attrs = number_attrs(self%id) 405 | end select 406 | end subroutine getNumberAttrs 407 | 408 | subroutine getAttTypeSize(self, a_name, att_type, att_type_size) 409 | class(H5Attributable), intent(in) :: self 410 | character(len=*), intent (in):: a_name 411 | integer(kind=I32), intent(out) :: att_type 412 | integer(kind=I64), intent(out) :: att_type_size 413 | integer(kind=I32) :: hdferr 414 | integer(kind=I32) :: dset_id 415 | 416 | select type (self) 417 | class is (H5Dataset) 418 | dset_id = open_dset(self%parent_id,self%d_name) 419 | call attr_type_size(dset_id, a_name, att_type, att_type_size, hdferr) 420 | hdferr = close_dset(dset_id) 421 | class default 422 | call attr_type_size(self%id, a_name, att_type, att_type_size, hdferr) 423 | end select 424 | end subroutine getAttTypeSize 425 | 426 | subroutine getAttDims(self, a_name, dims) 427 | class(H5Attributable), intent(in) :: self 428 | character(len=*), intent (in):: a_name 429 | integer, intent(out) :: dims(:) 430 | integer(kind=I32) :: hdferr 431 | integer(kind=I32) :: dset_id 432 | 433 | select type (self) 434 | class is (H5Dataset) 435 | dset_id = open_dset(self%parent_id,self%d_name) 436 | hdferr = get_att_dims(dset_id, a_name, dims) 437 | hdferr = close_dset(dset_id) 438 | class default 439 | hdferr = get_att_dims(self%id, a_name, dims) 440 | end select 441 | end subroutine getAttDims 442 | 443 | subroutine set_Int16_Attr0(self, a_name, val) 444 | class(H5Attributable), intent(in) :: self 445 | integer(kind=I16), intent (in):: val 446 | character(len=*), intent (in):: a_name 447 | integer(kind=I32) :: error 448 | integer(kind=I32) :: dset_id 449 | 450 | select type (self) 451 | class is (H5Dataset) 452 | dset_id = open_dset(self%parent_id,self%d_name) 453 | error = Create_Int16_Attr0(dset_id, a_name, val) 454 | error = close_dset(dset_id) 455 | class default 456 | error = Create_Int16_Attr0(self%id, a_name, val) 457 | end select 458 | end subroutine set_Int16_Attr0 459 | 460 | subroutine set_Int16_Attr1(self, a_name, val) 461 | class(H5Attributable), intent(in) :: self 462 | integer(kind=I16), intent (in):: val(:) 463 | character(len=*), intent (in):: a_name 464 | integer(kind=I32) :: error 465 | integer(kind=I32) :: dset_id 466 | 467 | select type (self) 468 | class is (H5Dataset) 469 | dset_id = open_dset(self%parent_id,self%d_name) 470 | error = Create_Int16_Attr1(dset_id, a_name, val) 471 | error = close_dset(dset_id) 472 | class default 473 | error = Create_Int16_Attr1(self%id, a_name, val) 474 | end select 475 | end subroutine set_Int16_Attr1 476 | 477 | subroutine set_Int32_Attr0(self, a_name, val) 478 | class(H5Attributable), intent(in) :: self 479 | integer(kind=I32), intent (in):: val 480 | character(len=*), intent (in):: a_name 481 | integer(kind=I32) :: error 482 | integer(kind=I32) :: dset_id 483 | 484 | select type (self) 485 | class is (H5Dataset) 486 | dset_id = open_dset(self%parent_id,self%d_name) 487 | error = Create_Int32_Attr0(dset_id, a_name, val) 488 | error = close_dset(dset_id) 489 | class default 490 | error = Create_Int32_Attr0(self%id, a_name, val) 491 | end select 492 | end subroutine set_Int32_Attr0 493 | 494 | subroutine set_Int32_Attr1(self, a_name, val) 495 | class(H5Attributable), intent(in) :: self 496 | integer(kind=I32), intent (in):: val(:) 497 | character(len=*), intent (in):: a_name 498 | integer(kind=I32) :: error 499 | integer(kind=I32) :: dset_id 500 | 501 | select type (self) 502 | class is (H5Dataset) 503 | dset_id = open_dset(self%parent_id,self%d_name) 504 | error = Create_Int32_Attr1(dset_id, a_name, val) 505 | error = close_dset(dset_id) 506 | class default 507 | error = Create_Int32_Attr1(self%id, a_name, val) 508 | end select 509 | end subroutine set_Int32_Attr1 510 | 511 | subroutine set_Real32_Attr0(self, a_name, val) 512 | class(H5Attributable), intent(in) :: self 513 | real(kind=SP), intent (in):: val 514 | character(len=*), intent (in):: a_name 515 | integer(kind=I32) :: error 516 | integer(kind=I32) :: dset_id 517 | 518 | select type (self) 519 | class is (H5Dataset) 520 | dset_id = open_dset(self%parent_id,self%d_name) 521 | error = Create_Real32_Attr0(dset_id, a_name, val) 522 | error = close_dset(dset_id) 523 | class default 524 | error = Create_Real32_Attr0(self%id, a_name, val) 525 | end select 526 | end subroutine set_Real32_Attr0 527 | 528 | subroutine set_Real32_Attr1(self, a_name, val) 529 | class(H5Attributable), intent(in) :: self 530 | real(kind=SP), intent (in):: val(:) 531 | character(len=*), intent (in):: a_name 532 | integer(kind=I32) :: error 533 | integer(kind=I32) :: dset_id 534 | 535 | select type (self) 536 | class is (H5Dataset) 537 | dset_id = open_dset(self%parent_id,self%d_name) 538 | error = Create_Real32_Attr1(dset_id, a_name, val) 539 | error = close_dset(dset_id) 540 | class default 541 | error = Create_Real32_Attr1(self%id, a_name, val) 542 | end select 543 | end subroutine set_Real32_Attr1 544 | 545 | subroutine set_Real64_Attr0(self, a_name, val) 546 | class(H5Attributable), intent(in) :: self 547 | real(kind=DP), intent (in):: val 548 | character(len=*), intent (in):: a_name 549 | integer(kind=I32) :: error 550 | integer(kind=I32) :: dset_id 551 | 552 | select type (self) 553 | class is (H5Dataset) 554 | dset_id = open_dset(self%parent_id,self%d_name) 555 | error = Create_Real64_Attr0(dset_id, a_name, val) 556 | error = close_dset(dset_id) 557 | class default 558 | error = Create_Real64_Attr0(self%id, a_name, val) 559 | end select 560 | end subroutine set_Real64_Attr0 561 | 562 | subroutine set_Real64_Attr1(self, a_name, val) 563 | class(H5Attributable), intent(in) :: self 564 | real(kind=DP), intent (in):: val(:) 565 | character(len=*), intent (in):: a_name 566 | integer(kind=I32) :: error 567 | integer(kind=I32) :: dset_id 568 | 569 | select type (self) 570 | class is (H5Dataset) 571 | dset_id = open_dset(self%parent_id,self%d_name) 572 | error = Create_Real64_Attr1(dset_id, a_name, val) 573 | error = close_dset(dset_id) 574 | class default 575 | error = Create_Real64_Attr1(self%id, a_name, val) 576 | end select 577 | end subroutine set_Real64_Attr1 578 | 579 | subroutine set_Char_Attr0(self, a_name, val) 580 | class(H5Attributable), intent(in) :: self 581 | character(len=*), intent (in):: val 582 | character(len=*), intent (in):: a_name 583 | integer(kind=I32) :: error 584 | integer(kind=I32) :: dset_id 585 | 586 | select type (self) 587 | class is (H5Dataset) 588 | dset_id = open_dset(self%parent_id,self%d_name) 589 | error = Create_Char_Attr0(dset_id, a_name, val) 590 | error = close_dset(dset_id) 591 | class default 592 | error = Create_Char_Attr0(self%id, a_name, val) 593 | end select 594 | end subroutine set_Char_Attr0 595 | 596 | subroutine set_Char_Attr1(self, a_name, val) 597 | class(H5Attributable), intent(in) :: self 598 | character(len=*), intent (in):: val(:) 599 | character(len=*), intent (in):: a_name 600 | integer(kind=I32) :: error 601 | integer(kind=I32) :: dset_id 602 | 603 | select type (self) 604 | class is (H5Dataset) 605 | dset_id = open_dset(self%parent_id,self%d_name) 606 | error = Create_Char_Attr1(dset_id, a_name, val) 607 | error = close_dset(dset_id) 608 | class default 609 | error = Create_Char_Attr1(self%id, a_name, val) 610 | end select 611 | end subroutine set_Char_Attr1 612 | 613 | subroutine get_Char_Attr0(self, a_name, val) 614 | class(H5Attributable), intent(in) :: self 615 | character(len=*), intent (out):: val 616 | character(len=*), intent (in):: a_name 617 | integer(kind=I32) :: error 618 | integer(kind=I32) :: dset_id 619 | 620 | select type (self) 621 | class is (H5Dataset) 622 | dset_id = open_dset(self%parent_id,self%d_name) 623 | error = Read_Char_Attr0(dset_id, a_name, val) 624 | error = close_dset(dset_id) 625 | class default 626 | error = Read_Char_Attr0(self%id, a_name, val) 627 | end select 628 | end subroutine get_Char_Attr0 629 | 630 | subroutine get_Char_Attr1(self, a_name, val) 631 | class(H5Attributable), intent(in) :: self 632 | character(len=*), intent (out):: val(:) 633 | character(len=*), intent (in):: a_name 634 | integer(kind=I32) :: error 635 | integer(kind=I32) :: dset_id 636 | 637 | select type (self) 638 | class is (H5Dataset) 639 | dset_id = open_dset(self%parent_id,self%d_name) 640 | error = Read_Char_Attr1(dset_id, a_name, val) 641 | error = close_dset(dset_id) 642 | class default 643 | error = Read_Char_Attr1(self%id, a_name, val) 644 | end select 645 | end subroutine get_Char_Attr1 646 | 647 | subroutine get_Int_Attr0(self, a_name, val) 648 | class(H5Attributable), intent(in) :: self 649 | integer(kind=I32), intent (out):: val 650 | character(len=*), intent (in):: a_name 651 | integer(kind=I32) :: error 652 | integer(kind=I32) :: dset_id 653 | 654 | select type (self) 655 | class is (H5Dataset) 656 | dset_id = open_dset(self%parent_id,self%d_name) 657 | error = Read_Int_Attr0(dset_id, a_name, val) 658 | error = close_dset(dset_id) 659 | class default 660 | error = Read_Int_Attr0(self%id, a_name, val) 661 | end select 662 | end subroutine get_Int_Attr0 663 | 664 | subroutine get_Int_Attr1(self, a_name, val) 665 | class(H5Attributable), intent(in) :: self 666 | integer(kind=I32), intent (out):: val(:) 667 | character(len=*), intent (in):: a_name 668 | integer(kind=I32) :: error 669 | integer(kind=I32) :: dset_id 670 | 671 | select type (self) 672 | class is (H5Dataset) 673 | dset_id = open_dset(self%parent_id,self%d_name) 674 | error = Read_Int_Attr1(dset_id, a_name, val) 675 | error = close_dset(dset_id) 676 | class default 677 | error = Read_Int_Attr1(self%id, a_name, val) 678 | end select 679 | end subroutine get_Int_Attr1 680 | 681 | subroutine get_Real32_Attr0(self, a_name, val) 682 | class(H5Attributable), intent(in) :: self 683 | real(kind=SP), intent (out):: val 684 | character(len=*), intent (in):: a_name 685 | integer(kind=I32) :: error 686 | integer(kind=I32) :: dset_id 687 | 688 | select type (self) 689 | class is (H5Dataset) 690 | dset_id = open_dset(self%parent_id,self%d_name) 691 | error = Read_Real32_Attr0(dset_id, a_name, val) 692 | error = close_dset(dset_id) 693 | class default 694 | error = Read_Real32_Attr0(self%id, a_name, val) 695 | end select 696 | end subroutine get_Real32_Attr0 697 | 698 | subroutine get_Real32_Attr1(self, a_name, val) 699 | class(H5Attributable), intent(in) :: self 700 | real(kind=SP), intent (out):: val(:) 701 | character(len=*), intent (in):: a_name 702 | integer(kind=I32) :: error 703 | integer(kind=I32) :: dset_id 704 | 705 | select type (self) 706 | class is (H5Dataset) 707 | dset_id = open_dset(self%parent_id,self%d_name) 708 | error = Read_Real32_Attr1(dset_id, a_name, val) 709 | error = close_dset(dset_id) 710 | class default 711 | error = Read_Real32_Attr1(self%id, a_name, val) 712 | end select 713 | end subroutine get_Real32_Attr1 714 | 715 | subroutine get_Real64_Attr0(self, a_name, val) 716 | class(H5Attributable), intent(in) :: self 717 | real(kind=DP), intent (out):: val 718 | character(len=*), intent (in):: a_name 719 | integer(kind=I32) :: error 720 | integer(kind=I32) :: dset_id 721 | 722 | select type (self) 723 | class is (H5Dataset) 724 | dset_id = open_dset(self%parent_id,self%d_name) 725 | error = Read_Real64_Attr0(dset_id, a_name, val) 726 | error = close_dset(dset_id) 727 | class default 728 | error = Read_Real64_Attr0(self%id, a_name, val) 729 | end select 730 | end subroutine get_Real64_Attr0 731 | 732 | subroutine get_Real64_Attr1(self, a_name, val) 733 | class(H5Attributable), intent(in) :: self 734 | real(kind=DP), intent (out):: val(:) 735 | character(len=*), intent (in):: a_name 736 | integer(kind=I32) :: error 737 | integer(kind=I32) :: dset_id 738 | 739 | select type (self) 740 | class is (H5Dataset) 741 | dset_id = open_dset(self%parent_id,self%d_name) 742 | error = Read_Real64_Attr1(dset_id, a_name, val) 743 | error = close_dset(dset_id) 744 | class default 745 | error = Read_Real64_Attr1(self%id, a_name, val) 746 | end select 747 | end subroutine get_Real64_Attr1 748 | 749 | !#################################################################################################! 750 | !######################################## Group Methods ##########################################! 751 | !#################################################################################################! 752 | subroutine openGroup(self, g_name, newGroup) 753 | class(H5Group) :: self 754 | type(H5Group), intent(out) :: newGroup 755 | character(len=*), intent(in) :: g_name 756 | 757 | newGroup%id = hdf_open_group(self%id, g_name) 758 | end subroutine openGroup 759 | 760 | subroutine setGroup(self, g_name, newGroup) 761 | class(H5Group) :: self 762 | character(len=*), intent(in) :: g_name 763 | type(H5Group), intent(out) :: newGroup 764 | 765 | newGroup%id=hdf_create_group(self%id, g_name) 766 | end subroutine setGroup 767 | 768 | subroutine closeGroup(self) 769 | class(H5Group) :: self 770 | integer(kind=I32) :: error 771 | 772 | error=hdf_close_group(self%id) 773 | end subroutine closeGroup 774 | 775 | subroutine getNumObj(self, nlinks) 776 | class(H5Group) :: self 777 | integer(kind=I32), intent(out) :: nlinks 778 | integer(kind=I32) :: error 779 | 780 | error=grp_num_of_obj(self%id, nlinks) 781 | end subroutine getNumObj 782 | 783 | subroutine getObjNameByIdx(self, idx, obj_name) 784 | class(H5Group) :: self 785 | integer(kind=I32), intent(in) :: idx 786 | character(len=*), intent(out) :: obj_name 787 | integer(kind=I32) :: hdferr 788 | 789 | hdferr = grp_obj_name_idx(self%id, idx, obj_name) 790 | end subroutine getObjNameByIdx 791 | 792 | function isDset(self, obj_name) 793 | class(H5Group) :: self 794 | character(len=*), intent(in) :: obj_name 795 | logical :: isDset 796 | integer(kind=I32) :: hdferr 797 | 798 | hdferr = obj_is_dset(self%id, obj_name, isDset) 799 | end function isDset 800 | 801 | function isGrp(self, obj_name) 802 | class(H5Group) :: self 803 | character(len=*), intent(in) :: obj_name 804 | logical :: isGrp 805 | integer(kind=I32) :: hdferr 806 | 807 | hdferr = obj_is_grp(self%id, obj_name, isGrp) 808 | end function isGrp 809 | !#################################################################################################! 810 | !######################################### File Methods ##########################################! 811 | !#################################################################################################! 812 | function newH5File( filename, state, mode ) 813 | type(h5file) :: newH5File 814 | character(len=*), intent(in) :: filename !< the HDF5 filename 815 | character(len=*), optional, intent(in) :: state !< file state (OLD, NEW, REPLACE) 816 | character(len=*), optional, intent(in) :: mode !< file mode (READ, WRITE, READWRITE) 817 | integer(kind=I32) :: error 818 | 819 | newH5File%id = hdf_open_file(filename, state, mode) 820 | end function newH5File 821 | 822 | subroutine closeFile( self ) 823 | class(H5File), intent(in) :: self 824 | integer(kind=I32) :: error 825 | 826 | error = hdf_close_file(self%id) 827 | end subroutine closeFile 828 | 829 | 830 | !#################################################################################################! 831 | !######################################## Dataset Methods ########################################! 832 | !#################################################################################################! 833 | function newH5Dataset(dset_name, parent_Group) 834 | type(H5Dataset) :: newH5Dataset 835 | character(len=*), intent(in) :: dset_name 836 | class(H5Group), intent(in) :: parent_Group 837 | 838 | newH5Dataset%d_name = dset_name 839 | newH5Dataset%parent_id = parent_Group%id 840 | newH5Dataset%compression_level = 9 841 | newH5Dataset%chunk_size = 100 842 | newH5Dataset%extendable = 0 843 | newH5Dataset%fill_value = 0 844 | end function newH5Dataset 845 | 846 | subroutine setEmpty(self) 847 | class(H5Dataset), intent(inout) :: self 848 | 849 | self%id=Create_Empty_Dataset(self%parent_id,self%d_name) 850 | end subroutine setEmpty 851 | 852 | subroutine get_Int_1d(self, val) 853 | class(H5Dataset), intent(inout) :: self 854 | integer(kind=I32), intent(out) :: val(:) 855 | 856 | self%id = Read_Int_1d_dataset(self%parent_id, self%d_name, val) 857 | end subroutine get_Int_1d 858 | 859 | subroutine get_Int_2d(self, val) 860 | class(H5Dataset), intent(inout) :: self 861 | integer(kind=I32), intent(out) :: val(:,:) 862 | 863 | self%id = Read_Int_2d_dataset(self%parent_id, self%d_name, val) 864 | end subroutine get_Int_2d 865 | 866 | subroutine get_Int_3d(self, val) 867 | class(H5Dataset), intent(inout) :: self 868 | integer(kind=I32), intent(out) :: val(:,:,:) 869 | 870 | self%id = Read_Int_3d_dataset(self%parent_id, self%d_name, val) 871 | end subroutine get_Int_3d 872 | 873 | subroutine get_Int_4d(self, val) 874 | class(H5Dataset), intent(inout) :: self 875 | integer(kind=I32), intent(out) :: val(:,:,:,:) 876 | 877 | self%id = Read_Int_4d_dataset(self%parent_id, self%d_name, val) 878 | end subroutine get_Int_4d 879 | 880 | subroutine get_Int_5d(self, val) 881 | class(H5Dataset), intent(inout) :: self 882 | integer(kind=I32), intent(out) :: val(:,:,:,:,:) 883 | 884 | self%id = Read_Int_5d_dataset(self%parent_id, self%d_name, val) 885 | end subroutine get_Int_5d 886 | 887 | subroutine get_Int_6d(self, val) 888 | class(H5Dataset), intent(inout) :: self 889 | integer(kind=I32), intent(out) :: val(:,:,:,:,:,:) 890 | 891 | self%id = Read_Int_6d_dataset(self%parent_id, self%d_name, val) 892 | end subroutine get_Int_6d 893 | 894 | subroutine get_Real32_1d(self, val) 895 | class(H5Dataset), intent(inout) :: self 896 | real(kind=SP), intent(out) :: val(:) 897 | 898 | self%id = Read_Real32_1d_dataset(self%parent_id, self%d_name, val) 899 | end subroutine get_Real32_1d 900 | 901 | subroutine get_Real32_2d(self, val) 902 | class(H5Dataset), intent(inout) :: self 903 | real(kind=SP), intent(out) :: val(:,:) 904 | 905 | self%id = Read_Real32_2d_dataset(self%parent_id, self%d_name, val) 906 | end subroutine get_Real32_2d 907 | 908 | subroutine get_Real32_3d(self, val) 909 | class(H5Dataset), intent(inout) :: self 910 | real(kind=SP), intent(out) :: val(:,:,:) 911 | 912 | self%id = Read_Real32_3d_dataset(self%parent_id, self%d_name, val) 913 | end subroutine get_Real32_3d 914 | 915 | subroutine get_Real32_4d(self, val) 916 | class(H5Dataset), intent(inout) :: self 917 | real(kind=SP), intent(out) :: val(:,:,:,:) 918 | 919 | self%id = Read_Real32_4d_dataset(self%parent_id, self%d_name, val) 920 | end subroutine get_Real32_4d 921 | 922 | subroutine get_Real32_5d(self, val) 923 | class(H5Dataset), intent(inout) :: self 924 | real(kind=SP), intent(out) :: val(:,:,:,:,:) 925 | 926 | self%id = Read_Real32_5d_dataset(self%parent_id, self%d_name, val) 927 | end subroutine get_Real32_5d 928 | 929 | subroutine get_Real32_6d(self, val) 930 | class(H5Dataset), intent(inout) :: self 931 | real(kind=SP), intent(out) :: val(:,:,:,:,:,:) 932 | 933 | self%id = Read_Real32_6d_dataset(self%parent_id, self%d_name, val) 934 | end subroutine get_Real32_6d 935 | 936 | subroutine get_Real64_1d(self, val) 937 | class(H5Dataset), intent(inout) :: self 938 | real(kind=DP), intent(out) :: val(:) 939 | 940 | self%id = Read_Real64_1d_dataset(self%parent_id, self%d_name, val) 941 | end subroutine get_Real64_1d 942 | 943 | subroutine get_Real64_2d(self, val) 944 | class(H5Dataset), intent(inout) :: self 945 | real(kind=DP), intent(out) :: val(:,:) 946 | 947 | self%id = Read_Real64_2d_dataset(self%parent_id, self%d_name, val) 948 | end subroutine get_Real64_2d 949 | 950 | subroutine get_Real64_3d(self, val) 951 | class(H5Dataset), intent(inout) :: self 952 | real(kind=DP), intent(out) :: val(:,:,:) 953 | 954 | self%id = Read_Real64_3d_dataset(self%parent_id, self%d_name, val) 955 | end subroutine get_Real64_3d 956 | 957 | subroutine get_Real64_4d(self, val) 958 | class(H5Dataset), intent(inout) :: self 959 | real(kind=DP), intent(out) :: val(:,:,:,:) 960 | 961 | self%id = Read_Real64_4d_dataset(self%parent_id, self%d_name, val) 962 | end subroutine get_Real64_4d 963 | 964 | subroutine get_Real64_5d(self, val) 965 | class(H5Dataset), intent(inout) :: self 966 | real(kind=DP), intent(out) :: val(:,:,:,:,:) 967 | 968 | self%id = Read_Real64_5d_dataset(self%parent_id, self%d_name, val) 969 | end subroutine get_Real64_5d 970 | 971 | subroutine get_Real64_6d(self, val) 972 | class(H5Dataset), intent(inout) :: self 973 | real(kind=DP), intent(out) :: val(:,:,:,:,:,:) 974 | 975 | self%id = Read_Real64_6d_dataset(self%parent_id, self%d_name, val) 976 | end subroutine get_Real64_6d 977 | 978 | subroutine get_Int_Slab1d(self, offset, dshape, val) 979 | class(H5Dataset) :: self 980 | integer(kind=I32), intent(out) :: val(:) 981 | integer(kind=I32), parameter :: D_RANK=rank(val) 982 | integer(kind=I64), intent(in) :: offset(D_RANK) 983 | integer(kind=I64), intent(in) :: dshape(D_RANK) 984 | 985 | self%id = Read_Int_1dSlab(self%parent_id, self%d_name, offset, dshape, val) 986 | end subroutine get_Int_Slab1d 987 | 988 | subroutine get_Int_Slab2d(self, offset, dshape, val) 989 | class(H5Dataset) :: self 990 | integer(kind=I32), intent(out) :: val(:,:) 991 | integer(kind=I32), parameter :: D_RANK=rank(val) 992 | integer(kind=I64), intent(in) :: offset(D_RANK) 993 | integer(kind=I64), intent(in) :: dshape(D_RANK) 994 | 995 | self%id = Read_Int_2dSlab(self%parent_id, self%d_name, offset, dshape, val) 996 | end subroutine get_Int_Slab2d 997 | 998 | subroutine get_Int_Slab3d(self, offset, dshape, val) 999 | class(H5Dataset) :: self 1000 | integer(kind=I32), intent(out) :: val(:,:,:) 1001 | integer(kind=I32), parameter :: D_RANK=rank(val) 1002 | integer(kind=I64), intent(in) :: offset(D_RANK) 1003 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1004 | 1005 | self%id = Read_Int_3dSlab(self%parent_id, self%d_name, offset, dshape, val) 1006 | end subroutine get_Int_Slab3d 1007 | 1008 | subroutine get_Int_Slab4d(self, offset, dshape, val) 1009 | class(H5Dataset) :: self 1010 | integer(kind=I32), intent(out) :: val(:,:,:,:) 1011 | integer(kind=I32), parameter :: D_RANK=rank(val) 1012 | integer(kind=I64), intent(in) :: offset(D_RANK) 1013 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1014 | 1015 | self%id = Read_Int_4dSlab(self%parent_id, self%d_name, offset, dshape, val) 1016 | end subroutine get_Int_Slab4d 1017 | 1018 | subroutine get_Int_Slab5d(self, offset, dshape, val) 1019 | class(H5Dataset) :: self 1020 | integer(kind=I32), intent(out) :: val(:,:,:,:,:) 1021 | integer(kind=I32), parameter :: D_RANK=rank(val) 1022 | integer(kind=I64), intent(in) :: offset(D_RANK) 1023 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1024 | 1025 | self%id = Read_Int_5dSlab(self%parent_id, self%d_name, offset, dshape, val) 1026 | end subroutine get_Int_Slab5d 1027 | 1028 | subroutine get_Real_Slab1d(self, offset, dshape, val) 1029 | class(H5Dataset) :: self 1030 | real(kind=SP), intent(out) :: val(:) 1031 | integer(kind=I32), parameter :: D_RANK=rank(val) 1032 | integer(kind=I64), intent(in) :: offset(D_RANK) 1033 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1034 | 1035 | self%id = Read_Real_1dSlab(self%parent_id, self%d_name, offset, dshape, val) 1036 | end subroutine get_Real_Slab1d 1037 | 1038 | subroutine get_Real_Slab2d(self, offset, dshape, val) 1039 | class(H5Dataset) :: self 1040 | real(kind=SP), intent(out) :: val(:,:) 1041 | integer(kind=I32), parameter :: D_RANK=rank(val) 1042 | integer(kind=I64), intent(in) :: offset(D_RANK) 1043 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1044 | 1045 | self%id = Read_Real_2dSlab(self%parent_id, self%d_name, offset, dshape, val) 1046 | end subroutine get_Real_Slab2d 1047 | 1048 | subroutine get_Real_Slab3d(self, offset, dshape, val) 1049 | class(H5Dataset) :: self 1050 | real(kind=SP), intent(out) :: val(:,:,:) 1051 | integer(kind=I32), parameter :: D_RANK=rank(val) 1052 | integer(kind=I64), intent(in) :: offset(D_RANK) 1053 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1054 | 1055 | self%id = Read_Real_3dSlab(self%parent_id, self%d_name, offset, dshape, val) 1056 | end subroutine get_Real_Slab3d 1057 | 1058 | subroutine get_Real_Slab4d(self, offset, dshape, val) 1059 | class(H5Dataset) :: self 1060 | real(kind=SP), intent(out) :: val(:,:,:,:) 1061 | integer(kind=I32), parameter :: D_RANK=rank(val) 1062 | integer(kind=I64), intent(in) :: offset(D_RANK) 1063 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1064 | 1065 | self%id = Read_Real_4dSlab(self%parent_id, self%d_name, offset, dshape, val) 1066 | end subroutine get_Real_Slab4d 1067 | 1068 | subroutine get_Real_Slab5d(self, offset, dshape, val) 1069 | class(H5Dataset) :: self 1070 | real(kind=SP), intent(out) :: val(:,:,:,:,:) 1071 | integer(kind=I32), parameter :: D_RANK=rank(val) 1072 | integer(kind=I64), intent(in) :: offset(D_RANK) 1073 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1074 | 1075 | self%id = Read_Real_5dSlab(self%parent_id, self%d_name, offset, dshape, val) 1076 | end subroutine get_Real_Slab5d 1077 | 1078 | subroutine showstatus(self) 1079 | class(H5Dataset) :: self 1080 | 1081 | print*,self%parent_id 1082 | print*,self%compression_level 1083 | print*,self%chunk_size 1084 | print*,trim(self%d_name) 1085 | print*,self%id 1086 | end subroutine showstatus 1087 | 1088 | subroutine setChunkSize(self, chunksize) 1089 | class(H5Dataset) :: self 1090 | integer(kind=I32) :: chunksize 1091 | 1092 | self%chunk_size=chunksize 1093 | end subroutine setChunkSize 1094 | 1095 | subroutine setCompressionLevel(self, comp_level) 1096 | class(H5Dataset) :: self 1097 | integer(kind=I32) :: comp_level 1098 | 1099 | self%compression_level=comp_level 1100 | end subroutine setCompressionLevel 1101 | 1102 | subroutine setFillValue(self, fillvalue) 1103 | class(H5Dataset) :: self 1104 | integer(kind=I32) :: fillvalue 1105 | 1106 | self%fill_value=fillvalue 1107 | end subroutine setFillValue 1108 | 1109 | subroutine setExtendable(self,extdims) 1110 | class(H5Dataset) :: self 1111 | integer(kind=I32) :: extdims 1112 | 1113 | self%extendable=extdims 1114 | end subroutine setExtendable 1115 | 1116 | subroutine getRank(self, d_rank) 1117 | class(H5Dataset) :: self 1118 | integer, intent(out) :: d_rank 1119 | integer(kind=I32) :: error 1120 | 1121 | error = hdf_get_rank(self%parent_id,self%d_name,d_rank) 1122 | end subroutine getRank 1123 | 1124 | subroutine getDims(self, dims) 1125 | class(H5Dataset) :: self 1126 | integer, intent(out) :: dims(:) 1127 | integer(kind=I32) :: error 1128 | 1129 | error = hdf_get_dims(self%parent_id,self%d_name,dims) 1130 | end subroutine getDims 1131 | 1132 | subroutine getDTypeSize(self,dset_type, dset_type_size) 1133 | class(H5Dataset) :: self 1134 | integer(kind=I32), intent(out) :: dset_type 1135 | integer(kind=I64), intent(out) :: dset_type_size 1136 | integer(kind=I32) :: error 1137 | 1138 | call get_dset_type(self%parent_id, self%d_name, dset_type, dset_type_size, error) 1139 | end subroutine getDTypeSize 1140 | 1141 | subroutine set_Int8_1d(self, val) 1142 | class(H5Dataset), intent(inout) :: self 1143 | integer(kind=I8), intent(in) :: val(:) 1144 | 1145 | self%id = Create_Int8_1d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1146 | self%chunk_size, self%compression_level, self%extendable) 1147 | end subroutine set_Int8_1d 1148 | 1149 | subroutine set_Int16_1d(self, val) 1150 | class(H5Dataset), intent(inout) :: self 1151 | integer(kind=I16), intent(in) :: val(:) 1152 | 1153 | self%id = Create_Int16_1d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1154 | self%chunk_size, self%compression_level, self%extendable) 1155 | end subroutine set_Int16_1d 1156 | 1157 | subroutine set_Int32_1d(self, val) 1158 | class(H5Dataset), intent(inout) :: self 1159 | integer(kind=I32), intent(in) :: val(:) 1160 | 1161 | self%id = Create_Int32_1d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1162 | self%chunk_size, self%compression_level, self%extendable) 1163 | end subroutine set_Int32_1d 1164 | 1165 | subroutine set_Real32_1d(self, val) 1166 | class(H5Dataset), intent(inout) :: self 1167 | real(kind=SP), intent(in) :: val(:) 1168 | 1169 | self%id = Create_Real32_1d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1170 | self%chunk_size, self%compression_level, self%extendable) 1171 | end subroutine set_Real32_1d 1172 | 1173 | subroutine set_Real64_1d(self, val) 1174 | class(H5Dataset), intent(inout) :: self 1175 | real(kind=DP), intent(in) :: val(:) 1176 | 1177 | self%id = Create_Real64_1d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1178 | self%chunk_size, self%compression_level, self%extendable) 1179 | end subroutine set_Real64_1d 1180 | 1181 | subroutine set_Int8_2d(self, val) 1182 | class(H5Dataset), intent(inout) :: self 1183 | integer(kind=I8), intent(in) :: val(:,:) 1184 | 1185 | self%id = Create_Int8_2d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1186 | self%chunk_size, self%compression_level, self%extendable) 1187 | end subroutine set_Int8_2d 1188 | 1189 | subroutine set_Int16_2d(self, val) 1190 | class(H5Dataset), intent(inout) :: self 1191 | integer(kind=I16), intent(in) :: val(:,:) 1192 | 1193 | self%id = Create_Int16_2d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1194 | self%chunk_size, self%compression_level, self%extendable) 1195 | end subroutine set_Int16_2d 1196 | 1197 | subroutine set_Int32_2d(self, val) 1198 | class(H5Dataset), intent(inout) :: self 1199 | integer(kind=I32), intent(in) :: val(:,:) 1200 | 1201 | self%id = Create_Int32_2d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1202 | self%chunk_size, self%compression_level, self%extendable) 1203 | end subroutine set_Int32_2d 1204 | 1205 | subroutine set_Real32_2d(self, val) 1206 | class(H5Dataset), intent(inout) :: self 1207 | real(kind=SP), intent(in) :: val(:,:) 1208 | 1209 | self%id = Create_Real32_2d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1210 | self%chunk_size, self%compression_level, self%extendable) 1211 | end subroutine set_Real32_2d 1212 | 1213 | subroutine set_Real64_2d(self, val) 1214 | class(H5Dataset), intent(inout) :: self 1215 | real(kind=DP), intent(in) :: val(:,:) 1216 | 1217 | self%id = Create_Real64_2d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1218 | self%chunk_size, self%compression_level, self%extendable) 1219 | end subroutine set_Real64_2d 1220 | 1221 | subroutine set_Int8_3d(self, val) 1222 | class(H5Dataset), intent(inout) :: self 1223 | integer(kind=I8), intent(in) :: val(:,:,:) 1224 | 1225 | self%id = Create_Int8_3d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1226 | self%chunk_size, self%compression_level, self%extendable) 1227 | end subroutine set_Int8_3d 1228 | 1229 | subroutine set_Int16_3d(self, val) 1230 | class(H5Dataset), intent(inout) :: self 1231 | integer(kind=I16), intent(in) :: val(:,:,:) 1232 | 1233 | self%id = Create_Int16_3d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1234 | self%chunk_size, self%compression_level, self%extendable) 1235 | end subroutine set_Int16_3d 1236 | 1237 | subroutine set_Int32_3d(self, val) 1238 | class(H5Dataset), intent(inout) :: self 1239 | integer(kind=I32), intent(in) :: val(:,:,:) 1240 | 1241 | self%id = Create_Int32_3d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1242 | self%chunk_size, self%compression_level, self%extendable) 1243 | end subroutine set_Int32_3d 1244 | 1245 | subroutine set_Real32_3d(self, val) 1246 | class(H5Dataset), intent(inout) :: self 1247 | real(kind=SP), intent(in) :: val(:,:,:) 1248 | 1249 | self%id = Create_Real32_3d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1250 | self%chunk_size, self%compression_level, self%extendable) 1251 | end subroutine set_Real32_3d 1252 | 1253 | subroutine set_Real64_3d(self, val) 1254 | class(H5Dataset), intent(inout) :: self 1255 | real(kind=DP), intent(in) :: val(:,:,:) 1256 | 1257 | self%id = Create_Real64_3d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1258 | self%chunk_size, self%compression_level, self%extendable) 1259 | end subroutine set_Real64_3d 1260 | 1261 | subroutine set_Int8_4d(self, val) 1262 | class(H5Dataset), intent(inout) :: self 1263 | integer(kind=I8), intent(in) :: val(:,:,:,:) 1264 | 1265 | self%id = Create_Int8_4d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1266 | self%chunk_size, self%compression_level, self%extendable) 1267 | end subroutine set_Int8_4d 1268 | 1269 | subroutine set_Int16_4d(self, val) 1270 | class(H5Dataset), intent(inout) :: self 1271 | integer(kind=I16), intent(in) :: val(:,:,:,:) 1272 | 1273 | self%id = Create_Int16_4d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1274 | self%chunk_size, self%compression_level, self%extendable) 1275 | end subroutine set_Int16_4d 1276 | 1277 | subroutine set_Int32_4d(self, val) 1278 | class(H5Dataset), intent(inout) :: self 1279 | integer(kind=I32), intent(in) :: val(:,:,:,:) 1280 | 1281 | self%id = Create_Int32_4d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1282 | self%chunk_size, self%compression_level, self%extendable) 1283 | end subroutine set_Int32_4d 1284 | 1285 | subroutine set_Real32_4d(self, val) 1286 | class(H5Dataset), intent(inout) :: self 1287 | real(kind=SP), intent(in) :: val(:,:,:,:) 1288 | 1289 | self%id = Create_Real32_4d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1290 | self%chunk_size, self%compression_level, self%extendable) 1291 | end subroutine set_Real32_4d 1292 | 1293 | subroutine set_Real64_4d(self, val) 1294 | class(H5Dataset), intent(inout) :: self 1295 | real(kind=DP), intent(in) :: val(:,:,:,:) 1296 | 1297 | self%id = Create_Real64_4d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1298 | self%chunk_size, self%compression_level, self%extendable) 1299 | end subroutine set_Real64_4d 1300 | 1301 | subroutine set_Int8_5d(self, val) 1302 | class(H5Dataset), intent(inout) :: self 1303 | integer(kind=I8), intent(in) :: val(:,:,:,:,:) 1304 | 1305 | self%id = Create_Int8_5d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1306 | self%chunk_size, self%compression_level, self%extendable) 1307 | end subroutine set_Int8_5d 1308 | 1309 | subroutine set_Int16_5d(self, val) 1310 | class(H5Dataset), intent(inout) :: self 1311 | integer(kind=I16), intent(in) :: val(:,:,:,:,:) 1312 | 1313 | self%id = Create_Int16_5d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1314 | self%chunk_size, self%compression_level, self%extendable) 1315 | end subroutine set_Int16_5d 1316 | 1317 | subroutine set_Int32_5d(self, val) 1318 | class(H5Dataset), intent(inout) :: self 1319 | integer(kind=I32), intent(in) :: val(:,:,:,:,:) 1320 | 1321 | self%id = Create_Int32_5d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1322 | self%chunk_size, self%compression_level, self%extendable) 1323 | end subroutine set_Int32_5d 1324 | 1325 | subroutine set_Real32_5d(self, val) 1326 | class(H5Dataset), intent(inout) :: self 1327 | real(kind=SP), intent(in) :: val(:,:,:,:,:) 1328 | 1329 | self%id = Create_Real32_5d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1330 | self%chunk_size, self%compression_level, self%extendable) 1331 | end subroutine set_Real32_5d 1332 | 1333 | subroutine set_Real64_5d(self, val) 1334 | class(H5Dataset), intent(inout) :: self 1335 | real(kind=DP), intent(in) :: val(:,:,:,:,:) 1336 | 1337 | self%id = Create_Real64_5d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1338 | self%chunk_size, self%compression_level, self%extendable) 1339 | end subroutine set_Real64_5d 1340 | 1341 | subroutine set_Int8_6d(self, val) 1342 | class(H5Dataset), intent(inout) :: self 1343 | integer(kind=I8), intent(in) :: val(:,:,:,:,:,:) 1344 | 1345 | self%id = Create_Int8_6d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1346 | self%chunk_size, self%compression_level, self%extendable) 1347 | end subroutine set_Int8_6d 1348 | 1349 | subroutine set_Int16_6d(self, val) 1350 | class(H5Dataset), intent(inout) :: self 1351 | integer(kind=I16), intent(in) :: val(:,:,:,:,:,:) 1352 | 1353 | self%id = Create_Int16_6d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1354 | self%chunk_size, self%compression_level, self%extendable) 1355 | end subroutine set_Int16_6d 1356 | 1357 | subroutine set_Int32_6d(self, val) 1358 | class(H5Dataset), intent(inout) :: self 1359 | integer(kind=I32), intent(in) :: val(:,:,:,:,:,:) 1360 | 1361 | self%id = Create_Int32_6d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1362 | self%chunk_size, self%compression_level, self%extendable) 1363 | end subroutine set_Int32_6d 1364 | 1365 | subroutine set_Real32_6d(self, val) 1366 | class(H5Dataset), intent(inout) :: self 1367 | real(kind=SP), intent(in) :: val(:,:,:,:,:,:) 1368 | 1369 | self%id = Create_Real32_6d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1370 | self%chunk_size, self%compression_level, self%extendable) 1371 | end subroutine set_Real32_6d 1372 | 1373 | subroutine set_Real64_6d(self, val) 1374 | class(H5Dataset), intent(inout) :: self 1375 | real(kind=DP), intent(in) :: val(:,:,:,:,:,:) 1376 | 1377 | self%id = Create_Real64_6d_Dataset(self%parent_id, self%d_name, val, self%fill_value, & 1378 | self%chunk_size, self%compression_level, self%extendable) 1379 | end subroutine set_Real64_6d 1380 | 1381 | subroutine Extend_Int8_1d(self, new_size, offset, dshape, val) 1382 | class(H5Dataset) :: self 1383 | integer(kind=I8), intent(in) :: val(:) 1384 | integer(kind=I32), parameter :: D_RANK=rank(val) 1385 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1386 | integer(kind=I64), intent(in) :: offset(D_RANK) 1387 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1388 | integer(kind=I32) :: error 1389 | 1390 | error = Extend_Int8_1d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1391 | end subroutine Extend_Int8_1d 1392 | 1393 | subroutine Extend_Int16_1d(self, new_size, offset, dshape, val) 1394 | class(H5Dataset) :: self 1395 | integer(kind=I16), intent(in) :: val(:) 1396 | integer(kind=I32), parameter :: D_RANK=rank(val) 1397 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1398 | integer(kind=I64), intent(in) :: offset(D_RANK) 1399 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1400 | integer(kind=I32) :: error 1401 | 1402 | error = Extend_Int16_1d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1403 | end subroutine Extend_Int16_1d 1404 | 1405 | subroutine Extend_Int32_1d(self, new_size, offset, dshape, val) 1406 | class(H5Dataset) :: self 1407 | integer(kind=I32), intent(in) :: val(:) 1408 | integer(kind=I32), parameter :: D_RANK=rank(val) 1409 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1410 | integer(kind=I64), intent(in) :: offset(D_RANK) 1411 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1412 | integer(kind=I32) :: error 1413 | 1414 | error = Extend_Int32_1d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1415 | end subroutine Extend_Int32_1d 1416 | 1417 | subroutine Extend_Real32_1d(self, new_size, offset, dshape, val) 1418 | class(H5Dataset) :: self 1419 | real(kind=SP), intent(in) :: val(:) 1420 | integer(kind=I32), parameter :: D_RANK=rank(val) 1421 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1422 | integer(kind=I64), intent(in) :: offset(D_RANK) 1423 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1424 | integer(kind=I32) :: error 1425 | 1426 | error = Extend_Real32_1d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1427 | end subroutine Extend_Real32_1d 1428 | 1429 | subroutine Extend_Real64_1d(self, new_size, offset, dshape, val) 1430 | class(H5Dataset) :: self 1431 | real(kind=DP), intent(in) :: val(:) 1432 | integer(kind=I32), parameter :: D_RANK=rank(val) 1433 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1434 | integer(kind=I64), intent(in) :: offset(D_RANK) 1435 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1436 | integer(kind=I32) :: error 1437 | 1438 | error = Extend_Real64_1d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1439 | end subroutine Extend_Real64_1d 1440 | 1441 | subroutine Extend_Int8_2d(self, new_size, offset, dshape, val) 1442 | class(H5Dataset) :: self 1443 | integer(kind=I8), intent(in) :: val(:,:) 1444 | integer(kind=I32), parameter :: D_RANK=rank(val) 1445 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1446 | integer(kind=I64), intent(in) :: offset(D_RANK) 1447 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1448 | integer(kind=I32) :: error 1449 | 1450 | error = Extend_Int8_2d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1451 | end subroutine Extend_Int8_2d 1452 | 1453 | subroutine Extend_Int16_2d(self, new_size, offset, dshape, val) 1454 | class(H5Dataset) :: self 1455 | integer(kind=I16), intent(in) :: val(:,:) 1456 | integer(kind=I32), parameter :: D_RANK=rank(val) 1457 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1458 | integer(kind=I64), intent(in) :: offset(D_RANK) 1459 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1460 | integer(kind=I32) :: error 1461 | 1462 | error = Extend_Int16_2d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1463 | end subroutine Extend_Int16_2d 1464 | 1465 | subroutine Extend_Int32_2d(self, new_size, offset, dshape, val) 1466 | class(H5Dataset) :: self 1467 | integer(kind=I32), intent(in) :: val(:,:) 1468 | integer(kind=I32), parameter :: D_RANK=rank(val) 1469 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1470 | integer(kind=I64), intent(in) :: offset(D_RANK) 1471 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1472 | integer(kind=I32) :: error 1473 | 1474 | error = Extend_Int32_2d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1475 | end subroutine Extend_Int32_2d 1476 | 1477 | subroutine Extend_Real32_2d(self, new_size, offset, dshape, val) 1478 | class(H5Dataset) :: self 1479 | real(kind=SP), intent(in) :: val(:,:) 1480 | integer(kind=I32), parameter :: D_RANK=rank(val) 1481 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1482 | integer(kind=I64), intent(in) :: offset(D_RANK) 1483 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1484 | integer(kind=I32) :: error 1485 | 1486 | error = Extend_Real32_2d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1487 | end subroutine Extend_Real32_2d 1488 | 1489 | subroutine Extend_Real64_2d(self, new_size, offset, dshape, val) 1490 | class(H5Dataset) :: self 1491 | real(kind=DP), intent(in) :: val(:,:) 1492 | integer(kind=I32), parameter :: D_RANK=rank(val) 1493 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1494 | integer(kind=I64), intent(in) :: offset(D_RANK) 1495 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1496 | integer(kind=I32) :: error 1497 | 1498 | error = Extend_Real64_2d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1499 | end subroutine Extend_Real64_2d 1500 | 1501 | subroutine Extend_Int8_3d(self, new_size, offset, dshape, val) 1502 | class(H5Dataset) :: self 1503 | integer(kind=I8), intent(in) :: val(:,:,:) 1504 | integer(kind=I32), parameter :: D_RANK=rank(val) 1505 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1506 | integer(kind=I64), intent(in) :: offset(D_RANK) 1507 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1508 | integer(kind=I32) :: error 1509 | 1510 | error = Extend_Int8_3d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1511 | end subroutine Extend_Int8_3d 1512 | 1513 | subroutine Extend_Int16_3d(self, new_size, offset, dshape, val) 1514 | class(H5Dataset) :: self 1515 | integer(kind=I16), intent(in) :: val(:,:,:) 1516 | integer(kind=I32), parameter :: D_RANK=rank(val) 1517 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1518 | integer(kind=I64), intent(in) :: offset(D_RANK) 1519 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1520 | integer(kind=I32) :: error 1521 | 1522 | error = Extend_Int16_3d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1523 | end subroutine Extend_Int16_3d 1524 | 1525 | subroutine Extend_Int32_3d(self, new_size, offset, dshape, val) 1526 | class(H5Dataset) :: self 1527 | integer(kind=I32), intent(in) :: val(:,:,:) 1528 | integer(kind=I32), parameter :: D_RANK=rank(val) 1529 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1530 | integer(kind=I64), intent(in) :: offset(D_RANK) 1531 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1532 | integer(kind=I32) :: error 1533 | 1534 | error = Extend_Int32_3d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1535 | end subroutine Extend_Int32_3d 1536 | 1537 | subroutine Extend_Real32_3d(self, new_size, offset, dshape, val) 1538 | class(H5Dataset) :: self 1539 | real(kind=SP), intent(in) :: val(:,:,:) 1540 | integer(kind=I32), parameter :: D_RANK=rank(val) 1541 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1542 | integer(kind=I64), intent(in) :: offset(D_RANK) 1543 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1544 | integer(kind=I32) :: error 1545 | 1546 | error = Extend_Real32_3d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1547 | end subroutine Extend_Real32_3d 1548 | 1549 | subroutine Extend_Real64_3d(self, new_size, offset, dshape, val) 1550 | class(H5Dataset) :: self 1551 | real(kind=DP), intent(in) :: val(:,:,:) 1552 | integer(kind=I32), parameter :: D_RANK=rank(val) 1553 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1554 | integer(kind=I64), intent(in) :: offset(D_RANK) 1555 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1556 | integer(kind=I32) :: error 1557 | 1558 | error = Extend_Real64_3d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1559 | end subroutine Extend_Real64_3d 1560 | 1561 | subroutine Extend_Int8_4d(self, new_size, offset, dshape, val) 1562 | class(H5Dataset) :: self 1563 | integer(kind=I8), intent(in) :: val(:,:,:,:) 1564 | integer(kind=I32), parameter :: D_RANK=rank(val) 1565 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1566 | integer(kind=I64), intent(in) :: offset(D_RANK) 1567 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1568 | integer(kind=I32) :: error 1569 | 1570 | error = Extend_Int8_4d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1571 | end subroutine Extend_Int8_4d 1572 | 1573 | subroutine Extend_Int16_4d(self, new_size, offset, dshape, val) 1574 | class(H5Dataset) :: self 1575 | integer(kind=I16), intent(in) :: val(:,:,:,:) 1576 | integer(kind=I32), parameter :: D_RANK=rank(val) 1577 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1578 | integer(kind=I64), intent(in) :: offset(D_RANK) 1579 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1580 | integer(kind=I32) :: error 1581 | 1582 | error = Extend_Int16_4d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1583 | end subroutine Extend_Int16_4d 1584 | 1585 | subroutine Extend_Int32_4d(self, new_size, offset, dshape, val) 1586 | class(H5Dataset) :: self 1587 | integer(kind=I32), intent(in) :: val(:,:,:,:) 1588 | integer(kind=I32), parameter :: D_RANK=rank(val) 1589 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1590 | integer(kind=I64), intent(in) :: offset(D_RANK) 1591 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1592 | integer(kind=I32) :: error 1593 | 1594 | error = Extend_Int32_4d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1595 | end subroutine Extend_Int32_4d 1596 | 1597 | subroutine Extend_Real32_4d(self, new_size, offset, dshape, val) 1598 | class(H5Dataset) :: self 1599 | real(kind=SP), intent(in) :: val(:,:,:,:) 1600 | integer(kind=I32), parameter :: D_RANK=rank(val) 1601 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1602 | integer(kind=I64), intent(in) :: offset(D_RANK) 1603 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1604 | integer(kind=I32) :: error 1605 | 1606 | error = Extend_Real32_4d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1607 | end subroutine Extend_Real32_4d 1608 | 1609 | subroutine Extend_Real64_4d(self, new_size, offset, dshape, val) 1610 | class(H5Dataset) :: self 1611 | real(kind=DP), intent(in) :: val(:,:,:,:) 1612 | integer(kind=I32), parameter :: D_RANK=rank(val) 1613 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1614 | integer(kind=I64), intent(in) :: offset(D_RANK) 1615 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1616 | integer(kind=I32) :: error 1617 | 1618 | error = Extend_Real64_4d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1619 | end subroutine Extend_Real64_4d 1620 | 1621 | subroutine Extend_Int8_5d(self, new_size, offset, dshape, val) 1622 | class(H5Dataset) :: self 1623 | integer(kind=I8), intent(in) :: val(:,:,:,:,:) 1624 | integer(kind=I32), parameter :: D_RANK=rank(val) 1625 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1626 | integer(kind=I64), intent(in) :: offset(D_RANK) 1627 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1628 | integer(kind=I32) :: error 1629 | 1630 | error = Extend_Int8_5d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1631 | end subroutine Extend_Int8_5d 1632 | 1633 | subroutine Extend_Int16_5d(self, new_size, offset, dshape, val) 1634 | class(H5Dataset) :: self 1635 | integer(kind=I16), intent(in) :: val(:,:,:,:,:) 1636 | integer(kind=I32), parameter :: D_RANK=rank(val) 1637 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1638 | integer(kind=I64), intent(in) :: offset(D_RANK) 1639 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1640 | integer(kind=I32) :: error 1641 | 1642 | error = Extend_Int16_5d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1643 | end subroutine Extend_Int16_5d 1644 | 1645 | subroutine Extend_Int32_5d(self, new_size, offset, dshape, val) 1646 | class(H5Dataset) :: self 1647 | integer(kind=I32), intent(in) :: val(:,:,:,:,:) 1648 | integer(kind=I32), parameter :: D_RANK=rank(val) 1649 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1650 | integer(kind=I64), intent(in) :: offset(D_RANK) 1651 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1652 | integer(kind=I32) :: error 1653 | 1654 | error = Extend_Int32_5d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1655 | end subroutine Extend_Int32_5d 1656 | 1657 | subroutine Extend_Real32_5d(self, new_size, offset, dshape, val) 1658 | class(H5Dataset) :: self 1659 | real(kind=SP), intent(in) :: val(:,:,:,:,:) 1660 | integer(kind=I32), parameter :: D_RANK=rank(val) 1661 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1662 | integer(kind=I64), intent(in) :: offset(D_RANK) 1663 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1664 | integer(kind=I32) :: error 1665 | 1666 | error = Extend_Real32_5d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1667 | end subroutine Extend_Real32_5d 1668 | 1669 | subroutine Extend_Real64_5d(self, new_size, offset, dshape, val) 1670 | class(H5Dataset) :: self 1671 | real(kind=DP), intent(in) :: val(:,:,:,:,:) 1672 | integer(kind=I32), parameter :: D_RANK=rank(val) 1673 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1674 | integer(kind=I64), intent(in) :: offset(D_RANK) 1675 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1676 | integer(kind=I32) :: error 1677 | 1678 | error = Extend_Real64_5d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1679 | end subroutine Extend_Real64_5d 1680 | 1681 | subroutine Extend_Int8_6d(self, new_size, offset, dshape, val) 1682 | class(H5Dataset) :: self 1683 | integer(kind=I8), intent(in) :: val(:,:,:,:,:,:) 1684 | integer(kind=I32), parameter :: D_RANK=rank(val) 1685 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1686 | integer(kind=I64), intent(in) :: offset(D_RANK) 1687 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1688 | integer(kind=I32) :: error 1689 | 1690 | error = Extend_Int8_6d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1691 | end subroutine Extend_Int8_6d 1692 | 1693 | subroutine Extend_Int16_6d(self, new_size, offset, dshape, val) 1694 | class(H5Dataset) :: self 1695 | integer(kind=I16), intent(in) :: val(:,:,:,:,:,:) 1696 | integer(kind=I32), parameter :: D_RANK=rank(val) 1697 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1698 | integer(kind=I64), intent(in) :: offset(D_RANK) 1699 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1700 | integer(kind=I32) :: error 1701 | 1702 | error = Extend_Int16_6d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1703 | end subroutine Extend_Int16_6d 1704 | 1705 | subroutine Extend_Int32_6d(self, new_size, offset, dshape, val) 1706 | class(H5Dataset) :: self 1707 | integer(kind=I32), intent(in) :: val(:,:,:,:,:,:) 1708 | integer(kind=I32), parameter :: D_RANK=rank(val) 1709 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1710 | integer(kind=I64), intent(in) :: offset(D_RANK) 1711 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1712 | integer(kind=I32) :: error 1713 | 1714 | error = Extend_Int32_6d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1715 | end subroutine Extend_Int32_6d 1716 | 1717 | subroutine Extend_Real32_6d(self, new_size, offset, dshape, val) 1718 | class(H5Dataset) :: self 1719 | real(kind=SP), intent(in) :: val(:,:,:,:,:,:) 1720 | integer(kind=I32), parameter :: D_RANK=rank(val) 1721 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1722 | integer(kind=I64), intent(in) :: offset(D_RANK) 1723 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1724 | integer(kind=I32) :: error 1725 | 1726 | error = Extend_Real32_6d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1727 | end subroutine Extend_Real32_6d 1728 | 1729 | subroutine Extend_Real64_6d(self, new_size, offset, dshape, val) 1730 | class(H5Dataset) :: self 1731 | real(kind=DP), intent(in) :: val(:,:,:,:,:,:) 1732 | integer(kind=I32), parameter :: D_RANK=rank(val) 1733 | integer(kind=I64), intent(in) :: new_size(D_RANK) 1734 | integer(kind=I64), intent(in) :: offset(D_RANK) 1735 | integer(kind=I64), intent(in) :: dshape(D_RANK) 1736 | integer(kind=I32) :: error 1737 | 1738 | error = Extend_Real64_6d_Dataset(self%parent_id, self%d_name, new_size, offset, dshape, val) 1739 | end subroutine Extend_Real64_6d 1740 | 1741 | subroutine defScale(self,dim_name) 1742 | class(H5Dataset) :: self 1743 | character(len=*), intent(in), optional :: dim_name 1744 | integer(kind=I32) :: ierr 1745 | integer(kind=I32) :: dim_id, dset_id 1746 | 1747 | dim_id = open_dset(self%parent_id,self%d_name) 1748 | if (present(dim_name)) then 1749 | ierr = def_scale(dim_id,dim_name) 1750 | else 1751 | ierr = def_scale(dim_id) 1752 | end if 1753 | end subroutine defScale 1754 | 1755 | subroutine setScale(self,dim_dset,idx_dim) 1756 | class(H5Dataset) :: self 1757 | class(H5Dataset), intent(in) :: dim_dset 1758 | integer(kind=I32), intent(in) :: idx_dim 1759 | integer(kind=I32) :: ierr 1760 | integer(kind=I32) :: dim_id, dset_id 1761 | 1762 | dset_id = open_dset(self%parent_id,self%d_name) 1763 | dim_id = open_dset(dim_dset%parent_id,dim_dset%d_name) 1764 | ierr = set_scale(dset_id,dim_id,idx_dim) 1765 | ierr = close_dset(dim_id) 1766 | ierr = close_dset(dset_id) 1767 | end subroutine setScale 1768 | 1769 | end module H5_OO_mod 1770 | -------------------------------------------------------------------------------- /src/Strings_Func_mod.f90: -------------------------------------------------------------------------------- 1 | !#################################################################################################! 2 | !BSD 3-Clause License 3 | ! 4 | !Copyright (c) 2017, Ricardo Torres 5 | !All rights reserved. 6 | ! 7 | !Redistribution and use in source and binary forms, with or without 8 | !modification, are permitted provided that the following conditions are met: 9 | ! 10 | !* Redistributions of source code must retain the above copyright notice, this 11 | ! list of conditions and the following disclaimer. 12 | 13 | !* Redistributions in binary form must reproduce the above copyright notice, 14 | ! this list of conditions and the following disclaimer in the documentation 15 | ! and/or other materials provided with the distribution. 16 | 17 | !* Neither the name of the copyright holder nor the names of its 18 | ! contributors may be used to endorse or promote products derived from 19 | ! this software without specific prior written permission. 20 | ! 21 | !THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | !AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | !IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | !DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | !FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | !DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | !SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | !CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | !OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | !OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | !#################################################################################################! 32 | 33 | module Strings_Func_mod 34 | use Types_mod 35 | implicit none 36 | 37 | contains 38 | !##################################################################################################################################! 39 | !------------------------------------------------------------------------ 40 | ! ...Functions to change case of letters... 41 | !------------------------------------------------------------------------ 42 | elemental function To_upper(str) 43 | character(*), intent(in) :: str 44 | character(len=len(str)) :: To_upper 45 | integer :: i 46 | 47 | To_upper=str 48 | do i = 1, len(str) 49 | select case(str(i:i)) 50 | case("a":"z") 51 | To_upper(i:i) = achar(iachar(str(i:i))-32) 52 | end select 53 | end do 54 | end function To_upper 55 | !------------------------------------------------------------------------ 56 | elemental function To_lower(str) 57 | character(*), intent(in) :: str 58 | character(len=len(str)) :: To_lower 59 | integer :: i 60 | 61 | To_lower=str 62 | do i = 1, len(str) 63 | select case(str(i:i)) 64 | case("A":"Z") 65 | To_lower(i:i) = achar(iachar(str(i:i))+32) 66 | end select 67 | end do 68 | end function To_lower 69 | !##################################################################################################################################! 70 | !------------------------------------------------------------------------ 71 | ! ...function N_Lines: Count number of lines of input file... 72 | !------------------------------------------------------------------------ 73 | integer(kind=I32) function N_Lines(filein) 74 | character(len=*), intent(in) :: filein 75 | integer(kind=I8) :: io, nunit 76 | 77 | open (newunit=nunit,file=trim(filein),iostat=io) 78 | N_Lines=-1 79 | 80 | do while (io==0) 81 | N_Lines = N_Lines + 1 82 | read(nunit,*,iostat=io) 83 | end do 84 | 85 | close(nunit) 86 | end function N_Lines 87 | !##################################################################################################################################! 88 | !------------------------------------------------------------------------ 89 | ! ...subroutine reportLog: Print a message to display... 90 | !------------------------------------------------------------------------ 91 | subroutine ReportLog(logmessage) 92 | character(len=*), intent(in) :: logmessage 93 | write(*,*)trim(logmessage) 94 | end subroutine ReportLog 95 | !##################################################################################################################################! 96 | !------------------------------------------------------------------------ 97 | ! ...subroutine Decomp_Names: decompose the filenamein array in fields... 98 | !------------------------------------------------------------------------ 99 | pure subroutine Decomp_Names(filenamein,field_names) 100 | character(len=*), intent(out) :: field_names(:) !string containing the names of the filenamein 101 | character(len=*), intent(in) :: filenamein !input string to be decomposed 102 | integer(kind=I16) :: reset !position of first slash (/) 103 | integer(kind=I16), allocatable :: position_under(:) !positions of the found underscores 104 | integer(kind=I16) :: name_len, name_spaces 105 | integer(kind=I16) :: i 106 | !----------------------------------------------------------------------------------------------- 107 | 108 | name_spaces=size(field_names) 109 | allocate(position_under(name_spaces)) 110 | reset=scan(trim(filenamein), '/',back=.true.) !To find the last slash 111 | name_len=len(trim(filenamein)) 112 | 113 | position_under(1) = scan(trim(filenamein(reset+1:name_len)), '_') 114 | position_under(1) = reset + position_under(1) 115 | if( name_spaces > 2 ) then 116 | do i=2,name_spaces-1 117 | position_under(i) = scan(trim(filenamein(sum(position_under(1:i-1))+1:name_len)), '_') 118 | end do 119 | end if 120 | position_under(name_spaces) = scan(trim(filenamein(sum(position_under(1:name_spaces-1))+1:name_len)), '.') 121 | if (position_under(name_spaces) == 0) then 122 | position_under(name_spaces) = len_trim(filenamein) - position_under(name_spaces-1) 123 | end if 124 | 125 | field_names(1)=filenamein(reset+1:position_under(1)-1) 126 | if( name_spaces > 1 ) then 127 | do i=2,name_spaces 128 | field_names(i)=filenamein(sum(position_under(1:i-1))+1:sum(position_under(1:i))-1) 129 | end do 130 | end if 131 | 132 | deallocate(position_under) 133 | end subroutine Decomp_Names 134 | !##################################################################################################################################! 135 | end module Strings_Func_mod 136 | -------------------------------------------------------------------------------- /src/Types_mod.f90: -------------------------------------------------------------------------------- 1 | module Types_mod 2 | use, intrinsic :: iso_fortran_env 3 | implicit none 4 | public :: SP, DP, QP, I8, I16, I32, I64 5 | integer, parameter :: SP = REAL32 ! Single precision 6 | integer, parameter :: DP = REAL64 ! Double precision 7 | integer, parameter :: QP = REAL128 ! Quadruple precision 8 | 9 | integer, parameter :: I8 = INT8 10 | integer, parameter :: I16 = INT16 11 | integer, parameter :: I32 = INT32 12 | integer, parameter :: I64 = INT64 13 | 14 | end module Types_mod 15 | -------------------------------------------------------------------------------- /tests/test_funcs.f90: -------------------------------------------------------------------------------- 1 | program test_h5_funcs 2 | use H5_Func_mod 3 | implicit none 4 | 5 | integer(kind=4) :: file_id, gr_id, file2_id 6 | integer(kind=4) :: error 7 | character(len=10) :: chararr(2) 8 | integer(kind=4) :: read_a(19) 9 | integer(kind=4) :: value 10 | integer(kind=4) :: test_arr(4,3) 11 | integer(kind=4) :: i, j 12 | 13 | file_id=hdf_open_file("new_test_file.h5", "N", "W") 14 | 15 | file2_id=hdf_open_file("new2_test_file.h5", "N", "W") 16 | 17 | gr_id=hdf_create_group(file_id,'grupo1') 18 | 19 | error=Create_Int16_Attr0(file_id, 'att0', int(45,2)) 20 | error=Create_Int16_Attr0(gr_id, 'attgr0', int(45,2)) 21 | error=Create_Int32_Attr1(file_id, 'att1', int([4,4,2,5,4,6,3,1,1,5,5,2,4,2154545,6,2,4,7,6],4)) 22 | 23 | error=Create_Char_Attr0(file_id,a_name='attchar',val='asdfasdf') 24 | chararr='' 25 | chararr(1)='alfa' 26 | chararr(2)='betas' 27 | error=Create_Char_Attr1(file_id,a_name='attchar3',val=chararr) 28 | 29 | do i=1,size(test_arr(:,1)) 30 | do j=1,size(test_arr(1,:)) 31 | test_arr(i,j)=i*j 32 | end do 33 | end do 34 | 35 | error=Create_Dset(gr_id,"2d_i32",test_arr) 36 | error=Create_Dset(gr_id,"2d_i16",int(test_arr,I16)) 37 | error=Create_Dset(gr_id,"2d_i8",int(test_arr,I8)) 38 | error=Create_Dset(gr_id,"2d_r32",real(test_arr,SP)) 39 | error=Create_Dset(gr_id,"2d_r64",real(test_arr,DP)) 40 | 41 | error=Create_Dset(gr_id,"1d_i32",test_arr(1,:)) 42 | error=Create_Dset(gr_id,"1d_i16",int(test_arr(1,:),I16), extendable=1) 43 | error=Create_Dset(gr_id,"1d_i8",int(test_arr(1,:),I8)) 44 | error=Create_Dset(gr_id,"1d_r32",real(test_arr(1,:),SP)) 45 | error=Create_Dset(gr_id,"1d_r64",real(test_arr(1,:),DP)) 46 | 47 | error=hdf_close_group(gr_id) 48 | 49 | error=hdf_close_file(file_id) 50 | 51 | error=Create_Char_Attr1(file2_id,a_name='attchar3',val=chararr) 52 | error=hdf_close_file(file2_id) 53 | file_id=hdf_open_file("new_test_file.h5", "o", "r") 54 | gr_id=hdf_open_group(file_id, 'grupo1') 55 | chararr='-' 56 | error=Read_Att(file_id, a_name='attchar3', val=chararr)!, gr_id=gr_id) 57 | error=Read_Att(file_id, a_name='att1', val=read_a(:)) 58 | error=Read_Att(gr_id, a_name='attgr0', val=value) 59 | 60 | call hdf_close(error) 61 | 62 | print*,chararr 63 | print*,read_a 64 | print*,shape(read_a),size(read_a), rank(read_a) 65 | print*,value 66 | 67 | 68 | end program test_h5_funcs 69 | -------------------------------------------------------------------------------- /tests/test_objs.f90: -------------------------------------------------------------------------------- 1 | program test_h5_funcs 2 | use H5_OO_mod 3 | implicit none 4 | 5 | type(H5File) :: f1 6 | type(H5Dataset) :: d1, d2 7 | type(H5Group) :: g1 8 | 9 | integer(kind=4) :: file_id, gr_id, file2_id 10 | integer(kind=4) :: error 11 | character(len=10) :: chararr(2) 12 | integer(kind=4) :: read_a(19) 13 | integer(kind=4) :: value 14 | integer(kind=4) :: test_arr(4,3) 15 | integer(kind=4) :: i, j 16 | real(kind=DP) :: r8_dset(4) 17 | 18 | 19 | f1=H5File("new_test_file.h5", "N", "W") 20 | 21 | call f1%setAttribute('thgttg',42) 22 | 23 | d1=H5Dataset('2d_i32',f1) 24 | 25 | call d1%setFillValue(-1) 26 | 27 | print*,f1%id 28 | 29 | call f1%setGroup('newgroup',g1) 30 | 31 | 32 | d2=H5Dataset('4d_r64',g1) 33 | ! call d1%showstatus() 34 | 35 | do i=1,size(test_arr(:,1)) 36 | do j=1,size(test_arr(1,:)) 37 | test_arr(i,j)=i*j 38 | end do 39 | end do 40 | 41 | call d1%setDataset(int(test_arr,1)) 42 | call d1%setAttribute('thgttg',int(42,2)) 43 | 44 | call d2%setDataset(real([[1],[2],[4],[5]],DP)) 45 | call d1%setAttribute('att1', int([4,4,2,5,4,6,3,1,1,5,5,2,4,2154545,6,2,4,7,6],4)) 46 | 47 | call f1%closeFile() 48 | 49 | 50 | f1=H5File("new_test_file.h5", "O", "R") 51 | 52 | call f1%getAttribute('thgttg',i) 53 | print*,i 54 | 55 | call f1%openGroup('newgroup',g1) 56 | 57 | d1=H5Dataset('2d_i32',f1) 58 | call d1%getAttribute('att1',read_a) 59 | print*,read_a 60 | 61 | d2=H5Dataset('4d_r64',g1) 62 | 63 | call d2%getDataset(r8_dset) 64 | 65 | print*,r8_dset 66 | 67 | call f1%closeFile() 68 | 69 | 70 | end program test_h5_funcs 71 | --------------------------------------------------------------------------------