Skip to content

Commit

Permalink
Initialize member variables of derived types (#806)
Browse files Browse the repository at this point in the history
* Initialize member variables of derived types
  • Loading branch information
fstein93 authored Jun 18, 2024
1 parent caf8a08 commit 34cde8d
Show file tree
Hide file tree
Showing 32 changed files with 278 additions and 274 deletions.
12 changes: 6 additions & 6 deletions src/block/dbcsr_block_access.F
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ MODULE dbcsr_block_access
LOGICAL, PARAMETER, PRIVATE :: detailed_timing = .FALSE.

TYPE block_parameters
LOGICAL :: tr
INTEGER :: logical_rows, logical_cols
INTEGER :: offset, nze
LOGICAL :: tr = .FALSE.
INTEGER :: logical_rows = -1, logical_cols = -1
INTEGER :: offset = -1, nze = -1
END TYPE block_parameters

TYPE dgemm_join
INTEGER :: p_a, p_b, p_c
INTEGER :: last_k, last_n
TYPE(dbcsr_scalar_type) :: alpha, beta
INTEGER :: p_a = -1, p_b = -1, p_c = -1
INTEGER :: last_k = -1, last_n = -1
TYPE(dbcsr_scalar_type) :: alpha = dbcsr_scalar_type(), beta = dbcsr_scalar_type()
END TYPE dgemm_join

CONTAINS
Expand Down
12 changes: 6 additions & 6 deletions src/block/dbcsr_iterator_operations.F
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ MODULE dbcsr_iterator_operations
LOGICAL, PARAMETER, PRIVATE :: detailed_timing = .FALSE.

TYPE block_parameters
LOGICAL :: tr
INTEGER :: logical_rows, logical_cols
INTEGER :: offset, nze
LOGICAL :: tr = .FALSE.
INTEGER :: logical_rows = -1, logical_cols = -1
INTEGER :: offset = -1, nze = -1
END TYPE block_parameters

TYPE dgemm_join
INTEGER :: p_a, p_b, p_c
INTEGER :: last_k, last_n
TYPE(dbcsr_scalar_type) :: alpha, beta
INTEGER :: p_a = -1, p_b = -1, p_c = -1
INTEGER :: last_k = -1, last_n = -1
TYPE(dbcsr_scalar_type) :: alpha = dbcsr_scalar_type(), beta = dbcsr_scalar_type()
END TYPE dgemm_join

CONTAINS
Expand Down
10 changes: 5 additions & 5 deletions src/core/dbcsr_config.F
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ MODULE dbcsr_config

TYPE, ABSTRACT :: CONF_PAR
CHARACTER :: source = 'D' ! Possible values are: D=Default, E=Environment, U=User code
CHARACTER(len=max_paramter_name_len) :: name
CHARACTER(len=max_paramter_name_len) :: name = ""

CONTAINS

Expand All @@ -109,7 +109,7 @@ MODULE dbcsr_config
END TYPE CONF_PAR

TYPE, EXTENDS(CONF_PAR) :: CONF_PAR_INT
INTEGER :: val, defval
INTEGER :: val = -1, defval = -1
LOGICAL :: ensure_positive = .TRUE.

CONTAINS
Expand All @@ -119,7 +119,7 @@ MODULE dbcsr_config
END TYPE CONF_PAR_INT

TYPE, EXTENDS(CONF_PAR) :: CONF_PAR_MM_DRIVER
INTEGER :: val, defval
INTEGER :: val = -1, defval = -1

CONTAINS

Expand All @@ -128,7 +128,7 @@ MODULE dbcsr_config
END TYPE CONF_PAR_MM_DRIVER

TYPE, EXTENDS(CONF_PAR) :: CONF_PAR_LOGICAL
LOGICAL :: val, defval
LOGICAL :: val = .FALSE., defval = .FALSE.

CONTAINS

Expand All @@ -137,7 +137,7 @@ MODULE dbcsr_config
END TYPE CONF_PAR_LOGICAL

TYPE, EXTENDS(CONF_PAR) :: CONF_PAR_REAL
REAL(KIND=real_8) :: val, defval
REAL(KIND=real_8) :: val = -1, defval = -1

CONTAINS

Expand Down
14 changes: 7 additions & 7 deletions src/core/dbcsr_dict.F
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ MODULE dbcsr_dict
PUBLIC :: dict_${keytype}$_${valuetype}$_item_type
#:endfor

#:for keytype, valuetype, keytype_fort, valuetype_fort, key_assign, value_assign, isequal in inst_params
#:for keytype, valuetype, keytype_fort, valuetype_fort, key_assign, value_assign, isequal, default_key, default_value in inst_params
!this is an internal type
!Calculating hashes might be expensive, therefore they are stored
!for use during change_capacity().
TYPE private_item_type_${keytype}$_${valuetype}$
PRIVATE
${keytype_fort}$ :: key
${valuetype_fort}$ :: value
INTEGER(KIND=int_8) :: hash
${keytype_fort}$ :: key ${key_assign}$${default_key}$
${valuetype_fort}$ :: value ${value_assign}$${default_value}$
INTEGER(KIND=int_8) :: hash = -1_int_8
TYPE(private_item_type_${keytype}$_${valuetype}$), POINTER :: next => Null()
END TYPE private_item_type_${keytype}$_${valuetype}$

Expand All @@ -58,8 +58,8 @@ MODULE dbcsr_dict

! this is a public type, its returned by dict_items()
TYPE dict_${keytype}$_${valuetype}$_item_type
${keytype_fort}$ :: key
${valuetype_fort}$ :: value
${keytype_fort}$ :: key ${key_assign}$${default_key}$
${valuetype_fort}$ :: value ${value_assign}$${default_value}$
END TYPE dict_${keytype}$_${valuetype}$_item_type
#:endfor

Expand Down Expand Up @@ -111,7 +111,7 @@ MODULE dbcsr_dict
$:fct
#:endfor

#:for keytype, valuetype, keytype_fort, valuetype_fort, key_assign, value_assign, isequal in inst_params
#:for keytype, valuetype, keytype_fort, valuetype_fort, key_assign, value_assign, isequal, default_key, default_value in inst_params
SUBROUTINE dict_${keytype}$_${valuetype}$_init(dict, initial_capacity)
!! Allocates the internal data-structures of the given dictionary.

Expand Down
4 changes: 3 additions & 1 deletion src/core/dbcsr_dict.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#:set valuetype_fort = ['INTEGER(kind=int_4)', 'TYPE(call_stat_type), POINTER']
#:set key_assign = ['=', '=']
#:set value_assign = ['=', '=>']
#:set default_key = ['""', '-1_int_4']
#:set default_value = ['-1_int_4', 'NULL()']

#:def isequal_str(k1, k2)
${k1}$ == ${k2}$
Expand Down Expand Up @@ -68,7 +70,7 @@ END FUNCTION hash_i4tuple
#:set usetimings = ['call_stat_type']


#:set inst_params = list(zip(keytype, valuetype, keytype_fort, valuetype_fort, key_assign, value_assign, isequal))
#:set inst_params = list(zip(keytype, valuetype, keytype_fort, valuetype_fort, key_assign, value_assign, isequal, default_key, default_value))

#:def uselist(list_in)
#! comma-separated list of unique entries of list_in
Expand Down
12 changes: 6 additions & 6 deletions src/core/dbcsr_iter_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ MODULE dbcsr_iter_types
!! contains the information about the current state of the program
!! to be able to decide if output is necessary

INTEGER :: ref_count, id_nr
INTEGER :: print_level, n_rlevel
INTEGER, DIMENSION(:), POINTER :: iteration
LOGICAL, DIMENSION(:), POINTER :: last_iter
CHARACTER(len=default_string_length) :: project_name
INTEGER :: ref_count = -1, id_nr = -1
INTEGER :: print_level = -1, n_rlevel = -1
INTEGER, DIMENSION(:), POINTER :: iteration => NULL()
LOGICAL, DIMENSION(:), POINTER :: last_iter => NULL()
CHARACTER(len=default_string_length) :: project_name = ""
CHARACTER(LEN=default_string_length), &
DIMENSION(:), POINTER :: level_name
DIMENSION(:), POINTER :: level_name => NULL()
END TYPE dbcsr_iteration_info_type

CONTAINS
Expand Down
18 changes: 9 additions & 9 deletions src/core/dbcsr_log_handling.F
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,30 @@ MODULE dbcsr_log_handling
!! are public.
!! DO NOT USE THE INTERNAL COMPONENTS DIRECTLY!!!

INTEGER :: id_nr, ref_count
INTEGER :: id_nr = -1, ref_count = -1
!! unique number to identify the logger
!! reference count (see cp2k/doc/ReferenceCounting.html)
INTEGER :: print_level
INTEGER :: print_level = -1
!! the level starting at which something gets printed
INTEGER :: default_local_unit_nr
INTEGER :: default_local_unit_nr = -1
!! default unit for local logging (-1 if not yet initialized). Local logging guarantee to each task its own file.
INTEGER :: default_global_unit_nr
INTEGER :: default_global_unit_nr = -1
!! default unit for global logging (-1 if not yet initialized). This unit is valid only on the processor with
!! %mp_env%mp%mynode==%mv_env%mp%source.
LOGICAL :: close_local_unit_on_dealloc, close_global_unit_on_dealloc
LOGICAL :: close_local_unit_on_dealloc = .FALSE., close_global_unit_on_dealloc = .FALSE.
!! if the local unit should be closed when this logger is deallocated
!! whether the global unit should be closed when this logger is deallocated
CHARACTER(len=default_string_length) :: suffix
CHARACTER(len=default_string_length) :: suffix = ""
!! a short string that is used as suffix in all the filenames created by this logger. Can be used to guarantee the
!! uniqueness of generated filename
CHARACTER(len=default_path_length) :: local_filename, global_filename
CHARACTER(len=default_path_length) :: local_filename = "", global_filename = ""
!! the root of the name of the file used for local logging (can be different from the name of the file corresponding to
!! default_local_unit_nr, only the one used if the unit needs to be opened)
!! the root of the name of the file used for global logging (can be different from the name of the file corresponding to
!! default_global_unit_nr, only the one used if the unit needs to be opened)
TYPE(dbcsr_mp_obj) :: mp_env
TYPE(dbcsr_mp_obj) :: mp_env = dbcsr_mp_obj()
!! the parallel environment for the output.
TYPE(dbcsr_iteration_info_type), POINTER :: iter_info
TYPE(dbcsr_iteration_info_type), POINTER :: iter_info => NULL()
END TYPE dbcsr_logger_type

TYPE dbcsr_logger_p_type
Expand Down
34 changes: 17 additions & 17 deletions src/core/dbcsr_timings_base_type.F
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@ MODULE dbcsr_timings_base_type
PRIVATE

TYPE routine_stat_type
INTEGER :: routine_id
CHARACTER(len=default_string_length) :: routineN
REAL(kind=dp) :: excl_walltime_accu
REAL(kind=dp) :: incl_walltime_accu
REAL(kind=dp) :: excl_energy_accu
REAL(kind=dp) :: incl_energy_accu
INTEGER :: active_calls
INTEGER :: total_calls
INTEGER :: stackdepth_accu
LOGICAL :: trace
INTEGER :: routine_id = -1
CHARACTER(len=default_string_length) :: routineN = ""
REAL(kind=dp) :: excl_walltime_accu = -1.0_dp
REAL(kind=dp) :: incl_walltime_accu = -1.0_dp
REAL(kind=dp) :: excl_energy_accu = -1.0_dp
REAL(kind=dp) :: incl_energy_accu = -1.0_dp
INTEGER :: active_calls = -1
INTEGER :: total_calls = -1
INTEGER :: stackdepth_accu = -1
LOGICAL :: trace = .FALSE.
END TYPE routine_stat_type

TYPE call_stat_type
INTEGER :: total_calls
REAL(kind=dp) :: incl_walltime_accu
REAL(kind=dp) :: incl_energy_accu
INTEGER :: total_calls = -1
REAL(kind=dp) :: incl_walltime_accu = -1.0_dp
REAL(kind=dp) :: incl_energy_accu = -1.0_dp
END TYPE call_stat_type

TYPE callstack_entry_type
INTEGER :: routine_id
REAL(kind=dp) :: walltime_start
REAL(kind=dp) :: energy_start
INTEGER :: routine_id = -1
REAL(kind=dp) :: walltime_start = -1.0_dp
REAL(kind=dp) :: energy_start = -1.0_dp
END TYPE callstack_entry_type

TYPE routine_report_type
CHARACTER(LEN=default_string_length) :: routineN
CHARACTER(LEN=default_string_length) :: routineN = ""
REAL(KIND=dp) :: max_icost = 0.0_dp
REAL(KIND=dp) :: sum_icost = 0.0_dp
REAL(KIND=dp) :: max_ecost = 0.0_dp
Expand Down
18 changes: 9 additions & 9 deletions src/core/dbcsr_timings_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ MODULE dbcsr_timings_types
PRIVATE

TYPE timer_env_type
INTEGER :: ref_count
TYPE(dict_str_i4_type) :: routine_names
TYPE(list_routinestat_type) :: routine_stats
TYPE(list_callstackentry_type) :: callstack
TYPE(dict_i4tuple_callstat_type) :: callgraph
INTEGER :: trace_max
INTEGER :: trace_unit
CHARACTER(len=13) :: trace_str
LOGICAL :: trace_all
INTEGER :: ref_count = -1
TYPE(dict_str_i4_type) :: routine_names = dict_str_i4_type()
TYPE(list_routinestat_type) :: routine_stats = list_routinestat_type()
TYPE(list_callstackentry_type) :: callstack = list_callstackentry_type()
TYPE(dict_i4tuple_callstat_type) :: callgraph = dict_i4tuple_callstat_type()
INTEGER :: trace_max = -1
INTEGER :: trace_unit = -1
CHARACTER(len=13) :: trace_str = ""
LOGICAL :: trace_all = .FALSE.
END TYPE timer_env_type

PUBLIC :: timer_env_type
Expand Down
Loading

0 comments on commit 34cde8d

Please sign in to comment.