1 |
utke |
1.2 |
C $Header: /u/gcmpack/MITgcm/verification/OpenAD/code_oad_all/the_fourth_level_loop.F,v 1.1 2009/01/29 21:46:50 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 |
|
|
# include "OBCS.h" |
56 |
|
|
# endif |
57 |
|
|
# ifdef ALLOW_EXF |
58 |
|
|
# include "EXF_FIELDS.h" |
59 |
|
|
# include "EXF_PARAM.h" |
60 |
|
|
# ifdef ALLOW_BULKFORMULAE |
61 |
|
|
# include "EXF_CONSTANTS.h" |
62 |
|
|
# endif |
63 |
|
|
# endif /* ALLOW_EXF */ |
64 |
|
|
# ifdef ALLOW_SEAICE |
65 |
|
|
# include "SEAICE.h" |
66 |
|
|
# endif |
67 |
|
|
# ifdef ALLOW_EBM |
68 |
|
|
# include "EBM.h" |
69 |
|
|
# endif |
70 |
|
|
# ifdef ALLOW_KPP |
71 |
|
|
# include "KPP.h" |
72 |
|
|
# include "KPP_DIAGS.h" |
73 |
|
|
# include "KPP_PARAMS.h" |
74 |
|
|
# endif |
75 |
|
|
# ifdef ALLOW_DIVIDED_ADJOINT_MPI |
76 |
|
|
# include "mpif.h" |
77 |
|
|
# endif |
78 |
|
|
|
79 |
|
|
# include "tamc.h" |
80 |
|
|
# include "ctrl.h" |
81 |
|
|
# include "ctrl_dummy.h" |
82 |
|
|
# include "cost.h" |
83 |
|
|
|
84 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
85 |
|
|
|
86 |
|
|
integer ilev_4 |
87 |
|
|
integer uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4 |
88 |
|
|
integer theCurrentStep |
89 |
|
|
INTEGER myThid |
90 |
|
|
INTEGER myIter |
91 |
|
|
_RL myTime |
92 |
|
|
|
93 |
|
|
C !LOCAL VARIABLES: |
94 |
|
|
C == Local variables == |
95 |
|
|
integer ilev_3 |
96 |
|
|
integer remainingSteps |
97 |
|
|
|
98 |
|
|
#ifdef ALLOW_DEBUG |
99 |
|
|
IF (debugMode) CALL DEBUG_ENTER('THE_FOURTH_LEVEL_LOOP',myThid) |
100 |
|
|
#endif |
101 |
utke |
1.2 |
#ifdef OAD_DEBUG_JOINT |
102 |
|
|
write(standardmessageunit,'(A,1(I6,A))') |
103 |
|
|
+ 'OAD: THE_FOURTH_LEVEL_LOOP(',iLev_4,')' |
104 |
|
|
#endif |
105 |
utke |
1.1 |
do ilev_3 = 1,uCheckLev3 |
106 |
|
|
if (theCurrentStep .le. nTimeSteps) then |
107 |
|
|
#ifdef ALLOW_DEBUG |
108 |
|
|
IF (debugMode) CALL DEBUG_CALL('THE_THIRD_LEVEL_LOOP', |
109 |
|
|
+myThid) |
110 |
|
|
#endif |
111 |
|
|
CALL THE_THIRD_LEVEL_LOOP( ilev_4, iLev_3, |
112 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
113 |
|
|
+theCurrentStep, |
114 |
|
|
+mytime, myiter, mythid ) |
115 |
|
|
end if |
116 |
|
|
end do |
117 |
|
|
#ifdef ALLOW_DEBUG |
118 |
|
|
IF (debugMode) CALL DEBUG_LEAVE('THE_FOURTH_LEVEL_LOOP',myThid) |
119 |
|
|
#endif |
120 |
|
|
|
121 |
|
|
END |
122 |
|
|
|
123 |
|
|
SUBROUTINE THE_FOURTH_LEVEL_PLAIN( |
124 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
125 |
|
|
+theCurrentStep, |
126 |
|
|
+myTime, myIter,myThid ) |
127 |
|
|
IMPLICIT NONE |
128 |
|
|
|
129 |
|
|
C == Global variables == |
130 |
|
|
#include "SIZE.h" |
131 |
|
|
#include "EEPARAMS.h" |
132 |
|
|
#include "PARAMS.h" |
133 |
|
|
|
134 |
|
|
c************************************** |
135 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
136 |
|
|
|
137 |
|
|
c These includes are needed for |
138 |
|
|
c AD-checkpointing. |
139 |
|
|
c They provide the fields to be stored. |
140 |
|
|
|
141 |
|
|
# include "GRID.h" |
142 |
|
|
# include "DYNVARS.h" |
143 |
|
|
# include "FFIELDS.h" |
144 |
|
|
# include "EOS.h" |
145 |
|
|
# include "GAD.h" |
146 |
|
|
# ifdef ALLOW_CAL |
147 |
|
|
# include "cal.h" |
148 |
|
|
# endif |
149 |
|
|
# ifdef ALLOW_CD_CODE |
150 |
|
|
# include "CD_CODE_VARS.h" |
151 |
|
|
# endif |
152 |
|
|
# ifdef ALLOW_PTRACERS |
153 |
|
|
# include "PTRACERS_SIZE.h" |
154 |
|
|
# include "PTRACERS.h" |
155 |
|
|
# endif |
156 |
|
|
# ifdef EXACT_CONSERV |
157 |
|
|
# include "SURFACE.h" |
158 |
|
|
# endif |
159 |
|
|
# ifdef ALLOW_OBCS |
160 |
|
|
# include "OBCS.h" |
161 |
|
|
# endif |
162 |
|
|
# ifdef ALLOW_EXF |
163 |
|
|
# include "EXF_FIELDS.h" |
164 |
|
|
# include "EXF_PARAM.h" |
165 |
|
|
# ifdef ALLOW_BULKFORMULAE |
166 |
|
|
# include "EXF_CONSTANTS.h" |
167 |
|
|
# endif |
168 |
|
|
# endif /* ALLOW_EXF */ |
169 |
|
|
# ifdef ALLOW_SEAICE |
170 |
|
|
# include "SEAICE.h" |
171 |
|
|
# endif |
172 |
|
|
# ifdef ALLOW_EBM |
173 |
|
|
# include "EBM.h" |
174 |
|
|
# endif |
175 |
|
|
# ifdef ALLOW_KPP |
176 |
|
|
# include "KPP.h" |
177 |
|
|
# include "KPP_DIAGS.h" |
178 |
|
|
# include "KPP_PARAMS.h" |
179 |
|
|
# endif |
180 |
|
|
# ifdef ALLOW_DIVIDED_ADJOINT_MPI |
181 |
|
|
# include "mpif.h" |
182 |
|
|
# endif |
183 |
|
|
|
184 |
|
|
# include "tamc.h" |
185 |
|
|
# include "ctrl.h" |
186 |
|
|
# include "ctrl_dummy.h" |
187 |
|
|
# include "cost.h" |
188 |
|
|
|
189 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
190 |
|
|
|
191 |
|
|
integer uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4 |
192 |
|
|
integer theCurrentStep |
193 |
|
|
INTEGER myThid |
194 |
|
|
INTEGER myIter |
195 |
|
|
_RL myTime |
196 |
|
|
|
197 |
|
|
C !LOCAL VARIABLES: |
198 |
|
|
C == Local variables == |
199 |
|
|
integer ilev_3 |
200 |
|
|
|
201 |
|
|
#ifdef ALLOW_DEBUG |
202 |
|
|
IF (debugMode) CALL DEBUG_ENTER('THE_FOURTH_LEVEL_PLAIN',myThid) |
203 |
|
|
#endif |
204 |
utke |
1.2 |
#ifdef OAD_DEBUG_JOINT |
205 |
|
|
write(standardmessageunit,'(A)') |
206 |
|
|
+ 'OAD: THE_FOURTH_LEVEL_PLAIN()' |
207 |
|
|
#endif |
208 |
utke |
1.1 |
if (uCheckLev3 .gt. 0 ) then |
209 |
|
|
do ilev_3 = 1,uCheckLev3 |
210 |
|
|
if (theCurrentStep .le. nTimeSteps) then |
211 |
|
|
#ifdef ALLOW_DEBUG |
212 |
|
|
IF (debugMode) CALL DEBUG_CALL('THE_THIRD_LEVEL_LOOP', |
213 |
|
|
+myThid) |
214 |
|
|
#endif |
215 |
|
|
CALL THE_THIRD_LEVEL_LOOP( 1, iLev_3, |
216 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
217 |
|
|
+theCurrentStep, |
218 |
|
|
+mytime, myiter, mythid ) |
219 |
|
|
end if |
220 |
|
|
end do |
221 |
|
|
else |
222 |
|
|
#ifdef ALLOW_DEBUG |
223 |
|
|
IF (debugMode) CALL DEBUG_CALL('THE_THIRD_LEVEL_PLAIN',myThid) |
224 |
|
|
#endif |
225 |
|
|
CALL THE_THIRD_LEVEL_PLAIN( |
226 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
227 |
|
|
+theCurrentStep, |
228 |
|
|
+mytime, myiter, mythid ) |
229 |
|
|
end if |
230 |
|
|
#ifdef ALLOW_DEBUG |
231 |
|
|
IF (debugMode) CALL DEBUG_LEAVE('THE_FOURTH_LEVEL_LOOP',myThid) |
232 |
|
|
#endif |
233 |
|
|
|
234 |
|
|
END |