[1] | 1 | SUBROUTINE local_stop |
---|
| 2 | |
---|
[3] | 3 | !------------------------------------------------------------------------------! |
---|
[1] | 4 | ! Actual revisions: |
---|
| 5 | ! ----------------- |
---|
| 6 | ! |
---|
[198] | 7 | ! |
---|
[1] | 8 | ! |
---|
| 9 | ! Former revisions: |
---|
| 10 | ! ----------------- |
---|
[3] | 11 | ! $Id: local_stop.f90 198 2008-09-17 08:55:28Z raasch $ |
---|
[110] | 12 | ! |
---|
[198] | 13 | ! 147 2008-02-01 12:41:46Z raasch |
---|
| 14 | ! Bugfix: a stop command was missing in some cases of the parallel branch |
---|
| 15 | ! |
---|
[110] | 16 | ! 108 2007-08-24 15:10:38Z letzel |
---|
| 17 | ! modifications to terminate coupled runs |
---|
| 18 | ! |
---|
[3] | 19 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
| 20 | ! |
---|
[1] | 21 | ! Revision 1.2 2003/03/16 09:40:28 raasch |
---|
| 22 | ! Two underscores (_) are placed in front of all define-strings |
---|
| 23 | ! |
---|
| 24 | ! Revision 1.1 2002/12/19 15:46:23 raasch |
---|
| 25 | ! Initial revision |
---|
| 26 | ! |
---|
| 27 | ! |
---|
| 28 | ! Description: |
---|
| 29 | ! ------------ |
---|
| 30 | ! Stop program execution |
---|
[3] | 31 | !------------------------------------------------------------------------------! |
---|
[1] | 32 | |
---|
| 33 | USE pegrid |
---|
[108] | 34 | USE control_parameters |
---|
[1] | 35 | |
---|
| 36 | #if defined( __parallel ) |
---|
[108] | 37 | IF ( coupling_mode == 'uncoupled' ) THEN |
---|
| 38 | CALL MPI_FINALIZE( ierr ) |
---|
[147] | 39 | STOP |
---|
[108] | 40 | ELSE |
---|
[1] | 41 | |
---|
[108] | 42 | SELECT CASE ( terminate_coupled_remote ) |
---|
| 43 | |
---|
| 44 | CASE ( 0 ) |
---|
| 45 | IF ( myid == 0 ) THEN |
---|
| 46 | PRINT*, '+++ local_stop:' |
---|
| 47 | PRINT*, ' local model "', TRIM( coupling_mode ), & |
---|
| 48 | '" stops now' |
---|
| 49 | ENDIF |
---|
| 50 | ! |
---|
| 51 | !-- Inform the remote model of the termination and its reason, provided |
---|
| 52 | !-- the remote model has not already been informed of another |
---|
| 53 | !-- termination reason (terminate_coupled > 0) before. |
---|
| 54 | IF ( terminate_coupled == 0 ) THEN |
---|
| 55 | terminate_coupled = 1 |
---|
| 56 | CALL MPI_SENDRECV( & |
---|
| 57 | terminate_coupled, 1, MPI_INTEGER, myid, 0, & |
---|
| 58 | terminate_coupled_remote, 1, MPI_INTEGER, myid, 0, & |
---|
| 59 | comm_inter, status, ierr ) |
---|
| 60 | ENDIF |
---|
| 61 | CALL MPI_FINALIZE( ierr ) |
---|
[147] | 62 | STOP |
---|
[108] | 63 | |
---|
| 64 | CASE ( 1 ) |
---|
| 65 | IF ( myid == 0 ) THEN |
---|
| 66 | PRINT*, '+++ local_stop:' |
---|
| 67 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
| 68 | '" stopped' |
---|
| 69 | ENDIF |
---|
| 70 | CALL MPI_FINALIZE( ierr ) |
---|
[147] | 71 | STOP |
---|
[108] | 72 | |
---|
| 73 | CASE ( 2 ) |
---|
| 74 | IF ( myid == 0 ) THEN |
---|
| 75 | PRINT*, '+++ local_stop:' |
---|
| 76 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
| 77 | '" terminated' |
---|
| 78 | PRINT*, ' with stop_dt = .T.' |
---|
| 79 | ENDIF |
---|
| 80 | stop_dt = .TRUE. |
---|
| 81 | |
---|
| 82 | CASE ( 3 ) |
---|
| 83 | IF ( myid == 0 ) THEN |
---|
| 84 | PRINT*, '+++ local_stop:' |
---|
| 85 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
| 86 | '" terminated' |
---|
| 87 | PRINT*, ' with terminate_run = .T. (CPU-time limit)' |
---|
| 88 | ENDIF |
---|
| 89 | terminate_run = .TRUE. |
---|
| 90 | |
---|
| 91 | CASE ( 4 ) |
---|
| 92 | IF ( myid == 0 ) THEN |
---|
| 93 | PRINT*, '+++ local_stop:' |
---|
| 94 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
| 95 | '" terminated' |
---|
| 96 | PRINT*, ' with terminate_run = .T. (restart)' |
---|
| 97 | ENDIF |
---|
| 98 | terminate_run = .TRUE. |
---|
| 99 | time_restart = time_restart + dt_restart |
---|
| 100 | |
---|
| 101 | CASE ( 5 ) |
---|
| 102 | IF ( myid == 0 ) THEN |
---|
| 103 | PRINT*, '+++ local_stop:' |
---|
| 104 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
| 105 | '" terminated' |
---|
| 106 | PRINT*, ' with terminate_run = .T. (single restart)' |
---|
| 107 | ENDIF |
---|
| 108 | terminate_run = .TRUE. |
---|
| 109 | time_restart = 9999999.9 |
---|
| 110 | |
---|
| 111 | END SELECT |
---|
| 112 | |
---|
| 113 | ENDIF |
---|
| 114 | |
---|
| 115 | #else |
---|
| 116 | |
---|
[1] | 117 | STOP |
---|
| 118 | |
---|
[108] | 119 | #endif |
---|
| 120 | |
---|
[1] | 121 | END SUBROUTINE local_stop |
---|