Skip to content

Commit

Permalink
Refactor MPI file handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederick Stein authored and fstein93 committed Dec 14, 2022
1 parent eb42053 commit 09b7866
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 116 deletions.
18 changes: 11 additions & 7 deletions src/input/cp_output_handling.F
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ MODULE cp_output_handling
USE message_passing, ONLY: mp_file_close,&
mp_file_delete,&
mp_file_get_amode,&
mp_file_open
mp_file_open,&
mp_file_type
USE string_utilities, ONLY: compress,&
s2a
#include "../base/base_uses.f90"
Expand Down Expand Up @@ -821,13 +822,14 @@ FUNCTION cp_print_key_unit_nr(logger, basis_section, print_key_path, extension,
CHARACTER(len=default_string_length) :: my_file_action, my_file_form, &
my_file_position, my_file_status, &
outPath
INTEGER :: c_i_level, f_backup_level, i, iounit, &
mpi_amode, my_backup_level, my_nbak, &
nbak, s_backup_level, unit_nr
INTEGER :: c_i_level, f_backup_level, i, mpi_amode, &
my_backup_level, my_nbak, nbak, &
s_backup_level, unit_nr
LOGICAL :: do_log, found, my_do_backup, my_local, &
my_mpi_io, my_on_file, &
my_should_output, replace
TYPE(cp_iteration_info_type), POINTER :: iteration_info
TYPE(mp_file_type) :: mp_unit
TYPE(section_vals_type), POINTER :: print_key

my_local = .FALSE.
Expand Down Expand Up @@ -968,9 +970,9 @@ FUNCTION cp_print_key_unit_nr(logger, basis_section, print_key_path, extension,
ELSE
IF (replace) CALL mp_file_delete(filename)
CALL mp_file_open(groupid=logger%para_env%group, &
fh=iounit, filepath=filename, amode_status=mpi_amode)
fh=mp_unit, filepath=filename, amode_status=mpi_amode)
IF (PRESENT(fout)) fout = filename
res = iounit
res = mp_unit%get_handle()
END IF
IF (do_log) THEN
unit_nr = cp_logger_get_unit_nr(logger, local=my_local)
Expand Down Expand Up @@ -1020,6 +1022,7 @@ SUBROUTINE cp_print_key_finished_output(unit_nr, logger, basis_section, &
CHARACTER(len=default_string_length) :: outPath
LOGICAL :: my_local, my_mpi_io, my_on_file, &
my_should_output
TYPE(mp_file_type) :: mp_unit
TYPE(section_vals_type), POINTER :: print_key

my_local = .FALSE.
Expand All @@ -1044,7 +1047,8 @@ SUBROUTINE cp_print_key_finished_output(unit_nr, logger, basis_section, &
IF (.NOT. my_mpi_io) THEN
CALL close_file(unit_nr, "KEEP")
ELSE
CALL mp_file_close(unit_nr)
CALL mp_unit%set_handle(unit_nr)
CALL mp_file_close(mp_unit)
END IF
unit_nr = -1
ELSE
Expand Down

0 comments on commit 09b7866

Please sign in to comment.