107 integer,
parameter,
public :: &
108 RESTART_UNDEFINED = -1, &
123 integer,
parameter :: RESTART_N_DATA_TYPES = 12
127 integer :: data_type = restart_undefined
128 integer ::
type = restart_undefined
130 character(len=MAX_PATH_LEN) :: dir
131 character(len=MAX_PATH_LEN) :: pwd
133 type(namespace_t),
pointer,
public :: namespace
134 type(mpi_grp_t) :: mpi_grp
135 type(multicomm_t),
pointer :: mc
137 integer(int64),
allocatable :: map(:)
145 character(len=20) :: tag
146 character(len=MAX_PATH_LEN) :: basedir
147 character(len=MAX_PATH_LEN) :: dir
152 integer,
parameter,
public :: &
153 RESTART_TYPE_DUMP = 1, &
156 integer,
parameter,
public :: &
157 RESTART_FLAG_STATES = 1, &
163 type(restart_data_t) :: info(RESTART_N_DATA_TYPES)
168 subroutine block_signals()
170 end subroutine block_signals
174 subroutine unblock_signals()
176 end subroutine unblock_signals
183 type(MPI_Comm),
intent(in) :: comm
185 logical :: clean_stop, file_exists
192 inquire(file=
'stop', exist=file_exists)
193 if (file_exists)
then
201 call mpi_bcast(clean_stop, 1, mpi_logical, 0, comm,
mpi_err)
217 logical :: set(restart_n_data_types)
218 integer :: iline, n_cols, data_type
219 character(len=MAX_PATH_LEN) :: default_basedir
239 info(:)%basedir =
'restart'
388 if (
parse_block(namespace,
'RestartOptions', blk) == 0)
then
390 default_basedir =
'restart'
396 if (data_type < 0 .or. data_type > restart_n_data_types)
then
397 call messages_input_error(namespace,
'RestartOptions',
"Invalid data type", row=iline-1, column=0)
399 if (data_type == 0)
then
402 set(data_type) = .
true.
412 info(:)%basedir = default_basedir
422 subroutine restart_init(restart, namespace, data_type, type, mc, ierr, mesh, dir, exact)
425 integer,
intent(in) :: data_type
426 integer,
intent(in) ::
type
429 integer,
intent(out) :: ierr
430 class(
mesh_t),
optional,
intent(in) :: mesh
432 character(len=*),
optional,
intent(in) :: dir
434 logical,
optional,
intent(in) :: exact
437 logical :: grid_changed, grid_reordered,
restart_write, dir_exists
438 character(len=20) :: tag
439 character(len=MAX_PATH_LEN) :: basedir, dirname
446 if (
present(exact) .and. .not.
present(mesh))
then
447 message(1) =
"Error in restart_init: the 'exact' optional argument requires a mesh."
451 restart%has_mesh =
present(mesh)
457 if (data_type < restart_undefined .and. data_type > restart_n_data_types)
then
458 message(1) =
"Illegal data_type in restart_init"
461 restart%data_type = data_type
462 restart%namespace => namespace
464 select case (restart%type)
465 case (restart_type_dump)
479 if (restart%skip)
then
480 message(1) =
'Restart information will not be written.'
486 restart%skip = .false.
489 message(1) =
"Unknown restart type in restart_init"
495 if (restart%data_type == restart_undefined)
then
500 basedir = info(restart%data_type)%basedir
501 if (index(basedir,
'/', .
true.) /= len_trim(basedir))
then
502 basedir = trim(basedir)//
"/"
504 dirname = info(restart%data_type)%dir
508 restart%dir = trim(basedir)//trim(dirname)
510 if (index(restart%dir,
'/', .
true.) == len_trim(restart%dir))
then
511 restart%dir = restart%dir(1:len_trim(restart%dir)-1)
515 restart%pwd = restart%dir
519 if (restart%type == restart_type_dump .and. .not. dir_exists)
then
520 call io_mkdir(trim(restart%pwd), namespace, parents=.
true.)
523 if (restart%mpi_grp%size > 1)
then
524 call restart%mpi_grp%bcast(dir_exists, 1, mpi_logical, 0)
527 if (restart%data_type == restart_undefined)
then
530 tag = info(data_type)%tag
533 select case (restart%type)
534 case (restart_type_dump)
535 if (.not. restart%skip)
then
536 message(1) =
"Info: "//trim(tag)//
" restart information will be written to '"//trim(restart%pwd)//
"'."
541 if (
present(mesh))
then
542 call index_dump(mesh%idx, mesh%np_part_global, restart%pwd, restart%mpi_grp, &
543 restart%namespace, ierr)
545 message(1) =
"Unable to write index map to '"//trim(restart%pwd)//
"'."
551 message(1) =
"Unable to write mesh fingerprint to '"//trim(restart%pwd)//
"/grid'."
559 if (.not. dir_exists)
then
561 restart%skip = .
true.
563 message(1) =
"Info: Could not find '"//trim(restart%pwd)//
"' directory for restart."
564 message(2) =
"Info: No restart information will be read."
568 message(1) =
"Info: "//trim(tag)//
" restart information will be read from '"//trim(restart%pwd)//
"'."
571 if (
present(mesh))
then
573 restart%mpi_grp, grid_changed, grid_reordered, restart%map, ierr)
578 message(1) =
"Unable to check mesh compatibility: unable to read mesh fingerprint"
579 message(2) =
"in '"//trim(restart%pwd)//
"'."
580 else if (ierr > 0)
then
581 message(1) =
"Mesh from current calculation is not compatible with mesh found in"
582 message(2) =
"'"//trim(restart%pwd)//
"'."
584 message(3) =
"No restart information will be read."
590 if (grid_changed)
then
591 if (grid_reordered)
then
592 message(1) =
"Info: Octopus is attempting to restart from a mesh with a different order of points."
594 message(1) =
"Info: Octopus is attempting to restart from a different mesh."
599 if (
present(exact))
then
600 restart%skip = grid_changed .and. .not. grid_reordered .and. exact
601 if (restart%skip)
then
602 message(1) =
"This calculation requires the exact same mesh to restart."
603 message(2) =
"No restart information will be read from '"//trim(restart%pwd)//
"'."
608 restart%skip = .false.
619 if (restart%mpi_grp%size > 1)
then
620 call restart%mpi_grp%barrier()
629 type(
restart_t),
intent(inout) :: restart
634 select case (restart%type)
636 message(1) =
"Info: Finished reading information from '"//trim(restart%dir)//
"'."
637 call io_rm(trim(restart%pwd)//
"/loading", restart%namespace)
638 case (restart_type_dump)
639 call io_rm(trim(restart%pwd)//
"/dumping", restart%namespace)
640 message(1) =
"Info: Finished writing information to '"//trim(restart%dir)//
"'."
646 restart%data_type = 0
647 restart%skip = .
true.
648 safe_deallocate_a(restart%map)
649 restart%has_mesh = .false.
679 type(
restart_t),
intent(inout) :: restart
680 character(len=*),
intent(in) :: dirname
681 integer,
intent(out) :: ierr
685 assert(.not. restart%skip)
689 select case (restart%type)
690 case (restart_type_dump)
699 if (index(dirname,
'/', .
true.) == len_trim(dirname))
then
700 restart%pwd = trim(restart%dir)//
"/"//dirname(1:len_trim(dirname)-1)
702 restart%pwd = trim(restart%dir)//
"/"//trim(dirname)
713 type(
restart_t),
intent(inout) :: restart
717 assert(.not. restart%skip)
719 restart%pwd = restart%dir
729 character(len=*),
intent(in) :: dirname
733 assert(.not. restart%skip)
735 assert(restart%type == restart_type_dump)
737 call io_mkdir(trim(restart%pwd)//
"/"//trim(dirname), restart%namespace, parents=.
true.)
747 character(len=*),
intent(in) :: name
749 assert(.not. restart%skip)
750 assert(restart%type == restart_type_dump)
754 call io_rm(trim(restart%pwd)//
"/"//trim(name), restart%namespace)
767 function restart_open(restart, filename, status, position, silent)
769 character(len=*),
intent(in) :: filename
770 character(len=*),
optional,
intent(in) :: status
771 character(len=*),
optional,
intent(in) :: position
772 logical,
optional,
intent(in) :: silent
776 character(len=20) :: action, status_
780 assert(.not. restart%skip)
782 select case (restart%type)
783 case (restart_type_dump)
794 message(1) =
"Error in restart_open: illegal restart type"
798 if (
present(status)) status_ = status
801 action=trim(action), status=trim(status_), &
802 die=die, position=position, form=
"formatted", grp=restart%mpi_grp)
805 message(1) =
"Unable to open file '"//trim(restart%pwd)//
"/"//trim(filename)//
"'."
814 subroutine restart_write(restart, iunit, lines, nlines, ierr)
816 integer,
intent(in) :: iunit
817 character(len=*),
intent(in) :: lines(:)
818 integer,
intent(in) :: nlines
819 integer,
intent(out) :: ierr
829 write(iunit,
"(a)") trim(lines(iline))
841 subroutine restart_read(restart, iunit, lines, nlines, ierr)
843 integer,
intent(in) :: iunit
844 character(len=*),
intent(out) :: lines(:)
845 integer,
intent(in) :: nlines
846 integer,
intent(out) :: ierr
850 call iopar_read(restart%mpi_grp, iunit, lines, nlines, ierr)
860 integer,
intent(inout) :: iunit
864 if (iunit > 0)
call io_close(iunit, restart%mpi_grp)
887 integer,
intent(in) :: flag
907 integer,
intent(in) :: type1
908 integer,
intent(in) :: type2
924#include "restart_inc.F90"
927#include "complex.F90"
928#include "restart_inc.F90"
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 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 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)
subroutine, public io_rm(fname, namespace)
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)
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)
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
type(mpi_grp_t), public mpi_world
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
integer, public mpi_err
used to store return values of mpi calls
This module handles the communicators for the various parallelization strategies.
Some general things and nomenclature:
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)
integer, parameter, public restart_partition
subroutine, public restart_module_init(namespace)
subroutine drestart_write_binary5(restart, filename, np, ff, ierr, root)
subroutine, public restart_read(restart, iunit, lines, nlines, ierr)
character(len=max_path_len) function, public restart_dir(restart)
Returns the name of the directory containing the restart information. The use of this function should...
integer, parameter, public restart_all
subroutine drestart_read_binary1(restart, filename, np, ff, ierr)
subroutine zrestart_write_mesh_function(restart, space, filename, mesh, ff, ierr, root)
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)
subroutine, public restart_close(restart, iunit)
Close a file previously opened with restart_open.
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)
subroutine, public restart_rm(restart, name)
Remove directory or file "name" that is located inside the current restart directory.
subroutine, public restart_mkdir(restart, dirname)
Make directory "dirname" inside the current restart directory.
integer pure function restart_get_data_type(restart)
Returns the data type of the restart.
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)
type(restart_data_t), dimension(restart_n_data_types) info
subroutine drestart_write_binary3(restart, filename, np, ff, ierr, root)
subroutine drestart_read_mesh_function(restart, space, 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_mix
subroutine drestart_write_binary3_int32(restart, filename, np, ff, ierr, root)
subroutine zrestart_write_binary1_int32(restart, filename, np, ff, ierr, root)
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, public restart_init(restart, namespace, data_type, type, mc, ierr, mesh, dir, exact)
Initializes a restart object.
integer, parameter, public restart_proj
subroutine zrestart_read_mesh_function(restart, space, filename, mesh, ff, ierr)
In domain parallel case each process reads a part of the file. At the end all the processes have the ...
subroutine zrestart_read_binary1(restart, filename, np, ff, ierr)
integer, parameter, public restart_flag_rho
integer, parameter, public restart_em_resp
subroutine, public restart_write(restart, iunit, lines, nlines, ierr)
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)
logical pure function, public restart_skip(restart)
Returns true if the restart information should neither be read nor written. This might happen because...
integer, parameter, public restart_flag_vhxc
logical pure function, public restart_has_map(restart)
Returns true if the restart was from a different order of mesh points.
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)
subroutine zrestart_write_binary2_int32(restart, filename, np, ff, ierr, root)
logical pure function, public restart_has_flag(restart, flag)
Returns true if...
integer function, public restart_open(restart, filename, status, position, silent)
Open file "filename" found inside the current restart directory. Depending on the type of restart,...
subroutine, public restart_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_td
integer, parameter, public restart_type_load
subroutine zrestart_read_binary2(restart, filename, np, ff, ierr)
integer, parameter, public restart_vdw
subroutine zrestart_read_binary5(restart, filename, np, ff, ierr)
subroutine zrestart_write_binary2(restart, filename, np, ff, ierr, root)
subroutine drestart_write_mesh_function(restart, space, filename, mesh, ff, ierr, root)
integer, parameter, public restart_unocc
subroutine zrestart_write_binary3(restart, filename, np, ff, ierr, root)
logical pure function, public restart_are_basedirs_equal(type1, type2)
Returns true if...
subroutine zrestart_read_binary2_int32(restart, filename, np, ff, ierr)
subroutine, public restart_end(restart)
subroutine, public restart_close_dir(restart)
Change back to the base directory. To be called after restart_open_dir.
subroutine drestart_write_binary2_int32(restart, filename, np, ff, ierr, root)
This module defines the unit system, used for input and output.
Describes mesh distribution to nodes.
Stores all communicators and groups.