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 | !!---------------------------------------------------------------------- |
---|
12 | |
---|
13 | !!---------------------------------------------------------------------- |
---|
14 | !! stp_ctl : Control the run |
---|
15 | !!---------------------------------------------------------------------- |
---|
16 | USE oce ! ocean dynamics and tracers variables |
---|
17 | USE dom_oce ! ocean space and time domain variables |
---|
18 | USE sol_oce ! ocean space and time domain variables |
---|
19 | USE sbc_oce ! surface boundary conditions variables |
---|
20 | USE in_out_manager ! I/O manager |
---|
21 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
22 | USE lib_mpp ! distributed memory computing |
---|
23 | USE dynspg_oce ! pressure gradient schemes |
---|
24 | USE c1d ! 1D vertical configuration |
---|
25 | |
---|
26 | |
---|
27 | IMPLICIT NONE |
---|
28 | PRIVATE |
---|
29 | |
---|
30 | PUBLIC stp_ctl ! routine called by step.F90 |
---|
31 | !!---------------------------------------------------------------------- |
---|
32 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
33 | !! $Id$ |
---|
34 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
35 | !!---------------------------------------------------------------------- |
---|
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 | !! - Print solver statistics in numsol |
---|
48 | !! - Stop the run IF problem for the solver ( indec < 0 ) |
---|
49 | !! |
---|
50 | !! ** Actions : 'time.step' file containing the last ocean time-step |
---|
51 | !! |
---|
52 | !!---------------------------------------------------------------------- |
---|
53 | INTEGER, INTENT( in ) :: kt ! ocean time-step index |
---|
54 | INTEGER, INTENT( inout ) :: kindic ! indicator of solver convergence |
---|
55 | !! |
---|
56 | CHARACTER(len = 32) :: clfname ! time stepping output file name |
---|
57 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
58 | INTEGER :: ii, ij, ik ! temporary integers |
---|
59 | REAL(wp) :: zumax, zsmin, zssh2 ! temporary scalars |
---|
60 | REAL(wp) :: ztmax, ztmin ! temporary scalars |
---|
61 | INTEGER, DIMENSION(3) :: ilocu ! |
---|
62 | INTEGER, DIMENSION(2) :: ilocs ! |
---|
63 | !!---------------------------------------------------------------------- |
---|
64 | |
---|
65 | IF( kt == nit000 .AND. lwp ) THEN |
---|
66 | WRITE(numout,*) |
---|
67 | WRITE(numout,*) 'stp_ctl : time-stepping control' |
---|
68 | WRITE(numout,*) '~~~~~~~' |
---|
69 | ! open time.step file with special treatment for SAS |
---|
70 | IF ( nn_components == jp_iam_sas ) THEN |
---|
71 | clfname = 'time.step.sas' |
---|
72 | ELSE |
---|
73 | clfname = 'time.step' |
---|
74 | ENDIF |
---|
75 | CALL ctl_opn( numstp, TRIM(clfname), 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
76 | ENDIF |
---|
77 | |
---|
78 | IF(lwp) WRITE ( numstp, '(1x, i8)' ) kt !* save the current time step in numstp |
---|
79 | IF(lwp) REWIND( numstp ) ! -------------------------- |
---|
80 | |
---|
81 | ! !* Test maximum of velocity (zonal only) |
---|
82 | ! ! ------------------------ |
---|
83 | !! zumax = MAXVAL( ABS( un(:,:,:) ) ) ! slower than the following loop on NEC SX5 |
---|
84 | zumax = 0.e0 |
---|
85 | DO jk = 1, jpk |
---|
86 | DO jj = 1, jpj |
---|
87 | DO ji = 1, jpi |
---|
88 | zumax = MAX(zumax,ABS(un(ji,jj,jk))) |
---|
89 | END DO |
---|
90 | END DO |
---|
91 | END DO |
---|
92 | IF( lk_mpp ) CALL mpp_max( zumax ) ! max over the global domain |
---|
93 | ! |
---|
94 | IF( MOD( kt, nwrite ) == 1 .AND. lwp ) WRITE(numout,*) ' ==>> time-step= ',kt,' abs(U) max: ', zumax |
---|
95 | ! |
---|
96 | IF( zumax > 20.e0 ) THEN |
---|
97 | IF( lk_mpp ) THEN |
---|
98 | CALL mpp_maxloc(ABS(un),umask,zumax,ii,ij,ik) |
---|
99 | ELSE |
---|
100 | ilocu = MAXLOC( ABS( un(:,:,:) ) ) |
---|
101 | ii = ilocu(1) + nimpp - 1 |
---|
102 | ij = ilocu(2) + njmpp - 1 |
---|
103 | ik = ilocu(3) |
---|
104 | ENDIF |
---|
105 | IF(lwp) THEN |
---|
106 | WRITE(numout,cform_err) |
---|
107 | WRITE(numout,*) ' stpctl: the zonal velocity is larger than 20 m/s' |
---|
108 | WRITE(numout,*) ' ====== ' |
---|
109 | WRITE(numout,9400) kt, zumax, ii, ij, ik |
---|
110 | WRITE(numout,*) |
---|
111 | WRITE(numout,*) ' output of last fields in numwso' |
---|
112 | ENDIF |
---|
113 | kindic = -3 |
---|
114 | ENDIF |
---|
115 | 9400 FORMAT (' kt=',i6,' max abs(U): ',1pg11.4,', i j k: ',3i5) |
---|
116 | |
---|
117 | ! !* Test minimum of salinity |
---|
118 | ! ! ------------------------ |
---|
119 | !! zsmin = MINVAL( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 ) slower than the following loop on NEC SX5 |
---|
120 | zsmin = 100.e0 |
---|
121 | DO jj = 2, jpjm1 |
---|
122 | DO ji = 1, jpi |
---|
123 | IF( tmask(ji,jj,1) == 1) zsmin = MIN(zsmin,tsn(ji,jj,1,jp_sal)) |
---|
124 | END DO |
---|
125 | END DO |
---|
126 | IF( lk_mpp ) CALL mpp_min( zsmin ) ! min over the global domain |
---|
127 | ! |
---|
128 | IF( MOD( kt, nwrite ) == 1 .AND. lwp ) WRITE(numout,*) ' ==>> time-step= ',kt,' SSS min:', zsmin |
---|
129 | ! |
---|
130 | IF( zsmin < 0.) THEN |
---|
131 | IF (lk_mpp) THEN |
---|
132 | CALL mpp_minloc ( tsn(:,:,1,jp_sal),tmask(:,:,1), zsmin, ii,ij ) |
---|
133 | ELSE |
---|
134 | ilocs = MINLOC( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 ) |
---|
135 | ii = ilocs(1) + nimpp - 1 |
---|
136 | ij = ilocs(2) + njmpp - 1 |
---|
137 | ENDIF |
---|
138 | ! |
---|
139 | IF(lwp) THEN |
---|
140 | WRITE(numout,cform_err) |
---|
141 | WRITE(numout,*) 'stp_ctl : NEGATIVE sea surface salinity' |
---|
142 | WRITE(numout,*) '======= ' |
---|
143 | WRITE(numout,9500) kt, zsmin, ii, ij |
---|
144 | WRITE(numout,*) |
---|
145 | WRITE(numout,*) ' output of last fields in numwso' |
---|
146 | ENDIF |
---|
147 | kindic = -3 |
---|
148 | ENDIF |
---|
149 | 9500 FORMAT (' kt=',i6,' min SSS: ',1pg11.4,', i j: ',2i5) |
---|
150 | |
---|
151 | ! ==================================================================================================== |
---|
152 | ! ==================================================================================================== |
---|
153 | ! !AXY (25/10/17) |
---|
154 | ! !* Test max/min limits of temperature |
---|
155 | ! ! ---------------------------------- |
---|
156 | ztmax = -5.e0 ! arbitrary low maximum value |
---|
157 | ztmin = 100.e0 ! arbitrary high minimum value |
---|
158 | DO jj = 2, jpjm1 |
---|
159 | DO ji = 1, jpi |
---|
160 | IF( tmask(ji,jj,1) == 1) THEN |
---|
161 | ztmax = MAX(ztmax,tsn(ji,jj,1,jp_tem)) ! find local maximum |
---|
162 | ztmin = MIN(ztmin,tsn(ji,jj,1,jp_tem)) ! find local minimum |
---|
163 | ENDIF |
---|
164 | END DO |
---|
165 | END DO |
---|
166 | IF( lk_mpp ) CALL mpp_max( ztmax ) ! max over the global domain |
---|
167 | IF( lk_mpp ) CALL mpp_min( ztmin ) ! min over the global domain |
---|
168 | ! |
---|
169 | IF( ztmax > 40.) THEN ! we've got a problem |
---|
170 | IF (lk_mpp) THEN |
---|
171 | CALL mpp_maxloc ( tsn(:,:,1,jp_tem),tmask(:,:,1), ztmax, ii,ij ) |
---|
172 | ELSE |
---|
173 | ilocs = MAXLOC( tsn(:,:,1,jp_tem), mask = tmask(:,:,1) == 1.e0 ) |
---|
174 | ii = ilocs(1) + nimpp - 1 |
---|
175 | ij = ilocs(2) + njmpp - 1 |
---|
176 | ENDIF |
---|
177 | ! |
---|
178 | IF(lwp) THEN |
---|
179 | WRITE(numout,*) '***** WARNING *****' |
---|
180 | WRITE(numout,*) 'stp_ctl : sea surface temperature > 40C' |
---|
181 | WRITE(numout,*) '======= ' |
---|
182 | WRITE(numout,9600) kt, ztmax, ii, ij |
---|
183 | ENDIF |
---|
184 | ENDIF |
---|
185 | ! |
---|
186 | IF( ztmin < -3.) THEN ! we've got a problem |
---|
187 | IF (lk_mpp) THEN |
---|
188 | CALL mpp_minloc ( tsn(:,:,1,jp_tem),tmask(:,:,1), ztmin, ii,ij ) |
---|
189 | ELSE |
---|
190 | ilocs = MINLOC( tsn(:,:,1,jp_tem), mask = tmask(:,:,1) == 1.e0 ) |
---|
191 | ii = ilocs(1) + nimpp - 1 |
---|
192 | ij = ilocs(2) + njmpp - 1 |
---|
193 | ENDIF |
---|
194 | ! |
---|
195 | IF(lwp) THEN |
---|
196 | WRITE(numout,*) '***** WARNING *****' |
---|
197 | WRITE(numout,*) 'stp_ctl : sea surface temperature < -3C' |
---|
198 | WRITE(numout,*) '======= ' |
---|
199 | WRITE(numout,9700) kt, ztmin, ii, ij |
---|
200 | ENDIF |
---|
201 | ENDIF |
---|
202 | 9600 FORMAT (' kt=',i6,' max SST: ',1pg11.4,', i j: ',2i5) |
---|
203 | 9700 FORMAT (' kt=',i6,' min SST: ',1pg11.4,', i j: ',2i5) |
---|
204 | ! ==================================================================================================== |
---|
205 | ! ==================================================================================================== |
---|
206 | |
---|
207 | IF( lk_c1d ) RETURN ! No log file in case of 1D vertical configuration |
---|
208 | |
---|
209 | ! log file (solver or ssh statistics) |
---|
210 | ! -------- |
---|
211 | IF( lk_dynspg_flt ) THEN ! elliptic solver statistics (if required) |
---|
212 | ! |
---|
213 | IF(lwp) WRITE(numsol,9200) kt, niter, res, SQRT(epsr)/eps ! Solver |
---|
214 | ! |
---|
215 | IF( kindic < 0 .AND. zsmin > 0.e0 .AND. zumax <= 20.e0 ) THEN ! create a abort file if problem found |
---|
216 | IF(lwp) THEN |
---|
217 | WRITE(numout,*) ' stpctl: the elliptic solver DO not converge or explode' |
---|
218 | WRITE(numout,*) ' ====== ' |
---|
219 | WRITE(numout,9200) kt, niter, res, sqrt(epsr)/eps |
---|
220 | WRITE(numout,*) |
---|
221 | WRITE(numout,*) ' stpctl: output of last fields' |
---|
222 | WRITE(numout,*) ' ====== ' |
---|
223 | ENDIF |
---|
224 | ENDIF |
---|
225 | ! |
---|
226 | ELSE !* ssh statistics (and others...) |
---|
227 | IF( kt == nit000 .AND. lwp ) THEN ! open ssh statistics file (put in solver.stat file) |
---|
228 | CALL ctl_opn( numsol, 'solver.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
229 | ENDIF |
---|
230 | ! |
---|
231 | zssh2 = SUM( sshn(:,:) * sshn(:,:) * tmask_i(:,:) ) |
---|
232 | IF( lk_mpp ) CALL mpp_sum( zssh2 ) ! sum over the global domain |
---|
233 | ! |
---|
234 | IF(lwp) WRITE(numsol,9300) kt, zssh2, zumax, zsmin ! ssh statistics |
---|
235 | ! |
---|
236 | ENDIF |
---|
237 | |
---|
238 | 9200 FORMAT('it:', i8, ' iter:', i4, ' r: ',e16.10, ' b: ',e16.10 ) |
---|
239 | 9300 FORMAT(' it :', i8, ' ssh2: ', e16.10, ' Umax: ',e16.10,' Smin: ',e16.10) |
---|
240 | ! |
---|
241 | END SUBROUTINE stp_ctl |
---|
242 | |
---|
243 | !!====================================================================== |
---|
244 | END MODULE stpctl |
---|