| 1 | MODULE stoppage |
|---|
| 2 | !----------------------------------------------------------------------- |
|---|
| 3 | ! NAME |
|---|
| 4 | ! stoppage |
|---|
| 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 | ! DEPENDENCIES |
|---|
| 17 | ! ------------ |
|---|
| 18 | use numerics, only: di |
|---|
| 19 | |
|---|
| 20 | ! DECLARATION |
|---|
| 21 | ! ----------- |
|---|
| 22 | implicit none |
|---|
| 23 | |
|---|
| 24 | contains |
|---|
| 25 | !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|---|
| 26 | |
|---|
| 27 | !======================================================================= |
|---|
| 28 | SUBROUTINE stop_clean(fname,fline,message,ierr) |
|---|
| 29 | !----------------------------------------------------------------------- |
|---|
| 30 | ! NAME |
|---|
| 31 | ! stop_clean |
|---|
| 32 | ! |
|---|
| 33 | ! DESCRIPTION |
|---|
| 34 | ! Stop simulation cleanly, closing files and printing diagnostics. |
|---|
| 35 | ! |
|---|
| 36 | ! AUTHORS & DATE |
|---|
| 37 | ! JB Clement, 2025 |
|---|
| 38 | ! |
|---|
| 39 | ! NOTES |
|---|
| 40 | ! Taken from Mars PCM. |
|---|
| 41 | !----------------------------------------------------------------------- |
|---|
| 42 | |
|---|
| 43 | ! DEPENDENCIES |
|---|
| 44 | ! ------------ |
|---|
| 45 | #ifdef CPP_IOIPSL |
|---|
| 46 | use IOIPSL |
|---|
| 47 | #else |
|---|
| 48 | ! If not using IOIPSL, we still need to use (a local version of) getin_dump |
|---|
| 49 | use ioipsl_getincom |
|---|
| 50 | #endif |
|---|
| 51 | #ifdef CPP_XIOS |
|---|
| 52 | use wxios ! For XIOS outputs |
|---|
| 53 | #endif |
|---|
| 54 | |
|---|
| 55 | ! DECLARATION |
|---|
| 56 | ! ----------- |
|---|
| 57 | implicit none |
|---|
| 58 | |
|---|
| 59 | #include "iniprint.h" |
|---|
| 60 | |
|---|
| 61 | ! ARGUMENTS |
|---|
| 62 | ! --------- |
|---|
| 63 | character(*), intent(in) :: fname ! Name of file |
|---|
| 64 | integer(di), intent(in) :: fline ! Line number of file |
|---|
| 65 | integer(di), intent(in) :: ierr ! Severity of situation (= 0 normal) |
|---|
| 66 | character(*), intent(in) :: message ! Message to print |
|---|
| 67 | |
|---|
| 68 | ! CODE |
|---|
| 69 | ! ---- |
|---|
| 70 | #ifdef CPP_XIOS |
|---|
| 71 | CALL wxios_close() ! Closing XIOS properly |
|---|
| 72 | #endif |
|---|
| 73 | |
|---|
| 74 | #ifdef CPP_IOIPSL |
|---|
| 75 | call histclo() |
|---|
| 76 | call restclo() |
|---|
| 77 | #endif |
|---|
| 78 | |
|---|
| 79 | call getin_dump() |
|---|
| 80 | write(lunout,'(a,i5,a)') ' Stopping in "'//fname//'" at line ',fline,'.' |
|---|
| 81 | write(lunout,'(a)') ' Reason: '//message |
|---|
| 82 | if (ierr == 0) then |
|---|
| 83 | write(lunout,'(a)') ' Everything is cool!' |
|---|
| 84 | error stop ierr |
|---|
| 85 | else |
|---|
| 86 | write(lunout,'(a,i4)') ' Houston, we have a problem! Error code = ',ierr |
|---|
| 87 | error stop ierr |
|---|
| 88 | end if |
|---|
| 89 | |
|---|
| 90 | END SUBROUTINE stop_clean |
|---|
| 91 | !======================================================================= |
|---|
| 92 | |
|---|
| 93 | END MODULE stoppage |
|---|