2018-09-27 23:39:59 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @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
|
2020-01-02 18:09:52 +05:30
|
|
|
!> everything is fine. Exit code 1 signals an error, message according to IO_error.
|
2018-09-27 23:39:59 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
subroutine quit(stop_id)
|
2023-01-23 16:15:03 +05:30
|
|
|
use, intrinsic :: ISO_fortran_env, only: ERROR_UNIT
|
2018-09-27 23:39:59 +05:30
|
|
|
#include <petsc/finclude/petscsys.h>
|
2021-07-22 03:13:55 +05:30
|
|
|
use PETScSys
|
|
|
|
#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>14) && !defined(PETSC_HAVE_MPI_F90MODULE_VISIBILITY)
|
|
|
|
use MPI_f08
|
|
|
|
#endif
|
2020-01-03 01:48:56 +05:30
|
|
|
use HDF5
|
2018-10-09 17:43:51 +05:30
|
|
|
|
2022-06-22 02:41:22 +05:30
|
|
|
#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>14) && !defined(PETSC_HAVE_MPI_F90MODULE_VISIBILITY)
|
2022-06-22 02:16:54 +05:30
|
|
|
implicit none(type,external)
|
2022-06-22 02:41:22 +05:30
|
|
|
#else
|
|
|
|
implicit none
|
|
|
|
#endif
|
|
|
|
|
2019-06-16 00:02:53 +05:30
|
|
|
integer, intent(in) :: stop_id
|
2022-06-22 02:41:22 +05:30
|
|
|
|
2019-06-16 00:02:53 +05:30
|
|
|
integer, dimension(8) :: dateAndTime
|
2022-01-13 12:47:31 +05:30
|
|
|
integer :: err_HDF5
|
2022-09-11 03:23:59 +05:30
|
|
|
integer(MPI_INTEGER_KIND) :: err_MPI, worldsize
|
2022-01-13 12:47:31 +05:30
|
|
|
PetscErrorCode :: err_PETSc
|
2022-05-27 03:55:25 +05:30
|
|
|
|
2022-09-11 03:23:59 +05:30
|
|
|
|
|
|
|
call h5open_f(err_HDF5) ! prevents error if not opened yet
|
2023-04-18 15:31:03 +05:30
|
|
|
if (err_HDF5 < 0) write(ERROR_UNIT,'(a,i5)') ' Error in h5open_f ',err_HDF5
|
2022-01-13 12:47:31 +05:30
|
|
|
call h5close_f(err_HDF5)
|
2023-04-18 15:31:03 +05:30
|
|
|
if (err_HDF5 < 0) write(ERROR_UNIT,'(a,i5)') ' Error in h5close_f ',err_HDF5
|
2022-05-27 03:55:25 +05:30
|
|
|
|
2022-01-13 12:47:31 +05:30
|
|
|
call PetscFinalize(err_PETSc)
|
2022-05-27 03:55:25 +05:30
|
|
|
|
2019-06-16 00:02:53 +05:30
|
|
|
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)
|
2022-05-27 03:55:25 +05:30
|
|
|
|
2022-09-11 03:23:59 +05:30
|
|
|
if (stop_id == 0 .and. err_HDF5 == 0 .and. err_PETSC == 0) then
|
|
|
|
call MPI_Finalize(err_MPI)
|
|
|
|
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI_Finalize error'
|
|
|
|
stop 0 ! normal termination
|
|
|
|
else
|
|
|
|
call MPI_Comm_size(MPI_COMM_WORLD,worldsize,err_MPI)
|
|
|
|
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI_Comm error'
|
|
|
|
if (stop_id /= 0 .and. worldsize > 1) call MPI_Abort(MPI_COMM_WORLD,1,err_MPI)
|
|
|
|
stop 1 ! error (message from IO_error)
|
|
|
|
endif
|
2018-09-27 23:39:59 +05:30
|
|
|
|
|
|
|
end subroutine quit
|