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