[5310] | 1 | ! /!\ We can't put this in a module right away with FCM1, as this creates a circular dependency e.g. with wxios through iniprint_mod |
---|
| 2 | |
---|
[5246] | 3 | SUBROUTINE abort_gcm(modname, message, ierr) |
---|
| 4 | ! Stops the simulation cleanly, closing files and printing various |
---|
| 5 | ! comments |
---|
[5310] | 6 | |
---|
[5246] | 7 | ! Input: modname = name of calling program |
---|
| 8 | ! message = stuff to print |
---|
| 9 | ! ierr = severity of situation ( = 0 normal ) |
---|
[1632] | 10 | |
---|
[5310] | 11 | USE IOIPSL, ONLY: histclo, restclo, getin_dump |
---|
| 12 | USE wxios_mod, ONLY: using_xios, wxios_close |
---|
| 13 | USE mod_phys_lmdz_mpi_data, ONLY: mpi_rank |
---|
| 14 | USE lmdz_mpi, ONLY: using_mpi |
---|
| 15 | USE mod_const_mpi, ONLY: comm_lmdz |
---|
| 16 | USE iniprint_mod_h, ONLY: lunout, prt_level |
---|
| 17 | IMPLICIT NONE |
---|
[5246] | 18 | |
---|
[5310] | 19 | CHARACTER(LEN = *), INTENT(IN) :: modname |
---|
| 20 | INTEGER, INTENT(IN) :: ierr |
---|
| 21 | CHARACTER(LEN = *), INTENT(IN) :: message |
---|
[4600] | 22 | |
---|
[5310] | 23 | INTEGER :: ierror_mpi |
---|
[5246] | 24 | |
---|
[5310] | 25 | WRITE(lunout, *) 'in abort_gcm' |
---|
| 26 | |
---|
| 27 | !$OMP MASTER |
---|
| 28 | CALL histclo |
---|
| 29 | CALL restclo |
---|
| 30 | IF (mpi_rank == 0) THEN |
---|
| 31 | CALL getin_dump |
---|
| 32 | ENDIF |
---|
| 33 | !$OMP END MASTER |
---|
| 34 | WRITE(lunout, *) 'Stopping in ', modname |
---|
| 35 | WRITE(lunout, *) 'Reason = ', message |
---|
| 36 | IF (ierr == 0) THEN |
---|
| 37 | WRITE(lunout, *) 'Everything is cool' |
---|
| 38 | IF (.NOT. using_mpi) THEN |
---|
| 39 | STOP |
---|
| 40 | END IF |
---|
| 41 | ELSE |
---|
| 42 | WRITE(lunout, *) 'Houston, we have a problem, ierr = ', ierr |
---|
| 43 | |
---|
| 44 | IF (using_mpi) THEN |
---|
| 45 | !$OMP CRITICAL (MPI_ABORT_GCM) |
---|
| 46 | CALL MPI_ABORT(comm_lmdz, 1, ierror_mpi) |
---|
| 47 | !$OMP END CRITICAL (MPI_ABORT_GCM) |
---|
| 48 | ELSE |
---|
| 49 | STOP 1 |
---|
| 50 | END IF |
---|
| 51 | END IF |
---|
[5246] | 52 | END SUBROUTINE abort_gcm |
---|