/[MITgcm]/MITgcm/pkg/exf/exf_adjoint_snapshots_ad.F
ViewVC logotype

Contents of /MITgcm/pkg/exf/exf_adjoint_snapshots_ad.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.11 - (show annotations) (download)
Thu Apr 3 10:00:58 2014 UTC (10 years, 8 months ago) by atn
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64w, checkpoint64v, checkpoint65, checkpoint65p, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e
Changes since 1.10: +7 -1 lines
add missing adlwdown snapshot

1 C $Header: /u/gcmpack/MITgcm/pkg/exf/exf_adjoint_snapshots_ad.F,v 1.10 2012/08/29 02:14:13 jmc Exp $
2 C $Name: $
3
4 #include "EXF_OPTIONS.h"
5 #include "AD_CONFIG.h"
6
7 CBOP
8 C !ROUTINE: adexf_adjoint_snapshots
9 C !INTERFACE:
10 subroutine adexf_adjoint_snapshots(
11 & iwhen, myTime, myIter, myThid )
12
13 C !DESCRIPTION: \bv
14 C *==========================================================*
15 C | SUBROUTINE adexf_adjoint_snapshots |
16 C *==========================================================*
17 C Extract adjoint variable from TAMC/TAF-generated
18 C adjoint common blocks, contained in adcommon.h
19 C and write fields to file;
20 C Make sure common blocks in adcommon.h are up-to-date
21 C w.r.t. current adjoint code.
22 C *==========================================================*
23 C | SUBROUTINE adexf_adjoint_snapshots |
24 C *==========================================================*
25 C \ev
26
27 C !USES:
28 IMPLICIT NONE
29
30 C == Global variables ===
31 #include "SIZE.h"
32 #include "EEPARAMS.h"
33 #include "PARAMS.h"
34 #include "EXF_PARAM.h"
35 #ifdef ALLOW_MNC
36 # include "MNC_PARAMS.h"
37 #endif
38 #include "GRID.h"
39 #ifdef ALLOW_AUTODIFF_MONITOR
40 # include "AUTODIFF_PARAMS.h"
41 # include "AUTODIFF.h"
42 # include "adcommon.h"
43 #endif
44
45 C !INPUT/OUTPUT PARAMETERS:
46 C == Routine arguments ==
47 C myTime :: time counter for this thread
48 C myIter :: iteration counter for this thread
49 C myThid :: Thread number for this instance of the routine.
50 integer iwhen
51 _RL myTime
52 integer myIter
53 integer myThid
54
55 #if (defined (ALLOW_ADJOINT_RUN) || defined (ALLOW_ADMTLM))
56 #ifdef ALLOW_AUTODIFF_MONITOR
57
58 C !FUNCTIONS:
59 LOGICAL DIFFERENT_MULTIPLE
60 EXTERNAL DIFFERENT_MULTIPLE
61
62 C !LOCAL VARIABLES:
63 c == local variables ==
64 C suff :: Hold suffix part of a filename
65 C msgBuf :: Error message buffer
66 CHARACTER*(MAX_LEN_FNAM) suff
67 CHARACTER*(MAX_LEN_MBUF) msgBuf
68 INTEGER dumpAdRecEx
69 CEOP
70
71 CALL TIMER_START('I/O (WRITE) [ADJOINT LOOP]', myThid )
72
73 IF (
74 & DIFFERENT_MULTIPLE(adjDumpFreq,myTime,deltaTClock)
75 & ) THEN
76
77 C-- Set suffix for this set of data files.
78 WRITE(suff,'(I10.10)') myIter
79 C ==>> Resetting run-time parameter writeBinaryPrec in the middle of a run
80 C ==>> is very very very nasty !!!
81 c writeBinaryPrec = writeStatePrec
82 C <<== If you really want to mess-up with this at your own risk,
83 C <<== uncomment the line above
84
85 c determine ad dump record number (used only if dumpAdByRec is true)
86 IF (useSeaice.AND.(iWhen.EQ.3)) THEN
87 dumpAdRecEx=dumpAdRecMn+1
88 ELSE
89 dumpAdRecEx=dumpAdRecMn
90 ENDIF
91 c#ifdef ALLOW_DEBUG
92 c IF ( debugMode ) print*,'dumpAdRecEx',dumpAdRecEx
93 c#endif
94
95 IF (.NOT.dumpAdByRec) THEN
96
97 IF ( iwhen .EQ.1 ) THEN
98
99 CALL WRITE_FLD_XY_RL ( 'ADJustress.',
100 & suff, adustress, myIter, myThid)
101 CALL WRITE_FLD_XY_RL ( 'ADJvstress.',
102 & suff, advstress, myIter, myThid)
103 CALL WRITE_FLD_XY_RL ( 'ADJhflux.',
104 & suff, adhflux, myIter, myThid)
105 CALL WRITE_FLD_XY_RL ( 'ADJsflux.',
106 & suff, adsflux, myIter, myThid)
107
108 ELSEIF ( iwhen .EQ.2 ) THEN
109
110 # ifdef ALLOW_ATM_TEMP
111 CALL WRITE_FLD_XY_RL ( 'ADJatemp.',
112 & suff, adatemp, myIter, myThid)
113 CALL WRITE_FLD_XY_RL ( 'ADJaqh.',
114 & suff, adaqh, myIter, myThid)
115 CALL WRITE_FLD_XY_RL ( 'ADJprecip.',
116 & suff, adprecip, myIter, myThid)
117 # endif
118 IF ( useAtmWind ) THEN
119 CALL WRITE_FLD_XY_RL ( 'ADJuwind.',
120 & suff, aduwind, myIter, myThid)
121 CALL WRITE_FLD_XY_RL ( 'ADJvwind.',
122 & suff, advwind, myIter, myThid)
123 ENDIF
124 # ifdef ALLOW_DOWNWARD_RADIATION
125 CALL WRITE_FLD_XY_RL ( 'ADJswdown.',
126 & suff, adswdown, myIter, myThid)
127 CALL WRITE_FLD_XY_RL ( 'ADJlwdown.',
128 & suff, adlwdown, myIter, myThid)
129 # endif
130 # ifdef ALLOW_CLIMSST_RELAXATION
131 CALL WRITE_FLD_XY_RL ( 'ADJclimsst.',
132 & suff, adclimsst, myIter, myThid)
133 # endif
134 # ifdef ALLOW_CLIMSSS_RELAXATION
135 CALL WRITE_FLD_XY_RL ( 'ADJclimsss.',
136 & suff, adclimsss, myIter, myThid)
137 # endif
138
139 ELSEIF ( iwhen .EQ.3 ) THEN
140
141 CALL WRITE_FLD_XY_RS ( 'ADJtaux.',suff, adfu, myIter, myThid)
142 CALL WRITE_FLD_XY_RS ( 'ADJtauy.',suff, adfv, myIter, myThid)
143 CALL WRITE_FLD_XY_RS ( 'ADJqnet.',suff, adqnet, myIter, myThid)
144 CALL WRITE_FLD_XY_RS ( 'ADJempr.',suff, adempmr, myIter, myThid)
145 #ifdef SHORTWAVE_HEATING
146 CALL WRITE_FLD_XY_RS ( 'ADJqsw.',suff, adqsw, myIter, myThid)
147 #endif
148
149 ENDIF
150
151 ELSEIF ( dumpAdRecEx .GT. 0 ) THEN
152
153 IF ( iwhen .EQ.1 ) THEN
154
155 CALL WRITE_REC_XY_RL ( 'ADJustress',
156 & adustress, dumpAdRecEx, myIter, myThid)
157 CALL WRITE_REC_XY_RL ( 'ADJvstress',
158 & advstress, dumpAdRecEx, myIter, myThid)
159 CALL WRITE_REC_XY_RL ( 'ADJhflux',
160 & adhflux, dumpAdRecEx, myIter, myThid)
161 CALL WRITE_REC_XY_RL ( 'ADJsflux',
162 & adsflux, dumpAdRecEx, myIter, myThid)
163
164 ELSEIF ( iwhen .EQ.2 ) THEN
165
166 # ifdef ALLOW_ATM_TEMP
167 CALL WRITE_REC_XY_RL ( 'ADJatemp',
168 & adatemp, dumpAdRecEx, myIter, myThid)
169 CALL WRITE_REC_XY_RL ( 'ADJaqh',
170 & adaqh, dumpAdRecEx, myIter, myThid)
171 CALL WRITE_REC_XY_RL ( 'ADJprecip',
172 & adprecip, dumpAdRecEx, myIter, myThid)
173 # endif
174 IF ( useAtmWind ) THEN
175 CALL WRITE_REC_XY_RL ( 'ADJuwind',
176 & aduwind, dumpAdRecEx, myIter, myThid)
177 CALL WRITE_REC_XY_RL ( 'ADJvwind',
178 & advwind, dumpAdRecEx, myIter, myThid)
179 ENDIF
180 # ifdef ALLOW_DOWNWARD_RADIATION
181 CALL WRITE_REC_XY_RL ( 'ADJswdown',
182 & adswdown, dumpAdRecEx, myIter, myThid)
183 CALL WRITE_REC_XY_RL ( 'ADJlwdown',
184 & adlwdown, dumpAdRecEx, myIter, myThid)
185 # endif
186 # ifdef ALLOW_CLIMSST_RELAXATION
187 CALL WRITE_REC_XY_RL ( 'ADJclimsst',
188 & adclimsst, dumpAdRecEx, myIter, myThid)
189 # endif
190 # ifdef ALLOW_CLIMSSS_RELAXATION
191 CALL WRITE_REC_XY_RL ( 'ADJclimsss',
192 & adclimsss, dumpAdRecEx, myIter, myThid)
193 # endif
194
195 ELSEIF ( iwhen .EQ.3 ) THEN
196
197 CALL WRITE_REC_XY_RS ( 'ADJtaux',
198 & adfu, dumpAdRecEx, myIter, myThid)
199 CALL WRITE_REC_XY_RS ( 'ADJtauy',
200 & adfv, dumpAdRecEx, myIter, myThid)
201 CALL WRITE_REC_XY_RS ( 'ADJqnet',
202 & adqnet, dumpAdRecEx, myIter, myThid)
203 CALL WRITE_REC_XY_RS ( 'ADJempr',
204 & adempmr, dumpAdRecEx, myIter, myThid)
205 #ifdef SHORTWAVE_HEATING
206 CALL WRITE_REC_XY_RS ( 'ADJqsw',
207 & adqsw, dumpAdRecEx, myIter, myThid)
208 #endif
209
210 ENDIF
211
212 ENDIF
213
214 #ifdef ALLOW_MNC
215 IF (useMNC .AND. autodiff_mnc) THEN
216
217 IF ( iwhen.EQ.1 ) THEN
218 c
219 CALL MNC_CW_SET_UDIM('adexf', -1, myThid)
220 CALL MNC_CW_RL_W_S('D','adexf',0,0,'T',myTime,myThid)
221 CALL MNC_CW_SET_UDIM('adexf', 0, myThid)
222 CALL MNC_CW_I_W_S('I','adexf',0,0,'iter',myIter,myThid)
223 CALL MNC_CW_RL_W_S('D','adexf',0,0,'model_time',myTime,
224 & myThid)
225 c
226 CALL MNC_CW_RL_W('D','adexf',0,0,'adustress',
227 & adustress, myThid)
228 CALL MNC_CW_RL_W('D','adexf',0,0,'advstress',
229 & advstress, myThid)
230 CALL MNC_CW_RL_W('D','adexf',0,0,'adhflux',
231 & adhflux, myThid)
232 CALL MNC_CW_RL_W('D','adexf',0,0,'adsflux',
233 & adsflux, myThid)
234 ELSEIF ( iwhen.EQ.2 ) THEN
235 # ifdef ALLOW_ATM_TEMP
236 CALL MNC_CW_RL_W('D','adexf',0,0,'adatemp',
237 & adatemp, myThid)
238 CALL MNC_CW_RL_W('D','adexf',0,0,'adaqh',
239 & adaqh, myThid)
240 CALL MNC_CW_RL_W('D','adexf',0,0,'adprecip',
241 & adprecip, myThid)
242 # endif
243 IF ( useAtmWind ) THEN
244 CALL MNC_CW_RL_W('D','adexf',0,0,'aduwind',
245 & aduwind, myThid)
246 CALL MNC_CW_RL_W('D','adexf',0,0,'advwind',
247 & advwind, myThid)
248 ENDIF
249 # ifdef ALLOW_DOWNWARD_RADIATION
250 CALL MNC_CW_RL_W('D','adexf',0,0,'adswdown',
251 & adswdown, myThid)
252 CALL MNC_CW_RL_W('D','adexf',0,0,'adlwdown',
253 & adlwdown, myThid)
254 # endif
255 # ifdef ALLOW_CLIMSST_RELAXATION
256 CALL MNC_CW_RL_W('D','adexf',0,0,'adclimsst',
257 & adclimsst, myThid)
258 # endif
259 # ifdef ALLOW_CLIMSSS_RELAXATION
260 CALL MNC_CW_RL_W('D','adexf',0,0,'adclimsss',
261 & adclimsss, myThid)
262 # endif
263 c
264 ENDIF
265
266 ENDIF
267 #endif /* ALLOW_MNC */
268
269 ENDIF
270
271 #ifdef ALLOW_MONITOR
272 CALL ADEXF_MONITOR ( iwhen, myTime, myIter, myThid )
273 #endif
274
275 CALL TIMER_STOP( 'I/O (WRITE) [ADJOINT LOOP]', myThid )
276
277 #endif /* ALLOW_AUTODIFF_MONITOR */
278 #endif /* ALLOW_ADJOINT_RUN */
279
280 RETURN
281 END

  ViewVC Help
Powered by ViewVC 1.1.22