Skip to content

Commit

Permalink
Conventions: Fix uninitialised variables and missing default initiali…
Browse files Browse the repository at this point in the history
…zers (cp2k#3480)

This PR:
- fixes uninitialised variables
- adds default initializers for most types
- adds an implicit interface to one module
- removes ~300 suppressions of the convention checker

Default initializers are still missing due if the respective type member variables of the libraries
- DBCSR
- SIRIUS
- PEXSI

For the record:
- Types derived from the abstract type eri_type_eri_element_func may be false positives as all their member variables have a default (the base type does not have any member variables)
- semi_empirical_int_debug could be reimplemented using submodules (requiring adjustments on the build system) due to dependencies between this file and semi_empirical_int_utils
  • Loading branch information
fstein93 authored Jun 17, 2024
1 parent fe90383 commit b7b4e7f
Show file tree
Hide file tree
Showing 126 changed files with 2,426 additions and 2,640 deletions.
2 changes: 1 addition & 1 deletion src/cp_eri_mme_interface.F
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ MODULE cp_eri_mme_interface
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)
TYPE(eri_mme_param) :: par
TYPE(eri_mme_param) :: par = eri_mme_param(minimax_grid=NULL())
#else
TYPE(eri_mme_param) :: par = eri_mme_param()
#endif
Expand Down
30 changes: 15 additions & 15 deletions src/ewald_environment_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,24 @@ MODULE ewald_environment_types
! **************************************************************************************************
TYPE ewald_environment_type
PRIVATE
LOGICAL :: do_multipoles ! Flag for using the multipole code
INTEGER :: do_ipol ! Solver for induced dipoles
INTEGER :: max_multipole ! max expansion in the multipoles
INTEGER :: max_ipol_iter ! max number of interaction for induced dipoles
INTEGER :: ewald_type ! type of ewald
INTEGER :: gmax(3) ! max Miller index
INTEGER :: ns_max ! # grid points for small grid (PME)
INTEGER :: o_spline ! order of spline (SPME)
REAL(KIND=dp) :: precs ! precision achieved when evaluating the real-space part
REAL(KIND=dp) :: alpha, rcut ! ewald alpha and real-space cutoff
REAL(KIND=dp) :: epsilon ! tolerance for small grid (PME)
REAL(KIND=dp) :: eps_pol ! tolerance for convergence of induced dipoles
TYPE(mp_para_env_type), POINTER :: para_env
TYPE(section_vals_type), POINTER :: poisson_section
LOGICAL :: do_multipoles = .FALSE. ! Flag for using the multipole code
INTEGER :: do_ipol = -1 ! Solver for induced dipoles
INTEGER :: max_multipole = -1 ! max expansion in the multipoles
INTEGER :: max_ipol_iter = -1 ! max number of interaction for induced dipoles
INTEGER :: ewald_type = -1 ! type of ewald
INTEGER :: gmax(3) = -1 ! max Miller index
INTEGER :: ns_max = -1 ! # grid points for small grid (PME)
INTEGER :: o_spline = -1 ! order of spline (SPME)
REAL(KIND=dp) :: precs = 0.0_dp ! precision achieved when evaluating the real-space part
REAL(KIND=dp) :: alpha = 0.0_dp, rcut = 0.0_dp ! ewald alpha and real-space cutoff
REAL(KIND=dp) :: epsilon = 0.0_dp ! tolerance for small grid (PME)
REAL(KIND=dp) :: eps_pol = 0.0_dp ! tolerance for convergence of induced dipoles
TYPE(mp_para_env_type), POINTER :: para_env => NULL()
TYPE(section_vals_type), POINTER :: poisson_section => NULL()
! interaction cutoff is required to make the electrostatic interaction
! continuous at a pair distance equal to rcut. this is ignored by the
! multipole code and is otherwise only active when SHIFT_CUTOFF is used.
REAL(KIND=dp), DIMENSION(:, :, :), POINTER :: interaction_cutoffs
REAL(KIND=dp), DIMENSION(:, :, :), POINTER :: interaction_cutoffs => NULL()
! store current cell, used to rebuild lazily.
REAL(KIND=dp), DIMENSION(3, 3) :: cell_hmat = -1.0_dp
END TYPE ewald_environment_type
Expand Down
16 changes: 7 additions & 9 deletions src/ewalds_multipole_sr.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@

#:def ewalds_multipole_sr_macro(mode, damping=False, store_energy=False, store_forces=False)
! Compute the Short Range constribution according the task
IF (debug_this_module) THEN
f = HUGE(0.0_dp)
tij = HUGE(0.0_dp)
tij_a = HUGE(0.0_dp)
tij_ab = HUGE(0.0_dp)
tij_abc = HUGE(0.0_dp)
tij_abcd = HUGE(0.0_dp)
tij_abcde = HUGE(0.0_dp)
END IF
f = HUGE(0.0_dp)
tij = HUGE(0.0_dp)
tij_a = HUGE(0.0_dp)
tij_ab = HUGE(0.0_dp)
tij_abc = HUGE(0.0_dp)
tij_abcd = HUGE(0.0_dp)
tij_abcde = HUGE(0.0_dp)
r = SQRT(rab2)
irab2 = 1.0_dp/rab2
ir = 1.0_dp/r
Expand Down
6 changes: 3 additions & 3 deletions src/exclusion_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ MODULE exclusion_types
!> 12.2010 created [Joost VandeVondele]
! **************************************************************************************************
TYPE exclusion_type
INTEGER, POINTER, DIMENSION(:) :: list_exclude_vdw
INTEGER, POINTER, DIMENSION(:) :: list_exclude_ei
INTEGER, POINTER, DIMENSION(:) :: list_onfo
INTEGER, POINTER, DIMENSION(:) :: list_exclude_vdw => NULL()
INTEGER, POINTER, DIMENSION(:) :: list_exclude_ei => NULL()
INTEGER, POINTER, DIMENSION(:) :: list_onfo => NULL()
END TYPE

PUBLIC :: exclusion_type, &
Expand Down
24 changes: 12 additions & 12 deletions src/exstates_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ MODULE exstates_types
! *****************************************************************************

TYPE wfn_history_type
INTEGER :: state
REAL(KIND=dp) :: evalue
INTEGER :: state = -1
REAL(KIND=dp) :: evalue = 0.0_dp
TYPE(cp_fm_type), POINTER, DIMENSION(:) :: evect => NULL()
TYPE(cp_fm_type), POINTER, DIMENSION(:) :: cpmos => NULL()
REAL(KIND=dp) :: xsval, gsval, gsmin
REAL(KIND=dp) :: xsval = 0.0_dp, gsval = 0.0_dp, gsmin = 0.0_dp
END TYPE wfn_history_type

! *****************************************************************************
Expand All @@ -52,11 +52,11 @@ MODULE exstates_types
!> \author JGH
! *****************************************************************************
TYPE excited_energy_type
INTEGER :: state
REAL(KIND=dp) :: evalue
INTEGER :: xc_kernel_method
INTEGER :: state = -1
REAL(KIND=dp) :: evalue = 0.0_dp
INTEGER :: xc_kernel_method = -1
REAL(KIND=dp) :: eps_delta_rho = 1.E-02_dp
INTEGER :: diff_order
INTEGER :: diff_order = -1
LOGICAL :: debug_forces = .FALSE.
TYPE(cp_fm_type), POINTER, DIMENSION(:) :: evect => NULL()
TYPE(cp_fm_type), POINTER, DIMENSION(:) :: cpmos => NULL()
Expand All @@ -68,13 +68,13 @@ MODULE exstates_types
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_px1_asymm => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_px1_admm_asymm => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_wx1 => NULL()
TYPE(pw_r3d_rs_type) :: vh_rspace
TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: vxc_rspace => NULL()
TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: vtau_rspace => NULL()
TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: vadmm_rspace => NULL()
TYPE(pw_r3d_rs_type) :: vh_rspace = pw_r3d_rs_type()
TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: vxc_rspace => NULL()
TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: vtau_rspace => NULL()
TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: vadmm_rspace => NULL()
TYPE(local_rho_type), POINTER :: local_rho_set => NULL()
TYPE(local_rho_type), POINTER :: local_rho_set_admm => NULL()
TYPE(wfn_history_type) :: wfn_history
TYPE(wfn_history_type) :: wfn_history = wfn_history_type()
END TYPE excited_energy_type

CONTAINS
Expand Down
44 changes: 22 additions & 22 deletions src/farming_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@ MODULE farming_types

! **************************************************************************************************
TYPE job_type
CHARACTER(LEN=default_path_length) :: cwd ! the directory to go to
CHARACTER(LEN=default_path_length) :: input ! the input file to use
CHARACTER(LEN=default_path_length) :: output ! the output file to use
INTEGER :: ID ! the ID of this job
INTEGER, POINTER, DIMENSION(:) :: dependencies ! the dependencies of this job
INTEGER :: status ! pending,running,finished
CHARACTER(LEN=default_path_length) :: cwd = "" ! the directory to go to
CHARACTER(LEN=default_path_length) :: input = "" ! the input file to use
CHARACTER(LEN=default_path_length) :: output = "" ! the output file to use
INTEGER :: ID = -1 ! the ID of this job
INTEGER, POINTER, DIMENSION(:) :: dependencies => NULL() ! the dependencies of this job
INTEGER :: status = -1 ! pending,running,finished
END TYPE job_type

! **************************************************************************************************
TYPE farming_env_type
INTEGER :: group_size_wish
LOGICAL :: group_size_wish_set
INTEGER :: ngroup_wish
LOGICAL :: ngroup_wish_set
LOGICAL :: restart
LOGICAL :: CYCLE
LOGICAL :: captain_minion
INTEGER, DIMENSION(:), POINTER :: group_partition ! user preference for partitioning the cpus
CHARACTER(LEN=default_path_length) :: restart_file_name ! restart file for farming
CHARACTER(LEN=default_path_length) :: cwd ! directory we started from
INTEGER :: Njobs ! how many jobs to run
INTEGER :: restart_n ! where to start
INTEGER :: max_steps ! max number of steps,
INTEGER :: group_size_wish = -1
LOGICAL :: group_size_wish_set = .FALSE.
INTEGER :: ngroup_wish = -1
LOGICAL :: ngroup_wish_set = .FALSE.
LOGICAL :: restart = .FALSE.
LOGICAL :: CYCLE = .FALSE.
LOGICAL :: captain_minion = .FALSE.
INTEGER, DIMENSION(:), POINTER :: group_partition => NULL() ! user preference for partitioning the cpus
CHARACTER(LEN=default_path_length) :: restart_file_name = "" ! restart file for farming
CHARACTER(LEN=default_path_length) :: cwd = "" ! directory we started from
INTEGER :: Njobs = -1 ! how many jobs to run
INTEGER :: restart_n = -1 ! where to start
INTEGER :: max_steps = -1 ! max number of steps,
! results in max_steps*Ngroup jobs being run
INTEGER :: stride ! for creating minion groups.
TYPE(job_type), DIMENSION(:), POINTER :: job ! a list of jobs
REAL(KIND=dp) :: wait_time
INTEGER :: stride = -1 ! for creating minion groups.
TYPE(job_type), DIMENSION(:), POINTER :: job => NULL() ! a list of jobs
REAL(KIND=dp) :: wait_time = 0.0_dp
END TYPE farming_env_type

CONTAINS
Expand Down
6 changes: 3 additions & 3 deletions src/fist_efield_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ MODULE fist_efield_types
TYPE fist_efield_type
LOGICAL :: apply_field = .FALSE.
LOGICAL :: displacement = .FALSE.
REAL(KIND=dp) :: strength
REAL(KIND=dp), DIMENSION(3) :: polarisation
REAL(KIND=dp), DIMENSION(3) :: dfilter
REAL(KIND=dp) :: strength = 0.0_dp
REAL(KIND=dp), DIMENSION(3) :: polarisation = 0.0_dp
REAL(KIND=dp), DIMENSION(3) :: dfilter = 0.0_dp
END TYPE fist_efield_type
! **************************************************************************************************

Expand Down
5 changes: 3 additions & 2 deletions src/fist_energy_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ MODULE fist_energy_types

! **************************************************************************************************
TYPE fist_energy_type
REAL(kind=dp) :: kin, pot, e_gspace, e_self, e_neut, e_bonded, e_induction
REAL(kind=dp) :: kin_shell, harm_shell
REAL(kind=dp) :: kin = 0.0_dp, pot = 0.0_dp, e_gspace = 0.0_dp, e_self = 0.0_dp, &
e_neut = 0.0_dp, e_bonded = 0.0_dp, e_induction = 0.0_dp
REAL(kind=dp) :: kin_shell = 0.0_dp, harm_shell = 0.0_dp
END TYPE fist_energy_type

! *** Public data types ***
Expand Down
26 changes: 13 additions & 13 deletions src/fist_environment_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ MODULE fist_environment_types
! **************************************************************************************************
TYPE fist_environment_type
PRIVATE
LOGICAL :: qmmm
LOGICAL :: shell_model, shell_model_ad
TYPE(qmmm_env_mm_type), POINTER :: qmmm_env
TYPE(cell_type), POINTER :: cell_ref
TYPE(ewald_environment_type), POINTER :: ewald_env
TYPE(ewald_pw_type), POINTER :: ewald_pw
TYPE(fist_energy_type), POINTER :: thermo
TYPE(mp_para_env_type), POINTER :: para_env
TYPE(cp_subsys_type), POINTER :: subsys
TYPE(fist_nonbond_env_type), POINTER :: fist_nonbond_env
TYPE(section_vals_type), POINTER :: input
TYPE(exclusion_type), DIMENSION(:), POINTER :: exclusions
TYPE(fist_efield_type), POINTER :: efield
LOGICAL :: qmmm = .FALSE.
LOGICAL :: shell_model = .FALSE., shell_model_ad = .FALSE.
TYPE(qmmm_env_mm_type), POINTER :: qmmm_env => NULL()
TYPE(cell_type), POINTER :: cell_ref => NULL()
TYPE(ewald_environment_type), POINTER :: ewald_env => NULL()
TYPE(ewald_pw_type), POINTER :: ewald_pw => NULL()
TYPE(fist_energy_type), POINTER :: thermo => NULL()
TYPE(mp_para_env_type), POINTER :: para_env => NULL()
TYPE(cp_subsys_type), POINTER :: subsys => NULL()
TYPE(fist_nonbond_env_type), POINTER :: fist_nonbond_env => NULL()
TYPE(section_vals_type), POINTER :: input => NULL()
TYPE(exclusion_type), DIMENSION(:), POINTER :: exclusions => NULL()
TYPE(fist_efield_type), POINTER :: efield => NULL()
END TYPE fist_environment_type

! *** Public data types ***
Expand Down
20 changes: 10 additions & 10 deletions src/fist_force.F
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ MODULE fist_force
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'fist_force'

TYPE debug_variables_type
REAL(KIND=dp) :: pot_manybody, pot_bend, pot_torsion
REAL(KIND=dp) :: pot_nonbond, pot_g, pot_bond
REAL(KIND=dp) :: pot_imptors, pot_urey_bradley
REAL(KIND=dp) :: pot_opbend
REAL(KIND=dp), DIMENSION(:, :), POINTER :: f_nonbond, f_g, f_bond, f_bend, &
f_torsion, f_imptors, f_ub, &
f_opbend
REAL(KIND=dp), DIMENSION(3, 3) :: pv_nonbond, pv_g, pv_bond, pv_ub, &
pv_bend, pv_torsion, pv_imptors, &
pv_opbend
REAL(KIND=dp) :: pot_manybody = 0.0_dp, pot_bend = 0.0_dp, pot_torsion = 0.0_dp
REAL(KIND=dp) :: pot_nonbond = 0.0_dp, pot_g = 0.0_dp, pot_bond = 0.0_dp
REAL(KIND=dp) :: pot_imptors = 0.0_dp, pot_urey_bradley = 0.0_dp
REAL(KIND=dp) :: pot_opbend = 0.0_dp
REAL(KIND=dp), DIMENSION(:, :), POINTER :: f_nonbond => NULL(), f_g => NULL(), f_bond => NULL(), f_bend => NULL(), &
f_torsion => NULL(), f_imptors => NULL(), f_ub => NULL(), &
f_opbend => NULL()
REAL(KIND=dp), DIMENSION(3, 3) :: pv_nonbond = 0.0_dp, pv_g = 0.0_dp, pv_bond = 0.0_dp, pv_ub = 0.0_dp, &
pv_bend = 0.0_dp, pv_torsion = 0.0_dp, pv_imptors = 0.0_dp, &
pv_opbend = 0.0_dp
END TYPE debug_variables_type

CONTAINS
Expand Down
24 changes: 12 additions & 12 deletions src/fist_neighbor_list_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ MODULE fist_neighbor_list_types

! **************************************************************************************************
TYPE neighbor_kind_pairs_type
INTEGER, POINTER, DIMENSION(:, :) :: list, ij_kind
INTEGER, POINTER, DIMENSION(:) :: id_kind
INTEGER, POINTER, DIMENSION(:) :: grp_kind_start, grp_kind_end
INTEGER :: cell_vector(3), npairs
INTEGER :: ngrp_kind
REAL(KIND=dp) :: rmax
INTEGER, POINTER, DIMENSION(:, :) :: list => NULL(), ij_kind => NULL()
INTEGER, POINTER, DIMENSION(:) :: id_kind => NULL()
INTEGER, POINTER, DIMENSION(:) :: grp_kind_start => NULL(), grp_kind_end => NULL()
INTEGER :: cell_vector(3) = -1, npairs = -1
INTEGER :: ngrp_kind = -1
REAL(KIND=dp) :: rmax = 0.0_dp
! The *_scale arrays are scaling factors for the corresponding nonbonding
! interaction energies and forces for the pairs in 'list'. To keep the size
! of these arrays small, pairs whose interaction must be scaled are moved
Expand All @@ -38,16 +38,16 @@ MODULE fist_neighbor_list_types
! reallocate the *_scale arrays for every new scaled pair interaction.
! The field is_info is only used to switch between the regular nonbonded
! and the nonbonded14 splines for the van der waals interactions.
REAL(KIND=dp), POINTER, DIMENSION(:) :: ei_scale
REAL(KIND=dp), POINTER, DIMENSION(:) :: vdw_scale
LOGICAL, POINTER, DIMENSION(:) :: is_onfo
INTEGER :: nscale
REAL(KIND=dp), POINTER, DIMENSION(:) :: ei_scale => NULL()
REAL(KIND=dp), POINTER, DIMENSION(:) :: vdw_scale => NULL()
LOGICAL, POINTER, DIMENSION(:) :: is_onfo => NULL()
INTEGER :: nscale = -1
END TYPE neighbor_kind_pairs_type

! **************************************************************************************************
TYPE fist_neighbor_type
TYPE(neighbor_kind_pairs_type), DIMENSION(:), POINTER :: neighbor_kind_pairs
INTEGER :: nlists
TYPE(neighbor_kind_pairs_type), DIMENSION(:), POINTER :: neighbor_kind_pairs => NULL()
INTEGER :: nlists = -1
END TYPE fist_neighbor_type

PUBLIC :: neighbor_kind_pairs_type, &
Expand Down
4 changes: 2 additions & 2 deletions src/fist_neighbor_lists.F
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ MODULE fist_neighbor_lists
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'fist_neighbor_lists'

TYPE local_atoms_type
INTEGER, DIMENSION(:), POINTER :: list, &
list_local_a_index
INTEGER, DIMENSION(:), POINTER :: list => NULL(), &
list_local_a_index => NULL()
END TYPE local_atoms_type

! Public subroutines
Expand Down
Loading

0 comments on commit b7b4e7f

Please sign in to comment.