1 |
C $Header: /u/gcmpack/MITgcm_contrib/heimbach/OpenAD/code_common/the_fourth_level_loop.F,v 1.2 2008/11/18 17:57:05 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_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 |
print *, 'JU: THE_FOURTH_LEVEL_LOOP(',ilev_4,')' |
102 |
do ilev_3 = 1,uCheckLev3 |
103 |
if (theCurrentStep .le. nTimeSteps) then |
104 |
#ifdef ALLOW_DEBUG |
105 |
IF (debugMode) CALL DEBUG_CALL('THE_THIRD_LEVEL_LOOP', |
106 |
+myThid) |
107 |
#endif |
108 |
CALL THE_THIRD_LEVEL_LOOP( ilev_4, iLev_3, |
109 |
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
110 |
+theCurrentStep, |
111 |
+mytime, myiter, mythid ) |
112 |
end if |
113 |
end do |
114 |
#ifdef ALLOW_DEBUG |
115 |
IF (debugMode) CALL DEBUG_LEAVE('THE_FOURTH_LEVEL_LOOP',myThid) |
116 |
#endif |
117 |
|
118 |
END |
119 |
|
120 |
SUBROUTINE THE_FOURTH_LEVEL_PLAIN( |
121 |
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
122 |
+theCurrentStep, |
123 |
+myTime, myIter,myThid ) |
124 |
IMPLICIT NONE |
125 |
|
126 |
C == Global variables == |
127 |
#include "SIZE.h" |
128 |
#include "EEPARAMS.h" |
129 |
#include "PARAMS.h" |
130 |
|
131 |
c************************************** |
132 |
#ifdef ALLOW_AUTODIFF_TAMC |
133 |
|
134 |
c These includes are needed for |
135 |
c AD-checkpointing. |
136 |
c They provide the fields to be stored. |
137 |
|
138 |
# include "GRID.h" |
139 |
# include "DYNVARS.h" |
140 |
# include "FFIELDS.h" |
141 |
# include "EOS.h" |
142 |
# include "GAD.h" |
143 |
# ifdef ALLOW_CAL |
144 |
# include "cal.h" |
145 |
# endif |
146 |
# ifdef ALLOW_CD_CODE |
147 |
# include "CD_CODE_VARS.h" |
148 |
# endif |
149 |
# ifdef ALLOW_PTRACERS |
150 |
# include "PTRACERS_SIZE.h" |
151 |
# include "PTRACERS.h" |
152 |
# endif |
153 |
# ifdef EXACT_CONSERV |
154 |
# include "SURFACE.h" |
155 |
# endif |
156 |
# ifdef ALLOW_OBCS |
157 |
# include "OBCS.h" |
158 |
# endif |
159 |
# ifdef ALLOW_EXF |
160 |
# include "EXF_FIELDS.h" |
161 |
# include "EXF_PARAM.h" |
162 |
# ifdef ALLOW_BULKFORMULAE |
163 |
# include "EXF_CONSTANTS.h" |
164 |
# endif |
165 |
# endif /* ALLOW_EXF */ |
166 |
# ifdef ALLOW_SEAICE |
167 |
# include "SEAICE.h" |
168 |
# endif |
169 |
# ifdef ALLOW_EBM |
170 |
# include "EBM.h" |
171 |
# endif |
172 |
# ifdef ALLOW_KPP |
173 |
# include "KPP.h" |
174 |
# include "KPP_DIAGS.h" |
175 |
# include "KPP_PARAMS.h" |
176 |
# endif |
177 |
# ifdef ALLOW_DIVIDED_ADJOINT_MPI |
178 |
# include "mpif.h" |
179 |
# endif |
180 |
|
181 |
# include "tamc.h" |
182 |
# include "ctrl.h" |
183 |
# include "ctrl_dummy.h" |
184 |
# include "cost.h" |
185 |
|
186 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
187 |
|
188 |
integer uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4 |
189 |
integer theCurrentStep |
190 |
INTEGER myThid |
191 |
INTEGER myIter |
192 |
_RL myTime |
193 |
|
194 |
C !LOCAL VARIABLES: |
195 |
C == Local variables == |
196 |
integer ilev_3 |
197 |
|
198 |
#ifdef ALLOW_DEBUG |
199 |
IF (debugMode) CALL DEBUG_ENTER('THE_FOURTH_LEVEL_PLAIN',myThid) |
200 |
#endif |
201 |
print *, 'JU: THE_FOURTH_LEVEL_PLAIN()' |
202 |
if (uCheckLev3 .gt. 0 ) then |
203 |
do ilev_3 = 1,uCheckLev3 |
204 |
if (theCurrentStep .le. nTimeSteps) then |
205 |
#ifdef ALLOW_DEBUG |
206 |
IF (debugMode) CALL DEBUG_CALL('THE_THIRD_LEVEL_LOOP', |
207 |
+myThid) |
208 |
#endif |
209 |
CALL THE_THIRD_LEVEL_LOOP( 1, iLev_3, |
210 |
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
211 |
+theCurrentStep, |
212 |
+mytime, myiter, mythid ) |
213 |
end if |
214 |
end do |
215 |
else |
216 |
#ifdef ALLOW_DEBUG |
217 |
IF (debugMode) CALL DEBUG_CALL('THE_THIRD_LEVEL_PLAIN',myThid) |
218 |
#endif |
219 |
CALL THE_THIRD_LEVEL_PLAIN( |
220 |
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
221 |
+theCurrentStep, |
222 |
+mytime, myiter, mythid ) |
223 |
end if |
224 |
#ifdef ALLOW_DEBUG |
225 |
IF (debugMode) CALL DEBUG_LEAVE('THE_FOURTH_LEVEL_LOOP',myThid) |
226 |
#endif |
227 |
|
228 |
END |