| 1 | MODULE stop_pem |
|---|
| 2 | |
|---|
| 3 | implicit none |
|---|
| 4 | |
|---|
| 5 | !======================================================================= |
|---|
| 6 | contains |
|---|
| 7 | !======================================================================= |
|---|
| 8 | |
|---|
| 9 | !======================================================================= |
|---|
| 10 | SUBROUTINE stop_clean(modname,message,ierr) |
|---|
| 11 | ! Stop the simulation cleanly, closing files and printing various comments |
|---|
| 12 | ! Inputs: modname = name of calling program |
|---|
| 13 | ! message = stuff to print |
|---|
| 14 | ! ierr = severity of situation (= 0 normal) |
|---|
| 15 | |
|---|
| 16 | #ifdef CPP_IOIPSL |
|---|
| 17 | use IOIPSL |
|---|
| 18 | #else |
|---|
| 19 | ! If not using IOIPSL, we still need to use (a local version of) getin_dump |
|---|
| 20 | use ioipsl_getincom |
|---|
| 21 | #endif |
|---|
| 22 | |
|---|
| 23 | #ifdef CPP_XIOS |
|---|
| 24 | use wxios ! For XIOS outputs |
|---|
| 25 | #endif |
|---|
| 26 | |
|---|
| 27 | implicit none |
|---|
| 28 | |
|---|
| 29 | #include "iniprint.h" |
|---|
| 30 | |
|---|
| 31 | ! Arguments |
|---|
| 32 | !---------- |
|---|
| 33 | character(*), intent(in) :: modname |
|---|
| 34 | integer, intent(in) :: ierr |
|---|
| 35 | character(*), intent(in) :: message |
|---|
| 36 | |
|---|
| 37 | ! Code |
|---|
| 38 | !----- |
|---|
| 39 | #ifdef CPP_XIOS |
|---|
| 40 | CALL wxios_close() ! Closing XIOS properly |
|---|
| 41 | #endif |
|---|
| 42 | |
|---|
| 43 | #ifdef CPP_IOIPSL |
|---|
| 44 | call histclo() |
|---|
| 45 | call restclo() |
|---|
| 46 | #endif |
|---|
| 47 | |
|---|
| 48 | call getin_dump() |
|---|
| 49 | write(lunout,*) 'stop_pem: stopping in ', modname |
|---|
| 50 | write(lunout,*) 'Reason = ', message |
|---|
| 51 | if (ierr == 0) then |
|---|
| 52 | write(lunout,*) 'Everything is cool!' |
|---|
| 53 | error stop |
|---|
| 54 | else |
|---|
| 55 | write(lunout,*) 'Houston, we have a problem! ierr =', ierr |
|---|
| 56 | error stop 1 |
|---|
| 57 | endif |
|---|
| 58 | |
|---|
| 59 | END SUBROUTINE stop_clean |
|---|
| 60 | !======================================================================= |
|---|
| 61 | |
|---|
| 62 | END MODULE stop_pem |
|---|