From 77ca9b614b9ca4c6c59284fc06fa588be51aa789 Mon Sep 17 00:00:00 2001 From: Alexander Hampel Date: Thu, 23 Mar 2023 17:40:13 -0400 Subject: [PATCH] fix: read_input_from_hdf error check was not working --- python/triqs_dft_tools/sumk_dft_tools.py | 53 ++++++++++++++---------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/python/triqs_dft_tools/sumk_dft_tools.py b/python/triqs_dft_tools/sumk_dft_tools.py index 13eb053c..ffc93993 100644 --- a/python/triqs_dft_tools/sumk_dft_tools.py +++ b/python/triqs_dft_tools/sumk_dft_tools.py @@ -341,10 +341,11 @@ class SumkDFTTools(SumkDFT): things_to_read = ['n_parproj', 'proj_mat_all', 'rot_mat_all', 'rot_mat_all_time_inv'] - value_read = self.read_input_from_hdf( + subgroup_present, values_not_read = self.read_input_from_hdf( subgrp=self.parproj_data, things_to_read=things_to_read) - if not value_read: - return value_read + if len(values_not_read) > 0 and mpi.is_master_node: + raise ValueError( + 'ERROR: One or more necessary SumK input properties have not been found in the given h5 archive:', self.values_not_read) if self.symm_op: self.symmpar = Symmetry(self.hdf_file, subgroup=self.symmpar_data) @@ -489,15 +490,17 @@ class SumkDFTTools(SumkDFT): if (pdos): things_to_read = ['maxlm', 'bc'] - value_read = self.read_input_from_hdf( - subgrp=self.bc_data, things_to_read=things_to_read) - if not value_read: - return value_read + subgroup_present, values_not_read = self.read_input_from_hdf( + subgrp=self.bc_data, things_to_read=things_to_read) + if len(values_not_read) > 0 and mpi.is_master_node: + raise ValueError( + 'ERROR: One or more necessary SumK input properties have not been found in the given h5 archive:', self.values_not_read) things_to_read = ['n_atoms'] - value_read = self.read_input_from_hdf( - subgrp=self.symmcorr_data, things_to_read=things_to_read) - if not value_read: - return value_read + subgroup_present, values_not_read = self.read_input_from_hdf( + subgrp=self.symmcorr_data, things_to_read=things_to_read) + if len(values_not_read) > 0 and mpi.is_master_node: + raise ValueError( + 'ERROR: One or more necessary SumK input properties have not been found in the given h5 archive:', self.values_not_read) if mesh is None or with_Sigma: assert isinstance(self.mesh, MeshReFreq), "mesh must be given if self.mesh is a MeshImFreq" @@ -658,10 +661,11 @@ class SumkDFTTools(SumkDFT): #read in the energy contour energies and projectors things_to_read = ['n_k','bmat','symlat','n_symm','vkl', 'n_orbitals', 'proj_mat', 'hopping'] - value_read = self.read_input_from_hdf( + subgroup_present, values_not_read = self.read_input_from_hdf( subgrp=self.fs_data, things_to_read=things_to_read) - if not value_read: - return value_read + if len(values_not_read) > 0 and mpi.is_master_node: + raise ValueError( + 'ERROR: One or more necessary SumK input properties have not been found in the given h5 archive:', self.values_not_read) if with_Sigma is True or mesh is None: assert isinstance(self.mesh, MeshReFreq), "SumkDFT.mesh must be real if with_Sigma is True or mesh is not given" @@ -827,16 +831,18 @@ class SumkDFTTools(SumkDFT): things_to_read = ['n_k', 'n_orbitals', 'proj_mat', 'hopping', 'n_parproj', 'proj_mat_all'] - value_read = self.read_input_from_hdf( + subgroup_present, values_not_read = self.read_input_from_hdf( subgrp=self.bands_data, things_to_read=things_to_read) - if not value_read: - return value_read + if len(values_not_read) > 0 and mpi.is_master_node: + raise ValueError( + 'ERROR: One or more necessary SumK input properties have not been found in the given h5 archive:', self.values_not_read) if ishell is not None: things_to_read = ['rot_mat_all', 'rot_mat_all_time_inv'] - value_read = self.read_input_from_hdf( + subgroup_present, values_not_read = self.read_input_from_hdf( subgrp=self.parproj_data, things_to_read=things_to_read) - if not value_read: - return value_read + if len(values_not_read) > 0 and mpi.is_master_node: + raise ValueError( + 'ERROR: One or more necessary SumK input properties have not been found in the given h5 archive:', self.values_not_read) if mu is None: mu = self.chemical_potential @@ -966,10 +972,11 @@ class SumkDFTTools(SumkDFT): things_to_read = ['dens_mat_below', 'n_parproj', 'proj_mat_all', 'rot_mat_all', 'rot_mat_all_time_inv'] - value_read = self.read_input_from_hdf( + subgroup_present, values_not_read = self.read_input_from_hdf( subgrp=self.parproj_data, things_to_read=things_to_read) - if not value_read: - return value_read + if len(values_not_read) > 0 and mpi.is_master_node: + raise ValueError( + 'ERROR: One or more necessary SumK input properties have not been found in the given h5 archive:', self.values_not_read) if self.symm_op: self.symmpar = Symmetry(self.hdf_file, subgroup=self.symmpar_data)