| [3989] | 1 | MODULE stop_pem |
|---|
| [3991] | 2 | !----------------------------------------------------------------------- |
|---|
| 3 | ! NAME |
|---|
| 4 | ! stop_pem |
|---|
| 5 | ! |
|---|
| 6 | ! DESCRIPTION |
|---|
| 7 | ! Clean stopping utilities for PEM: close outputs and report reason. |
|---|
| 8 | ! |
|---|
| 9 | ! AUTHORS & DATE |
|---|
| 10 | ! JB Clement, 2025 |
|---|
| 11 | ! |
|---|
| 12 | ! NOTES |
|---|
| 13 | ! |
|---|
| 14 | !----------------------------------------------------------------------- |
|---|
| [3076] | 15 | |
|---|
| [3991] | 16 | ! DECLARATION |
|---|
| 17 | ! ----------- |
|---|
| [3076] | 18 | implicit none |
|---|
| 19 | |
|---|
| 20 | contains |
|---|
| [3991] | 21 | !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|---|
| [3076] | 22 | |
|---|
| [3989] | 23 | !======================================================================= |
|---|
| 24 | SUBROUTINE stop_clean(modname,message,ierr) |
|---|
| [3991] | 25 | !----------------------------------------------------------------------- |
|---|
| 26 | ! NAME |
|---|
| 27 | ! stop_clean |
|---|
| 28 | ! |
|---|
| 29 | ! DESCRIPTION |
|---|
| 30 | ! Stop simulation cleanly, closing files and printing diagnostics. |
|---|
| 31 | ! |
|---|
| 32 | ! AUTHORS & DATE |
|---|
| 33 | ! JB Clement, 2025 |
|---|
| 34 | ! |
|---|
| 35 | ! NOTES |
|---|
| 36 | ! Taken from Mars PCM. |
|---|
| 37 | !----------------------------------------------------------------------- |
|---|
| [3076] | 38 | |
|---|
| [3991] | 39 | ! DEPENDENCIES |
|---|
| 40 | ! ------------ |
|---|
| [2888] | 41 | #ifdef CPP_IOIPSL |
|---|
| [3076] | 42 | use IOIPSL |
|---|
| [2888] | 43 | #else |
|---|
| [3989] | 44 | ! If not using IOIPSL, we still need to use (a local version of) getin_dump |
|---|
| [3076] | 45 | use ioipsl_getincom |
|---|
| [2888] | 46 | #endif |
|---|
| 47 | #ifdef CPP_XIOS |
|---|
| [3989] | 48 | use wxios ! For XIOS outputs |
|---|
| [2888] | 49 | #endif |
|---|
| 50 | |
|---|
| [3991] | 51 | ! DECLARATION |
|---|
| 52 | ! ----------- |
|---|
| [3076] | 53 | implicit none |
|---|
| 54 | |
|---|
| [2888] | 55 | #include "iniprint.h" |
|---|
| 56 | |
|---|
| [3991] | 57 | ! ARGUMENTS |
|---|
| 58 | ! --------- |
|---|
| 59 | character(*), intent(in) :: modname ! name of calling program |
|---|
| 60 | integer, intent(in) :: ierr ! severity of situation (= 0 normal) |
|---|
| 61 | character(*), intent(in) :: message ! stuff to print |
|---|
| [2888] | 62 | |
|---|
| [3991] | 63 | ! CODE |
|---|
| 64 | ! ---- |
|---|
| [2888] | 65 | #ifdef CPP_XIOS |
|---|
| [3989] | 66 | CALL wxios_close() ! Closing XIOS properly |
|---|
| [2888] | 67 | #endif |
|---|
| 68 | |
|---|
| 69 | #ifdef CPP_IOIPSL |
|---|
| [3989] | 70 | call histclo() |
|---|
| 71 | call restclo() |
|---|
| [2888] | 72 | #endif |
|---|
| [3076] | 73 | |
|---|
| [3989] | 74 | call getin_dump() |
|---|
| 75 | write(lunout,*) 'stop_pem: stopping in ', modname |
|---|
| [3076] | 76 | write(lunout,*) 'Reason = ', message |
|---|
| 77 | if (ierr == 0) then |
|---|
| [3351] | 78 | write(lunout,*) 'Everything is cool!' |
|---|
| [3989] | 79 | error stop |
|---|
| [3076] | 80 | else |
|---|
| [3989] | 81 | write(lunout,*) 'Houston, we have a problem! ierr =', ierr |
|---|
| 82 | error stop 1 |
|---|
| [3076] | 83 | endif |
|---|
| 84 | |
|---|
| [3989] | 85 | END SUBROUTINE stop_clean |
|---|
| 86 | !======================================================================= |
|---|
| [3076] | 87 | |
|---|
| [3989] | 88 | END MODULE stop_pem |
|---|