Commit 6cd972e0 authored by Jefferson Stafusa E. Portela's avatar Jefferson Stafusa E. Portela
Browse files

Merge branch '85-implementing-hdf5-2' into 'master'

Resolve "Implementing HDF5"

Closes #85

See merge request !120
parents 998331f8 c92d350e
Pipeline #12835 passed with stage
in 4 minutes and 29 seconds
......@@ -16,4 +16,5 @@ Documentation/doc.idx
Documentation/doc.log
Documentation/doc.synctex.gz
Documentation/doc.toc
HDF5/
environment
......@@ -16,7 +16,8 @@ stages:
stage: build
<<: *exemptfiles_definition
script:
- . configure.sh GNU serial
- apt-get update && apt install -y curl libghc-zlib-dev g++
- . configure.sh GNU serial HDF5
- gfortran -v
- make all
......@@ -24,15 +25,17 @@ stages:
stage: build
<<: *exemptfiles_definition
script:
- apt-get update && apt install -y curl libghc-zlib-dev
- pgfortran --version
- . configure.sh PGI serial
- . configure.sh PGI serial HDF5
- make all
.warnconv_template: &warnconv_definition
stage: warnconv
<<: *exemptfiles_definition
script:
- . configure.sh Devel serial
- apt-get update && apt install -y curl libghc-zlib-dev g++
- . configure.sh Devel serial HDF5
- gfortran -v
- make all
......@@ -40,7 +43,8 @@ stages:
stage: test
<<: *exemptfiles_definition
script:
- . configure.sh Devel serial
- apt-get update && apt install -y curl libghc-zlib-dev g++
- . configure.sh Devel serial HDF5
- gfortran -v
- make lib
- make ana
......@@ -48,7 +52,7 @@ stages:
- cd testsuite
- cmake -E make_directory tests
- cd tests
- cmake -G "Unix Makefiles" -DCMAKE_Fortran_FLAGS_RELEASE=${ALF_FLAGS_PROG} -DCMAKE_BUILD_TYPE=RELEASE ..
- cmake ..
- cmake --build . --target all --config Release
- ctest -VV -O log.txt
- cat log.txt | grep "tests passed" | cut -d " " -f 1
......@@ -116,8 +120,9 @@ GQMCT_Stretch_MPI:
- README.md
- license.*
script:
- apt-get update && apt install -y curl libghc-zlib-dev g++
- gfortran -v
- . configure.sh Devel Tempering
- . configure.sh Devel Tempering HDF5
- export ALF_FC="mpif90"
- make all
......@@ -131,8 +136,9 @@ GQMCT_Intel-21:
- README.md
- license.*
script:
- apt-get update && apt install -y curl libghc-zlib-dev
- . /opt/intel/oneapi/setvars.sh
- . configure.sh INTEL serial
- . configure.sh INTEL serial HDF5
- make all
#GQMCT_Jessie_conv:
......@@ -177,8 +183,9 @@ GQMCT_PGI_conv:
- README.md
- license.*
script:
- apt-get update && apt install -y curl libghc-zlib-dev
- pgfortran --version
- . configure.sh PGI serial
- . configure.sh PGI serial HDF5
- make all
#GQMCT_Jessie_tests:
......@@ -231,16 +238,16 @@ GQMCT_PGI_tests:
- README.md
- license.*
script:
- apt-get update && apt install -y curl libghc-zlib-dev
- pgfortran --version
- . configure.sh PGI serial
- . configure.sh PGI serial HDF5
- make lib
- make ana
- make program
- cd testsuite
- cmake -E make_directory tests
- cd tests
- export PGIDIR="/opt/nvidia/hpc_sdk/Linux_x86_64/21.3/compilers"
- cmake -G "Unix Makefiles" -DCMAKE_Fortran_FLAGS_RELEASE="${ALF_FLAGS_PROG} -noswitcherror -L${PGIDIR}/lib/ -llapack -lblas" -DCMAKE_Fortran_COMPILER="${PGIDIR}/bin/pgfortran" -DCMAKE_BUILD_TYPE=RELEASE -DLAPACK_LIBRARIES="${PGIDIR}/lib/liblapack.a" -DBLAS_LIBRARIES="${PGIDIR}/lib/libblas.a" ..
- cmake ..
- cmake --build . --target all --config Release
- ctest -VV -O log.txt
- cat log.txt | grep "tests passed" | cut -d " " -f 1
......@@ -253,8 +260,9 @@ GQMCT_Stretch_valgrind:
- Prog/*.(f|F)90
- Libraries/Modules/*.(f|F)90
script:
- apt-get update && apt install -y curl libghc-zlib-dev g++
- export ALF_FLAGS_EXT="-g"
- . configure.sh GNU serial
- . configure.sh GNU serial HDF5
- gfortran -v
- make lib
- make program
......
.PHONY : all tidy clean
BINS= cov_scal.out cov_tau.out cov_tau_ph.out Max_SAC.out cov_eq.out cov_mut.out ana.out
OBJS= cov_scal.o cov_tau.o cov_tau_ph.o Max_SAC.o cov_eq.o cov_mut.o ana.o
BINS_H5=ana_hdf5.out
OBJS= cov_scal.o cov_tau.o cov_tau_ph.o Max_SAC.o cov_eq.o cov_mut.o ana.o ana_hdf5.o
OBJS1=Predefined_Latt_mod.o ana_mod.o
MODS=predefined_lattices.mod ana_mod.mod
all: $(BINS)
ifneq (,$(findstring DHDF5,$(ALF_FLAGS_ANA)))
@make $(BINS_H5)
endif
Predefined_Latt_mod.o: ../Prog/Predefined_Latt_mod.F90
$(ALF_FC) -c -o $@ $(ALF_FLAGS_ANA) $<
$(ALF_FC) -c -o $@ $(ALF_FLAGS_ANA) $<
cov_tau_ph.o: cov_tau.F90
$(ALF_FC) -c -o $@ $(ALF_FLAGS_ANA) -DPartHole $<
......@@ -23,4 +27,4 @@ tidy:
rm -f $(OBJS) $(OBJS1) $(MODS) cov_tau_ph.F90
clean: tidy
rm -f $(BINS)
rm -f $(BINS) $(BINS_H5)
! Copyright (C) 2020-2021 The ALF project
!
! The ALF project is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! The ALF project is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Foobar. If not, see http://www.gnu.org/licenses/.
!
! Under Section 7 of GPL version 3 we require you to fulfill the following additional terms:
!
! - It is our hope that this program makes a contribution to the scientific community. Being
! part of that community we feel that it is reasonable to require you to give an attribution
! back to the original authors if you have benefitted from this program.
! Guidelines for a proper citation can be found on the project's homepage
! http://alf.physik.uni-wuerzburg.de .
!
! - We require the preservation of the above copyright notice and this license in all original files.
!
! - We prohibit the misrepresentation of the origin of the original source files. To obtain
! the original source files please visit the homepage http://alf.physik.uni-wuerzburg.de .
!
! - If you make substantial changes to the program we require you to either consider contributing
! to the ALF project or to mark your material in a reasonable way as different from the original version.
Program ana_hdf5
!--------------------------------------------------------------------
!> @author
!> ALF-project
!
!> @brief
!> Program for postprocessing Monte Carlo bins saved in HDF5 file "data.h5".
!> Analyzes all observables in "data.h5" if no command line arguments are supplied,
!> otherwise analyzes the observables given as command line arguments.
!
!--------------------------------------------------------------------
use hdf5
use ana_mod
implicit none
Integer :: i, hdferr, nargs, storage_type, nlinks, max_corder
Character (len=64) :: File_out, File_in, name
Character (len=64), allocatable :: names(:)
INTEGER(HID_T) :: file_id, group_id
INTEGER(HSIZE_T) :: n
File_in = 'data.h5'
CALL h5open_f(hdferr)
CALL h5fopen_f (File_in, H5F_ACC_RDONLY_F, file_id, hdferr)
group_id = file_id
call h5gget_info_f(group_id, storage_type, nlinks, max_corder, hdferr)
nargs = COMMAND_ARGUMENT_COUNT()
if ( nargs > 0 ) then
allocate( names(nargs) )
do i = 1, nargs
CALL GET_COMMAND_ARGUMENT(i, name)
names(i) = name
enddo
else
allocate( names(nlinks) )
do n=0, nlinks-1
call h5lget_name_by_idx_f(group_id, '/', H5_INDEX_NAME_F, H5_ITER_INC_F, n, name, hdferr)
names(n+1) = name
enddo
endif
do n=1, size(names)
name = names(n)
i = len(trim(name)) -4
if ( i > 1 ) then
if ( name(i:) == '_scal' ) then
print *, ''
print '(A,A)', "analyzing scalar observable ", name
call Cov_vec(name, File_in)
endif
endif
enddo
do n=1, size(names)
name = names(n)
i = len(trim(name)) -2
if ( i > 1 ) then
if ( name(i:) == '_eq' ) then
print *, ''
print '(A,A)', "analyzing equal time correlation ", name
call Cov_eq(name, File_in)
endif
endif
enddo
do n=1, size(names)
name = names(n)
i = len(trim(name)) -3
if ( i > 1 ) then
if ( name(i:) == '_tau' ) then
print *, ''
print '(A,A)', "analyzing time displaced correlation ", name
call Cov_tau(name, File_in)
endif
endif
enddo
end Program ana_hdf5
......@@ -44,6 +44,11 @@
Use Matrix
Use Lattices_v3, only: Unit_cell, Lattice, Make_lattice, Fourier_K_to_R
Use Predefined_Lattices, only: Predefined_Latt
#ifdef HDF5
use hdf5
use h5lt
Use alf_hdf5
#endif
contains
......@@ -55,7 +60,7 @@
!> @brief
!> Reads in bins of scalar observables from file
!>
!> @param [IN] file Character(len=64)
!> @param [IN] file Character(len=*)
!> \verbatim
!> Name of file that gets read in
!> \endverbatim
......@@ -73,7 +78,7 @@
!> \endverbatim
!-------------------------------------------------------------------
Implicit none
Character (len=64), intent(in) :: file
Character (len=*), intent(in) :: file
Real (Kind=Kind(0.d0)), allocatable, intent(out) :: sgn(:)
Complex (Kind=Kind(0.d0)), pointer, intent(out) :: bins(:,:)
Character (len=64), intent(out) :: analysis_mode
......@@ -124,6 +129,97 @@
!==============================================================================
#ifdef HDF5
Subroutine read_vec_hdf5(filename, groupname, sgn, bins, analysis_mode)
!--------------------------------------------------------------------
!> @author
!> ALF Collaboration
!>
!> @brief
!> Reads in bins of scalar observables from HDF5 file
!>
!> @param [IN] filename Character(len=*)
!> \verbatim
!> Name of file that gets read in
!> \endverbatim
!> @param [IN] groupname Character(len=*)
!> \verbatim
!> Name of observable that gets read in
!> \endverbatim
!> @param [OUT] sgn Real(:)
!> \verbatimam
!> Sign of bins
!> \endverbatim
!> @param [OUT] bins Complex(:,:)
!> \verbatim
!> Monte Carlo bins
!> \endverbatim
!> @param [OUT] analysis_mode Character(len=64)
!> \verbatim
!> How to analyze the observable
!> \endverbatim
!-------------------------------------------------------------------
Implicit none
Character (len=*), intent(in) :: filename
Character (len=*), intent(in) :: groupname
Real (Kind=Kind(0.d0)), allocatable, intent(out) :: sgn(:)
Complex (Kind=Kind(0.d0)), pointer, intent(out) :: bins(:,:)
Character (len=64), intent(out) :: analysis_mode
Integer :: Nobs, Nbins
Character (len=64) :: file, obs_dsetname, sgn_dsetname
INTEGER :: rank, hdferr
INTEGER(HSIZE_T) :: mem_dims(1)
INTEGER(HSIZE_T), allocatable :: dims(:), maxdims(:)
INTEGER(HID_T) :: file_id, dset_id, dataspace, memspace
TYPE(C_PTR) :: dat_ptr
file = 'data.h5'
write(obs_dsetname,'(2A)') trim(groupname), "/obser"
write(sgn_dsetname,'(2A)') trim(groupname), "/sign"
CALL h5open_f(hdferr)
CALL h5fopen_f (File, H5F_ACC_RDONLY_F, file_id, hdferr)
call read_attribute(file_id, groupname, "analysis_mode", analysis_mode, hdferr)
!Open the dataset.
CALL h5dopen_f(file_id, obs_dsetname, dset_id, hdferr)
!Get dataset's dataspace handle.
CALL h5dget_space_f(dset_id, dataspace, hdferr)
!Get dataspace's rank.
CALL h5sget_simple_extent_ndims_f(dataspace, rank, hdferr)
allocate( dims(rank), maxdims(rank) )
!Get dataspace's dimensions.
CALL h5sget_simple_extent_dims_f(dataspace, dims, maxdims, hdferr)
Nobs = int( dims(2) )
Nbins = int( dims(3) )
deallocate( dims )
Allocate ( Bins(Nobs,Nbins), sgn(Nbins))
dat_ptr = C_LOC(bins(1,1))
CALL h5dopen_f(file_id, obs_dsetname, dset_id, hdferr)
CALL h5dget_space_f(dset_id, dataspace, hdferr)
CALL H5dread_f(dset_id, H5T_NATIVE_DOUBLE, dat_ptr, hdferr, &
mem_space_id = dataspace, file_space_id = dataspace)
allocate( dims(1) )
dims(1) = Nbins
CALL h5dopen_f(file_id, sgn_dsetname, dset_id, hdferr)
CALL H5dread_f(dset_id, H5T_NATIVE_DOUBLE, sgn, dims, hdferr)
deallocate( dims )
End Subroutine read_vec_hdf5
#endif
!==============================================================================
Subroutine read_latt(file, sgn, bins, bins0, Latt, Latt_unit, dtau, Channel)
!--------------------------------------------------------------------
!> @author
......@@ -165,7 +261,7 @@
!> \endverbatim
!-------------------------------------------------------------------
Implicit none
Character (len=64), intent(in) :: file
Character (len=*), intent(in) :: file
Real (Kind=Kind(0.d0)), allocatable, intent(out) :: sgn(:)
Complex (Kind=Kind(0.d0)), pointer , intent(out) :: bins(:,:,:,:,:)
Complex (Kind=Kind(0.d0)), pointer , intent(out) :: bins0(:,:)
......@@ -295,6 +391,160 @@
End Subroutine read_latt
!==============================================================================
#ifdef HDF5
Subroutine read_latt_hdf5(filename, name, sgn, bins, bins0, Latt, Latt_unit, dtau, Channel)
!--------------------------------------------------------------------
!> @author
!> ALF Collaboration
!>
!> @brief
!> Reads in bins of lattice-type observables (both equal time and timedisplaced)
!> from HDF5 file data.h5
!>
!> @param [IN] name Character(len=64)
!> \verbatim
!> Name of observable that gets read in
!> \endverbatim
!> @param [OUT] sgn Real(:)
!> \verbatimam
!> Sign of bins
!> \endverbatim
!> @param [OUT] bins Complex(:,:,:,:,:)
!> \verbatim
!> Monte Carlo bins of correlation
!> @param [OUT] bins0 Complex(:,:)
!> \verbatim
!> Monte Carlo bins of background
!> \endverbatim
!> @param [OUT] Latt Type(Lattice)
!> \verbatim
!> Bravais lattice
!> \endverbatim
!> @param [OUT] Latt_unit Type(Unit_cell)
!> \verbatim
!> Unit cell
!> \endverbatim
!> @param [OUT] dtau Real
!> \verbatim
!> Size of imaginary time step
!> \endverbatim
!> @param [OUT] file Character(len=2)
!> \verbatim
!> MaxEnt Channel. Relevant for timedisplaced correlation.
!> \endverbatim
!-------------------------------------------------------------------
Implicit none
Character (len=*), intent(in) :: filename
Character (len=*), intent(in) :: name
Real (Kind=Kind(0.d0)), allocatable, intent(out) :: sgn(:)
Complex (Kind=Kind(0.d0)), pointer , intent(out) :: Bins(:,:,:,:,:)
Complex (Kind=Kind(0.d0)), pointer , intent(out) :: Bins0(:,:)
Type (Lattice) , intent(out) :: Latt
Type (Unit_cell) , intent(out) :: Latt_unit
Real (Kind=Kind(0.d0)) , intent(out) :: dtau
Character (len=2) , intent(out) :: Channel
Integer :: Nbins, Norb
Character (len=64) :: obs_dsetname, bak_dsetname, sgn_dsetname, par_dsetname, attr_name
INTEGER :: ierr, rank, Nunit, Ntau, Ndim, no
INTEGER(HSIZE_T), allocatable :: dims(:), maxdims(:)
INTEGER(HID_T) :: file_id, dset_id, grp_id, dataspace
TYPE(C_PTR) :: dat_ptr
Real (Kind=Kind(0.d0)) :: a1_p(2), a2_p(2), L1_p(2), L2_p(2)
write(obs_dsetname,'(2A)') trim(name), "/obser"
write(bak_dsetname,'(2A)') trim(name), "/back"
write(sgn_dsetname,'(2A)') trim(name), "/sign"
!Initialize HDF5
CALL h5open_f(ierr)
!Open HDF5 file
CALL h5fopen_f (filename, H5F_ACC_RDONLY_F, file_id, ierr)
!Open the dataset.
CALL h5dopen_f(file_id, obs_dsetname, dset_id, ierr)
!Get dataset's dataspace handle.
CALL h5dget_space_f(dset_id, dataspace, ierr)
!Get dataspace's rank.
CALL h5sget_simple_extent_ndims_f(dataspace, rank, ierr)
allocate( dims(rank), maxdims(rank) )
!Get dataspace's dimensions.
CALL h5sget_simple_extent_dims_f(dataspace, dims, maxdims, ierr)
if ( rank == 5 ) then
Nunit = int( dims(2) )
Ntau = 1
Norb = int( dims(3) )
Nbins = int( dims(5) )
else
Nunit = int( dims(2) )
Ntau = int( dims(3) )
Norb = int( dims(4) )
Nbins = int( dims(6) )
endif
deallocate( dims )
CALL h5gopen_f(file_id, name, grp_id, ierr)
call read_attribute(grp_id, '.', "dtau", dtau, ierr)
call read_attribute(grp_id, '.', "Channel", Channel, ierr)
call h5gclose_f(grp_id, ierr)
par_dsetname = "lattice"
write(par_dsetname, '(A, "/lattice")') trim(name)
CALL h5gopen_f(file_id, par_dsetname, grp_id, ierr)
call h5ltget_attribute_double_f(grp_id, '.', "a1", a1_p , ierr)
call h5ltget_attribute_double_f(grp_id, '.', "a2", a2_p , ierr)
call h5ltget_attribute_double_f(grp_id, '.', "L1", L1_p , ierr)
call h5ltget_attribute_double_f(grp_id, '.', "L2", L2_p , ierr)
Call Make_Lattice( L1_p, L2_p, a1_p, a2_p, Latt )
attr_name = "N_coord"
call read_attribute(grp_id, '.', attr_name, Latt_unit%Norb, ierr)
attr_name = "Norb"
call read_attribute(grp_id, '.', attr_name, Latt_unit%N_coord, ierr)
attr_name = "Ndim"
call read_attribute(grp_id, '.', attr_name, Ndim, ierr)
allocate(Latt_unit%Orb_pos_p(Latt_unit%Norb, Ndim))
do no = 1, Latt_unit%Norb
write(attr_name, '("Orbital", I0)') no
call h5ltget_attribute_double_f(grp_id, '.', attr_name, Latt_unit%Orb_pos_p(no,:), ierr )
enddo
Allocate ( Bins(Nunit,Ntau,Norb,Norb,Nbins), Bins0(Norb,Nbins), sgn(Nbins) )
dat_ptr = C_LOC(Bins(1,1,1,1,1))
CALL h5dopen_f(file_id, obs_dsetname, dset_id, ierr)
CALL h5dget_space_f(dset_id, dataspace, ierr)
CALL H5dread_f(dset_id, H5T_NATIVE_DOUBLE, dat_ptr, ierr, &
mem_space_id = dataspace, file_space_id = dataspace)
call h5dclose_f(dset_id, ierr)
dat_ptr = C_LOC(Bins0(1,1))
CALL h5dopen_f(file_id, bak_dsetname, dset_id, ierr)
CALL h5dget_space_f(dset_id, dataspace, ierr)
CALL H5dread_f(dset_id, H5T_NATIVE_DOUBLE, dat_ptr, ierr, &
mem_space_id = dataspace, file_space_id = dataspace)
call h5dclose_f(dset_id, ierr)
allocate( dims(1) )
dims(1) = Nbins
CALL h5dopen_f(file_id, sgn_dsetname, dset_id, ierr)
CALL H5dread_f(dset_id, H5T_NATIVE_DOUBLE, sgn, dims, ierr)
call h5dclose_f(dset_id, ierr)
deallocate( dims )
call h5fclose_f(file_id, ierr)
End Subroutine read_latt_hdf5
#endif
!==============================================================================
Subroutine jack(func, data, N_skip, N_rebin, best, err)
......@@ -426,7 +676,7 @@
!==============================================================================
subroutine Cov_tau(file)
subroutine Cov_tau(name_obs, filename_h5)
!--------------------------------------------------------------------
!> @author
!> ALF-project
......@@ -434,35 +684,42 @@
!> @brief
!> Analysis of imaginary time displaced correlation functions.
!>
!> @param [IN] file Character(len=64)
!> @param [IN] name_obs Character(len=64)
!> \verbatim
!> Name of file that gets read in
!> \endverbatim
!> @param [IN] PartHole logical
!> \verbatimam
!> If true, it is assumed that observable is symmetric in imaginary time around tau = beta/2
!> @param [IN] filename_h5 Character(len=64), optional
!> \verbatim
!> Name of file that gets read in
!> \endverbatim
!
!--------------------------------------------------------------------
Implicit none
Character (len=64), intent(in) :: file
Character (len=*), intent(in) :: name_obs
Character (len=*), intent(in), optional :: filename_h5
Character (len=64) :: name_obs
Character (len=64) :: name_obs2
Real (Kind=Kind(0.d0)), allocatable :: sgn(:)
Complex (Kind=Kind(0.d0)), pointer :: Bins_raw(:,:,:,:,:), Bins0_raw(:,:)
Type (Lattice) :: Latt
Type (Unit_cell) :: Latt_unit
real (Kind=Kind(0.d0)) :: dtau
real (Kind=Kind(0.d0)):: dtau
Character (len=2) :: Channel
Integer :: i
i = len(trim(file)) - 4
name_obs = file(:i)
i = len(trim(name_obs)) - 4
name_obs2 = name_obs(:i)
call read_latt(file, sgn, bins_raw, bins0_raw, Latt, Latt_unit, dtau, Channel)
call ana_tau(name_obs, sgn, bins_raw, bins0_raw, Latt, Latt_unit, dtau, Channel)
if( present(filename_h5) ) then
#ifdef HDF5