clean termination in case of MPI runs (no deadlock)
This commit is contained in:
parent
1add486115
commit
784cd3405e
30
src/quit.f90
30
src/quit.f90
|
@ -22,23 +22,16 @@ subroutine quit(stop_id)
|
|||
|
||||
integer, dimension(8) :: dateAndTime
|
||||
integer :: err_HDF5
|
||||
integer(MPI_INTEGER_KIND) :: err_MPI
|
||||
integer(MPI_INTEGER_KIND) :: err_MPI, worldsize
|
||||
PetscErrorCode :: err_PETSc
|
||||
|
||||
call h5open_f(err_HDF5)
|
||||
if (err_HDF5 /= 0_MPI_INTEGER_KIND) write(6,'(a,i5)') ' Error in h5open_f ',err_HDF5 ! prevents error if not opened yet
|
||||
|
||||
call h5open_f(err_HDF5) ! prevents error if not opened yet
|
||||
if (err_HDF5 /= 0) write(6,'(a,i5)') ' Error in h5open_f ',err_HDF5
|
||||
call h5close_f(err_HDF5)
|
||||
if (err_HDF5 /= 0_MPI_INTEGER_KIND) write(6,'(a,i5)') ' Error in h5close_f ',err_HDF5
|
||||
if (err_HDF5 /= 0) write(6,'(a,i5)') ' Error in h5close_f ',err_HDF5
|
||||
|
||||
call PetscFinalize(err_PETSc)
|
||||
CHKERRQ(err_PETSc)
|
||||
|
||||
#ifdef _OPENMP
|
||||
call MPI_finalize(err_MPI)
|
||||
if (err_MPI /= 0_MPI_INTEGER_KIND) write(6,'(a,i5)') ' Error in MPI_finalize',err_MPI
|
||||
#else
|
||||
err_MPI = 0_MPI_INTEGER_KIND
|
||||
#endif
|
||||
|
||||
call date_and_time(values = dateAndTime)
|
||||
write(6,'(/,a)') ' DAMASK terminated on:'
|
||||
|
@ -49,10 +42,15 @@ subroutine quit(stop_id)
|
|||
dateAndTime(6),':',&
|
||||
dateAndTime(7)
|
||||
|
||||
if (stop_id == 0 .and. &
|
||||
err_HDF5 == 0 .and. &
|
||||
err_MPI == 0_MPI_INTEGER_KIND .and. &
|
||||
err_PETSC == 0) stop 0 ! normal termination
|
||||
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
|
||||
|
||||
end subroutine quit
|
||||
|
|
Loading…
Reference in New Issue