| 1 | MODULE stop_pem |
|---|
| 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 | !----------------------------------------------------------------------- |
|---|
| 15 | |
|---|
| 16 | ! DECLARATION |
|---|
| 17 | ! ----------- |
|---|
| 18 | implicit none |
|---|
| 19 | |
|---|
| 20 | contains |
|---|
| 21 | !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|---|
| 22 | |
|---|
| 23 | !======================================================================= |
|---|
| 24 | SUBROUTINE stop_clean(modname,message,ierr) |
|---|
| 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 | !----------------------------------------------------------------------- |
|---|
| 38 | |
|---|
| 39 | ! DEPENDENCIES |
|---|
| 40 | ! ------------ |
|---|
| 41 | #ifdef CPP_IOIPSL |
|---|
| 42 | use IOIPSL |
|---|
| 43 | #else |
|---|
| 44 | ! If not using IOIPSL, we still need to use (a local version of) getin_dump |
|---|
| 45 | use ioipsl_getincom |
|---|
| 46 | #endif |
|---|
| 47 | #ifdef CPP_XIOS |
|---|
| 48 | use wxios ! For XIOS outputs |
|---|
| 49 | #endif |
|---|
| 50 | |
|---|
| 51 | ! DECLARATION |
|---|
| 52 | ! ----------- |
|---|
| 53 | implicit none |
|---|
| 54 | |
|---|
| 55 | #include "iniprint.h" |
|---|
| 56 | |
|---|
| 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 |
|---|
| 62 | |
|---|
| 63 | ! CODE |
|---|
| 64 | ! ---- |
|---|
| 65 | #ifdef CPP_XIOS |
|---|
| 66 | CALL wxios_close() ! Closing XIOS properly |
|---|
| 67 | #endif |
|---|
| 68 | |
|---|
| 69 | #ifdef CPP_IOIPSL |
|---|
| 70 | call histclo() |
|---|
| 71 | call restclo() |
|---|
| 72 | #endif |
|---|
| 73 | |
|---|
| 74 | call getin_dump() |
|---|
| 75 | write(lunout,*) 'stop_pem: stopping in ', modname |
|---|
| 76 | write(lunout,*) 'Reason = ', message |
|---|
| 77 | if (ierr == 0) then |
|---|
| 78 | write(lunout,*) 'Everything is cool!' |
|---|
| 79 | error stop |
|---|
| 80 | else |
|---|
| 81 | write(lunout,*) 'Houston, we have a problem! ierr =', ierr |
|---|
| 82 | error stop 1 |
|---|
| 83 | endif |
|---|
| 84 | |
|---|
| 85 | END SUBROUTINE stop_clean |
|---|
| 86 | !======================================================================= |
|---|
| 87 | |
|---|
| 88 | END MODULE stop_pem |
|---|