59 integer,
parameter :: RESTART_N_DATA_TYPES = 15
61 integer,
parameter,
public :: &
62 RESTART_UNDEFINED = -1, &
82 character(len=20) :: tag
83 character(len=MAX_PATH_LEN) :: basedir
84 character(len=MAX_PATH_LEN) :: dir
89 integer,
parameter,
public :: &
90 RESTART_TYPE_DUMP = 1, &
94 integer,
parameter,
public :: &
95 RESTART_FLAG_STATES = 1, &
106 character(len=20) :: tag
107 character(len=MAX_PATH_LEN) :: dir
109 integer :: default_flags = 0
112 character(len=4),
parameter :: type_string(2) = (/
"DUMP",
"LOAD"/)
124 type(namespace_t),
pointer,
public :: namespace
125 integer :: data_type = restart_undefined
126 integer ::
type = restart_undefined
128 character(len=MAX_PATH_LEN) :: dir_
129 character(len=MAX_PATH_LEN) :: pwd
132 character(len=MAX_PATH_LEN),
public :: basedir
134 type(mpi_grp_t) ,
public :: mpi_grp
135 logical :: initialized = .false.
136 logical,
public :: grid_changed = .false.
140 procedure,
private :: restart_basic_init
141 generic :: init => restart_basic_init
164 integer(int64),
allocatable :: map(:)
166 integer,
public :: file_format_states
175 procedure,
private :: drestart_write_mesh_function, zrestart_write_mesh_function
176 generic :: write_mesh_function => drestart_write_mesh_function, zrestart_write_mesh_function
227 subroutine block_signals()
229 end subroutine block_signals
234 subroutine unblock_signals()
236 end subroutine unblock_signals
243 type(mpi_comm),
intent(in) :: comm
246 logical :: file_exists
253 inquire(file=
'stop', exist=file_exists)
254 if (file_exists)
then
262 call mpi_bcast(
clean_stop, 1, mpi_logical, 0, comm)
277 integer,
intent(in) :: data_type
278 integer,
intent(in) ::
type
280 integer,
intent(out) :: ierr
281 character(len=*),
optional,
intent(in) :: dir
284 character(len=MAX_PATH_LEN) :: basedir, dirname
285 integer :: iline, n_cols, idata_type, i
286 character(len=MAX_PATH_LEN) :: default_basedir
287 character(len=20) :: tag
289 logical :: restart_write, dir_exists
290 character(len=MAX_NAMESPACE_LEN) :: namespace_prefix
298 namespace_prefix = trim(namespace%get())
300 default_basedir = trim(
io_workdir())//
'/restart/'
301 restart%basedir = default_basedir
302 restart%skip_ = .false.
303 restart%data_type = data_type
304 if(data_type>0 .and. data_type<=restart_n_data_types)
then
305 restart%flags =
basic_info(data_type)%default_flags
310 if (data_type < restart_undefined .and. data_type > restart_n_data_types)
then
311 message(1) =
"Illegal data_type in restart_init"
314 restart%namespace => namespace
458 if (
parse_block(namespace,
'RestartOptions', blk) == 0)
then
465 if (idata_type < 0 .or. idata_type > restart_n_data_types)
then
466 call messages_input_error(namespace,
'RestartOptions',
"Invalid data type", row=iline-1, column=0)
468 if (data_type == 0)
then
472 if (idata_type == data_type .or. idata_type == 0)
then
477 namespace_prefix = namespace_prefix(1:len_trim(namespace_prefix)-len_trim(
'.RestartOptions'))
479 if (len_trim(namespace_prefix) == 0 .or. trim(namespace%get()) == trim(namespace_prefix))
then
480 namespace_prefix = trim(namespace%get())
484 namespace_prefix =
""
495 basedir = restart%basedir
498 do i=1, len(namespace_prefix)
499 if (namespace_prefix(i:i) ==
'.') namespace_prefix(i:i) =
'/'
503 basedir = trim(basedir)//trim(namespace_prefix)
505 dirname = trim(
basic_info(restart%data_type)%dir)
509 select case (restart%type)
510 case (restart_type_dump)
522 restart%skip_ = .not. restart_write
524 if (restart%skip_)
then
525 message(1) =
'Restart information will not be written.'
531 restart%skip_ = .false.
534 message(1) =
"Unknown restart type in restart_init"
540 if (restart%data_type == restart_undefined)
then
547 restart%dir_ = trim(basedir)//trim(dirname)
549 if (index(restart%dir_,
'/', .
true.) == len_trim(restart%dir_))
then
550 restart%dir_ = restart%dir_(1:len_trim(restart%dir_)-1)
554 restart%pwd = restart%dir_
557 if (restart%mpi_grp%is_root())
then
559 if (restart%type == restart_type_dump .and. .not. dir_exists)
then
563 if (restart%mpi_grp%size > 1)
then
564 call restart%mpi_grp%bcast(dir_exists, 1, mpi_logical, 0)
567 if (restart%data_type == restart_undefined)
then
573 select case (restart%type)
574 case (restart_type_dump)
575 if (.not. restart%skip_)
then
576 message(1) =
"Info: "//trim(tag)//
" restart information will be written to '"//trim(restart%pwd)//
"'."
581 if (.not. dir_exists)
then
583 restart%skip_ = .
true.
585 message(1) =
"Info: Could not find '"//trim(restart%pwd)//
"' directory for restart."
586 message(2) =
"Info: No restart information will be read."
589 message(1) =
"Info: "//trim(tag)//
" restart information will be read from '"//trim(restart%pwd)//
"'."
595 restart%initialized = .
true.
604 res = restart%mpi_grp%is_root()
614 subroutine restart_init(restart, namespace, data_type, type, mc, ierr, mesh, dir, exact)
617 integer,
intent(in) :: data_type
618 integer,
intent(in) ::
type
621 integer,
intent(out) :: ierr
622 class(
mesh_t),
optional,
intent(in) :: mesh
624 character(len=*),
optional,
intent(in) :: dir
626 logical,
optional,
intent(in) :: exact
629 logical :: grid_changed, grid_reordered, exact_, with_changed_grid
630 integer :: default_format
640 restart%has_mesh =
present(mesh)
645 if (
present(exact) .and. .not.
present(mesh))
then
646 message(1) =
"Error in restart_init: the 'exact' optional argument requires a mesh."
652 restart%has_mesh =
present(mesh)
655 if(
present(mesh))
then
676 default_format = option__restartfileformatstates__adios2
678 default_format = option__restartfileformatstates__obf
680 call parse_variable(namespace,
'RestartFileFormatStates', default_format, restart%file_format_states)
685 if (restart%file_format_states == option__restartfileformatstates__adios2)
then
689 message(1) =
"Error: adios2 restart file format requested, but not compiled against ADIOS2 library."
701 call parse_variable(namespace,
'RestartWithChangedGrid', .false., with_changed_grid)
703 select case (restart%type)
704 case (restart_type_dump)
705 if (.not. restart%skip_)
then
708 call index_dump(mesh%idx, mesh%np_part_global, restart%pwd, restart%mpi_grp, &
709 restart%namespace, ierr)
711 message(1) =
"Unable to write index map to '"//trim(restart%pwd)//
"'."
717 message(1) =
"Unable to write mesh fingerprint to '"//trim(restart%pwd)//
"/grid'."
723 if(.not. restart%skip_)
then
725 restart%mpi_grp, grid_changed, grid_reordered, restart%map, ierr)
730 message(1) =
"Unable to check mesh compatibility: unable to read mesh fingerprint"
731 message(2) =
"in '"//trim(restart%pwd)//
"'."
732 else if (ierr > 1)
then
733 message(1) =
"Mesh from current calculation is not compatible with mesh found in"
734 message(2) =
"'"//trim(restart%pwd)//
"'."
736 message(3) =
"No restart information will be read."
741 restart%grid_changed = grid_changed
744 if (grid_changed)
then
745 if (grid_reordered)
then
746 message(1) =
"Info: Octopus is attempting to restart from a mesh with a different order of points."
748 message(1) =
"Info: Octopus is attempting to restart from a different mesh."
750 if (with_changed_grid)
then
753 message(2) =
"This is disabled. To enable this, set RestartWithChangedGrid=True."
760 restart%skip_ = grid_changed .and. .not. grid_reordered
761 if (restart%skip_)
then
762 message(1) =
"This calculation requires the exact same mesh to restart."
763 message(2) =
"No restart information will be read from '"//trim(restart%pwd)//
"'."
768 restart%skip_ = .false.
776 if (restart%mpi_grp%size > 1)
then
777 call restart%mpi_grp%barrier()
792 restart%data_type = 0
793 restart%skip_ = .
true.
801 class(
restart_t),
intent(inout) :: restart
805 if (restart%mpi_grp%is_root() .and. .not. restart%skip_)
then
806 select case (restart%type)
808 message(1) =
"Info: Finished reading information "//trim(
basic_info(restart%type)%tag)//
" from '"//trim(restart%dir_)//
"'."
809 call io_rm(trim(restart%pwd)//
"/loading")
810 case (restart_type_dump)
811 call io_rm(trim(restart%pwd)//
"/dumping")
812 message(1) =
"Info: Finished writing information "//trim(
basic_info(restart%type)%tag)//
" to '"//trim(restart%dir_)//
"'."
817 safe_deallocate_a(restart%map)
818 restart%has_mesh = .false.
836 character(len=MAX_PATH_LEN) :: restart_basic_dir
838 push_sub(restart_basic_dir)
842 pop_sub(restart_basic_dir)
851 character(len=*),
intent(in) :: dirname
852 integer,
intent(out) :: ierr
856 assert(.not. restart%skip_)
860 select case (restart%type)
861 case (restart_type_dump)
864 if (.not.
loct_dir_exists(trim(restart%dir_)//
"/"//trim(dirname)))
then
870 if (index(dirname,
'/', .
true.) == len_trim(dirname))
then
871 restart%pwd = trim(restart%dir_)//
"/"//dirname(1:len_trim(dirname)-1)
873 restart%pwd = trim(restart%dir_)//
"/"//trim(dirname)
888 assert(.not. restart%skip_)
890 restart%pwd = restart%dir_
900 character(len=*),
intent(in) :: dirname
904 assert(.not. restart%skip_)
906 assert(restart%type == restart_type_dump)
908 call io_mkdir(trim(restart%pwd)//
"/"//trim(dirname), parents=.
true.)
918 character(len=*),
intent(in) :: name
920 assert(.not. restart%skip_)
921 assert(restart%type == restart_type_dump)
925 call io_rm(trim(restart%pwd)//
"/"//trim(name))
940 character(len=*),
intent(in) :: filename
941 character(len=*),
optional,
intent(in) :: status
942 character(len=*),
optional,
intent(in) :: position
943 logical,
optional,
intent(in) :: silent
944 integer :: restart_basic_open
947 character(len=20) :: action, status_
949 push_sub(restart_basic_open)
951 assert(restart%initialized)
952 assert(.not. restart%skip_)
954 select case (restart%type)
955 case (restart_type_dump)
966 message(1) =
"Error in restart_basic_open: illegal restart type"
970 if (
present(status)) status_ = status
972 restart_basic_open =
io_open(trim(restart%pwd)//
"/"//trim(filename), &
973 action=trim(action), status=trim(status_), &
974 die=die, position=position, form=
"formatted", grp=restart%mpi_grp)
976 if (restart_basic_open == -1 .and. .not.
optional_default(silent, .false.))
then
977 message(1) =
"Unable to open file '"//trim(restart%pwd)//
"/"//trim(filename)//
"'."
981 pop_sub(restart_basic_open)
988 integer,
intent(in) :: iunit
989 character(len=*),
intent(in) :: lines(:)
990 integer,
intent(in) :: nlines
991 integer,
intent(out) :: ierr
997 if (iunit /= -1)
then
999 if (restart%mpi_grp%is_root())
then
1000 do iline = 1, nlines
1001 write(iunit,
"(a)") trim(lines(iline))
1015 integer,
intent(in) :: iunit
1016 character(len=*),
intent(out) :: lines(:)
1017 integer,
intent(in) :: nlines
1018 integer,
intent(out) :: ierr
1022 call iopar_read(restart%mpi_grp, iunit, lines, nlines, ierr)
1032 integer,
intent(inout) :: iunit
1036 if (iunit /= -1)
call io_close(iunit, restart%mpi_grp)
1038 call restart%mpi_grp%barrier()
1061 integer,
intent(in) :: flag
1088 character(:),
allocatable :: info
1097 character(:),
allocatable :: info
1105#include "restart_inc.F90"
1108#include "complex.F90"
1109#include "restart_inc.F90"
block signals while writing the restart files
unblock signals when writing restart is finished
This module implements batches of mesh functions.
This module handles the calculation mode.
character(len= *), parameter, public em_resp_fd_dir
character(len= *), parameter, public gs_dir
character(len= *), parameter, public iteration_dir
character(len= *), parameter, public casida_dir
character(len= *), parameter, public vib_modes_dir
character(len= *), parameter, public partition_dir
character(len= *), parameter, public kdotp_dir
character(len= *), parameter, public dm_dir
character(len= *), parameter, public em_resp_dir
character(len= *), parameter, public td_dir
character(len= *), parameter, public vdw_dir
character(len= *), parameter, public oct_dir
This module implements the index, used for the mesh points.
subroutine, public index_dump(idx, np, dir, mpi_grp, namespace, ierr)
subroutine, public io_close(iunit, grp)
subroutine, public iopar_read(grp, iunit, lines, n_lines, ierr)
character(len=max_path_len) function, public io_workpath(path, namespace)
construct path name from given name and namespace
subroutine, public io_rm(fname, namespace)
character(len=max_path_len) function, public io_workdir()
construct working directory
subroutine, public io_mkdir(fname, namespace, parents)
logical function, public io_dir_exists(dir, namespace)
Returns true if a dir with name 'dir' exists.
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
System information (time, memory, sysname)
subroutine, public loct_rm(name)
logical function, public loct_dir_exists(dirname)
This module defines functions over batches of mesh functions.
This module defines the meshes, which are used in Octopus.
subroutine, public mesh_check_dump_compatibility(mesh, dir, filename, namespace, mpi_grp, grid_changed, grid_reordered, map, ierr)
subroutine, public mesh_write_fingerprint(mesh, dir, filename, mpi_grp, namespace, ierr)
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public messages_obsolete_variable(namespace, name, rep)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_input_error(namespace, var, details, row, column)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
type(mpi_comm), parameter, public mpi_comm_undefined
used to indicate a communicator has not been initialized
type(mpi_grp_t), public mpi_world
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
This module handles the communicators for the various parallelization strategies.
type(namespace_t), public global_namespace
Some general things and nomenclature:
character(len=:) function, allocatable, public parse_get_full_name(namespace, varname)
Given a namespace and a variable name, this function will iterate over all namespace ancestors contai...
subroutine, public parse_block_string(blk, l, c, res, convert_to_c)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine zrestart_write_binary3_int32(restart, filename, np, ff, ierr, root)
subroutine drestart_write_binary1_int32(restart, filename, np, ff, ierr, root)
subroutine drestart_read_binary3(restart, filename, np, ff, ierr)
logical pure function restart_has_map(restart)
Returns true if the restart was from a different order of mesh points.
integer, parameter, public restart_partition
integer, parameter, public restart_custom
subroutine drestart_write_binary5(restart, filename, np, ff, ierr, root)
subroutine restart_basic_end(restart)
subroutine restart_basic_open_dir(restart, dirname, ierr)
Change the restart directory to dirname, where "dirname" is a subdirectory of the base restart direct...
integer, parameter, public restart_dm
subroutine restart_basic_mkdir(restart, dirname)
Make directory "dirname" inside the current restart directory.
integer, parameter, public restart_all
subroutine restart_basic_close(restart, iunit)
Close a file previously opened with restart_basic_open.
subroutine drestart_read_binary1(restart, filename, np, ff, ierr)
subroutine restart_basic_close_dir(restart)
Change back to the base directory. To be called after restart_basic_open_dir.
subroutine zrestart_write_binary1(restart, filename, np, ff, ierr, root)
integer, parameter, public restart_casida
subroutine zrestart_write_binary5_int32(restart, filename, np, ff, ierr, root)
logical function, public clean_stop(comm)
returns true if a file named stop exists
subroutine zrestart_read_binary5_int32(restart, filename, np, ff, ierr)
integer, parameter, public restart_kdotp
subroutine zrestart_read_binary3(restart, filename, np, ff, ierr)
integer, parameter, public restart_oct
subroutine drestart_read_binary3_int32(restart, filename, np, ff, ierr)
type(restart_basic_data_t), dimension(restart_undefined:restart_n_data_types), parameter basic_info
Information about the components for a given system.
subroutine zrestart_read_binary3_int32(restart, filename, np, ff, ierr)
subroutine drestart_read_binary2(restart, filename, np, ff, ierr)
integer, parameter, public restart_gs
subroutine zrestart_read_binary1_int32(restart, filename, np, ff, ierr)
integer, parameter, public restart_iteration
subroutine drestart_write_binary3(restart, filename, np, ff, ierr, root)
integer, parameter, public restart_flag_mix
subroutine drestart_write_binary3_int32(restart, filename, np, ff, ierr, root)
subroutine zrestart_write_binary1_int32(restart, filename, np, ff, ierr, root)
subroutine restart_init(restart, namespace, data_type, type, mc, ierr, mesh, dir, exact)
Initializes a specific restart object.
integer function restart_basic_open(restart, filename, status, position, silent)
Open file "filename" found inside the current restart directory. Depending on the type of restart,...
integer, parameter, public restart_flag_skip
integer, parameter, public restart_em_resp_fd
subroutine drestart_read_binary2_int32(restart, filename, np, ff, ierr)
subroutine drestart_write_binary5_int32(restart, filename, np, ff, ierr, root)
subroutine restart_basic_rm(restart, name)
Remove directory or file "name" that is located inside the current restart directory.
subroutine restart_end(restart)
integer, parameter, public restart_proj
subroutine zrestart_read_binary1(restart, filename, np, ff, ierr)
integer, parameter, public restart_flag_rho
integer, parameter, public restart_em_resp
integer, parameter, public restart_vib_modes
subroutine drestart_write_binary1(restart, filename, np, ff, ierr, root)
subroutine drestart_read_binary1_int32(restart, filename, np, ff, ierr)
subroutine zrestart_write_binary5(restart, filename, np, ff, ierr, root)
subroutine zrestart_read_mesh_function(restart, filename, mesh, ff, ierr)
In domain parallel case each process reads a part of the file. At the end all the processes have the ...
integer, parameter, public restart_flag_vhxc
logical pure function restart_basic_has_flag(restart, flag)
Returns true if...
subroutine restart_basic_write(restart, iunit, lines, nlines, ierr)
integer, parameter, public restart_flag_literal
subroutine drestart_read_binary5_int32(restart, filename, np, ff, ierr)
subroutine drestart_write_binary2(restart, filename, np, ff, ierr, root)
subroutine drestart_read_binary5(restart, filename, np, ff, ierr)
character(len=max_path_len) function restart_basic_dir(restart)
Returns the name of the directory containing the restart information. The use of this function should...
subroutine zrestart_write_binary2_int32(restart, filename, np, ff, ierr, root)
character(len=4), dimension(2), parameter type_string
logical pure function restart_basic_skip(restart)
Returns true if the restart information should neither be read nor written. This might happen because...
integer, parameter, public restart_td
subroutine drestart_read_mesh_function(restart, filename, mesh, ff, ierr)
In domain parallel case each process reads a part of the file. At the end all the processes have the ...
integer, parameter, public restart_type_load
character(:) function, allocatable restart_basic_get_info(restart)
subroutine restart_basic_read(restart, iunit, lines, nlines, ierr)
subroutine zrestart_read_binary2(restart, filename, np, ff, ierr)
integer pure function restart_basic_get_data_type(restart)
Returns the data type of the restart.
integer, parameter, public restart_vdw
subroutine zrestart_read_binary5(restart, filename, np, ff, ierr)
subroutine zrestart_write_binary2(restart, filename, np, ff, ierr, root)
integer, parameter, public restart_unocc
subroutine zrestart_write_binary3(restart, filename, np, ff, ierr, root)
subroutine zrestart_read_binary2_int32(restart, filename, np, ff, ierr)
logical function restart_basic_do_i_write(restart)
character(:) function, allocatable restart_get_info(restart)
subroutine restart_basic_init(restart, namespace, data_type, type, ierr, dir)
subroutine drestart_write_binary2_int32(restart, filename, np, ff, ierr, root)
subroutine, public add_last_slash(str)
Adds a '/' in the end of the string, only if it missing. Useful for directories.
This module defines the unit system, used for input and output.
Describes mesh distribution to nodes.
Stores all communicators and groups.
restart_basic_data_t stores global information about a specific component we want to save....
restart_basic_t stores the basic information about a restart object.