Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/mpas-framework/src/framework/framework.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# framework
list(APPEND CPPDEFS "-Dcoupled")
list(APPEND COMMON_RAW_SOURCES
framework/mpas_kind_types.F
framework/mpas_framework.F
Expand Down
62 changes: 36 additions & 26 deletions components/mpas-framework/src/framework/mpas_abort.F
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ subroutine mpas_dmpar_global_abort(mesg, deferredAbort)!{{{
use mpas_kind_types, only : StrKIND
use mpas_io_units, only : mpas_new_unit
use mpas_threading, only : mpas_threading_get_thread_num

#ifdef coupled
use shr_sys_mod, only : shr_sys_abort
#endif

#ifdef _MPI
#ifndef NOMPIMOD
Expand All @@ -44,7 +48,7 @@ subroutine mpas_dmpar_global_abort(mesg, deferredAbort)!{{{
#endif
#endif

character(len=*), intent(in) :: mesg !< Input: Abort message
character(len=*), intent(in), optional :: mesg !< Input: Abort message
logical, intent(in), optional :: deferredAbort !< Input: Defer call to abort until later

integer :: threadNum
Expand All @@ -63,40 +67,46 @@ subroutine mpas_dmpar_global_abort(mesg, deferredAbort)!{{{
local_deferredAbort = .false.
end if

threadNum = mpas_threading_get_thread_num()
if (present(mesg)) then
threadNum = mpas_threading_get_thread_num()

#ifdef _MPI
call MPI_Comm_rank(MPI_COMM_WORLD, my_proc_id, mpi_ierr)
call MPI_Comm_size(MPI_COMM_WORLD, nprocs, mpi_ierr)
if (nprocs < 1E4) then
write(errorFile,fmt='(a,i4.4,a)') 'log.', my_proc_id, '.abort'
else if (nprocs < 1E5) then
write(errorFile,fmt='(a,i5.5,a)') 'log.', my_proc_id, '.abort'
else if (nprocs < 1E6) then
write(errorFile,fmt='(a,i6.6,a)') 'log.', my_proc_id, '.abort'
else if (nprocs < 1E7) then
write(errorFile,fmt='(a,i7.7,a)') 'log.', my_proc_id, '.abort'
else if (nprocs < 1E8) then
write(errorFile,fmt='(a,i8.8,a)') 'log.', my_proc_id, '.abort'
else
write(errorFile,fmt='(a,i9.9,a)') 'log.', my_proc_id, '.abort'
end if
call MPI_Comm_rank(MPI_COMM_WORLD, my_proc_id, mpi_ierr)
call MPI_Comm_size(MPI_COMM_WORLD, nprocs, mpi_ierr)
if (nprocs < 1E4) then
write(errorFile,fmt='(a,i4.4,a)') 'log.', my_proc_id, '.abort'
else if (nprocs < 1E5) then
write(errorFile,fmt='(a,i5.5,a)') 'log.', my_proc_id, '.abort'
else if (nprocs < 1E6) then
write(errorFile,fmt='(a,i6.6,a)') 'log.', my_proc_id, '.abort'
else if (nprocs < 1E7) then
write(errorFile,fmt='(a,i7.7,a)') 'log.', my_proc_id, '.abort'
else if (nprocs < 1E8) then
write(errorFile,fmt='(a,i8.8,a)') 'log.', my_proc_id, '.abort'
else
write(errorFile,fmt='(a,i9.9,a)') 'log.', my_proc_id, '.abort'
end if
#else
errorFile = 'log.abort'
errorFile = 'log.abort'
#endif

if ( threadNum == 0 ) then
call mpas_new_unit(errorUnit)
open(unit=errorUnit, file=trim(errorFile), form='formatted', position='append')
write(errorUnit,*) trim(mesg)
close(errorUnit)
if ( threadNum == 0 ) then
call mpas_new_unit(errorUnit)
open(unit=errorUnit, file=trim(errorFile), form='formatted', position='append')
write(errorUnit,*) trim(mesg)
close(errorUnit)
end if
end if

if (.not. local_deferredAbort) then
#ifdef _MPI
call MPI_Abort(MPI_COMM_WORLD, mpi_errcode, mpi_ierr)
#ifdef coupled
call shr_sys_abort('MPAS framework abort')
#else
stop
#ifdef _MPI
call MPI_Abort(MPI_COMM_WORLD, mpi_errcode, mpi_ierr)
#else
stop
#endif
#endif
end if

Expand Down
6 changes: 1 addition & 5 deletions components/mpas-framework/src/framework/mpas_log.F
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,7 @@ subroutine log_abort()
deallocate(mpas_log_info % outputLog)
deallocate(mpas_log_info)

#ifdef _MPI
call MPI_Abort(MPI_COMM_WORLD, mpi_errcode, mpi_ierr)
#else
stop
#endif
call mpas_dmpar_global_abort()

!--------------------------------------------------------------------
end subroutine log_abort
Expand Down