1 |
C $Header: /u/gcmpack/MITgcm/model/src/check_pickup.F,v 1.3 2008/08/24 21:38:19 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
c#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
6 |
|
7 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
8 |
CBOP |
9 |
C !ROUTINE: CHECK_PICKUP |
10 |
C !INTERFACE: |
11 |
SUBROUTINE CHECK_PICKUP( |
12 |
I missFldList, |
13 |
I nMissing, nbFields, |
14 |
I myIter, myThid ) |
15 |
|
16 |
C !DESCRIPTION: |
17 |
C Check that fields that are needed to restart have been read. |
18 |
C In case some fields are missing, stop if pickupStrictlyMatch=T |
19 |
C or try, if possible, to restart without the missing field. |
20 |
|
21 |
C !USES: |
22 |
IMPLICIT NONE |
23 |
#include "SIZE.h" |
24 |
#include "EEPARAMS.h" |
25 |
#include "PARAMS.h" |
26 |
#include "RESTART.h" |
27 |
c#ifdef ALLOW_GENERIC_ADVDIFF |
28 |
c# include "GAD.h" |
29 |
c#endif |
30 |
|
31 |
C !INPUT/OUTPUT PARAMETERS: |
32 |
C missFldList :: List of missing fields (attempted to read but not found) |
33 |
C nMissing :: Number of missing fields (attempted to read but not found) |
34 |
C nbFields :: number of fields in pickup file (read from meta file) |
35 |
C myIter :: Iteration number |
36 |
C myThid :: my Thread Id. number |
37 |
CHARACTER*(8) missFldList(*) |
38 |
INTEGER nMissing |
39 |
INTEGER nbFields |
40 |
INTEGER myIter |
41 |
INTEGER myThid |
42 |
CEOP |
43 |
|
44 |
C !FUNCTIONS |
45 |
INTEGER ILNBLNK |
46 |
EXTERNAL ILNBLNK |
47 |
|
48 |
C !LOCAL VARIABLES: |
49 |
INTEGER j |
50 |
INTEGER ioUnit |
51 |
INTEGER warnCnts |
52 |
LOGICAL stopFlag |
53 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
54 |
|
55 |
ioUnit = errorMessageUnit |
56 |
|
57 |
c IF (pickup_read_mdsio) THEN |
58 |
_BEGIN_MASTER( myThid ) |
59 |
|
60 |
IF ( nbFields.GE.1 ) THEN |
61 |
C- flag startFromPickupAB2 is becoming obsolete with new way to read |
62 |
C pickup file: cancel its effect (from initialisation) by resetting |
63 |
C start-AB parameters: |
64 |
tempStartAB = nIter0 |
65 |
saltStartAB = nIter0 |
66 |
mom_StartAB = nIter0 |
67 |
nHydStartAB = nIter0 |
68 |
ENDIF |
69 |
IF ( selectNHfreeSurf.GE.1 ) THEN |
70 |
IF ( nbFields.EQ.0 ) THEN |
71 |
WRITE(msgBuf,'(4A)') '** WARNINGS ** CHECK_PICKUP: ', |
72 |
& 'restart like hydrostatic free-surf (dPhiNH missing)' |
73 |
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
74 |
ELSE |
75 |
C- assume reading dPhiNH was OK (otherwise expected in missing field list) |
76 |
dPhiNHstatus = 1 |
77 |
ENDIF |
78 |
ENDIF |
79 |
|
80 |
IF ( nMissing.GE.1 ) THEN |
81 |
stopFlag = .FALSE. |
82 |
warnCnts = nMissing |
83 |
DO j=1,nMissing |
84 |
C- Case where missing field is not essential or can be recomputed |
85 |
IF ( missFldList(j).EQ.'dEtaHdt ' |
86 |
& .AND. .NOT.useRealFreshWaterFlux ) THEN |
87 |
warnCnts = warnCnts - 1 |
88 |
IF ( .NOT.pickupStrictlyMatch ) THEN |
89 |
WRITE(msgBuf,'(4A)') ' CHECK_PICKUP: ', |
90 |
& 'no RealFreshWaterFlux => can restart without "dEtaHdt "' |
91 |
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
92 |
ENDIF |
93 |
ELSEIF ( missFldList(j).EQ.'dPhiNH ' |
94 |
& .AND. implicitNHPress.EQ.1. _d 0 ) THEN |
95 |
warnCnts = warnCnts - 1 |
96 |
dPhiNHstatus = 0 |
97 |
IF ( .NOT.pickupStrictlyMatch ) THEN |
98 |
WRITE(msgBuf,'(4A)') ' CHECK_PICKUP: ', |
99 |
& 'fully Implic.NH-Press => can restart without "dPhiNH "' |
100 |
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
101 |
ENDIF |
102 |
C- Old pickup for which special code takes care of missing fields |
103 |
ELSEIF ( missFldList(j).EQ.'dEtaHdt ' |
104 |
& .AND.usePickupBeforeC54 ) THEN |
105 |
C- with RealFreshWaterFlux, needs dEtaHdt to restart when: |
106 |
C * synchronousTimeStep & usingPCoords => needs PmEpR for surf-forcing |
107 |
C <- present code might be wrong if usePickupBeforeC54 and LinFS |
108 |
C * synchronousTimeStep & nonlinFreeSurf > 0 => needs PmEpR for surf-forcing |
109 |
C * select_rStar <> 0 => needs dEtaHdt for 1rst Integr_continuity |
110 |
IF ( .NOT.pickupStrictlyMatch ) THEN |
111 |
WRITE(msgBuf,'(4A)') '** WARNINGS ** CHECK_PICKUP: ', |
112 |
& 'restart as before C54 without "dEtaHdt "' |
113 |
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
114 |
ENDIF |
115 |
|
116 |
C- fields used only to speed-up solver(s) convergence: |
117 |
C (no serious problems expected if missing, but get a non-perfect restart) |
118 |
ELSEIF ( missFldList(j).EQ.'EtaN ' |
119 |
& .AND. rigidLid ) THEN |
120 |
IF ( .NOT.pickupStrictlyMatch ) THEN |
121 |
WRITE(msgBuf,'(4A)') '** WARNINGS ** CHECK_PICKUP: ', |
122 |
& 'restart with 1rst guess == 0 for CG2D solver' |
123 |
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
124 |
ENDIF |
125 |
ELSEIF ( missFldList(j).EQ.'Phi_NHyd' ) THEN |
126 |
IF ( .NOT.pickupStrictlyMatch ) THEN |
127 |
WRITE(msgBuf,'(4A)') '** WARNINGS ** CHECK_PICKUP: ', |
128 |
& 'restart with 1rst guess == 0 for CG3D solver' |
129 |
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
130 |
ENDIF |
131 |
ELSEIF ( missFldList(j).EQ.'dPhiNH ' ) THEN |
132 |
dPhiNHstatus = 0 |
133 |
IF ( .NOT.pickupStrictlyMatch ) THEN |
134 |
WRITE(msgBuf,'(4A)') '** WARNINGS ** CHECK_PICKUP: ', |
135 |
& 'restart like hydrostatic free-surf (dPhiNH missing)' |
136 |
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
137 |
ENDIF |
138 |
ELSEIF ( missFldList(j).EQ.'AddMass ' |
139 |
& .AND. selectAddFluid.EQ.2 ) THEN |
140 |
IF ( .NOT.pickupStrictlyMatch ) THEN |
141 |
WRITE(msgBuf,'(4A)') '** WARNINGS ** CHECK_PICKUP: ', |
142 |
& 'restart with AddMass == 0' |
143 |
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
144 |
ENDIF |
145 |
|
146 |
C- Absolutely needed fields: |
147 |
ELSEIF ( missFldList(j).EQ.'Uvel ' .OR. |
148 |
& missFldList(j).EQ.'Vvel ' .OR. |
149 |
& missFldList(j).EQ.'Theta ' .OR. |
150 |
& missFldList(j).EQ.'Salt ' .OR. |
151 |
& missFldList(j).EQ.'EtaN ' ) THEN |
152 |
stopFlag = .TRUE. |
153 |
WRITE(msgBuf,'(4A)') 'CHECK_PICKUP: ', |
154 |
& 'cannot restart without field "',missFldList(j),'"' |
155 |
CALL PRINT_ERROR( msgBuf, myThid ) |
156 |
|
157 |
C- fields needed for restart (alternative not presently implemented) |
158 |
ELSEIF ( missFldList(j).EQ.'PhiHyd ' .OR. |
159 |
& missFldList(j).EQ.'AddMass ' .OR. |
160 |
& missFldList(j).EQ.'dEtaHdt ' .OR. |
161 |
& missFldList(j).EQ.'EtaH ' ) THEN |
162 |
stopFlag = .TRUE. |
163 |
WRITE(msgBuf,'(4A)') 'CHECK_PICKUP: ', |
164 |
& 'cannot currently restart without field "',missFldList(j),'"' |
165 |
CALL PRINT_ERROR( msgBuf, myThid ) |
166 |
|
167 |
C- fields with alternative in place to restart without: |
168 |
C- (but get a non-perfect restart) |
169 |
ELSEIF ( missFldList(j).EQ.'GuNm1 ' .OR. |
170 |
& missFldList(j).EQ.'GvNm1 ' ) THEN |
171 |
mom_StartAB = 0 |
172 |
ELSEIF ( missFldList(j).EQ.'GuNm2 ' .OR. |
173 |
& missFldList(j).EQ.'GvNm2 ' ) THEN |
174 |
mom_StartAB = MIN( mom_startAB, 1 ) |
175 |
ELSEIF ( missFldList(j).EQ.'GtNm1 ' .OR. |
176 |
& missFldList(j).EQ.'TempNm1 ' ) THEN |
177 |
tempStartAB = 0 |
178 |
ELSEIF ( missFldList(j).EQ.'GtNm2 ' .OR. |
179 |
& missFldList(j).EQ.'TempNm2 ' ) THEN |
180 |
tempStartAB = MIN( tempStartAB, 1 ) |
181 |
ELSEIF ( missFldList(j).EQ.'GsNm1 ' .OR. |
182 |
& missFldList(j).EQ.'SaltNm1 ' ) THEN |
183 |
saltStartAB = 0 |
184 |
ELSEIF ( missFldList(j).EQ.'GsNm2 ' .OR. |
185 |
& missFldList(j).EQ.'SaltNm2 ' ) THEN |
186 |
saltStartAB = MIN( saltStartAB, 1 ) |
187 |
ELSEIF ( missFldList(j).EQ.'GwNm1 ' ) THEN |
188 |
nHydStartAB = 0 |
189 |
ELSEIF ( missFldList(j).EQ.'GwNm2 ' ) THEN |
190 |
nHydStartAB = MIN( nHydStartAB, 1 ) |
191 |
|
192 |
ELSE |
193 |
C- not recognized fields: |
194 |
stopFlag = .TRUE. |
195 |
WRITE(msgBuf,'(4A)') 'CHECK_PICKUP: ', |
196 |
& 'missing field "',missFldList(j),'" not recognized' |
197 |
CALL PRINT_ERROR( msgBuf, myThid ) |
198 |
ENDIF |
199 |
ENDDO |
200 |
|
201 |
IF ( stopFlag ) THEN |
202 |
STOP 'ABNORMAL END: S/R CHECK_PICKUP' |
203 |
ELSEIF ( pickupStrictlyMatch ) THEN |
204 |
WRITE(msgBuf,'(4A)') 'CHECK_PICKUP: ', |
205 |
& 'try with " pickupStrictlyMatch=.FALSE.,"', |
206 |
& ' in file: "data", NameList: "PARM03"' |
207 |
CALL PRINT_ERROR( msgBuf, myThid ) |
208 |
STOP 'ABNORMAL END: S/R CHECK_PICKUP' |
209 |
ELSEIF ( warnCnts .GT. 0 ) THEN |
210 |
WRITE(msgBuf,'(4A)') '** WARNINGS ** CHECK_PICKUP: ', |
211 |
& 'Will get only an approximated Restart' |
212 |
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
213 |
IF ( mom_StartAB.LT.nIter0 .OR. |
214 |
& nHydStartAB.LT.nIter0 .OR. |
215 |
& tempStartAB.LT.nIter0 .OR. |
216 |
& saltStartAB.LT.nIter0 ) THEN |
217 |
WRITE(msgBuf,'(2(A,I10))') |
218 |
& ' Continue with mom_StartAB =', mom_StartAB, |
219 |
& ' ; nHydStartAB =', nHydStartAB |
220 |
CALL PRINT_MESSAGE(msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
221 |
WRITE(msgBuf,'(2(A,I10))') |
222 |
& ' with tempStartAB =', tempStartAB, |
223 |
& ' ; saltStartAB =', saltStartAB |
224 |
CALL PRINT_MESSAGE(msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
225 |
ENDIF |
226 |
ENDIF |
227 |
|
228 |
ENDIF |
229 |
|
230 |
_END_MASTER( myThid ) |
231 |
c ENDIF |
232 |
|
233 |
RETURN |
234 |
END |