MODULE stoppage !----------------------------------------------------------------------- ! NAME ! stoppage ! ! DESCRIPTION ! Clean stopping utilities for PEM: close outputs and report reason. ! ! AUTHORS & DATE ! JB Clement, 2025 ! ! NOTES ! !----------------------------------------------------------------------- ! DEPENDENCIES ! ------------ use numerics, only: di ! DECLARATION ! ----------- implicit none contains !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ !======================================================================= SUBROUTINE stop_clean(fname,fline,message,ierr) !----------------------------------------------------------------------- ! NAME ! stop_clean ! ! DESCRIPTION ! Stop simulation cleanly, closing files and printing diagnostics. ! ! AUTHORS & DATE ! JB Clement, 2025 ! ! NOTES ! Taken from Mars PCM. !----------------------------------------------------------------------- ! DEPENDENCIES ! ------------ #ifdef CPP_IOIPSL use IOIPSL #else ! If not using IOIPSL, we still need to use (a local version of) getin_dump use ioipsl_getincom #endif use display, only: print_msg, LVL_ERR ! DECLARATION ! ----------- implicit none #include "iniprint.h" ! ARGUMENTS ! --------- character(*), intent(in) :: fname ! Name of file integer(di), intent(in) :: fline ! Line number of file integer(di), intent(in) :: ierr ! Severity of situation (= 0 normal) character(*), intent(in) :: message ! Message to print ! LOCAL VARIABLES ! --------------- character(100) :: msg ! CODE ! ---- #ifdef CPP_IOIPSL call histclo() call restclo() #endif call getin_dump() write(msg,'(a,i5,a)') 'Stopping in "'//fname//'" at line ',fline,'.' call print_msg(msg,LVL_ERR) call print_msg('Reason: '//message,LVL_ERR) write(msg,'(a,i3)') 'Houston, we have a problem! Error code = ',ierr call print_msg(msg,LVL_ERR) error stop ierr END SUBROUTINE stop_clean !======================================================================= END MODULE stoppage