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 #ifdef CPP_XIOS use wxios ! For XIOS outputs #endif ! 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 ! CODE ! ---- #ifdef CPP_XIOS CALL wxios_close() ! Closing XIOS properly #endif #ifdef CPP_IOIPSL call histclo() call restclo() #endif call getin_dump() write(lunout,'(a,i5,a)') ' Stopping in "'//fname//'" at line ',fline,'.' write(lunout,'(a)') ' Reason: '//message if (ierr == 0) then write(lunout,'(a)') ' Everything is cool!' error stop ierr else write(lunout,'(a,i4)') ' Houston, we have a problem! Error code = ',ierr error stop ierr end if END SUBROUTINE stop_clean !======================================================================= END MODULE stoppage