Page 7 - Demo
P. 7


                                    Data File Viewer%uf09f %uf09f RCP Consult 2022-2025 Page 71.9 FORTRAN ImplementationThe list of accessible functions/subroutines for binding of binary dataOpenBinaryDataFileInit(datafile)Open a MAT/HDF5 binary file and read all data fromdatafile (character) %u2013 filename having extension *.mat or *.h5Returns identifier (integer*8) of opened data file or 0 if error.GetBinaryDataFileVariable(fid, variable, m1, m2, bytes)Returns identifier of variable data, dimensions and bytes of typefid (integer*8) %u2013 identifier of data filevariable (character)%u2013 name of variable in directory of data filem1, m2 (integers) %u2013 dimension of variable data arraybytes (integer) %u2013 size in bytes of variable data elementCloseBinaryDataFile(fid)Close a MAT/HDF5 binary filefid (integer*8) %u2013 identifier of data fileThe invoking of binary data file in the source file is very straightforward. First you need prepare all required variables and their types in the declarative part of a function or subroutine. For example, if you process double precision data from a data file it looks like integer*8 fid ! identifier of data file real*8 ar(1) ! array of interest to be used integer*8 id ! identifier of array for variable integer m1,m2,nb ! dimensions and size of array element pointer(id,ar) ! binding of variable data with array real*8, allocatable::cr(:,:) ! declaration of array for reshapingIn the executable part of a function or subroutine the data file must be opened and becomes an unique identifier. For example fid=OpenBinaryDataFile(\! filename must be null terminatedor fid=OpenBinaryDataFile(\! filename must be null terminatedNext an identifier of data array and corresponding dimensions and size in bytes for a variable of interest should be defined. id=GetBinaryDataFileVariable(fid,\! varname must be null terminatedNow it is possible to reshape an array of variable to a real shape as is stored in data file cr=reshape(ar, (/m1, m2/)) ! cr array will now be declared as cr(m1,m2)Finally, after loading data from binary file it must be closed by call CloseBinaryDataFile(fid)
                                
   1   2   3   4   5   6   7   8   9   10   11