1 |
jmc |
1.3 |
C $Header: /u/gcmpack/MITgcm/verification/OpenAD/code_oad_all/the_fourth_level_loop.F,v 1.2 2009/02/24 21:40:24 utke Exp $ |
2 |
utke |
1.1 |
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "PACKAGES_CONFIG.h" |
5 |
|
|
#include "CPP_OPTIONS.h" |
6 |
|
|
#ifdef ALLOW_OBCS |
7 |
|
|
# include "OBCS_OPTIONS.h" |
8 |
|
|
#endif |
9 |
|
|
#ifdef ALLOW_SEAICE |
10 |
|
|
# include "SEAICE_OPTIONS.h" |
11 |
|
|
#endif |
12 |
|
|
#ifdef ALLOW_GMREDI |
13 |
|
|
# include "GMREDI_OPTIONS.h" |
14 |
|
|
#endif |
15 |
|
|
|
16 |
|
|
C start with a copy of THE_MAIN_LOOP |
17 |
|
|
C and remove some the obvious extras |
18 |
|
|
SUBROUTINE THE_FOURTH_LEVEL_LOOP(ilev_4, |
19 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
20 |
|
|
+theCurrentStep, |
21 |
|
|
+myTime, myIter,myThid ) |
22 |
|
|
IMPLICIT NONE |
23 |
|
|
|
24 |
|
|
C == Global variables == |
25 |
|
|
#include "SIZE.h" |
26 |
|
|
#include "EEPARAMS.h" |
27 |
|
|
#include "PARAMS.h" |
28 |
|
|
|
29 |
|
|
c************************************** |
30 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
31 |
|
|
|
32 |
|
|
c These includes are needed for |
33 |
|
|
c AD-checkpointing. |
34 |
|
|
c They provide the fields to be stored. |
35 |
|
|
|
36 |
|
|
# include "GRID.h" |
37 |
|
|
# include "DYNVARS.h" |
38 |
|
|
# include "FFIELDS.h" |
39 |
|
|
# include "EOS.h" |
40 |
|
|
# include "GAD.h" |
41 |
|
|
# ifdef ALLOW_CAL |
42 |
|
|
# include "cal.h" |
43 |
|
|
# endif |
44 |
|
|
# ifdef ALLOW_CD_CODE |
45 |
|
|
# include "CD_CODE_VARS.h" |
46 |
|
|
# endif |
47 |
|
|
# ifdef ALLOW_PTRACERS |
48 |
|
|
# include "PTRACERS_SIZE.h" |
49 |
|
|
# include "PTRACERS.h" |
50 |
|
|
# endif |
51 |
|
|
# ifdef EXACT_CONSERV |
52 |
|
|
# include "SURFACE.h" |
53 |
|
|
# endif |
54 |
|
|
# ifdef ALLOW_OBCS |
55 |
jmc |
1.3 |
# include "OBCS_PARAMS.h" |
56 |
|
|
# include "OBCS_GRID.h" |
57 |
|
|
# include "OBCS_FIELDS.h" |
58 |
|
|
# include "OBCS_SEAICE.h" |
59 |
utke |
1.1 |
# endif |
60 |
|
|
# ifdef ALLOW_EXF |
61 |
|
|
# include "EXF_FIELDS.h" |
62 |
|
|
# include "EXF_PARAM.h" |
63 |
|
|
# ifdef ALLOW_BULKFORMULAE |
64 |
|
|
# include "EXF_CONSTANTS.h" |
65 |
|
|
# endif |
66 |
|
|
# endif /* ALLOW_EXF */ |
67 |
|
|
# ifdef ALLOW_SEAICE |
68 |
|
|
# include "SEAICE.h" |
69 |
|
|
# endif |
70 |
|
|
# ifdef ALLOW_EBM |
71 |
|
|
# include "EBM.h" |
72 |
|
|
# endif |
73 |
|
|
# ifdef ALLOW_KPP |
74 |
|
|
# include "KPP.h" |
75 |
|
|
# include "KPP_DIAGS.h" |
76 |
|
|
# include "KPP_PARAMS.h" |
77 |
|
|
# endif |
78 |
|
|
# ifdef ALLOW_DIVIDED_ADJOINT_MPI |
79 |
|
|
# include "mpif.h" |
80 |
|
|
# endif |
81 |
|
|
|
82 |
|
|
# include "tamc.h" |
83 |
|
|
# include "ctrl.h" |
84 |
|
|
# include "ctrl_dummy.h" |
85 |
|
|
# include "cost.h" |
86 |
|
|
|
87 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
88 |
|
|
|
89 |
|
|
integer ilev_4 |
90 |
|
|
integer uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4 |
91 |
|
|
integer theCurrentStep |
92 |
|
|
INTEGER myThid |
93 |
|
|
INTEGER myIter |
94 |
|
|
_RL myTime |
95 |
|
|
|
96 |
|
|
C !LOCAL VARIABLES: |
97 |
|
|
C == Local variables == |
98 |
|
|
integer ilev_3 |
99 |
|
|
integer remainingSteps |
100 |
|
|
|
101 |
|
|
#ifdef ALLOW_DEBUG |
102 |
|
|
IF (debugMode) CALL DEBUG_ENTER('THE_FOURTH_LEVEL_LOOP',myThid) |
103 |
|
|
#endif |
104 |
utke |
1.2 |
#ifdef OAD_DEBUG_JOINT |
105 |
|
|
write(standardmessageunit,'(A,1(I6,A))') |
106 |
|
|
+ 'OAD: THE_FOURTH_LEVEL_LOOP(',iLev_4,')' |
107 |
|
|
#endif |
108 |
utke |
1.1 |
do ilev_3 = 1,uCheckLev3 |
109 |
|
|
if (theCurrentStep .le. nTimeSteps) then |
110 |
|
|
#ifdef ALLOW_DEBUG |
111 |
|
|
IF (debugMode) CALL DEBUG_CALL('THE_THIRD_LEVEL_LOOP', |
112 |
|
|
+myThid) |
113 |
|
|
#endif |
114 |
|
|
CALL THE_THIRD_LEVEL_LOOP( ilev_4, iLev_3, |
115 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
116 |
|
|
+theCurrentStep, |
117 |
|
|
+mytime, myiter, mythid ) |
118 |
|
|
end if |
119 |
|
|
end do |
120 |
|
|
#ifdef ALLOW_DEBUG |
121 |
|
|
IF (debugMode) CALL DEBUG_LEAVE('THE_FOURTH_LEVEL_LOOP',myThid) |
122 |
|
|
#endif |
123 |
|
|
|
124 |
|
|
END |
125 |
|
|
|
126 |
|
|
SUBROUTINE THE_FOURTH_LEVEL_PLAIN( |
127 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
128 |
|
|
+theCurrentStep, |
129 |
|
|
+myTime, myIter,myThid ) |
130 |
|
|
IMPLICIT NONE |
131 |
|
|
|
132 |
|
|
C == Global variables == |
133 |
|
|
#include "SIZE.h" |
134 |
|
|
#include "EEPARAMS.h" |
135 |
|
|
#include "PARAMS.h" |
136 |
|
|
|
137 |
|
|
c************************************** |
138 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
139 |
|
|
|
140 |
|
|
c These includes are needed for |
141 |
|
|
c AD-checkpointing. |
142 |
|
|
c They provide the fields to be stored. |
143 |
|
|
|
144 |
|
|
# include "GRID.h" |
145 |
|
|
# include "DYNVARS.h" |
146 |
|
|
# include "FFIELDS.h" |
147 |
|
|
# include "EOS.h" |
148 |
|
|
# include "GAD.h" |
149 |
|
|
# ifdef ALLOW_CAL |
150 |
|
|
# include "cal.h" |
151 |
|
|
# endif |
152 |
|
|
# ifdef ALLOW_CD_CODE |
153 |
|
|
# include "CD_CODE_VARS.h" |
154 |
|
|
# endif |
155 |
|
|
# ifdef ALLOW_PTRACERS |
156 |
|
|
# include "PTRACERS_SIZE.h" |
157 |
|
|
# include "PTRACERS.h" |
158 |
|
|
# endif |
159 |
|
|
# ifdef EXACT_CONSERV |
160 |
|
|
# include "SURFACE.h" |
161 |
|
|
# endif |
162 |
|
|
# ifdef ALLOW_OBCS |
163 |
jmc |
1.3 |
# include "OBCS_PARAMS.h" |
164 |
|
|
# include "OBCS_GRID.h" |
165 |
|
|
# include "OBCS_FIELDS.h" |
166 |
|
|
# include "OBCS_SEAICE.h" |
167 |
utke |
1.1 |
# endif |
168 |
|
|
# ifdef ALLOW_EXF |
169 |
|
|
# include "EXF_FIELDS.h" |
170 |
|
|
# include "EXF_PARAM.h" |
171 |
|
|
# ifdef ALLOW_BULKFORMULAE |
172 |
|
|
# include "EXF_CONSTANTS.h" |
173 |
|
|
# endif |
174 |
|
|
# endif /* ALLOW_EXF */ |
175 |
|
|
# ifdef ALLOW_SEAICE |
176 |
|
|
# include "SEAICE.h" |
177 |
|
|
# endif |
178 |
|
|
# ifdef ALLOW_EBM |
179 |
|
|
# include "EBM.h" |
180 |
|
|
# endif |
181 |
|
|
# ifdef ALLOW_KPP |
182 |
|
|
# include "KPP.h" |
183 |
|
|
# include "KPP_DIAGS.h" |
184 |
|
|
# include "KPP_PARAMS.h" |
185 |
|
|
# endif |
186 |
|
|
# ifdef ALLOW_DIVIDED_ADJOINT_MPI |
187 |
|
|
# include "mpif.h" |
188 |
|
|
# endif |
189 |
|
|
|
190 |
|
|
# include "tamc.h" |
191 |
|
|
# include "ctrl.h" |
192 |
|
|
# include "ctrl_dummy.h" |
193 |
|
|
# include "cost.h" |
194 |
|
|
|
195 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
196 |
|
|
|
197 |
|
|
integer uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4 |
198 |
|
|
integer theCurrentStep |
199 |
|
|
INTEGER myThid |
200 |
|
|
INTEGER myIter |
201 |
|
|
_RL myTime |
202 |
|
|
|
203 |
|
|
C !LOCAL VARIABLES: |
204 |
|
|
C == Local variables == |
205 |
|
|
integer ilev_3 |
206 |
|
|
|
207 |
|
|
#ifdef ALLOW_DEBUG |
208 |
|
|
IF (debugMode) CALL DEBUG_ENTER('THE_FOURTH_LEVEL_PLAIN',myThid) |
209 |
|
|
#endif |
210 |
utke |
1.2 |
#ifdef OAD_DEBUG_JOINT |
211 |
|
|
write(standardmessageunit,'(A)') |
212 |
|
|
+ 'OAD: THE_FOURTH_LEVEL_PLAIN()' |
213 |
|
|
#endif |
214 |
utke |
1.1 |
if (uCheckLev3 .gt. 0 ) then |
215 |
|
|
do ilev_3 = 1,uCheckLev3 |
216 |
|
|
if (theCurrentStep .le. nTimeSteps) then |
217 |
|
|
#ifdef ALLOW_DEBUG |
218 |
|
|
IF (debugMode) CALL DEBUG_CALL('THE_THIRD_LEVEL_LOOP', |
219 |
|
|
+myThid) |
220 |
|
|
#endif |
221 |
|
|
CALL THE_THIRD_LEVEL_LOOP( 1, iLev_3, |
222 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
223 |
|
|
+theCurrentStep, |
224 |
|
|
+mytime, myiter, mythid ) |
225 |
|
|
end if |
226 |
|
|
end do |
227 |
|
|
else |
228 |
|
|
#ifdef ALLOW_DEBUG |
229 |
|
|
IF (debugMode) CALL DEBUG_CALL('THE_THIRD_LEVEL_PLAIN',myThid) |
230 |
|
|
#endif |
231 |
|
|
CALL THE_THIRD_LEVEL_PLAIN( |
232 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
233 |
|
|
+theCurrentStep, |
234 |
|
|
+mytime, myiter, mythid ) |
235 |
|
|
end if |
236 |
|
|
#ifdef ALLOW_DEBUG |
237 |
|
|
IF (debugMode) CALL DEBUG_LEAVE('THE_FOURTH_LEVEL_LOOP',myThid) |
238 |
|
|
#endif |
239 |
|
|
|
240 |
|
|
END |