! $Id: abort_gcm.F90 5118 2024-07-24 14:39:59Z abarral $ ! ! SUBROUTINE abort_gcm(modname, message, ierr) USE IOIPSL !! ug Pour les sorties XIOS USE lmdz_wxios USE lmdz_iniprint, ONLY: lunout, prt_level ! ! Stops the simulation cleanly, closing files and printing various ! comments ! ! Input: modname = name of calling program ! message = stuff to print ! ierr = severity of situation ( = 0 normal ) CHARACTER(LEN = *), INTENT(IN) :: modname INTEGER, INTENT(IN) :: ierr CHARACTER(LEN = *), INTENT(IN) :: message WRITE(lunout, *) 'in abort_gcm' IF (using_xios) THEN !Fermeture propre de XIOS CALL wxios_close() ENDIF CALL histclo CALL restclo CALL getin_dump WRITE(lunout, *) 'Stopping in ', modname WRITE(lunout, *) 'Reason = ', message IF (ierr == 0) THEN WRITE(lunout, *) 'Everything is cool' stop else WRITE(lunout, *) 'Houston, we have a problem, ierr = ', ierr stop 1 ENDIF END SUBROUTINE abort_gcm