From 0e65d44bdc39d27653141f3f1453a745d4868cc4 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 23 Apr 2022 14:41:10 +0200 Subject: [PATCH 1/8] separating functionality signal handling and CLI handling are not really related --- src/CPFEM2.f90 | 3 +- src/DAMASK_interface.f90 | 106 +------------------------------- src/grid/DAMASK_grid.f90 | 11 ++-- src/signals.f90 | 128 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 138 insertions(+), 110 deletions(-) create mode 100644 src/signals.f90 diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 index b24ba5480..909da7f1e 100644 --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -5,6 +5,7 @@ !-------------------------------------------------------------------------------------------------- module CPFEM2 use parallelization + use signals use DAMASK_interface use prec use IO @@ -21,7 +22,6 @@ module CPFEM2 use material use phase use homogenization - use discretization #if defined(MESH) use FEM_quadrature @@ -44,6 +44,7 @@ subroutine CPFEM_initAll call parallelization_init call DAMASK_interface_init ! Spectral and FEM interface to commandline + call signals_init call prec_init call IO_init #if defined(MESH) diff --git a/src/DAMASK_interface.f90 b/src/DAMASK_interface.f90 index 1a6bb3ee6..2dee9b13c 100644 --- a/src/DAMASK_interface.f90 +++ b/src/DAMASK_interface.f90 @@ -24,10 +24,6 @@ module DAMASK_interface implicit none private - logical, volatile, public, protected :: & - interface_SIGTERM, & !< termination signal - interface_SIGUSR1, & !< 1. user-defined signal - interface_SIGUSR2 !< 2. user-defined signal integer, public, protected :: & interface_restartInc = 0 !< Increment at which calculation starts character(len=:), allocatable, public, protected :: & @@ -36,10 +32,7 @@ module DAMASK_interface public :: & getSolverJobName, & - DAMASK_interface_init, & - interface_setSIGTERM, & - interface_setSIGUSR1, & - interface_setSIGUSR2 + DAMASK_interface_init contains @@ -197,13 +190,6 @@ subroutine DAMASK_interface_init if (interface_restartInc > 0) & print'(a,i6.6)', ' Restart from increment: ', interface_restartInc - call signalterm_c(c_funloc(catchSIGTERM)) - 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 @@ -376,92 +362,4 @@ function makeRelativePath(a,b) end function makeRelativePath - -!-------------------------------------------------------------------------------------------------- -!> @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 +end module DAMASK_interface diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 39870a8ff..72cc83452 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -15,6 +15,7 @@ program DAMASK_grid use prec use parallelization + use signals use DAMASK_interface use IO use config @@ -448,15 +449,15 @@ program DAMASK_grid print'(/,1x,a,i0,a)', 'increment ', totalIncsCounter, ' NOT converged' 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 (mod(inc,loadCases(l)%f_out) == 0 .or. signal) then print'(/,1x,a)', '... writing results to file ...............................................' flush(IO_STDOUT) call CPFEM_results(totalIncsCounter,t) endif - if (signal) call interface_setSIGUSR1(.false.) - call MPI_Allreduce(interface_SIGUSR2,signal,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI) + if (signal) call signals_setSIGUSR1(.false.) + 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 (mod(inc,loadCases(l)%f_restart) == 0 .or. signal) then do field = 1, nActiveFields @@ -469,8 +470,8 @@ program DAMASK_grid end do call CPFEM_restartWrite endif - if (signal) call interface_setSIGUSR2(.false.) - call MPI_Allreduce(interface_SIGTERM,signal,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI) + if (signal) call signals_setSIGUSR2(.false.) + 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 (signal) exit loadCaseLooping endif skipping diff --git a/src/signals.f90 b/src/signals.f90 new file mode 100644 index 000000000..bf53912f4 --- /dev/null +++ b/src/signals.f90 @@ -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 From b80b406ad5e4deb4e117b35d2868a01b68c64a81 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 23 Apr 2022 14:52:10 +0200 Subject: [PATCH 2/8] more specific name 'interface' can be an interface to anything, 'CLI' is an established abbreviation for 'command line interface' --- src/{DAMASK_interface.f90 => CLI.f90} | 54 +++++++++----------- src/CPFEM2.f90 | 12 ++--- src/grid/DAMASK_grid.f90 | 10 ++-- src/grid/discretization_grid.f90 | 6 +-- src/grid/grid_mech_FEM.f90 | 10 ++-- src/grid/grid_mech_spectral_basic.f90 | 10 ++-- src/grid/grid_mech_spectral_polarisation.f90 | 10 ++-- src/grid/grid_thermal_spectral.f90 | 4 +- 8 files changed, 56 insertions(+), 60 deletions(-) rename src/{DAMASK_interface.f90 => CLI.f90} (89%) diff --git a/src/DAMASK_interface.f90 b/src/CLI.f90 similarity index 89% rename from src/DAMASK_interface.f90 rename to src/CLI.f90 index 2dee9b13c..15b83ab80 100644 --- a/src/DAMASK_interface.f90 +++ b/src/CLI.f90 @@ -1,13 +1,9 @@ !-------------------------------------------------------------------------------------------------- -!> @author Jaeyong Jung, 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 Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH -!> @brief Interfacing between the PETSc-based solvers and the material subroutines provided -!! 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. +!> @author Jaeyong Jung, 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 Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH +!> @brief Parse command line interface for PETSc-based solvers !-------------------------------------------------------------------------------------------------- #define PETSC_MAJOR 3 #define PETSC_MINOR_MIN 12 @@ -25,14 +21,14 @@ module DAMASK_interface implicit none private integer, public, protected :: & - interface_restartInc = 0 !< Increment at which calculation starts + CLI_restartInc = 0 !< Increment at which calculation starts character(len=:), allocatable, public, protected :: & - interface_geomFile, & !< parameter given for geometry file - interface_loadFile !< parameter given for load case file + CLI_geomFile, & !< parameter given for geometry file + CLI_loadFile !< parameter given for load case file public :: & getSolverJobName, & - DAMASK_interface_init + CLI_init contains @@ -40,7 +36,7 @@ contains !> @brief initializes the solver by interpreting the command line arguments. Also writes !! information on computation to screen !-------------------------------------------------------------------------------------------------- -subroutine DAMASK_interface_init +subroutine CLI_init #include #if PETSC_VERSION_MAJOR!=3 || PETSC_VERSION_MINORPETSC_MINOR_MAX @@ -156,8 +152,8 @@ subroutine DAMASK_interface_init call get_command_argument(i+1,workingDirArg,status=err) case ('-r', '--rs', '--restart') call get_command_argument(i+1,arg,status=err) - read(arg,*,iostat=stat) interface_restartInc - if (interface_restartInc < 0 .or. stat /=0) then + read(arg,*,iostat=stat) CLI_restartInc + if (CLI_restartInc < 0 .or. stat /=0) then print'(/,a)', ' ERROR: Could not parse restart increment: '//trim(arg) call quit(1) endif @@ -171,8 +167,8 @@ subroutine DAMASK_interface_init endif if (len_trim(workingDirArg) > 0) call setWorkingDirectory(trim(workingDirArg)) - interface_geomFile = getGeometryFile(geometryArg) - interface_loadFile = getLoadCaseFile(loadCaseArg) + CLI_geomFile = getGeometryFile(geometryArg) + CLI_loadFile = getLoadCaseFile(loadCaseArg) call get_command(commandLine) print'(/,a)', ' Host name: '//getHostName() @@ -184,13 +180,13 @@ subroutine DAMASK_interface_init print'(a)', ' Geometry argument: '//trim(geometryArg) print'(a)', ' Load case argument: '//trim(loadcaseArg) print'(/,a)', ' Working directory: '//getCWD() - print'(a)', ' Geometry file: '//interface_geomFile - print'(a)', ' Load case file: '//interface_loadFile + print'(a)', ' Geometry file: '//CLI_geomFile + print'(a)', ' Load case file: '//CLI_loadFile print'(a)', ' Solver job name: '//getSolverJobName() - if (interface_restartInc > 0) & - print'(a,i6.6)', ' Restart from increment: ', interface_restartInc + if (CLI_restartInc > 0) & + print'(a,i6.6)', ' Restart from increment: ', CLI_restartInc -end subroutine DAMASK_interface_init +end subroutine CLI_init !-------------------------------------------------------------------------------------------------- @@ -229,15 +225,15 @@ function getSolverJobName() character(len=:), allocatable :: getSolverJobName integer :: posExt,posSep - posExt = scan(interface_geomFile,'.',back=.true.) - posSep = scan(interface_geomFile,'/',back=.true.) + posExt = scan(CLI_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.) - posSep = scan(interface_loadFile,'/',back=.true.) + posExt = scan(CLI_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 diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 index 909da7f1e..7bf91c3a8 100644 --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -43,7 +43,7 @@ contains subroutine CPFEM_initAll 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 IO_init @@ -55,18 +55,18 @@ subroutine CPFEM_initAll call YAML_types_init call YAML_parse_init call HDF5_utilities_init - call results_init(restart=interface_restartInc>0) + call results_init(restart=CLI_restartInc>0) call config_init call math_init call rotations_init call polynomials_init call lattice_init #if defined(MESH) - call discretization_mesh_init(restart=interface_restartInc>0) + call discretization_mesh_init(restart=CLI_restartInc>0) #elif defined(GRID) - call discretization_grid_init(restart=interface_restartInc>0) + call discretization_grid_init(restart=CLI_restartInc>0) #endif - call material_init(restart=interface_restartInc>0) + call material_init(restart=CLI_restartInc>0) call phase_init call homogenization_init call CPFEM_init @@ -86,7 +86,7 @@ subroutine CPFEM_init 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) fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r') diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 72cc83452..f28bd324f 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -134,8 +134,8 @@ program DAMASK_grid if (maxCutBack < 0) call IO_error(301,ext_msg='maxCutBack') if (worldrank == 0) then - fileContent = IO_read(interface_loadFile) - fname = interface_loadFile + fileContent = IO_read(CLI_loadFile) + fname = CLI_loadFile if (scan(fname,'/') /= 0) fname = fname(scan(fname,'/',.true.)+1:) call results_openJobFile(parallel=.false.) call results_writeDataset_str(fileContent,'setup',fname,'load case definition (grid solver)') @@ -315,7 +315,7 @@ program DAMASK_grid !-------------------------------------------------------------------------------------------------- ! write header of output file 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') write(statUnit,'(a)') 'Increment Time CutbackLevel Converged IterationsNeeded' ! statistics file else writeHeader @@ -324,7 +324,7 @@ program DAMASK_grid endif writeHeader endif - writeUndeformed: if (interface_restartInc < 1) then + writeUndeformed: if (CLI_restartInc < 1) then print'(/,1x,a)', '... writing initial configuration to file .................................' flush(IO_STDOUT) call CPFEM_results(0,0.0_pReal) @@ -348,7 +348,7 @@ program DAMASK_grid endif 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 guess = .true. ! QUESTION:why forced guessing instead of inheriting loadcase preference else skipping diff --git a/src/grid/discretization_grid.f90 b/src/grid/discretization_grid.f90 index 3cd779ec0..ec119e11a 100644 --- a/src/grid/discretization_grid.f90 +++ b/src/grid/discretization_grid.f90 @@ -76,14 +76,14 @@ subroutine discretization_grid_init(restart) if (worldrank == 0) then - fileContent = IO_read(interface_geomFile) + fileContent = IO_read(CLI_geomFile) call VTI_readCellsSizeOrigin(cells,geomSize,origin,fileContent) materialAt_global = VTI_readDataset_int(fileContent,'material') + 1 if (any(materialAt_global < 1)) & call IO_error(180,ext_msg='material ID < 1') if (size(materialAt_global) /= product(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:) call results_openJobFile(parallel=.false.) call results_writeDataset_str(fileContent,'setup',fname,'geometry definition (grid solver)') @@ -329,7 +329,7 @@ function discretization_grid_getInitialCondition(label) result(ic) displs, sendcounts 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 allocate(ic_global(0)) ! needed for IntelMPI endif diff --git a/src/grid/grid_mech_FEM.f90 b/src/grid/grid_mech_FEM.f90 index 3c42c8c23..cef83e4a3 100644 --- a/src/grid/grid_mech_FEM.f90 +++ b/src/grid/grid_mech_FEM.f90 @@ -231,8 +231,8 @@ subroutine grid_mechanical_FEM_init !-------------------------------------------------------------------------------------------------- ! init fields - restartRead: if (interface_restartInc > 0) then - print'(/,1x,a,i0,a)', 'reading restart data of increment ', interface_restartInc, ' from file' + restartRead: if (CLI_restartInc > 0) then + print'(/,1x,a,i0,a)', 'reading restart data of increment ', CLI_restartInc, ' from file' fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r') 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_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 = spread(spread(spread(math_I3,3,cells(1)),4,cells(2)),5,cells3) endif restartRead @@ -269,8 +269,8 @@ subroutine grid_mechanical_FEM_init call DMDAVecRestoreArrayF90(mechanical_grid,solution_lastInc,u_lastInc,err_PETSc) CHKERRQ(err_PETSc) - restartRead2: if (interface_restartInc > 0) then - print'(1x,a,i0,a)', 'reading more restart data of increment ', interface_restartInc, ' from file' + restartRead2: if (CLI_restartInc > 0) then + 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 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' diff --git a/src/grid/grid_mech_spectral_basic.f90 b/src/grid/grid_mech_spectral_basic.f90 index 2f2b73f01..61d17f6bd 100644 --- a/src/grid/grid_mech_spectral_basic.f90 +++ b/src/grid/grid_mech_spectral_basic.f90 @@ -201,8 +201,8 @@ subroutine grid_mechanical_spectral_basic_init call DMDAVecGetArrayF90(da,solution_vec,F,err_PETSc) ! places pointer on PETSc data CHKERRQ(err_PETSc) - restartRead: if (interface_restartInc > 0) then - print'(/,1x,a,i0,a)', 'reading restart data of increment ', interface_restartInc, ' from file' + restartRead: if (CLI_restartInc > 0) then + print'(/,1x,a,i0,a)', 'reading restart data of increment ', CLI_restartInc, ' from file' fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r') 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_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 = reshape(F_lastInc,[9,cells(1),cells(2),cells3]) end if restartRead @@ -235,8 +235,8 @@ subroutine grid_mechanical_spectral_basic_init call DMDAVecRestoreArrayF90(da,solution_vec,F,err_PETSc) ! deassociate pointer CHKERRQ(err_PETSc) - restartRead2: if (interface_restartInc > 0) then - print'(1x,a,i0,a)', 'reading more restart data of increment ', interface_restartInc, ' from file' + restartRead2: if (CLI_restartInc > 0) then + 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 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' diff --git a/src/grid/grid_mech_spectral_polarisation.f90 b/src/grid/grid_mech_spectral_polarisation.f90 index b72cc4232..a75a01016 100644 --- a/src/grid/grid_mech_spectral_polarisation.f90 +++ b/src/grid/grid_mech_spectral_polarisation.f90 @@ -223,8 +223,8 @@ subroutine grid_mechanical_spectral_polarisation_init F => FandF_tau(0: 8,:,:,:) F_tau => FandF_tau(9:17,:,:,:) - restartRead: if (interface_restartInc > 0) then - print'(/,1x,a,i0,a)', 'reading restart data of increment ', interface_restartInc, ' from file' + restartRead: if (CLI_restartInc > 0) then + print'(/,1x,a,i0,a)', 'reading restart data of increment ', CLI_restartInc, ' from file' fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r') 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_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 = reshape(F_lastInc,[9,cells(1),cells(2),cells3]) 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 CHKERRQ(err_PETSc) - restartRead2: if (interface_restartInc > 0) then - print'(1x,a,i0,a)', 'reading more restart data of increment ', interface_restartInc, ' from file' + restartRead2: if (CLI_restartInc > 0) then + 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 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' diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index 6bbeabf00..18a79820e 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -140,8 +140,8 @@ subroutine grid_thermal_spectral_init() CHKERRQ(err_PETSc) - restartRead: if (interface_restartInc > 0) then - print'(/,1x,a,i0,a)', 'reading restart data of increment ', interface_restartInc, ' from file' + restartRead: if (CLI_restartInc > 0) then + print'(/,1x,a,i0,a)', 'reading restart data of increment ', CLI_restartInc, ' from file' fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r') groupHandle = HDF5_openGroup(fileHandle,'solver') From 91b71fdff8aa38b4669d0b5f03fb2ab18915ecdc Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Apr 2022 04:43:44 +0200 Subject: [PATCH 3/8] systematic naming scheme --- src/CLI.f90 | 6 +++--- src/CPFEM2.f90 | 2 +- src/config.f90 | 14 ++++++-------- src/grid/DAMASK_grid.f90 | 2 +- src/grid/discretization_grid.f90 | 2 +- src/grid/grid_mech_FEM.f90 | 2 +- src/grid/grid_mech_spectral_basic.f90 | 2 +- src/grid/grid_mech_spectral_polarisation.f90 | 2 +- src/grid/grid_thermal_spectral.f90 | 2 +- src/grid/spectral_utilities.f90 | 2 +- src/mesh/DAMASK_mesh.f90 | 4 ++-- src/mesh/discretization_mesh.f90 | 6 +++--- src/mesh/mesh_mech_FEM.f90 | 2 +- src/results.f90 | 4 +++- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/CLI.f90 b/src/CLI.f90 index 15b83ab80..ff3d7349f 100644 --- a/src/CLI.f90 +++ b/src/CLI.f90 @@ -9,7 +9,7 @@ #define PETSC_MINOR_MIN 12 #define PETSC_MINOR_MAX 17 -module DAMASK_interface +module CLI use, intrinsic :: ISO_fortran_env use PETScSys @@ -60,7 +60,7 @@ subroutine CLI_init quit - print'(/,1x,a)', '<<<+- DAMASK_interface init -+>>>' + print'(/,1x,a)', '<<<+- CLI init -+>>>' ! http://patorjk.com/software/taag/#p=display&f=Lean&t=DAMASK%203 #ifdef DEBUG @@ -358,4 +358,4 @@ function makeRelativePath(a,b) end function makeRelativePath -end module DAMASK_interface +end module CLI diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 index 7bf91c3a8..186441f3a 100644 --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -6,7 +6,7 @@ module CPFEM2 use parallelization use signals - use DAMASK_interface + use CLI use prec use IO use YAML_types diff --git a/src/config.f90 b/src/config.f90 index aaf6fee1a..767e3e6c9 100644 --- a/src/config.f90 +++ b/src/config.f90 @@ -1,8 +1,6 @@ !-------------------------------------------------------------------------------------------------- !> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH -!> @brief Reads in the material, numerics & debug configuration from their respective file -!> @details Reads the material configuration file, where solverJobName.yaml takes -!! precedence over material.yaml. +!> @brief Read in the material, numerics & debug configuration from their respective file !-------------------------------------------------------------------------------------------------- module config use IO @@ -28,19 +26,19 @@ contains !-------------------------------------------------------------------------------------------------- !> @brief Real *.yaml configuration files. !-------------------------------------------------------------------------------------------------- -subroutine config_init +subroutine config_init() print'(/,1x,a)', '<<<+- config init -+>>>'; flush(IO_STDOUT) - call parse_material - call parse_numerics - call parse_debug + call parse_material() + call parse_numerics() + call parse_debug() end subroutine config_init !-------------------------------------------------------------------------------------------------- -!> @brief Read material.yaml or .yaml. +!> @brief Read material.yaml. !-------------------------------------------------------------------------------------------------- subroutine parse_material() diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index f28bd324f..a290ac194 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -16,7 +16,7 @@ program DAMASK_grid use prec use parallelization use signals - use DAMASK_interface + use CLI use IO use config use math diff --git a/src/grid/discretization_grid.f90 b/src/grid/discretization_grid.f90 index ec119e11a..ddb36a246 100644 --- a/src/grid/discretization_grid.f90 +++ b/src/grid/discretization_grid.f90 @@ -15,7 +15,7 @@ module discretization_grid use parallelization use system_routines use VTI - use DAMASK_interface + use CLI use IO use config use results diff --git a/src/grid/grid_mech_FEM.f90 b/src/grid/grid_mech_FEM.f90 index cef83e4a3..53d788987 100644 --- a/src/grid/grid_mech_FEM.f90 +++ b/src/grid/grid_mech_FEM.f90 @@ -15,7 +15,7 @@ module grid_mechanical_FEM use prec use parallelization - use DAMASK_interface + use CLI use IO use HDF5 use HDF5_utilities diff --git a/src/grid/grid_mech_spectral_basic.f90 b/src/grid/grid_mech_spectral_basic.f90 index 61d17f6bd..c0b85d00e 100644 --- a/src/grid/grid_mech_spectral_basic.f90 +++ b/src/grid/grid_mech_spectral_basic.f90 @@ -15,7 +15,7 @@ module grid_mechanical_spectral_basic use prec use parallelization - use DAMASK_interface + use CLI use IO use HDF5 use HDF5_utilities diff --git a/src/grid/grid_mech_spectral_polarisation.f90 b/src/grid/grid_mech_spectral_polarisation.f90 index a75a01016..ec27c7390 100644 --- a/src/grid/grid_mech_spectral_polarisation.f90 +++ b/src/grid/grid_mech_spectral_polarisation.f90 @@ -15,7 +15,7 @@ module grid_mechanical_spectral_polarisation use prec use parallelization - use DAMASK_interface + use CLI use IO use HDF5 use HDF5_utilities diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index 18a79820e..8483fe336 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -16,7 +16,7 @@ module grid_thermal_spectral use prec use parallelization use IO - use DAMASK_interface + use CLI use HDF5_utilities use HDF5 use spectral_utilities diff --git a/src/grid/spectral_utilities.f90 b/src/grid/spectral_utilities.f90 index 4375ec860..c8321f83f 100644 --- a/src/grid/spectral_utilities.f90 +++ b/src/grid/spectral_utilities.f90 @@ -13,7 +13,7 @@ module spectral_utilities #endif use prec - use DAMASK_interface + use CLI use parallelization use math use rotations diff --git a/src/mesh/DAMASK_mesh.f90 b/src/mesh/DAMASK_mesh.f90 index 065eca1cb..85ce0e922 100644 --- a/src/mesh/DAMASK_mesh.f90 +++ b/src/mesh/DAMASK_mesh.f90 @@ -10,7 +10,7 @@ program DAMASK_mesh #include use PetscDM use prec - use DAMASK_interface + use CLI use parallelization use IO use math @@ -104,7 +104,7 @@ program DAMASK_mesh !-------------------------------------------------------------------------------------------------- ! 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) line = fileContent(l) if (IO_isBlank(line)) cycle ! skip empty lines diff --git a/src/mesh/discretization_mesh.f90 b/src/mesh/discretization_mesh.f90 index 70ee28343..b898c4e6b 100644 --- a/src/mesh/discretization_mesh.f90 +++ b/src/mesh/discretization_mesh.f90 @@ -15,7 +15,7 @@ module discretization_mesh use MPI_f08 #endif - use DAMASK_interface + use CLI use parallelization use IO use config @@ -101,9 +101,9 @@ subroutine discretization_mesh_init(restart) debug_ip = config_debug%get_asInt('integrationpoint',defaultVal=1) #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 - 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 CHKERRQ(err_PETSc) call DMGetDimension(globalMesh,dimPlex,err_PETSc) diff --git a/src/mesh/mesh_mech_FEM.f90 b/src/mesh/mesh_mech_FEM.f90 index 8cf9dbfa1..474faa4ae 100644 --- a/src/mesh/mesh_mech_FEM.f90 +++ b/src/mesh/mesh_mech_FEM.f90 @@ -20,7 +20,7 @@ module mesh_mechanical_FEM use FEM_utilities use discretization use discretization_mesh - use DAMASK_interface + use CLI use config use IO use FEM_quadrature diff --git a/src/results.f90 b/src/results.f90 index 9fccff03e..bd7f7d34d 100644 --- a/src/results.f90 +++ b/src/results.f90 @@ -6,17 +6,19 @@ !-------------------------------------------------------------------------------------------------- module results use prec - use DAMASK_interface use parallelization use IO use HDF5_utilities use HDF5 #ifdef PETSC + use CLI #include use PETScSys #if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>14) && !defined(PETSC_HAVE_MPI_F90MODULE_VISIBILITY) use MPI_f08 #endif +#else + use DAMASK_interface #endif implicit none From b4c6ca64fcfabdd98a8819e44281edeb1dbc3cdc Mon Sep 17 00:00:00 2001 From: Daniel Otto de Mentock Date: Mon, 25 Apr 2022 12:00:54 +0200 Subject: [PATCH 4/8] replaced setup.py with setup.cfg file modified .gitlab-ci.yml file to strip away "v" from git describe result --- .gitlab-ci.yml | 3 ++- python/setup.cfg | 31 +++++++++++++++++++++++++++++++ python/setup.py | 36 ------------------------------------ 3 files changed, 33 insertions(+), 37 deletions(-) create mode 100644 python/setup.cfg delete mode 100644 python/setup.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3c736136c..89c22a2f8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -233,7 +233,8 @@ update_revision: - cd $(mktemp -d) - git clone -q git@git.damask.mpie.de:damask/DAMASK.git . - git pull - - export VERSION=$(git describe ${CI_COMMIT_SHA}) + - VERSION=$(git describe ${CI_COMMIT_SHA}) + - export VERSION="${VERSION:1:-1}" - echo ${VERSION} > python/damask/VERSION - > git diff-index --quiet HEAD || diff --git a/python/setup.cfg b/python/setup.cfg new file mode 100644 index 000000000..89a3cacf5 --- /dev/null +++ b/python/setup.cfg @@ -0,0 +1,31 @@ +[metadata] +name = damask +version = file: damask/VERSION +author = The DAMASK team +author_email = damask@mpie.de +url = https://damask.mpie.de +description = DAMASK processing tools +long_description = Pre- and post-processing tools for DAMASK +license: AGPL3 +classifiers = + Intended Audience :: Science/Research + Topic :: Scientific/Engineering + Programming Language :: Python :: 3 + License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+) + Operating System :: OS Independent + +[options] +packages = damask +zip_safe = false +include_package_data = true +python_requires = >= 3.8 +install_requires = + importlib-metadata; python_version<"3.8" + pandas; python_version<="0.24" # requires numpy + numpy; python_version<="1.17" # needed for default_rng + scipy; python_version<="1.2" + h5py; python_version<="2.9" # requires numpy + vtk; python_version<="8.1" + matplotlib; python_version<="3.0" # requires numpy, pillow + pyyaml; python_version<="3.12" +setup_requires = setuptools diff --git a/python/setup.py b/python/setup.py deleted file mode 100644 index abb8053a9..000000000 --- a/python/setup.py +++ /dev/null @@ -1,36 +0,0 @@ -import setuptools -from pathlib import Path -import re - -# https://www.python.org/dev/peps/pep-0440 -with open(Path(__file__).parent/'damask/VERSION') as f: - version = re.sub(r'(-([^-]*)).*$',r'.\2',re.sub(r'^v(\d+\.\d+(\.\d+)?)',r'\1',f.readline().strip())) - -setuptools.setup( - name='damask', - version=version, - author='The DAMASK team', - author_email='damask@mpie.de', - description='DAMASK processing tools', - long_description='Pre- and post-processing tools for DAMASK', - url='https://damask.mpie.de', - packages=setuptools.find_packages(), - include_package_data=True, - python_requires = '>=3.8', - install_requires = [ - 'pandas>=0.24', # requires numpy - 'numpy>=1.17', # needed for default_rng - 'scipy>=1.2', - 'h5py>=2.9', # requires numpy - 'vtk>=8.1', - 'matplotlib>=3.0', # requires numpy, pillow - 'pyyaml>=3.12' - ], - classifiers = [ - 'Intended Audience :: Science/Research', - 'Topic :: Scientific/Engineering', - 'Programming Language :: Python :: 3', - 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)', - 'Operating System :: OS Independent', - ], -) From 59668d2910d203e570a7361f312fbbb130d79cf8 Mon Sep 17 00:00:00 2001 From: Daniel Otto de Mentock Date: Mon, 25 Apr 2022 14:58:15 +0200 Subject: [PATCH 5/8] removed zip_safe = false entry from setup.cfg --- .gitlab-ci.yml | 2 +- python/setup.cfg | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 89c22a2f8..07bad3a12 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -234,7 +234,7 @@ update_revision: - git clone -q git@git.damask.mpie.de:damask/DAMASK.git . - git pull - VERSION=$(git describe ${CI_COMMIT_SHA}) - - export VERSION="${VERSION:1:-1}" + - export VERSION="${VERSION:1}" - echo ${VERSION} > python/damask/VERSION - > git diff-index --quiet HEAD || diff --git a/python/setup.cfg b/python/setup.cfg index 89a3cacf5..30107fd10 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -16,16 +16,15 @@ classifiers = [options] packages = damask -zip_safe = false include_package_data = true python_requires = >= 3.8 install_requires = importlib-metadata; python_version<"3.8" - pandas; python_version<="0.24" # requires numpy - numpy; python_version<="1.17" # needed for default_rng + pandas; python_version<="0.24" # requires numpy + numpy; python_version<="1.17" # needed for default_rng scipy; python_version<="1.2" - h5py; python_version<="2.9" # requires numpy + h5py; python_version<="2.9" # requires numpy vtk; python_version<="8.1" - matplotlib; python_version<="3.0" # requires numpy, pillow + matplotlib; python_version<="3.0" # requires numpy, pillow pyyaml; python_version<="3.12" setup_requires = setuptools From 51996a707e33bbadeb4df5abeefe50e4bbd03af0 Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 26 Apr 2022 11:05:02 +0200 Subject: [PATCH 6/8] [skip ci] updated version information after successful test of 3.0.0-alpha6-252-g59668d291 --- python/damask/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/damask/VERSION b/python/damask/VERSION index 17295dc62..cd494347c 100644 --- a/python/damask/VERSION +++ b/python/damask/VERSION @@ -1 +1 @@ -v3.0.0-alpha6-249-gd2cf972b2 +3.0.0-alpha6-252-g59668d291 From dece12a1a6536ad74c15238fe7f37df3e177c09c Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 26 Apr 2022 12:19:13 -0400 Subject: [PATCH 7/8] remove unused CLI module inclusion --- src/config.f90 | 2 +- src/mesh/mesh_mech_FEM.f90 | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/config.f90 b/src/config.f90 index 767e3e6c9..78723c19f 100644 --- a/src/config.f90 +++ b/src/config.f90 @@ -1,6 +1,6 @@ !-------------------------------------------------------------------------------------------------- !> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH -!> @brief Read in the material, numerics & debug configuration from their respective file +!> @brief Read in the configuration of material, numerics, and debug from their respective file !-------------------------------------------------------------------------------------------------- module config use IO diff --git a/src/mesh/mesh_mech_FEM.f90 b/src/mesh/mesh_mech_FEM.f90 index 474faa4ae..5f02011eb 100644 --- a/src/mesh/mesh_mech_FEM.f90 +++ b/src/mesh/mesh_mech_FEM.f90 @@ -20,7 +20,6 @@ module mesh_mechanical_FEM use FEM_utilities use discretization use discretization_mesh - use CLI use config use IO use FEM_quadrature From af8003525a9f51107a236530bd8a6fb4df8d6099 Mon Sep 17 00:00:00 2001 From: Test User Date: Wed, 27 Apr 2022 01:01:01 +0200 Subject: [PATCH 8/8] [skip ci] updated version information after successful test of 3.0.0-alpha6-258-gea7c8ef23 --- python/damask/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/damask/VERSION b/python/damask/VERSION index cd494347c..b162a769d 100644 --- a/python/damask/VERSION +++ b/python/damask/VERSION @@ -1 +1 @@ -3.0.0-alpha6-252-g59668d291 +3.0.0-alpha6-258-gea7c8ef23