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