Skip to content

Commit

Permalink
Break IF, Fortran doesn't support shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
alazzaro committed Sep 10, 2021
1 parent cc47dde commit ca5cdc8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
40 changes: 22 additions & 18 deletions src/tmc/tmc_setup.F
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ SUBROUTINE do_tmc(input_declaration, root_section, para_env, globenv)

INTEGER :: bcast_output_unit, handle, i, ierr, &
output_unit
LOGICAL :: success
LOGICAL :: init_rng, success
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: init_rng_seed
TYPE(cp_logger_type), POINTER :: logger, logger_sub
TYPE(section_vals_type), POINTER :: tmc_ana_section
Expand Down Expand Up @@ -166,23 +166,27 @@ SUBROUTINE do_tmc(input_declaration, root_section, para_env, globenv)
!CALL init_move_types(tmc_params=tmc_env%params)

! init random number generator: use determistic random numbers
IF (tmc_env%tmc_comp_set%group_nr .EQ. 0 .AND. &
tmc_env%m_env%rnd_init .GT. 0) THEN
ALLOCATE (init_rng_seed(3, 2))
init_rng_seed(:, :) = &
RESHAPE((/tmc_env%m_env%rnd_init*42.0_dp, &
tmc_env%m_env%rnd_init*54.0_dp, &
tmc_env%m_env%rnd_init*63.0_dp, &
tmc_env%m_env%rnd_init*98.0_dp, &
tmc_env%m_env%rnd_init*10.0_dp, &
tmc_env%m_env%rnd_init*2.0_dp/), &
(/3, 2/))
tmc_env%rng_stream = rng_stream_type( &
name="TMC_deterministic_rng_stream", &
seed=init_rng_seed(:, :), &
distribution_type=UNIFORM)
DEALLOCATE (init_rng_seed)
ELSE
init_rng = .TRUE.
IF (tmc_env%tmc_comp_set%group_nr .EQ. 0) THEN
IF (tmc_env%m_env%rnd_init .GT. 0) THEN
init_rng = .FALSE.
ALLOCATE (init_rng_seed(3, 2))
init_rng_seed(:, :) = &
RESHAPE((/tmc_env%m_env%rnd_init*42.0_dp, &
tmc_env%m_env%rnd_init*54.0_dp, &
tmc_env%m_env%rnd_init*63.0_dp, &
tmc_env%m_env%rnd_init*98.0_dp, &
tmc_env%m_env%rnd_init*10.0_dp, &
tmc_env%m_env%rnd_init*2.0_dp/), &
(/3, 2/))
tmc_env%rng_stream = rng_stream_type( &
name="TMC_deterministic_rng_stream", &
seed=init_rng_seed(:, :), &
distribution_type=UNIFORM)
DEALLOCATE (init_rng_seed)
ENDIF
ENDIF
IF (init_rng) THEN
tmc_env%rng_stream = rng_stream_type( &
name="TMC_rng_stream", &
distribution_type=UNIFORM)
Expand Down
7 changes: 6 additions & 1 deletion tools/diff_cp2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import os
import imp


def read_file(filename, field, special_keys, stats_keys):
try:
nline = 0
Expand Down Expand Up @@ -129,6 +130,7 @@ def read_file(filename, field, special_keys, stats_keys):
print("Exit")
sys.exit(-1)


def print_value(ref, value, show_comp):
if ref > 0:
comp = (value - ref) / ref * 100
Expand All @@ -147,10 +149,12 @@ def print_value(ref, value, show_comp):
else:
sys.stdout.write(color + "%10.3f" % value + endc)


#################
# Main function #
#################


def main():
parser = argparse.ArgumentParser(description="Comparison of CP2K output timings.")
parser.add_argument("file_lists", nargs="+", help="list of files")
Expand Down Expand Up @@ -271,7 +275,7 @@ def main():
color = "\033[0m"
endc = "\033[0m"
for filename in args.file_lists:
if len(files[filename][1]) > 0 and ref !=0:
if len(files[filename][1]) > 0 and ref != 0:
comp = (float(files[filename][1]) - ref) / ref
if abs(comp) > 1e-14:
color = "\033[91m"
Expand Down Expand Up @@ -330,5 +334,6 @@ def main():

print("")


# ===============================================================================
main()

0 comments on commit ca5cdc8

Please sign in to comment.