Skip to content

exit_all not in a module #1142

Description

@hkershaw-brown

At some point the exit logic from utilities should be revisited.
This pull request is skirting around the issue to only deal with fixsystem.

! this routine is either in the null_mpi_utilities_mod.f90, or in
! the mpi_utilities_mod.f90 file, but it is not a module subroutine.
! the mpi files use this module, and you cannot have circular module
! references. the point of this call is that in the mpi multi-task
! case, you want to call MPI_Abort() to kill the other tasks associated
! with this job when you exit. in the non-mpi case, it just calls exit.
interface
subroutine exit_all(exitval)
integer, intent(in) :: exitval
end subroutine exit_all
end interface

Originally posted by @hkershaw-brown in #1121

The logic of utilities and mpi utilities and the orphan exit_all subroutine is not great.

!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
!> NOTE: non-module code, so this subroutine can be called from the
!> utilities module, which this module uses (and cannot have circular refs)
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
!> In case of error, call this instead of the fortran intrinsic exit().
!> It will signal the other MPI tasks that something bad happened and they
!> should also exit.
subroutine exit_all(exit_code)
use mpi_utilities_mod, only : get_dart_mpi_comm
integer, intent(in) :: exit_code
integer :: ierror
! call abort on our communicator
!print *, 'calling abort on comm ', get_dart_mpi_comm()
call MPI_Abort(get_dart_mpi_comm(), exit_code, ierror)
! execution should never get here
end subroutine exit_all

!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
!> NOTE: non-module code, so this subroutine can be called from the
!> utilities module, which this module uses (and cannot have circular refs)
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
!> Call exit with the specified code. NOT PART of the mpi_utilities_mod, so
!> this can be called from any code in the system.
subroutine exit_all(exit_code)
! !!NAG_BLOCK_EDIT START COMMENTED_OUT
! use F90_unix_proc, only : exit
! !!NAG_BLOCK_EDIT END COMMENTED_OUT
integer, intent(in) :: exit_code
call exit(exit_code)
end subroutine exit_all

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions