Merge branch 'split-CLI-signals' into 'development'
separating functionality See merge request damask/DAMASK!565
This commit is contained in:
commit
ea7c8ef235
|
@ -1,19 +1,15 @@
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @author Jaeyong Jung, Max-Planck-Institut für Eisenforschung GmbH
|
!> @author Jaeyong Jung, Max-Planck-Institut für Eisenforschung GmbH
|
||||||
!> @author Pratheek Shanthraj, Max-Planck-Institut für Eisenforschung GmbH
|
!> @author Pratheek Shanthraj, Max-Planck-Institut für Eisenforschung GmbH
|
||||||
!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH
|
!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH
|
||||||
!> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH
|
!> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH
|
||||||
!> @brief Interfacing between the PETSc-based solvers and the material subroutines provided
|
!> @brief Parse command line interface for PETSc-based solvers
|
||||||
!! by DAMASK
|
|
||||||
!> @details Interfacing between the PETSc-based solvers and the material subroutines provided
|
|
||||||
!> by DAMASK. Interpreting the command line arguments to get load case, geometry file,
|
|
||||||
!> and working directory.
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
#define PETSC_MAJOR 3
|
#define PETSC_MAJOR 3
|
||||||
#define PETSC_MINOR_MIN 12
|
#define PETSC_MINOR_MIN 12
|
||||||
#define PETSC_MINOR_MAX 17
|
#define PETSC_MINOR_MAX 17
|
||||||
|
|
||||||
module DAMASK_interface
|
module CLI
|
||||||
use, intrinsic :: ISO_fortran_env
|
use, intrinsic :: ISO_fortran_env
|
||||||
|
|
||||||
use PETScSys
|
use PETScSys
|
||||||
|
@ -24,22 +20,15 @@ module DAMASK_interface
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
private
|
private
|
||||||
logical, volatile, public, protected :: &
|
|
||||||
interface_SIGTERM, & !< termination signal
|
|
||||||
interface_SIGUSR1, & !< 1. user-defined signal
|
|
||||||
interface_SIGUSR2 !< 2. user-defined signal
|
|
||||||
integer, public, protected :: &
|
integer, public, protected :: &
|
||||||
interface_restartInc = 0 !< Increment at which calculation starts
|
CLI_restartInc = 0 !< Increment at which calculation starts
|
||||||
character(len=:), allocatable, public, protected :: &
|
character(len=:), allocatable, public, protected :: &
|
||||||
interface_geomFile, & !< parameter given for geometry file
|
CLI_geomFile, & !< parameter given for geometry file
|
||||||
interface_loadFile !< parameter given for load case file
|
CLI_loadFile !< parameter given for load case file
|
||||||
|
|
||||||
public :: &
|
public :: &
|
||||||
getSolverJobName, &
|
getSolverJobName, &
|
||||||
DAMASK_interface_init, &
|
CLI_init
|
||||||
interface_setSIGTERM, &
|
|
||||||
interface_setSIGUSR1, &
|
|
||||||
interface_setSIGUSR2
|
|
||||||
|
|
||||||
contains
|
contains
|
||||||
|
|
||||||
|
@ -47,7 +36,7 @@ contains
|
||||||
!> @brief initializes the solver by interpreting the command line arguments. Also writes
|
!> @brief initializes the solver by interpreting the command line arguments. Also writes
|
||||||
!! information on computation to screen
|
!! information on computation to screen
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
subroutine DAMASK_interface_init
|
subroutine CLI_init
|
||||||
#include <petsc/finclude/petscsys.h>
|
#include <petsc/finclude/petscsys.h>
|
||||||
|
|
||||||
#if PETSC_VERSION_MAJOR!=3 || PETSC_VERSION_MINOR<PETSC_MINOR_MIN || PETSC_VERSION_MINOR>PETSC_MINOR_MAX
|
#if PETSC_VERSION_MAJOR!=3 || PETSC_VERSION_MINOR<PETSC_MINOR_MIN || PETSC_VERSION_MINOR>PETSC_MINOR_MAX
|
||||||
|
@ -71,7 +60,7 @@ subroutine DAMASK_interface_init
|
||||||
quit
|
quit
|
||||||
|
|
||||||
|
|
||||||
print'(/,1x,a)', '<<<+- DAMASK_interface init -+>>>'
|
print'(/,1x,a)', '<<<+- CLI init -+>>>'
|
||||||
|
|
||||||
! http://patorjk.com/software/taag/#p=display&f=Lean&t=DAMASK%203
|
! http://patorjk.com/software/taag/#p=display&f=Lean&t=DAMASK%203
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -163,8 +152,8 @@ subroutine DAMASK_interface_init
|
||||||
call get_command_argument(i+1,workingDirArg,status=err)
|
call get_command_argument(i+1,workingDirArg,status=err)
|
||||||
case ('-r', '--rs', '--restart')
|
case ('-r', '--rs', '--restart')
|
||||||
call get_command_argument(i+1,arg,status=err)
|
call get_command_argument(i+1,arg,status=err)
|
||||||
read(arg,*,iostat=stat) interface_restartInc
|
read(arg,*,iostat=stat) CLI_restartInc
|
||||||
if (interface_restartInc < 0 .or. stat /=0) then
|
if (CLI_restartInc < 0 .or. stat /=0) then
|
||||||
print'(/,a)', ' ERROR: Could not parse restart increment: '//trim(arg)
|
print'(/,a)', ' ERROR: Could not parse restart increment: '//trim(arg)
|
||||||
call quit(1)
|
call quit(1)
|
||||||
endif
|
endif
|
||||||
|
@ -178,8 +167,8 @@ subroutine DAMASK_interface_init
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if (len_trim(workingDirArg) > 0) call setWorkingDirectory(trim(workingDirArg))
|
if (len_trim(workingDirArg) > 0) call setWorkingDirectory(trim(workingDirArg))
|
||||||
interface_geomFile = getGeometryFile(geometryArg)
|
CLI_geomFile = getGeometryFile(geometryArg)
|
||||||
interface_loadFile = getLoadCaseFile(loadCaseArg)
|
CLI_loadFile = getLoadCaseFile(loadCaseArg)
|
||||||
|
|
||||||
call get_command(commandLine)
|
call get_command(commandLine)
|
||||||
print'(/,a)', ' Host name: '//getHostName()
|
print'(/,a)', ' Host name: '//getHostName()
|
||||||
|
@ -191,20 +180,13 @@ subroutine DAMASK_interface_init
|
||||||
print'(a)', ' Geometry argument: '//trim(geometryArg)
|
print'(a)', ' Geometry argument: '//trim(geometryArg)
|
||||||
print'(a)', ' Load case argument: '//trim(loadcaseArg)
|
print'(a)', ' Load case argument: '//trim(loadcaseArg)
|
||||||
print'(/,a)', ' Working directory: '//getCWD()
|
print'(/,a)', ' Working directory: '//getCWD()
|
||||||
print'(a)', ' Geometry file: '//interface_geomFile
|
print'(a)', ' Geometry file: '//CLI_geomFile
|
||||||
print'(a)', ' Load case file: '//interface_loadFile
|
print'(a)', ' Load case file: '//CLI_loadFile
|
||||||
print'(a)', ' Solver job name: '//getSolverJobName()
|
print'(a)', ' Solver job name: '//getSolverJobName()
|
||||||
if (interface_restartInc > 0) &
|
if (CLI_restartInc > 0) &
|
||||||
print'(a,i6.6)', ' Restart from increment: ', interface_restartInc
|
print'(a,i6.6)', ' Restart from increment: ', CLI_restartInc
|
||||||
|
|
||||||
call signalterm_c(c_funloc(catchSIGTERM))
|
end subroutine CLI_init
|
||||||
call signalusr1_c(c_funloc(catchSIGUSR1))
|
|
||||||
call signalusr2_c(c_funloc(catchSIGUSR2))
|
|
||||||
call interface_setSIGTERM(.false.)
|
|
||||||
call interface_setSIGUSR1(.false.)
|
|
||||||
call interface_setSIGUSR2(.false.)
|
|
||||||
|
|
||||||
end subroutine DAMASK_interface_init
|
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
@ -243,15 +225,15 @@ function getSolverJobName()
|
||||||
character(len=:), allocatable :: getSolverJobName
|
character(len=:), allocatable :: getSolverJobName
|
||||||
integer :: posExt,posSep
|
integer :: posExt,posSep
|
||||||
|
|
||||||
posExt = scan(interface_geomFile,'.',back=.true.)
|
posExt = scan(CLI_geomFile,'.',back=.true.)
|
||||||
posSep = scan(interface_geomFile,'/',back=.true.)
|
posSep = scan(CLI_geomFile,'/',back=.true.)
|
||||||
|
|
||||||
getSolverJobName = interface_geomFile(posSep+1:posExt-1)
|
getSolverJobName = CLI_geomFile(posSep+1:posExt-1)
|
||||||
|
|
||||||
posExt = scan(interface_loadFile,'.',back=.true.)
|
posExt = scan(CLI_loadFile,'.',back=.true.)
|
||||||
posSep = scan(interface_loadFile,'/',back=.true.)
|
posSep = scan(CLI_loadFile,'/',back=.true.)
|
||||||
|
|
||||||
getSolverJobName = getSolverJobName//'_'//interface_loadFile(posSep+1:posExt-1)
|
getSolverJobName = getSolverJobName//'_'//CLI_loadFile(posSep+1:posExt-1)
|
||||||
|
|
||||||
end function getSolverJobName
|
end function getSolverJobName
|
||||||
|
|
||||||
|
@ -376,92 +358,4 @@ function makeRelativePath(a,b)
|
||||||
|
|
||||||
end function makeRelativePath
|
end function makeRelativePath
|
||||||
|
|
||||||
|
end module CLI
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
!> @brief Set global variable interface_SIGTERM to .true.
|
|
||||||
!> @details This function can be registered to catch signals send to the executable.
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
subroutine catchSIGTERM(signal) bind(C)
|
|
||||||
|
|
||||||
integer(C_INT), value :: signal
|
|
||||||
|
|
||||||
|
|
||||||
print'(a,i0)', ' received signal ',signal
|
|
||||||
call interface_setSIGTERM(.true.)
|
|
||||||
|
|
||||||
end subroutine catchSIGTERM
|
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
!> @brief Set global variable interface_SIGUSR1 to .true.
|
|
||||||
!> @details This function can be registered to catch signals send to the executable.
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
subroutine catchSIGUSR1(signal) bind(C)
|
|
||||||
|
|
||||||
integer(C_INT), value :: signal
|
|
||||||
|
|
||||||
|
|
||||||
print'(a,i0)', ' received signal ',signal
|
|
||||||
call interface_setSIGUSR1(.true.)
|
|
||||||
|
|
||||||
end subroutine catchSIGUSR1
|
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
!> @brief Set global variable interface_SIGUSR2 to .true.
|
|
||||||
!> @details This function can be registered to catch signals send to the executable.
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
subroutine catchSIGUSR2(signal) bind(C)
|
|
||||||
|
|
||||||
integer(C_INT), value :: signal
|
|
||||||
|
|
||||||
|
|
||||||
print'(a,i0,a)', ' received signal ',signal
|
|
||||||
call interface_setSIGUSR2(.true.)
|
|
||||||
|
|
||||||
end subroutine catchSIGUSR2
|
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
!> @brief Set global variable interface_SIGTERM.
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
subroutine interface_setSIGTERM(state)
|
|
||||||
|
|
||||||
logical, intent(in) :: state
|
|
||||||
|
|
||||||
|
|
||||||
interface_SIGTERM = state
|
|
||||||
print*, 'set SIGTERM to',state
|
|
||||||
|
|
||||||
end subroutine interface_setSIGTERM
|
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
!> @brief Set global variable interface_SIGUSR.
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
subroutine interface_setSIGUSR1(state)
|
|
||||||
|
|
||||||
logical, intent(in) :: state
|
|
||||||
|
|
||||||
|
|
||||||
interface_SIGUSR1 = state
|
|
||||||
print*, 'set SIGUSR1 to',state
|
|
||||||
|
|
||||||
end subroutine interface_setSIGUSR1
|
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
!> @brief Set global variable interface_SIGUSR2.
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
subroutine interface_setSIGUSR2(state)
|
|
||||||
|
|
||||||
logical, intent(in) :: state
|
|
||||||
|
|
||||||
|
|
||||||
interface_SIGUSR2 = state
|
|
||||||
print*, 'set SIGUSR2 to',state
|
|
||||||
|
|
||||||
end subroutine interface_setSIGUSR2
|
|
||||||
|
|
||||||
|
|
||||||
end module
|
|
|
@ -5,7 +5,8 @@
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
module CPFEM2
|
module CPFEM2
|
||||||
use parallelization
|
use parallelization
|
||||||
use DAMASK_interface
|
use signals
|
||||||
|
use CLI
|
||||||
use prec
|
use prec
|
||||||
use IO
|
use IO
|
||||||
use YAML_types
|
use YAML_types
|
||||||
|
@ -21,7 +22,6 @@ module CPFEM2
|
||||||
use material
|
use material
|
||||||
use phase
|
use phase
|
||||||
use homogenization
|
use homogenization
|
||||||
|
|
||||||
use discretization
|
use discretization
|
||||||
#if defined(MESH)
|
#if defined(MESH)
|
||||||
use FEM_quadrature
|
use FEM_quadrature
|
||||||
|
@ -43,7 +43,8 @@ contains
|
||||||
subroutine CPFEM_initAll
|
subroutine CPFEM_initAll
|
||||||
|
|
||||||
call parallelization_init
|
call parallelization_init
|
||||||
call DAMASK_interface_init ! Spectral and FEM interface to commandline
|
call CLI_init ! Spectral and FEM interface to commandline
|
||||||
|
call signals_init
|
||||||
call prec_init
|
call prec_init
|
||||||
call IO_init
|
call IO_init
|
||||||
#if defined(MESH)
|
#if defined(MESH)
|
||||||
|
@ -54,18 +55,18 @@ subroutine CPFEM_initAll
|
||||||
call YAML_types_init
|
call YAML_types_init
|
||||||
call YAML_parse_init
|
call YAML_parse_init
|
||||||
call HDF5_utilities_init
|
call HDF5_utilities_init
|
||||||
call results_init(restart=interface_restartInc>0)
|
call results_init(restart=CLI_restartInc>0)
|
||||||
call config_init
|
call config_init
|
||||||
call math_init
|
call math_init
|
||||||
call rotations_init
|
call rotations_init
|
||||||
call polynomials_init
|
call polynomials_init
|
||||||
call lattice_init
|
call lattice_init
|
||||||
#if defined(MESH)
|
#if defined(MESH)
|
||||||
call discretization_mesh_init(restart=interface_restartInc>0)
|
call discretization_mesh_init(restart=CLI_restartInc>0)
|
||||||
#elif defined(GRID)
|
#elif defined(GRID)
|
||||||
call discretization_grid_init(restart=interface_restartInc>0)
|
call discretization_grid_init(restart=CLI_restartInc>0)
|
||||||
#endif
|
#endif
|
||||||
call material_init(restart=interface_restartInc>0)
|
call material_init(restart=CLI_restartInc>0)
|
||||||
call phase_init
|
call phase_init
|
||||||
call homogenization_init
|
call homogenization_init
|
||||||
call CPFEM_init
|
call CPFEM_init
|
||||||
|
@ -85,7 +86,7 @@ subroutine CPFEM_init
|
||||||
print'(/,1x,a)', '<<<+- CPFEM init -+>>>'; flush(IO_STDOUT)
|
print'(/,1x,a)', '<<<+- CPFEM init -+>>>'; flush(IO_STDOUT)
|
||||||
|
|
||||||
|
|
||||||
if (interface_restartInc > 0) then
|
if (CLI_restartInc > 0) then
|
||||||
print'(/,a,i0,a)', ' reading restart information of increment from file'; flush(IO_STDOUT)
|
print'(/,a,i0,a)', ' reading restart information of increment from file'; flush(IO_STDOUT)
|
||||||
|
|
||||||
fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r')
|
fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r')
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH
|
!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH
|
||||||
!> @brief Reads in the material, numerics & debug configuration from their respective file
|
!> @brief Read in the configuration of material, numerics, and debug from their respective file
|
||||||
!> @details Reads the material configuration file, where solverJobName.yaml takes
|
|
||||||
!! precedence over material.yaml.
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
module config
|
module config
|
||||||
use IO
|
use IO
|
||||||
|
@ -28,19 +26,19 @@ contains
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief Real *.yaml configuration files.
|
!> @brief Real *.yaml configuration files.
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
subroutine config_init
|
subroutine config_init()
|
||||||
|
|
||||||
print'(/,1x,a)', '<<<+- config init -+>>>'; flush(IO_STDOUT)
|
print'(/,1x,a)', '<<<+- config init -+>>>'; flush(IO_STDOUT)
|
||||||
|
|
||||||
call parse_material
|
call parse_material()
|
||||||
call parse_numerics
|
call parse_numerics()
|
||||||
call parse_debug
|
call parse_debug()
|
||||||
|
|
||||||
end subroutine config_init
|
end subroutine config_init
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief Read material.yaml or <jobname>.yaml.
|
!> @brief Read material.yaml.
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
subroutine parse_material()
|
subroutine parse_material()
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@ program DAMASK_grid
|
||||||
|
|
||||||
use prec
|
use prec
|
||||||
use parallelization
|
use parallelization
|
||||||
use DAMASK_interface
|
use signals
|
||||||
|
use CLI
|
||||||
use IO
|
use IO
|
||||||
use config
|
use config
|
||||||
use math
|
use math
|
||||||
|
@ -133,8 +134,8 @@ program DAMASK_grid
|
||||||
if (maxCutBack < 0) call IO_error(301,ext_msg='maxCutBack')
|
if (maxCutBack < 0) call IO_error(301,ext_msg='maxCutBack')
|
||||||
|
|
||||||
if (worldrank == 0) then
|
if (worldrank == 0) then
|
||||||
fileContent = IO_read(interface_loadFile)
|
fileContent = IO_read(CLI_loadFile)
|
||||||
fname = interface_loadFile
|
fname = CLI_loadFile
|
||||||
if (scan(fname,'/') /= 0) fname = fname(scan(fname,'/',.true.)+1:)
|
if (scan(fname,'/') /= 0) fname = fname(scan(fname,'/',.true.)+1:)
|
||||||
call results_openJobFile(parallel=.false.)
|
call results_openJobFile(parallel=.false.)
|
||||||
call results_writeDataset_str(fileContent,'setup',fname,'load case definition (grid solver)')
|
call results_writeDataset_str(fileContent,'setup',fname,'load case definition (grid solver)')
|
||||||
|
@ -314,7 +315,7 @@ program DAMASK_grid
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! write header of output file
|
! write header of output file
|
||||||
if (worldrank == 0) then
|
if (worldrank == 0) then
|
||||||
writeHeader: if (interface_restartInc < 1) then
|
writeHeader: if (CLI_restartInc < 1) then
|
||||||
open(newunit=statUnit,file=trim(getSolverJobName())//'.sta',form='FORMATTED',status='REPLACE')
|
open(newunit=statUnit,file=trim(getSolverJobName())//'.sta',form='FORMATTED',status='REPLACE')
|
||||||
write(statUnit,'(a)') 'Increment Time CutbackLevel Converged IterationsNeeded' ! statistics file
|
write(statUnit,'(a)') 'Increment Time CutbackLevel Converged IterationsNeeded' ! statistics file
|
||||||
else writeHeader
|
else writeHeader
|
||||||
|
@ -323,7 +324,7 @@ program DAMASK_grid
|
||||||
endif writeHeader
|
endif writeHeader
|
||||||
endif
|
endif
|
||||||
|
|
||||||
writeUndeformed: if (interface_restartInc < 1) then
|
writeUndeformed: if (CLI_restartInc < 1) then
|
||||||
print'(/,1x,a)', '... writing initial configuration to file .................................'
|
print'(/,1x,a)', '... writing initial configuration to file .................................'
|
||||||
flush(IO_STDOUT)
|
flush(IO_STDOUT)
|
||||||
call CPFEM_results(0,0.0_pReal)
|
call CPFEM_results(0,0.0_pReal)
|
||||||
|
@ -347,7 +348,7 @@ program DAMASK_grid
|
||||||
endif
|
endif
|
||||||
Delta_t = Delta_t * real(subStepFactor,pReal)**real(-cutBackLevel,pReal) ! depending on cut back level, decrease time step
|
Delta_t = Delta_t * real(subStepFactor,pReal)**real(-cutBackLevel,pReal) ! depending on cut back level, decrease time step
|
||||||
|
|
||||||
skipping: if (totalIncsCounter <= interface_restartInc) then ! not yet at restart inc?
|
skipping: if (totalIncsCounter <= CLI_restartInc) then ! not yet at restart inc?
|
||||||
t = t + Delta_t ! just advance time, skip already performed calculation
|
t = t + Delta_t ! just advance time, skip already performed calculation
|
||||||
guess = .true. ! QUESTION:why forced guessing instead of inheriting loadcase preference
|
guess = .true. ! QUESTION:why forced guessing instead of inheriting loadcase preference
|
||||||
else skipping
|
else skipping
|
||||||
|
@ -448,15 +449,15 @@ program DAMASK_grid
|
||||||
print'(/,1x,a,i0,a)', 'increment ', totalIncsCounter, ' NOT converged'
|
print'(/,1x,a,i0,a)', 'increment ', totalIncsCounter, ' NOT converged'
|
||||||
endif; flush(IO_STDOUT)
|
endif; flush(IO_STDOUT)
|
||||||
|
|
||||||
call MPI_Allreduce(interface_SIGUSR1,signal,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI)
|
call MPI_Allreduce(signals_SIGUSR1,signal,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI)
|
||||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||||
if (mod(inc,loadCases(l)%f_out) == 0 .or. signal) then
|
if (mod(inc,loadCases(l)%f_out) == 0 .or. signal) then
|
||||||
print'(/,1x,a)', '... writing results to file ...............................................'
|
print'(/,1x,a)', '... writing results to file ...............................................'
|
||||||
flush(IO_STDOUT)
|
flush(IO_STDOUT)
|
||||||
call CPFEM_results(totalIncsCounter,t)
|
call CPFEM_results(totalIncsCounter,t)
|
||||||
endif
|
endif
|
||||||
if (signal) call interface_setSIGUSR1(.false.)
|
if (signal) call signals_setSIGUSR1(.false.)
|
||||||
call MPI_Allreduce(interface_SIGUSR2,signal,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI)
|
call MPI_Allreduce(signals_SIGUSR2,signal,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI)
|
||||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||||
if (mod(inc,loadCases(l)%f_restart) == 0 .or. signal) then
|
if (mod(inc,loadCases(l)%f_restart) == 0 .or. signal) then
|
||||||
do field = 1, nActiveFields
|
do field = 1, nActiveFields
|
||||||
|
@ -469,8 +470,8 @@ program DAMASK_grid
|
||||||
end do
|
end do
|
||||||
call CPFEM_restartWrite
|
call CPFEM_restartWrite
|
||||||
endif
|
endif
|
||||||
if (signal) call interface_setSIGUSR2(.false.)
|
if (signal) call signals_setSIGUSR2(.false.)
|
||||||
call MPI_Allreduce(interface_SIGTERM,signal,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI)
|
call MPI_Allreduce(signals_SIGTERM,signal,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI)
|
||||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||||
if (signal) exit loadCaseLooping
|
if (signal) exit loadCaseLooping
|
||||||
endif skipping
|
endif skipping
|
||||||
|
|
|
@ -15,7 +15,7 @@ module discretization_grid
|
||||||
use parallelization
|
use parallelization
|
||||||
use system_routines
|
use system_routines
|
||||||
use VTI
|
use VTI
|
||||||
use DAMASK_interface
|
use CLI
|
||||||
use IO
|
use IO
|
||||||
use config
|
use config
|
||||||
use results
|
use results
|
||||||
|
@ -76,14 +76,14 @@ subroutine discretization_grid_init(restart)
|
||||||
|
|
||||||
|
|
||||||
if (worldrank == 0) then
|
if (worldrank == 0) then
|
||||||
fileContent = IO_read(interface_geomFile)
|
fileContent = IO_read(CLI_geomFile)
|
||||||
call VTI_readCellsSizeOrigin(cells,geomSize,origin,fileContent)
|
call VTI_readCellsSizeOrigin(cells,geomSize,origin,fileContent)
|
||||||
materialAt_global = VTI_readDataset_int(fileContent,'material') + 1
|
materialAt_global = VTI_readDataset_int(fileContent,'material') + 1
|
||||||
if (any(materialAt_global < 1)) &
|
if (any(materialAt_global < 1)) &
|
||||||
call IO_error(180,ext_msg='material ID < 1')
|
call IO_error(180,ext_msg='material ID < 1')
|
||||||
if (size(materialAt_global) /= product(cells)) &
|
if (size(materialAt_global) /= product(cells)) &
|
||||||
call IO_error(180,ext_msg='mismatch in # of material IDs and cells')
|
call IO_error(180,ext_msg='mismatch in # of material IDs and cells')
|
||||||
fname = interface_geomFile
|
fname = CLI_geomFile
|
||||||
if (scan(fname,'/') /= 0) fname = fname(scan(fname,'/',.true.)+1:)
|
if (scan(fname,'/') /= 0) fname = fname(scan(fname,'/',.true.)+1:)
|
||||||
call results_openJobFile(parallel=.false.)
|
call results_openJobFile(parallel=.false.)
|
||||||
call results_writeDataset_str(fileContent,'setup',fname,'geometry definition (grid solver)')
|
call results_writeDataset_str(fileContent,'setup',fname,'geometry definition (grid solver)')
|
||||||
|
@ -329,7 +329,7 @@ function discretization_grid_getInitialCondition(label) result(ic)
|
||||||
displs, sendcounts
|
displs, sendcounts
|
||||||
|
|
||||||
if (worldrank == 0) then
|
if (worldrank == 0) then
|
||||||
ic_global = VTI_readDataset_real(IO_read(interface_geomFile),label)
|
ic_global = VTI_readDataset_real(IO_read(CLI_geomFile),label)
|
||||||
else
|
else
|
||||||
allocate(ic_global(0)) ! needed for IntelMPI
|
allocate(ic_global(0)) ! needed for IntelMPI
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -15,7 +15,7 @@ module grid_mechanical_FEM
|
||||||
|
|
||||||
use prec
|
use prec
|
||||||
use parallelization
|
use parallelization
|
||||||
use DAMASK_interface
|
use CLI
|
||||||
use IO
|
use IO
|
||||||
use HDF5
|
use HDF5
|
||||||
use HDF5_utilities
|
use HDF5_utilities
|
||||||
|
@ -231,8 +231,8 @@ subroutine grid_mechanical_FEM_init
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! init fields
|
! init fields
|
||||||
restartRead: if (interface_restartInc > 0) then
|
restartRead: if (CLI_restartInc > 0) then
|
||||||
print'(/,1x,a,i0,a)', 'reading restart data of increment ', interface_restartInc, ' from file'
|
print'(/,1x,a,i0,a)', 'reading restart data of increment ', CLI_restartInc, ' from file'
|
||||||
|
|
||||||
fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r')
|
fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r')
|
||||||
groupHandle = HDF5_openGroup(fileHandle,'solver')
|
groupHandle = HDF5_openGroup(fileHandle,'solver')
|
||||||
|
@ -254,7 +254,7 @@ subroutine grid_mechanical_FEM_init
|
||||||
call HDF5_read(u_current,groupHandle,'u')
|
call HDF5_read(u_current,groupHandle,'u')
|
||||||
call HDF5_read(u_lastInc,groupHandle,'u_lastInc')
|
call HDF5_read(u_lastInc,groupHandle,'u_lastInc')
|
||||||
|
|
||||||
elseif (interface_restartInc == 0) then restartRead
|
elseif (CLI_restartInc == 0) then restartRead
|
||||||
F_lastInc = spread(spread(spread(math_I3,3,cells(1)),4,cells(2)),5,cells3) ! initialize to identity
|
F_lastInc = spread(spread(spread(math_I3,3,cells(1)),4,cells(2)),5,cells3) ! initialize to identity
|
||||||
F = spread(spread(spread(math_I3,3,cells(1)),4,cells(2)),5,cells3)
|
F = spread(spread(spread(math_I3,3,cells(1)),4,cells(2)),5,cells3)
|
||||||
endif restartRead
|
endif restartRead
|
||||||
|
@ -269,8 +269,8 @@ subroutine grid_mechanical_FEM_init
|
||||||
call DMDAVecRestoreArrayF90(mechanical_grid,solution_lastInc,u_lastInc,err_PETSc)
|
call DMDAVecRestoreArrayF90(mechanical_grid,solution_lastInc,u_lastInc,err_PETSc)
|
||||||
CHKERRQ(err_PETSc)
|
CHKERRQ(err_PETSc)
|
||||||
|
|
||||||
restartRead2: if (interface_restartInc > 0) then
|
restartRead2: if (CLI_restartInc > 0) then
|
||||||
print'(1x,a,i0,a)', 'reading more restart data of increment ', interface_restartInc, ' from file'
|
print'(1x,a,i0,a)', 'reading more restart data of increment ', CLI_restartInc, ' from file'
|
||||||
call HDF5_read(C_volAvg,groupHandle,'C_volAvg',.false.)
|
call HDF5_read(C_volAvg,groupHandle,'C_volAvg',.false.)
|
||||||
call MPI_Bcast(C_volAvg,81_MPI_INTEGER_KIND,MPI_DOUBLE,0_MPI_INTEGER_KIND,MPI_COMM_WORLD,err_MPI)
|
call MPI_Bcast(C_volAvg,81_MPI_INTEGER_KIND,MPI_DOUBLE,0_MPI_INTEGER_KIND,MPI_COMM_WORLD,err_MPI)
|
||||||
if(err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
if(err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||||
|
|
|
@ -15,7 +15,7 @@ module grid_mechanical_spectral_basic
|
||||||
|
|
||||||
use prec
|
use prec
|
||||||
use parallelization
|
use parallelization
|
||||||
use DAMASK_interface
|
use CLI
|
||||||
use IO
|
use IO
|
||||||
use HDF5
|
use HDF5
|
||||||
use HDF5_utilities
|
use HDF5_utilities
|
||||||
|
@ -201,8 +201,8 @@ subroutine grid_mechanical_spectral_basic_init
|
||||||
call DMDAVecGetArrayF90(da,solution_vec,F,err_PETSc) ! places pointer on PETSc data
|
call DMDAVecGetArrayF90(da,solution_vec,F,err_PETSc) ! places pointer on PETSc data
|
||||||
CHKERRQ(err_PETSc)
|
CHKERRQ(err_PETSc)
|
||||||
|
|
||||||
restartRead: if (interface_restartInc > 0) then
|
restartRead: if (CLI_restartInc > 0) then
|
||||||
print'(/,1x,a,i0,a)', 'reading restart data of increment ', interface_restartInc, ' from file'
|
print'(/,1x,a,i0,a)', 'reading restart data of increment ', CLI_restartInc, ' from file'
|
||||||
|
|
||||||
fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r')
|
fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r')
|
||||||
groupHandle = HDF5_openGroup(fileHandle,'solver')
|
groupHandle = HDF5_openGroup(fileHandle,'solver')
|
||||||
|
@ -222,7 +222,7 @@ subroutine grid_mechanical_spectral_basic_init
|
||||||
call HDF5_read(F,groupHandle,'F')
|
call HDF5_read(F,groupHandle,'F')
|
||||||
call HDF5_read(F_lastInc,groupHandle,'F_lastInc')
|
call HDF5_read(F_lastInc,groupHandle,'F_lastInc')
|
||||||
|
|
||||||
elseif (interface_restartInc == 0) then restartRead
|
elseif (CLI_restartInc == 0) then restartRead
|
||||||
F_lastInc = spread(spread(spread(math_I3,3,cells(1)),4,cells(2)),5,cells3) ! initialize to identity
|
F_lastInc = spread(spread(spread(math_I3,3,cells(1)),4,cells(2)),5,cells3) ! initialize to identity
|
||||||
F = reshape(F_lastInc,[9,cells(1),cells(2),cells3])
|
F = reshape(F_lastInc,[9,cells(1),cells(2),cells3])
|
||||||
end if restartRead
|
end if restartRead
|
||||||
|
@ -235,8 +235,8 @@ subroutine grid_mechanical_spectral_basic_init
|
||||||
call DMDAVecRestoreArrayF90(da,solution_vec,F,err_PETSc) ! deassociate pointer
|
call DMDAVecRestoreArrayF90(da,solution_vec,F,err_PETSc) ! deassociate pointer
|
||||||
CHKERRQ(err_PETSc)
|
CHKERRQ(err_PETSc)
|
||||||
|
|
||||||
restartRead2: if (interface_restartInc > 0) then
|
restartRead2: if (CLI_restartInc > 0) then
|
||||||
print'(1x,a,i0,a)', 'reading more restart data of increment ', interface_restartInc, ' from file'
|
print'(1x,a,i0,a)', 'reading more restart data of increment ', CLI_restartInc, ' from file'
|
||||||
call HDF5_read(C_volAvg,groupHandle,'C_volAvg',.false.)
|
call HDF5_read(C_volAvg,groupHandle,'C_volAvg',.false.)
|
||||||
call MPI_Bcast(C_volAvg,81_MPI_INTEGER_KIND,MPI_DOUBLE,0_MPI_INTEGER_KIND,MPI_COMM_WORLD,err_MPI)
|
call MPI_Bcast(C_volAvg,81_MPI_INTEGER_KIND,MPI_DOUBLE,0_MPI_INTEGER_KIND,MPI_COMM_WORLD,err_MPI)
|
||||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||||
|
|
|
@ -15,7 +15,7 @@ module grid_mechanical_spectral_polarisation
|
||||||
|
|
||||||
use prec
|
use prec
|
||||||
use parallelization
|
use parallelization
|
||||||
use DAMASK_interface
|
use CLI
|
||||||
use IO
|
use IO
|
||||||
use HDF5
|
use HDF5
|
||||||
use HDF5_utilities
|
use HDF5_utilities
|
||||||
|
@ -223,8 +223,8 @@ subroutine grid_mechanical_spectral_polarisation_init
|
||||||
F => FandF_tau(0: 8,:,:,:)
|
F => FandF_tau(0: 8,:,:,:)
|
||||||
F_tau => FandF_tau(9:17,:,:,:)
|
F_tau => FandF_tau(9:17,:,:,:)
|
||||||
|
|
||||||
restartRead: if (interface_restartInc > 0) then
|
restartRead: if (CLI_restartInc > 0) then
|
||||||
print'(/,1x,a,i0,a)', 'reading restart data of increment ', interface_restartInc, ' from file'
|
print'(/,1x,a,i0,a)', 'reading restart data of increment ', CLI_restartInc, ' from file'
|
||||||
|
|
||||||
fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r')
|
fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r')
|
||||||
groupHandle = HDF5_openGroup(fileHandle,'solver')
|
groupHandle = HDF5_openGroup(fileHandle,'solver')
|
||||||
|
@ -246,7 +246,7 @@ subroutine grid_mechanical_spectral_polarisation_init
|
||||||
call HDF5_read(F_tau,groupHandle,'F_tau')
|
call HDF5_read(F_tau,groupHandle,'F_tau')
|
||||||
call HDF5_read(F_tau_lastInc,groupHandle,'F_tau_lastInc')
|
call HDF5_read(F_tau_lastInc,groupHandle,'F_tau_lastInc')
|
||||||
|
|
||||||
elseif (interface_restartInc == 0) then restartRead
|
elseif (CLI_restartInc == 0) then restartRead
|
||||||
F_lastInc = spread(spread(spread(math_I3,3,cells(1)),4,cells(2)),5,cells3) ! initialize to identity
|
F_lastInc = spread(spread(spread(math_I3,3,cells(1)),4,cells(2)),5,cells3) ! initialize to identity
|
||||||
F = reshape(F_lastInc,[9,cells(1),cells(2),cells3])
|
F = reshape(F_lastInc,[9,cells(1),cells(2),cells3])
|
||||||
F_tau = 2.0_pReal*F
|
F_tau = 2.0_pReal*F
|
||||||
|
@ -261,8 +261,8 @@ subroutine grid_mechanical_spectral_polarisation_init
|
||||||
call DMDAVecRestoreArrayF90(da,solution_vec,FandF_tau,err_PETSc) ! deassociate pointer
|
call DMDAVecRestoreArrayF90(da,solution_vec,FandF_tau,err_PETSc) ! deassociate pointer
|
||||||
CHKERRQ(err_PETSc)
|
CHKERRQ(err_PETSc)
|
||||||
|
|
||||||
restartRead2: if (interface_restartInc > 0) then
|
restartRead2: if (CLI_restartInc > 0) then
|
||||||
print'(1x,a,i0,a)', 'reading more restart data of increment ', interface_restartInc, ' from file'
|
print'(1x,a,i0,a)', 'reading more restart data of increment ', CLI_restartInc, ' from file'
|
||||||
call HDF5_read(C_volAvg,groupHandle,'C_volAvg',.false.)
|
call HDF5_read(C_volAvg,groupHandle,'C_volAvg',.false.)
|
||||||
call MPI_Bcast(C_volAvg,81_MPI_INTEGER_KIND,MPI_DOUBLE,0_MPI_INTEGER_KIND,MPI_COMM_WORLD,err_MPI)
|
call MPI_Bcast(C_volAvg,81_MPI_INTEGER_KIND,MPI_DOUBLE,0_MPI_INTEGER_KIND,MPI_COMM_WORLD,err_MPI)
|
||||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||||
|
|
|
@ -16,7 +16,7 @@ module grid_thermal_spectral
|
||||||
use prec
|
use prec
|
||||||
use parallelization
|
use parallelization
|
||||||
use IO
|
use IO
|
||||||
use DAMASK_interface
|
use CLI
|
||||||
use HDF5_utilities
|
use HDF5_utilities
|
||||||
use HDF5
|
use HDF5
|
||||||
use spectral_utilities
|
use spectral_utilities
|
||||||
|
@ -140,8 +140,8 @@ subroutine grid_thermal_spectral_init()
|
||||||
CHKERRQ(err_PETSc)
|
CHKERRQ(err_PETSc)
|
||||||
|
|
||||||
|
|
||||||
restartRead: if (interface_restartInc > 0) then
|
restartRead: if (CLI_restartInc > 0) then
|
||||||
print'(/,1x,a,i0,a)', 'reading restart data of increment ', interface_restartInc, ' from file'
|
print'(/,1x,a,i0,a)', 'reading restart data of increment ', CLI_restartInc, ' from file'
|
||||||
|
|
||||||
fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r')
|
fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r')
|
||||||
groupHandle = HDF5_openGroup(fileHandle,'solver')
|
groupHandle = HDF5_openGroup(fileHandle,'solver')
|
||||||
|
|
|
@ -13,7 +13,7 @@ module spectral_utilities
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
use prec
|
use prec
|
||||||
use DAMASK_interface
|
use CLI
|
||||||
use parallelization
|
use parallelization
|
||||||
use math
|
use math
|
||||||
use rotations
|
use rotations
|
||||||
|
|
|
@ -10,7 +10,7 @@ program DAMASK_mesh
|
||||||
#include <petsc/finclude/petscsys.h>
|
#include <petsc/finclude/petscsys.h>
|
||||||
use PetscDM
|
use PetscDM
|
||||||
use prec
|
use prec
|
||||||
use DAMASK_interface
|
use CLI
|
||||||
use parallelization
|
use parallelization
|
||||||
use IO
|
use IO
|
||||||
use math
|
use math
|
||||||
|
@ -104,7 +104,7 @@ program DAMASK_mesh
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! reading basic information from load case file and allocate data structure containing load cases
|
! reading basic information from load case file and allocate data structure containing load cases
|
||||||
fileContent = IO_readlines(trim(interface_loadFile))
|
fileContent = IO_readlines(trim(CLI_loadFile))
|
||||||
do l = 1, size(fileContent)
|
do l = 1, size(fileContent)
|
||||||
line = fileContent(l)
|
line = fileContent(l)
|
||||||
if (IO_isBlank(line)) cycle ! skip empty lines
|
if (IO_isBlank(line)) cycle ! skip empty lines
|
||||||
|
|
|
@ -15,7 +15,7 @@ module discretization_mesh
|
||||||
use MPI_f08
|
use MPI_f08
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
use DAMASK_interface
|
use CLI
|
||||||
use parallelization
|
use parallelization
|
||||||
use IO
|
use IO
|
||||||
use config
|
use config
|
||||||
|
@ -101,9 +101,9 @@ subroutine discretization_mesh_init(restart)
|
||||||
debug_ip = config_debug%get_asInt('integrationpoint',defaultVal=1)
|
debug_ip = config_debug%get_asInt('integrationpoint',defaultVal=1)
|
||||||
|
|
||||||
#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>16)
|
#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>16)
|
||||||
call DMPlexCreateFromFile(PETSC_COMM_WORLD,interface_geomFile,'n/a',PETSC_TRUE,globalMesh,err_PETSc)
|
call DMPlexCreateFromFile(PETSC_COMM_WORLD,CLI_geomFile,'n/a',PETSC_TRUE,globalMesh,err_PETSc)
|
||||||
#else
|
#else
|
||||||
call DMPlexCreateFromFile(PETSC_COMM_WORLD,interface_geomFile,PETSC_TRUE,globalMesh,err_PETSc)
|
call DMPlexCreateFromFile(PETSC_COMM_WORLD,CLI_geomFile,PETSC_TRUE,globalMesh,err_PETSc)
|
||||||
#endif
|
#endif
|
||||||
CHKERRQ(err_PETSc)
|
CHKERRQ(err_PETSc)
|
||||||
call DMGetDimension(globalMesh,dimPlex,err_PETSc)
|
call DMGetDimension(globalMesh,dimPlex,err_PETSc)
|
||||||
|
|
|
@ -20,7 +20,6 @@ module mesh_mechanical_FEM
|
||||||
use FEM_utilities
|
use FEM_utilities
|
||||||
use discretization
|
use discretization
|
||||||
use discretization_mesh
|
use discretization_mesh
|
||||||
use DAMASK_interface
|
|
||||||
use config
|
use config
|
||||||
use IO
|
use IO
|
||||||
use FEM_quadrature
|
use FEM_quadrature
|
||||||
|
|
|
@ -6,17 +6,19 @@
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
module results
|
module results
|
||||||
use prec
|
use prec
|
||||||
use DAMASK_interface
|
|
||||||
use parallelization
|
use parallelization
|
||||||
use IO
|
use IO
|
||||||
use HDF5_utilities
|
use HDF5_utilities
|
||||||
use HDF5
|
use HDF5
|
||||||
#ifdef PETSC
|
#ifdef PETSC
|
||||||
|
use CLI
|
||||||
#include <petsc/finclude/petscsys.h>
|
#include <petsc/finclude/petscsys.h>
|
||||||
use PETScSys
|
use PETScSys
|
||||||
#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>14) && !defined(PETSC_HAVE_MPI_F90MODULE_VISIBILITY)
|
#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>14) && !defined(PETSC_HAVE_MPI_F90MODULE_VISIBILITY)
|
||||||
use MPI_f08
|
use MPI_f08
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
use DAMASK_interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH
|
||||||
|
!> @brief Handling of UNIX signals.
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
module signals
|
||||||
|
use prec
|
||||||
|
use system_routines
|
||||||
|
|
||||||
|
implicit none
|
||||||
|
private
|
||||||
|
|
||||||
|
logical, volatile, public, protected :: &
|
||||||
|
signals_SIGTERM, & !< termination signal
|
||||||
|
signals_SIGUSR1, & !< 1. user-defined signal
|
||||||
|
signals_SIGUSR2 !< 2. user-defined signal
|
||||||
|
|
||||||
|
public :: &
|
||||||
|
signals_init, &
|
||||||
|
signals_setSIGTERM, &
|
||||||
|
signals_setSIGUSR1, &
|
||||||
|
signals_setSIGUSR2
|
||||||
|
|
||||||
|
contains
|
||||||
|
|
||||||
|
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
!> @brief Register signal handlers.
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
subroutine signals_init()
|
||||||
|
|
||||||
|
call signalterm_c(c_funloc(catchSIGTERM))
|
||||||
|
call signalusr1_c(c_funloc(catchSIGUSR1))
|
||||||
|
call signalusr2_c(c_funloc(catchSIGUSR2))
|
||||||
|
call signals_setSIGTERM(.false.)
|
||||||
|
call signals_setSIGUSR1(.false.)
|
||||||
|
call signals_setSIGUSR2(.false.)
|
||||||
|
|
||||||
|
end subroutine signals_init
|
||||||
|
|
||||||
|
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
!> @brief Set global variable signals_SIGTERM to .true.
|
||||||
|
!> @details This function can be registered to catch signals send to the executable.
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
subroutine catchSIGTERM(signal) bind(C)
|
||||||
|
|
||||||
|
integer(C_INT), value :: signal
|
||||||
|
|
||||||
|
|
||||||
|
print'(a,i0)', ' received signal ',signal
|
||||||
|
call signals_setSIGTERM(.true.)
|
||||||
|
|
||||||
|
end subroutine catchSIGTERM
|
||||||
|
|
||||||
|
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
!> @brief Set global variable signals_SIGUSR1 to .true.
|
||||||
|
!> @details This function can be registered to catch signals send to the executable.
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
subroutine catchSIGUSR1(signal) bind(C)
|
||||||
|
|
||||||
|
integer(C_INT), value :: signal
|
||||||
|
|
||||||
|
|
||||||
|
print'(a,i0)', ' received signal ',signal
|
||||||
|
call signals_setSIGUSR1(.true.)
|
||||||
|
|
||||||
|
end subroutine catchSIGUSR1
|
||||||
|
|
||||||
|
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
!> @brief Set global variable signals_SIGUSR2 to .true.
|
||||||
|
!> @details This function can be registered to catch signals send to the executable.
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
subroutine catchSIGUSR2(signal) bind(C)
|
||||||
|
|
||||||
|
integer(C_INT), value :: signal
|
||||||
|
|
||||||
|
|
||||||
|
print'(a,i0,a)', ' received signal ',signal
|
||||||
|
call signals_setSIGUSR2(.true.)
|
||||||
|
|
||||||
|
end subroutine catchSIGUSR2
|
||||||
|
|
||||||
|
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
!> @brief Set global variable signals_SIGTERM.
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
subroutine signals_setSIGTERM(state)
|
||||||
|
|
||||||
|
logical, intent(in) :: state
|
||||||
|
|
||||||
|
|
||||||
|
signals_SIGTERM = state
|
||||||
|
print*, 'set SIGTERM to',state
|
||||||
|
|
||||||
|
end subroutine signals_setSIGTERM
|
||||||
|
|
||||||
|
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
!> @brief Set global variable signals_SIGUSR.
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
subroutine signals_setSIGUSR1(state)
|
||||||
|
|
||||||
|
logical, intent(in) :: state
|
||||||
|
|
||||||
|
|
||||||
|
signals_SIGUSR1 = state
|
||||||
|
print*, 'set SIGUSR1 to',state
|
||||||
|
|
||||||
|
end subroutine signals_setSIGUSR1
|
||||||
|
|
||||||
|
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
!> @brief Set global variable signals_SIGUSR2.
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
subroutine signals_setSIGUSR2(state)
|
||||||
|
|
||||||
|
logical, intent(in) :: state
|
||||||
|
|
||||||
|
|
||||||
|
signals_SIGUSR2 = state
|
||||||
|
print*, 'set SIGUSR2 to',state
|
||||||
|
|
||||||
|
end subroutine signals_setSIGUSR2
|
||||||
|
|
||||||
|
|
||||||
|
end module signals
|
Loading…
Reference in New Issue