diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 97c23f6cd..2e4462243 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,8 +17,12 @@ list(APPEND OBJECTFILES $) add_library(PREC OBJECT "prec.f90") list(APPEND OBJECTFILES $) +add_library(QUIT OBJECT "quit.f90") +add_dependencies(QUIT PREC) +list(APPEND OBJECTFILES $) + add_library(DAMASK_INTERFACE OBJECT "DAMASK_interface.f90") -add_dependencies(DAMASK_INTERFACE PREC SYSTEM_ROUTINES) +add_dependencies(DAMASK_INTERFACE QUIT SYSTEM_ROUTINES) list(APPEND OBJECTFILES $) add_library(IO OBJECT "IO.f90") diff --git a/src/DAMASK_FEM.f90 b/src/DAMASK_FEM.f90 index 05668b14a..ba6d70f97 100644 --- a/src/DAMASK_FEM.f90 +++ b/src/DAMASK_FEM.f90 @@ -477,51 +477,3 @@ program DAMASK_FEM call quit(0_pInt) ! no complains ;) end program DAMASK_FEM - - -!-------------------------------------------------------------------------------------------------- -!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH -!> @brief quit subroutine -!> @details exits the program and reports current time and duration. Exit code 0 signals -!> everything is fine. Exit code 1 signals an error, message according to IO_error. Exit code -!> 2 signals no severe problems, but some increments did not converge -!-------------------------------------------------------------------------------------------------- -subroutine quit(stop_id) -#include -#ifdef _OPENMP - use MPI, only: & - MPI_finalize -#endif - use prec, only: & - pInt - use PetscSys - - implicit none - integer(pInt), intent(in) :: stop_id - integer, dimension(8) :: dateAndTime ! type default integer - integer(pInt) :: error = 0_pInt - PetscErrorCode :: ierr = 0 - logical :: ErrorInQuit - - call PETScFinalize(ierr) - if (ierr /= 0) write(6,'(a)') ' Error in PETScFinalize' -#ifdef _OPENMP - call MPI_finalize(error) - if (error /= 0) write(6,'(a)') ' Error in MPI_finalize' -#endif - ErrorInQuit = (ierr /= 0 .or. error /= 0_pInt) - - call date_and_time(values = dateAndTime) - write(6,'(/,a)') 'DAMASK terminated on:' - write(6,'(a,2(i2.2,a),i4.4)') 'Date: ',dateAndTime(3),'/',& - dateAndTime(2),'/',& - dateAndTime(1) - write(6,'(a,2(i2.2,a),i2.2)') 'Time: ',dateAndTime(5),':',& - dateAndTime(6),':',& - dateAndTime(7) - - if (stop_id == 0_pInt .and. .not. ErrorInQuit) stop 0 ! normal termination - if (stop_id == 2_pInt .and. .not. ErrorInQuit) stop 2 ! not all incs converged - stop 1 ! error (message from IO_error) - -end subroutine quit diff --git a/src/DAMASK_spectral.f90 b/src/DAMASK_spectral.f90 index c2858ebc2..0c3a04e04 100644 --- a/src/DAMASK_spectral.f90 +++ b/src/DAMASK_spectral.f90 @@ -632,51 +632,3 @@ program DAMASK_spectral call quit(0_pInt) ! no complains ;) end program DAMASK_spectral - - -!-------------------------------------------------------------------------------------------------- -!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH -!> @brief quit subroutine -!> @details exits the program and reports current time and duration. Exit code 0 signals -!> everything is fine. Exit code 1 signals an error, message according to IO_error. Exit code -!> 2 signals no severe problems, but some increments did not converge -!-------------------------------------------------------------------------------------------------- -subroutine quit(stop_id) -#include -#ifdef _OPENMP - use MPI, only: & - MPI_finalize -#endif - use prec, only: & - pInt - use PetscSys - - implicit none - integer(pInt), intent(in) :: stop_id - integer, dimension(8) :: dateAndTime ! type default integer - integer(pInt) :: error = 0_pInt - PetscErrorCode :: ierr = 0 - logical :: ErrorInQuit - - call PETScFinalize(ierr) - if (ierr /= 0) write(6,'(a)') ' Error in PETScFinalize' -#ifdef _OPENMP - call MPI_finalize(error) - if (error /= 0) write(6,'(a)') ' Error in MPI_finalize' -#endif - ErrorInQuit = (ierr /= 0 .or. error /= 0_pInt) - - call date_and_time(values = dateAndTime) - write(6,'(/,a)') 'DAMASK terminated on:' - write(6,'(a,2(i2.2,a),i4.4)') 'Date: ',dateAndTime(3),'/',& - dateAndTime(2),'/',& - dateAndTime(1) - write(6,'(a,2(i2.2,a),i2.2)') 'Time: ',dateAndTime(5),':',& - dateAndTime(6),':',& - dateAndTime(7) - - if (stop_id == 0_pInt .and. .not. ErrorInQuit) stop 0 ! normal termination - if (stop_id == 2_pInt .and. .not. ErrorInQuit) stop 2 ! not all incs converged - stop 1 ! error (message from IO_error) - -end subroutine quit diff --git a/src/quit.f90 b/src/quit.f90 new file mode 100644 index 000000000..fbe207f64 --- /dev/null +++ b/src/quit.f90 @@ -0,0 +1,44 @@ +!-------------------------------------------------------------------------------------------------- +!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH +!> @brief quit subroutine +!> @details exits the program and reports current time and duration. Exit code 0 signals +!> everything is fine. Exit code 1 signals an error, message according to IO_error. Exit code +!> 2 signals no severe problems, but some increments did not converge +!-------------------------------------------------------------------------------------------------- +subroutine quit(stop_id) +#include +#ifdef _OPENMP + use MPI, only: & + MPI_finalize +#endif + use prec, only: & + pInt + use PetscSys + + implicit none + integer(pInt), intent(in) :: stop_id + integer, dimension(8) :: dateAndTime ! type default integer + integer(pInt) :: error = 0_pInt + PetscErrorCode :: ierr = 0 + + call PETScFinalize(ierr) + CHKERRQ(ierr) +#ifdef _OPENMP + call MPI_finalize(error) + if (error /= 0) write(6,'(a)') ' Error in MPI_finalize' +#endif + + call date_and_time(values = dateAndTime) + write(6,'(/,a)') 'DAMASK terminated on:' + write(6,'(a,2(i2.2,a),i4.4)') 'Date: ',dateAndTime(3),'/',& + dateAndTime(2),'/',& + dateAndTime(1) + write(6,'(a,2(i2.2,a),i2.2)') 'Time: ',dateAndTime(5),':',& + dateAndTime(6),':',& + dateAndTime(7) + + if (stop_id == 0_pInt .and. (ierr /= 0_pInt .and. error /= 0_pInt)) stop 0 ! normal termination + if (stop_id == 2_pInt .and. (ierr /= 0_pInt .and. error /= 0_pInt)) stop 2 ! not all incs converged + stop 1 ! error (message from IO_error) + +end subroutine quit