From aba0d0dc73dbdc6069b0464602be8f52541ea681 Mon Sep 17 00:00:00 2001 From: Hans Pabst Date: Thu, 26 Sep 2024 16:47:15 +0200 Subject: [PATCH] Introduced CPVERSION_CHECK - Adjusted uses of plain CPVERSION accordingly. --- src/base/base_uses.f90 | 12 ++++++++++++ src/cp_eri_mme_interface.F | 2 +- src/dm_ls_scf_types.F | 4 ++-- src/emd/rt_bse_types.F | 2 +- src/mp2_types.F | 2 +- src/post_scf_bandstructure_types.F | 2 +- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/base/base_uses.f90 b/src/base/base_uses.f90 index 4459734eb8..cfbc8d8bbc 100644 --- a/src/base/base_uses.f90 +++ b/src/base/base_uses.f90 @@ -53,6 +53,18 @@ #define CPVERSION3(MAJOR, MINOR, UPDATE) (CPVERSION2(MAJOR, MINOR) + (UPDATE)) #define CPVERSION CPVERSION2 +! Usage: CPVERSION_CHECK(9, 5, >, __GNUC__, __GNUC_MINOR__) +! On top of CPVERSION macro, test if MAJOR_TEST and MINOR_TEST are defined. +! Perform actual comparison according to COMP argument. +#define CPVERSION_CHECK(MAJOR_BASE, MINOR_BASE, COMP, MAJOR_TEST, MINOR_TEST) ( \ + (defined(MAJOR_TEST) && defined(MINOR_TEST)) && \ + (CPVERSION2(MAJOR_BASE, MINOR_BASE) COMP CPVERSION2(MAJOR_TEST, MINOR_TEST))) + +! Avoid to default initialize type-components (default c'tor) +#if CPVERSION_CHECK(9, 5, >, __GNUC__, __GNUC_MINOR__) || defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER) +#define FTN_NO_DEFAULT_INIT +#endif + ! gfortran before 8.3 complains about internal symbols not being specified in ! any data clause when using DEFAULT(NONE) and OOP procedures are called from ! within the parallel region. diff --git a/src/cp_eri_mme_interface.F b/src/cp_eri_mme_interface.F index 75d3eef956..cd13268f58 100644 --- a/src/cp_eri_mme_interface.F +++ b/src/cp_eri_mme_interface.F @@ -79,7 +79,7 @@ MODULE cp_eri_mme_interface TYPE cp_eri_mme_param TYPE(cp_logger_type), POINTER :: logger => NULL() ! There is a bug with some older compilers preventing a default initialization of derived types with allocatable components -#if __GNUC__ < 9 || (__GNUC__ == 9 && __GNUC_MINOR__ < 5) +#if defined(FTN_NO_DEFAULT_INIT) TYPE(eri_mme_param) :: par = eri_mme_param(minimax_grid=NULL()) #else TYPE(eri_mme_param) :: par = eri_mme_param() diff --git a/src/dm_ls_scf_types.F b/src/dm_ls_scf_types.F index c74dc87d85..40fd63f688 100644 --- a/src/dm_ls_scf_types.F +++ b/src/dm_ls_scf_types.F @@ -93,7 +93,7 @@ MODULE dm_ls_scf_types REAL(KIND=dp), DIMENSION(2) :: homo_spin = 0.0_dp REAL(KIND=dp), DIMENSION(2) :: lumo_spin = 0.0_dp -#if defined(__GNUC__) && defined(__GNUC_MINOR__) && (CPVERSION(9, 5) > CPVERSION(__GNUC__, __GNUC_MINOR__)) +#if defined(FTN_NO_DEFAULT_INIT) TYPE(ls_mat_history_type) :: scf_history = ls_mat_history_type(matrix=null()) #else TYPE(ls_mat_history_type) :: scf_history = ls_mat_history_type() @@ -138,7 +138,7 @@ MODULE dm_ls_scf_types LOGICAL :: report_all_sparsities = .FALSE., perform_mu_scan = .FALSE., use_s_sqrt = .FALSE. -#if defined(__GNUC__) && defined(__GNUC_MINOR__) && (CPVERSION(9, 5) > CPVERSION(__GNUC__, __GNUC_MINOR__)) +#if defined(FTN_NO_DEFAULT_INIT) TYPE(ls_mstruct_type) :: ls_mstruct = ls_mstruct_type(atom_to_molecule=NULL()) TYPE(ls_scf_curvy_type) :: curvy_data = ls_scf_curvy_type(matrix_dp=null(), matrix_p=null(), & matrix_psave=null(), matrix_bch=null()) diff --git a/src/emd/rt_bse_types.F b/src/emd/rt_bse_types.F index c03e90fec7..8e5d40947d 100644 --- a/src/emd/rt_bse_types.F +++ b/src/emd/rt_bse_types.F @@ -247,7 +247,7 @@ MODULE rt_bse_types ! Workspace required for hartree_pw TYPE(dbcsr_type) :: v_dbcsr = dbcsr_type(), & w_dbcsr = dbcsr_type() -#if defined(__GNUC__) && defined(__GNUC_MINOR__) && CPVERSION(9, 5) > CPVERSION(__GNUC__, __GNUC_MINOR__) +#if defined(FTN_NO_DEFAULT_INIT) TYPE(dbt_type) :: screened_dbt, & sigma_dbt, & greens_dbt, & diff --git a/src/mp2_types.F b/src/mp2_types.F index 66b0afaf54..1550ca1782 100644 --- a/src/mp2_types.F +++ b/src/mp2_types.F @@ -335,7 +335,7 @@ MODULE mp2_types TYPE(ri_mp2_type) :: ri_mp2 = ri_mp2_type() TYPE(ri_rpa_type) :: ri_rpa = ri_rpa_type() ! There is a bug with some older compilers preventing requiring an explicit initialization of allocatable components -#if __GNUC__ < 9 || (__GNUC__ == 9 && __GNUC_MINOR__ < 5) +#if defined(FTN_NO_DEFAULT_INIT) TYPE(ri_rpa_im_time_type) :: ri_rpa_im_time = ri_rpa_im_time_type(Eigenval_Gamma=NULL(), & wkp_V=NULL(), & starts_array_mc_RI=NULL(), & diff --git a/src/post_scf_bandstructure_types.F b/src/post_scf_bandstructure_types.F index bcd1435c05..9f3349a5a5 100644 --- a/src/post_scf_bandstructure_types.F +++ b/src/post_scf_bandstructure_types.F @@ -179,7 +179,7 @@ MODULE post_scf_bandstructure_types mat_RI_RI_tensor = dbcsr_p_type() ! tensors for sparse matrix-tensor operations -#if defined(__GNUC__) && defined(__GNUC_MINOR__) && CPVERSION(9, 5) > CPVERSION(__GNUC__, __GNUC_MINOR__) +#if defined(FTN_NO_DEFAULT_INIT) TYPE(dbt_type) :: t_G, & t_chi, & t_W, &