Skip to content

Commit

Permalink
Introduced CPVERSION_CHECK
Browse files Browse the repository at this point in the history
- Adjusted uses of plain CPVERSION accordingly.
  • Loading branch information
hfp committed Sep 26, 2024
1 parent 2a71da7 commit aba0d0d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/base/base_uses.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/cp_eri_mme_interface.F
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/dm_ls_scf_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion src/emd/rt_bse_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -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, &
Expand Down
2 changes: 1 addition & 1 deletion src/mp2_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -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(), &
Expand Down
2 changes: 1 addition & 1 deletion src/post_scf_bandstructure_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -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, &
Expand Down

0 comments on commit aba0d0d

Please sign in to comment.