1 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/ecco_check.F,v 1.21 2014/11/03 16:09:58 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "ECCO_OPTIONS.h" |
5 |
|
6 |
C-- File ecco_check.F: |
7 |
C-- Contents |
8 |
C-- o ECCO_CHECK |
9 |
C-- o ECCO_CHECK_FILES |
10 |
|
11 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
12 |
|
13 |
SUBROUTINE ECCO_CHECK( myThid ) |
14 |
C *==========================================================* |
15 |
C | SUBROUTINE ECCO_CHECK | |
16 |
C | o Check runtime activated packages have been built in. | |
17 |
C *==========================================================* |
18 |
C | All packages can be selected/deselected at build time | |
19 |
C | ( when code is compiled ) and activated/deactivated at | |
20 |
C | runtime. This routine does a quick check to trap packages| |
21 |
C | that were activated at runtime but that were not compiled| |
22 |
C | in at build time. | |
23 |
C *==========================================================* |
24 |
IMPLICIT NONE |
25 |
|
26 |
C === Global variables === |
27 |
#include "SIZE.h" |
28 |
#include "EEPARAMS.h" |
29 |
#include "PARAMS.h" |
30 |
#include "DYNVARS.h" |
31 |
#ifdef ALLOW_CAL |
32 |
# include "cal.h" |
33 |
#endif |
34 |
#ifdef ALLOW_ECCO |
35 |
# include "ecco_cost.h" |
36 |
#endif |
37 |
#ifdef ALLOW_PROFILES |
38 |
# include "profiles.h" |
39 |
#endif |
40 |
|
41 |
C === Routine arguments === |
42 |
C myThid - Number of this instances |
43 |
INTEGER myThid |
44 |
|
45 |
C === Local variables === |
46 |
C msgBuf - Informational/error meesage buffer |
47 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
48 |
#ifdef ALLOW_GENCOST_CONTRIBUTION |
49 |
INTEGER k, igen_etaday |
50 |
#endif |
51 |
|
52 |
_BEGIN_MASTER(myThid) |
53 |
|
54 |
#if (defined (ALLOW_TRANSPORT_COST_CONTRIBUTION) || \ |
55 |
defined (ALLOW_NEW_SSH_COST)) |
56 |
IF ( ndaysrec .GT. maxNumDays ) THEN |
57 |
WRITE(msgBuf,'(2A,2I10)') |
58 |
& 'ECCO_CHECK: for ALLOW_TRANSPORT_COST_CONTRIBUTION: ', |
59 |
& 'ndaysrec > maxNumDays in ecco_cost.h ', |
60 |
& ndaysrec, maxNumDays |
61 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
62 |
& SQUEEZE_RIGHT , myThid ) |
63 |
CALL PRINT_ERROR( msgBuf , myThid ) |
64 |
STOP 'ABNORMAL END: S/R ECCO_CHECK' |
65 |
ENDIF |
66 |
#endif |
67 |
|
68 |
#ifdef ALLOW_PROFILES_CONTRIBUTION |
69 |
IF ( .NOT.usePROFILES ) THEN |
70 |
WRITE(msgBuf,'(3A)') '** WARNING ** S/R ECCO_CHECK: ', |
71 |
& 'ALLOW_PROFILES_CONTRIBUTION requires ', |
72 |
& 'netcdf and usePROFILES to be .true.' |
73 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
74 |
& SQUEEZE_RIGHT , myThid ) |
75 |
ENDIF |
76 |
#endif |
77 |
|
78 |
cgf next line is only for backward compatibility |
79 |
IF ( (using_topex).AND.(.NOT.using_tpj) ) using_tpj=.TRUE. |
80 |
|
81 |
_END_MASTER(myThid) |
82 |
|
83 |
c check for missing data files |
84 |
#ifdef ALLOW_BP_COST_CONTRIBUTION |
85 |
CALL ECCO_CHECK_FILES( using_cost_bp,'bp', |
86 |
& bpdatfile, bpstartdate(1), myThid ) |
87 |
#endif |
88 |
#ifdef ALLOW_SST_COST_CONTRIBUTION |
89 |
CALL ECCO_CHECK_FILES( using_cost_sst,'sst', |
90 |
& sstdatfile, sststartdate(1), myThid ) |
91 |
#endif |
92 |
#ifdef ALLOW_TMI_SST_COST_CONTRIBUTION |
93 |
CALL ECCO_CHECK_FILES( using_cost_sst,'sst', |
94 |
& tmidatfile, tmistartdate(1), myThid ) |
95 |
#endif |
96 |
#if (defined (ALLOW_SCAT_COST_CONTRIBUTION) || \ |
97 |
defined (ALLOW_DAILYSCAT_COST_CONTRIBUTION) ) |
98 |
CALL ECCO_CHECK_FILES( using_cost_scat,'scat', |
99 |
& scatxdatfile, scatxstartdate(1), myThid ) |
100 |
CALL ECCO_CHECK_FILES( using_cost_scat,'scat', |
101 |
& scatydatfile, scatystartdate(1), myThid ) |
102 |
#endif |
103 |
|
104 |
c left for later : slightly different treatment would apply to profiles and gencost |
105 |
|
106 |
#ifdef ALLOW_GENCOST_CONTRIBUTION |
107 |
do k=1,NGENCOST |
108 |
if (gencost_pointer3d(k).GT.NGENCOST3D) then |
109 |
WRITE(msgBuf,'(2A)') |
110 |
& 'ECCO_CHECK: too many 3D cost terms; please', |
111 |
& 'increase NGENCOST3D and recompile.' |
112 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
113 |
& SQUEEZE_RIGHT , myThid ) |
114 |
CALL PRINT_ERROR( msgBuf , myThid ) |
115 |
STOP 'ABNORMAL END: S/R ECCO_CHECK' |
116 |
endif |
117 |
|
118 |
if ( gencost_datafile(k) .ne. ' ' ) then |
119 |
|
120 |
CALL ECCO_CHECK_FILES( using_gencost(k), 'gencost', |
121 |
& gencost_datafile(k), gencost_startdate1(k), myThid ) |
122 |
|
123 |
c altimetry related checks |
124 |
if (gencost_name(k).EQ.'sshv4-tp') using_tpj=using_gencost(k) |
125 |
if (gencost_name(k).EQ.'sshv4-ers') using_ers=using_gencost(k) |
126 |
if (gencost_name(k).EQ.'sshv4-gfo') using_gfo=using_gencost(k) |
127 |
if (gencost_name(k).EQ.'sshv4-mdt') using_mdt=using_gencost(k) |
128 |
|
129 |
c seaice related checks |
130 |
if (gencost_name(k).EQ.'siv4-conc') |
131 |
& using_cost_seaice=using_gencost(k) |
132 |
if (gencost_name(k).EQ.'siv4-deconc') |
133 |
& using_cost_seaice=using_gencost(k) |
134 |
if (gencost_name(k).EQ.'siv4-exconc') |
135 |
& using_cost_seaice=using_gencost(k) |
136 |
catn-- put stop statement if use old siv4 names: |
137 |
if (gencost_name(k).EQ.'siv4-sst') then |
138 |
WRITE(msgBuf,'(2A)') |
139 |
& 'ECCO_CHECK: OLD seaice gencost_name siv4-sst is retired,', |
140 |
& ' NEW name is siv4-deconc' |
141 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
142 |
& SQUEEZE_RIGHT , myThid ) |
143 |
CALL PRINT_ERROR( msgBuf , myThid ) |
144 |
STOP 'ABNORMAL END: S/R ECCO_CHECK' |
145 |
endif |
146 |
if (gencost_name(k).EQ.'siv4-vol') then |
147 |
WRITE(msgBuf,'(2A)') |
148 |
& 'ECCO_CHECK: OLD seaice gencost_name siv4-vol is retired,', |
149 |
& ' NEW name is siv4-exconc' |
150 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
151 |
& SQUEEZE_RIGHT , myThid ) |
152 |
CALL PRINT_ERROR( msgBuf , myThid ) |
153 |
STOP 'ABNORMAL END: S/R ECCO_CHECK' |
154 |
endif |
155 |
|
156 |
endif !if ( gencost_datafile(k) .ne. ' ' ) then |
157 |
enddo |
158 |
|
159 |
c check that one of the used gencost term defines etaday (needed in sshv4) |
160 |
IF ( (using_tpj ).OR.(using_ers).OR.(using_gfo) |
161 |
& .OR.(using_mdt) ) using_cost_altim = .TRUE. |
162 |
|
163 |
igen_etaday=0 |
164 |
do k=1,NGENCOST |
165 |
if ( (gencost_barfile(k).EQ.'etaday').AND. |
166 |
& (using_gencost(k)) ) igen_etaday=k |
167 |
enddo |
168 |
|
169 |
if (igen_etaday.EQ.0) then |
170 |
c warn user as we override using_cost_altim |
171 |
using_cost_altim = .FALSE. |
172 |
WRITE(msgBuf,'(2A)') |
173 |
& '** WARNING ** S/R ECCO_CHECK: missing file: ', |
174 |
& ' for altimeter data so cost gets switched off' |
175 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
176 |
& SQUEEZE_RIGHT, myThid ) |
177 |
else |
178 |
c print result to screen |
179 |
write(msgbuf,'(a,i3)') |
180 |
& 'etaday defined by gencost ',igen_etaday |
181 |
call print_message( msgbuf, standardmessageunit, |
182 |
& SQUEEZE_RIGHT , mythid) |
183 |
endif |
184 |
|
185 |
#endif |
186 |
|
187 |
RETURN |
188 |
END |
189 |
|
190 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
191 |
|
192 |
SUBROUTINE ECCO_CHECK_FILES( |
193 |
O using_cost_local, |
194 |
I localname, localobsfile, localstartdate1, |
195 |
I myThid ) |
196 |
|
197 |
C *==========================================================* |
198 |
C | SUBROUTINE ECCO_CHECK_FILES | |
199 |
C | o Check that obs files are present for specified years. | |
200 |
C | If not then set using_cost_local to false. | |
201 |
C *==========================================================* |
202 |
IMPLICIT NONE |
203 |
|
204 |
C === Global variables === |
205 |
#include "SIZE.h" |
206 |
#include "EEPARAMS.h" |
207 |
#include "PARAMS.h" |
208 |
#include "ecco.h" |
209 |
#ifdef ALLOW_CAL |
210 |
# include "cal.h" |
211 |
#endif |
212 |
|
213 |
C === Routine arguments === |
214 |
C myThid - Number of this instances |
215 |
INTEGER myThid |
216 |
LOGICAL using_cost_local |
217 |
character*(*) localname |
218 |
character*(MAX_LEN_FNAM) localobsfile |
219 |
integer localstartdate1 |
220 |
|
221 |
C === Local variables === |
222 |
C msgBuf - Informational/error meesage buffer |
223 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
224 |
INTEGER irec, mody, modm, yday, locy, il |
225 |
LOGICAL exst, singleFileTest, yearlyFileTest |
226 |
character*(128) fname |
227 |
|
228 |
c == external functions == |
229 |
|
230 |
integer ilnblnk |
231 |
external ilnblnk |
232 |
|
233 |
c == end of interface == |
234 |
|
235 |
c left for later : refine test accounting for localstartdate1 |
236 |
|
237 |
#ifdef ALLOW_CAL |
238 |
|
239 |
_BEGIN_MASTER(myThid) |
240 |
|
241 |
IF ( (using_cost_local).AND.(localobsfile.EQ.' ') ) THEN |
242 |
c warn user as we override using_cost_local |
243 |
WRITE(msgBuf,'(4A)') |
244 |
& '** WARNING ** ECCO_CHECK_FILES: missing file', |
245 |
& ' definition so ',localname,' gets switched off' |
246 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
247 |
& SQUEEZE_RIGHT , myThid) |
248 |
c switch off cost function term |
249 |
using_cost_local = .FALSE. |
250 |
ENDIF |
251 |
|
252 |
singleFileTest = .FALSE. |
253 |
IF (using_cost_local) THEN |
254 |
inquire( file=localobsfile, exist=exst ) |
255 |
IF ( exst ) singleFileTest=.TRUE. |
256 |
ENDIF |
257 |
|
258 |
yearlyFileTest = .FALSE. |
259 |
IF ( (using_cost_local).AND.(.NOT.singleFileTest) ) THEN |
260 |
DO irec = 1, nmonsrec |
261 |
mody = modelstartdate(1)/10000 |
262 |
modm = modelstartdate(1)/100 - mody*100 |
263 |
yday = mody + INT((modm-1+irec-1)/12) |
264 |
|
265 |
locy = localstartdate1/10000 |
266 |
|
267 |
il=ilnblnk(localobsfile) |
268 |
write(fname(1:128),'(2a,i4)') |
269 |
& localobsfile(1:il), '_', yday |
270 |
inquire( file=fname, exist=exst ) |
271 |
|
272 |
IF ( (.NOT.exst).AND.(yday.GE.locy) ) THEN |
273 |
c warn user as we override using_cost_local |
274 |
WRITE(msgBuf,'(5A)') |
275 |
& '** WARNING ** ECCO_CHECK_FILES: missing',fname, |
276 |
& ' so ',localname,' gets switched off' |
277 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
278 |
& SQUEEZE_RIGHT , myThid) |
279 |
c switch off cost function term |
280 |
using_cost_local = .FALSE. |
281 |
ELSEIF ( (exst).AND.(yday.GE.locy) ) THEN |
282 |
yearlyFileTest = .TRUE. |
283 |
ENDIF |
284 |
ENDDO |
285 |
ENDIF |
286 |
|
287 |
IF (using_cost_local) THEN |
288 |
IF ( (.NOT.yearlyFileTest).AND.(.NOT.singleFileTest) ) THEN |
289 |
c warn user as we override using_cost_local |
290 |
WRITE(msgBuf,'(4A)') |
291 |
& '** WARNING ** ECCO_CHECK_FILES: no data ', |
292 |
& ' so ',localname,' gets switched off' |
293 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
294 |
& SQUEEZE_RIGHT , myThid) |
295 |
c switch off cost function term |
296 |
using_cost_local = .FALSE. |
297 |
ENDIF |
298 |
ENDIF |
299 |
|
300 |
_END_MASTER(myThid) |
301 |
|
302 |
#endif /* ALLOW_CAL */ |
303 |
|
304 |
RETURN |
305 |
END |