1 | MODULE stpctl |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE stpctl *** |
---|
4 | !! Ocean run control : gross check of the ocean time stepping |
---|
5 | !!====================================================================== |
---|
6 | !! History : OPA ! 1991-03 (G. Madec) Original code |
---|
7 | !! 6.0 ! 1992-06 (M. Imbard) |
---|
8 | !! 8.0 ! 1997-06 (A.M. Treguier) |
---|
9 | !! NEMO 1.0 ! 2002-06 (G. Madec) F90: Free form and module |
---|
10 | !! 2.0 ! 2009-07 (G. Madec) Add statistic for time-spliting |
---|
11 | !! 3.7 ! 2016-09 (G. Madec) Remove solver |
---|
12 | !! 4.0 ! 2017-04 (G. Madec) regroup global communications |
---|
13 | !!---------------------------------------------------------------------- |
---|
14 | |
---|
15 | !!---------------------------------------------------------------------- |
---|
16 | !! stp_ctl : Control the run |
---|
17 | !!---------------------------------------------------------------------- |
---|
18 | USE oce ! ocean dynamics and tracers variables |
---|
19 | USE dom_oce ! ocean space and time domain variables |
---|
20 | USE c1d ! 1D vertical configuration |
---|
21 | USE diawri ! Standard run outputs (dia_wri_state routine) |
---|
22 | ! |
---|
23 | USE in_out_manager ! I/O manager |
---|
24 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
25 | USE lib_mpp ! distributed memory computing |
---|
26 | USE wet_dry, ONLY : ll_wd, ssh_ref ! reference depth for negative bathy |
---|
27 | |
---|
28 | IMPLICIT NONE |
---|
29 | PRIVATE |
---|
30 | |
---|
31 | PUBLIC stp_ctl ! routine called by step.F90 |
---|
32 | !!---------------------------------------------------------------------- |
---|
33 | !! NEMO/OPA 4.0 , NEMO Consortium (2017) |
---|
34 | !! $Id$ |
---|
35 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
36 | !!---------------------------------------------------------------------- |
---|
37 | CONTAINS |
---|
38 | |
---|
39 | SUBROUTINE stp_ctl( kt, kindic ) |
---|
40 | !!---------------------------------------------------------------------- |
---|
41 | !! *** ROUTINE stp_ctl *** |
---|
42 | !! |
---|
43 | !! ** Purpose : Control the run |
---|
44 | !! |
---|
45 | !! ** Method : - Save the time step in numstp |
---|
46 | !! - Print it each 50 time steps |
---|
47 | !! - Stop the run IF problem encountered by setting indic=-3 |
---|
48 | !! Problems checked: |ssh| maximum larger than 10 m |
---|
49 | !! |U| maximum larger than 10 m/s |
---|
50 | !! negative sea surface salinity |
---|
51 | !! |
---|
52 | !! ** Actions : "time.step" file = last ocean time-step |
---|
53 | !! "run.stat" file = run statistics |
---|
54 | !! nstop indicator sheared among all local domain (lk_mpp=T) |
---|
55 | !!---------------------------------------------------------------------- |
---|
56 | INTEGER, INTENT(in ) :: kt ! ocean time-step index |
---|
57 | INTEGER, INTENT(inout) :: kindic ! error indicator |
---|
58 | !! |
---|
59 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
60 | INTEGER :: iih, ijh ! local integers |
---|
61 | INTEGER :: iiu, iju, iku ! - - |
---|
62 | INTEGER :: iis, ijs, iks ! - - |
---|
63 | REAL(wp) :: zzz ! local real |
---|
64 | INTEGER , DIMENSION(3) :: ilocu, ilocs |
---|
65 | INTEGER , DIMENSION(2) :: iloch |
---|
66 | REAL(wp), DIMENSION(4) :: zmax |
---|
67 | !!---------------------------------------------------------------------- |
---|
68 | ! |
---|
69 | IF( kt == nit000 .AND. lwp ) THEN |
---|
70 | WRITE(numout,*) |
---|
71 | WRITE(numout,*) 'stp_ctl : time-stepping control' |
---|
72 | WRITE(numout,*) '~~~~~~~' |
---|
73 | ! ! open time.step file |
---|
74 | CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
75 | ! ! open run.stat file |
---|
76 | CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
77 | ENDIF |
---|
78 | ! |
---|
79 | IF(lwp) THEN !== current time step ==! ("time.step" file) |
---|
80 | WRITE ( numstp, '(1x, i8)' ) kt |
---|
81 | REWIND( numstp ) |
---|
82 | ENDIF |
---|
83 | ! |
---|
84 | ! !== test of extrema ==! |
---|
85 | IF( ll_wd ) THEN |
---|
86 | zmax(1) = MAXVAL( ABS( sshn(:,:) + ssh_ref*tmask(:,:,1) ) ) ! ssh max |
---|
87 | ELSE |
---|
88 | zmax(1) = MAXVAL( ABS( sshn(:,:) ) ) ! ssh max |
---|
89 | ENDIF |
---|
90 | zmax(2) = MAXVAL( ABS( un(:,:,:) ) ) ! velocity max (zonal only) |
---|
91 | zmax(3) = MAXVAL( -tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp ) ! minus salinity max |
---|
92 | zmax(4) = REAL( nstop , wp ) ! stop indicator |
---|
93 | ! |
---|
94 | IF( lk_mpp ) THEN |
---|
95 | CALL mpp_max_multiple( zmax(:), 4 ) ! max over the global domain |
---|
96 | ! |
---|
97 | nstop = INT( zmax(4) ) ! nstop indicator sheared among all local domains |
---|
98 | ENDIF |
---|
99 | ! |
---|
100 | IF( MOD( kt, nwrite ) == 1 .AND. lwp ) THEN |
---|
101 | WRITE(numout,*) ' ==>> time-step= ', kt, ' |ssh| max: ', zmax(1), ' |U| max: ', zmax(2), & |
---|
102 | & ' S min: ' , - zmax(3) |
---|
103 | ENDIF |
---|
104 | ! |
---|
105 | IF ( zmax(1) > 15._wp .OR. & ! too large sea surface height ( > 10 m) |
---|
106 | & zmax(2) > 10._wp .OR. & ! too large velocity ( > 10 m/s) |
---|
107 | & zmax(3) >= 0._wp .OR. & ! negative or zero sea surface salinity |
---|
108 | & ISNAN( zmax(1) + zmax(2) + zmax(3) ) ) THEN ! NaN encounter in the tests |
---|
109 | IF( lk_mpp ) THEN |
---|
110 | CALL mpp_maxloc( ABS(sshn) , ssmask(:,:) , zzz, iih, ijh ) |
---|
111 | CALL mpp_maxloc( ABS(un) , umask (:,:,:), zzz, iiu, iju, iku ) |
---|
112 | CALL mpp_minloc( tsn(:,:,:,jp_sal), tmask (:,:,:), zzz, iis, ijs, iks ) |
---|
113 | ELSE |
---|
114 | iloch = MINLOC( ABS( sshn(:,:) ) ) |
---|
115 | ilocu = MAXLOC( ABS( un (:,:,:) ) ) |
---|
116 | ilocs = MINLOC( tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp ) |
---|
117 | iih = iloch(1) + nimpp - 1 ; ijh = iloch(2) + njmpp - 1 |
---|
118 | iiu = ilocu(1) + nimpp - 1 ; iju = ilocu(2) + njmpp - 1 ; iku = ilocu(3) |
---|
119 | iis = ilocs(1) + nimpp - 1 ; ijs = ilocs(2) + njmpp - 1 ; iks = ilocu(3) |
---|
120 | ENDIF |
---|
121 | IF(lwp) THEN |
---|
122 | WRITE(numout,cform_err) |
---|
123 | WRITE(numout,*) ' stp_ctl: |ssh| > 10 m or |U| > 10 m/s or S < 0 or NaN encounter in the tests' |
---|
124 | WRITE(numout,*) ' ======= ' |
---|
125 | WRITE(numout,9100) kt, zmax(1), iih, ijh |
---|
126 | WRITE(numout,9200) kt, zmax(2), iiu, iju, iku |
---|
127 | WRITE(numout,9300) kt, - zmax(3), iis, ijs, iks |
---|
128 | WRITE(numout,*) |
---|
129 | WRITE(numout,*) ' output of last computed fields in output.abort.nc file' |
---|
130 | ENDIF |
---|
131 | kindic = -3 |
---|
132 | ! |
---|
133 | nstop = nstop + 1 ! increase nstop by 1 (on all local domains) |
---|
134 | CALL dia_wri_state( 'output.abort', kt ) ! create an output.abort file |
---|
135 | ! |
---|
136 | ENDIF |
---|
137 | 9100 FORMAT (' kt=',i8,' |ssh| max: ',1pg11.4,', at i j : ',2i5) |
---|
138 | 9200 FORMAT (' kt=',i8,' |U| max: ',1pg11.4,', at i j k: ',3i5) |
---|
139 | 9300 FORMAT (' kt=',i8,' S min: ',1pg11.4,', at i j : ',2i5) |
---|
140 | ! |
---|
141 | ! !== run statistics ==! ("run.stat" file) |
---|
142 | IF(lwp) WRITE(numrun,9400) kt, zmax(1), zmax(2), - zmax(3) |
---|
143 | ! |
---|
144 | 9400 FORMAT(' it :', i8, ' |ssh|_max: ', e16.10, ' |U|_max: ',e16.10,' S_min: ',e16.10) |
---|
145 | ! |
---|
146 | END SUBROUTINE stp_ctl |
---|
147 | |
---|
148 | !!====================================================================== |
---|
149 | END MODULE stpctl |
---|