1 | ! $Id: $ |
---|
2 | SUBROUTINE abort_physic(modname, message, ierr) |
---|
3 | |
---|
4 | USE IOIPSL |
---|
5 | USE mod_phys_lmdz_para |
---|
6 | USE print_control_mod, ONLY: lunout |
---|
7 | IMPLICIT NONE |
---|
8 | |
---|
9 | ! Stops the simulation cleanly, closing files and printing various |
---|
10 | ! comments |
---|
11 | |
---|
12 | ! Input: modname = name of calling program |
---|
13 | ! message = stuff to print |
---|
14 | ! ierr = severity of situation ( = 0 normal ) |
---|
15 | |
---|
16 | character(len=*), intent(in):: modname |
---|
17 | integer ierr, ierror_mpi |
---|
18 | character(len=*), intent(in):: message |
---|
19 | |
---|
20 | write(lunout,*) 'in abort_physic' |
---|
21 | !$OMP MASTER |
---|
22 | CALL histclo |
---|
23 | CALL restclo |
---|
24 | if (mpi_rank .eq. 0) then |
---|
25 | CALL getin_dump |
---|
26 | endif |
---|
27 | !$OMP END MASTER |
---|
28 | |
---|
29 | write(lunout,*) 'Stopping in ', modname |
---|
30 | write(lunout,*) 'Reason = ',message |
---|
31 | if (ierr == 0) then |
---|
32 | write(lunout,*) 'Everything is cool' |
---|
33 | if (using_mpi) then |
---|
34 | !$OMP CRITICAL (MPI_ABORT_PHYSIC) |
---|
35 | CALL MPI_ABORT(COMM_LMDZ_PHY, 0, ierror_mpi) |
---|
36 | !$OMP END CRITICAL (MPI_ABORT_PHYSIC) |
---|
37 | else |
---|
38 | stop 0 |
---|
39 | endif |
---|
40 | else |
---|
41 | write(lunout,*) 'Houston, we have a problem, ierr = ', ierr |
---|
42 | if (using_mpi) then |
---|
43 | !$OMP CRITICAL (MPI_ABORT_PHYSIC) |
---|
44 | CALL MPI_ABORT(COMM_LMDZ_PHY, 1, ierror_mpi) |
---|
45 | !$OMP END CRITICAL (MPI_ABORT_PHYSIC) |
---|
46 | else |
---|
47 | stop 1 |
---|
48 | endif |
---|
49 | endif |
---|
50 | END |
---|