1 |
heimbach |
1.1 |
C $Header: /u/gcmpack/MITgcm/verification/OpenAD/code_ad/the_third_level_loop.F,v 1.3 2005/12/10 17:44:23 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_THIRD_LEVEL_LOOP(iLev_4, iLev_3, |
19 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
20 |
|
|
+myTime, myIter,myThid ) |
21 |
|
|
IMPLICIT NONE |
22 |
|
|
|
23 |
|
|
C == Global variables == |
24 |
|
|
#include "SIZE.h" |
25 |
|
|
#include "EEPARAMS.h" |
26 |
|
|
#include "PARAMS.h" |
27 |
|
|
|
28 |
|
|
c************************************** |
29 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
30 |
|
|
|
31 |
|
|
c These includes are needed for |
32 |
|
|
c AD-checkpointing. |
33 |
|
|
c They provide the fields to be stored. |
34 |
|
|
|
35 |
|
|
# include "GRID.h" |
36 |
|
|
# include "DYNVARS.h" |
37 |
|
|
# include "FFIELDS.h" |
38 |
|
|
# include "EOS.h" |
39 |
|
|
# include "GAD.h" |
40 |
|
|
# ifdef ALLOW_CD_CODE |
41 |
|
|
# include "CD_CODE_VARS.h" |
42 |
|
|
# endif |
43 |
|
|
# ifdef ALLOW_PTRACERS |
44 |
|
|
# include "PTRACERS_SIZE.h" |
45 |
|
|
# include "PTRACERS.h" |
46 |
|
|
# endif |
47 |
|
|
# ifdef EXACT_CONSERV |
48 |
|
|
# include "SURFACE.h" |
49 |
|
|
# endif |
50 |
|
|
# ifdef ALLOW_OBCS |
51 |
|
|
# include "OBCS.h" |
52 |
|
|
# endif |
53 |
|
|
# ifdef ALLOW_EXF |
54 |
|
|
# include "exf_fields.h" |
55 |
|
|
# include "exf_clim_fields.h" |
56 |
|
|
# ifdef ALLOW_BULKFORMULAE |
57 |
|
|
# include "exf_constants.h" |
58 |
|
|
# endif |
59 |
|
|
# endif /* ALLOW_EXF */ |
60 |
|
|
# ifdef ALLOW_SEAICE |
61 |
|
|
# include "SEAICE.h" |
62 |
|
|
# endif |
63 |
|
|
# ifdef ALLOW_EBM |
64 |
|
|
# include "EBM.h" |
65 |
|
|
# endif |
66 |
|
|
# ifdef ALLOW_DIVIDED_ADJOINT_MPI |
67 |
|
|
# include "mpif.h" |
68 |
|
|
# endif |
69 |
|
|
|
70 |
|
|
# include "tamc.h" |
71 |
|
|
# include "ctrl.h" |
72 |
|
|
# include "ctrl_dummy.h" |
73 |
|
|
# include "cost.h" |
74 |
|
|
|
75 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
76 |
|
|
|
77 |
|
|
integer iLev_4 |
78 |
|
|
integer iLev_3 |
79 |
|
|
integer uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4 |
80 |
|
|
INTEGER myThid |
81 |
|
|
INTEGER myIter |
82 |
|
|
_RL myTime |
83 |
|
|
|
84 |
|
|
C !LOCAL VARIABLES: |
85 |
|
|
C == Local variables == |
86 |
|
|
integer ilev_2 |
87 |
|
|
|
88 |
|
|
#ifdef ALLOW_DEBUG |
89 |
|
|
IF (debugMode) CALL DEBUG_ENTER('THE_THIRD_LEVEL_LOOP',myThid) |
90 |
|
|
#endif |
91 |
|
|
print *, 'JU: THE_THIRD_LEVEL_LOOP(',iLev_4,',',iLev_3,')' |
92 |
|
|
if (uCheckLev2 .gt. 0 ) then |
93 |
|
|
do ilev_2 = 0,uCheckLev2 - 1 |
94 |
|
|
#ifdef ALLOW_DEBUG |
95 |
|
|
IF (debugMode) CALL DEBUG_CALL('THE_SECOND_LEVEL_LOOP',myThid) |
96 |
|
|
#endif |
97 |
|
|
CALL THE_SECOND_LEVEL_LOOP( iLev_4, iLev_3, iLev_2, |
98 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
99 |
|
|
+mytime, myiter, mythid ) |
100 |
|
|
enddo |
101 |
|
|
else |
102 |
|
|
#ifdef ALLOW_DEBUG |
103 |
|
|
IF (debugMode) CALL DEBUG_CALL('THE_SECOND_LEVEL_PLAIN',myThid) |
104 |
|
|
#endif |
105 |
|
|
CALL THE_SECOND_LEVEL_PLAIN( iLev_4, iLev_3, |
106 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
107 |
|
|
+mytime, myiter, mythid ) |
108 |
|
|
end if |
109 |
|
|
#ifdef ALLOW_DEBUG |
110 |
|
|
IF (debugMode) CALL DEBUG_LEAVE('THE_THIRD_LEVEL_LOOP',myThid) |
111 |
|
|
#endif |
112 |
|
|
|
113 |
|
|
END |
114 |
|
|
|
115 |
|
|
SUBROUTINE THE_THIRD_LEVEL_PLAIN(iLev_4, |
116 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
117 |
|
|
+myTime, myIter,myThid ) |
118 |
|
|
IMPLICIT NONE |
119 |
|
|
|
120 |
|
|
C == Global variables == |
121 |
|
|
#include "SIZE.h" |
122 |
|
|
#include "EEPARAMS.h" |
123 |
|
|
#include "PARAMS.h" |
124 |
|
|
|
125 |
|
|
c************************************** |
126 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
127 |
|
|
|
128 |
|
|
c These includes are needed for |
129 |
|
|
c AD-checkpointing. |
130 |
|
|
c They provide the fields to be stored. |
131 |
|
|
|
132 |
|
|
# include "GRID.h" |
133 |
|
|
# include "DYNVARS.h" |
134 |
|
|
# include "FFIELDS.h" |
135 |
|
|
# include "EOS.h" |
136 |
|
|
# include "GAD.h" |
137 |
|
|
# ifdef ALLOW_CD_CODE |
138 |
|
|
# include "CD_CODE_VARS.h" |
139 |
|
|
# endif |
140 |
|
|
# ifdef ALLOW_PTRACERS |
141 |
|
|
# include "PTRACERS_SIZE.h" |
142 |
|
|
# include "PTRACERS.h" |
143 |
|
|
# endif |
144 |
|
|
# ifdef EXACT_CONSERV |
145 |
|
|
# include "SURFACE.h" |
146 |
|
|
# endif |
147 |
|
|
# ifdef ALLOW_OBCS |
148 |
|
|
# include "OBCS.h" |
149 |
|
|
# endif |
150 |
|
|
# ifdef ALLOW_EXF |
151 |
|
|
# include "exf_fields.h" |
152 |
|
|
# include "exf_clim_fields.h" |
153 |
|
|
# ifdef ALLOW_BULKFORMULAE |
154 |
|
|
# include "exf_constants.h" |
155 |
|
|
# endif |
156 |
|
|
# endif /* ALLOW_EXF */ |
157 |
|
|
# ifdef ALLOW_SEAICE |
158 |
|
|
# include "SEAICE.h" |
159 |
|
|
# endif |
160 |
|
|
# ifdef ALLOW_EBM |
161 |
|
|
# include "EBM.h" |
162 |
|
|
# endif |
163 |
|
|
# ifdef ALLOW_DIVIDED_ADJOINT_MPI |
164 |
|
|
# include "mpif.h" |
165 |
|
|
# endif |
166 |
|
|
|
167 |
|
|
# include "tamc.h" |
168 |
|
|
# include "ctrl.h" |
169 |
|
|
# include "ctrl_dummy.h" |
170 |
|
|
# include "cost.h" |
171 |
|
|
|
172 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
173 |
|
|
|
174 |
|
|
integer iLev_4 |
175 |
|
|
integer uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4 |
176 |
|
|
INTEGER myThid |
177 |
|
|
INTEGER myIter |
178 |
|
|
_RL myTime |
179 |
|
|
|
180 |
|
|
C !LOCAL VARIABLES: |
181 |
|
|
C == Local variables == |
182 |
|
|
integer ilev_2 |
183 |
|
|
|
184 |
|
|
#ifdef ALLOW_DEBUG |
185 |
|
|
IF (debugMode) CALL DEBUG_ENTER('THE_THIRD_LEVEL_PLAIN',myThid) |
186 |
|
|
#endif |
187 |
|
|
print *, 'JU: THE_THIRD_LEVEL_PLAIN(',iLev_4,')' |
188 |
|
|
if (uCheckLev2 .gt. 0 ) then |
189 |
|
|
do ilev_2 = 0,uCheckLev2 - 1 |
190 |
|
|
#ifdef ALLOW_DEBUG |
191 |
|
|
IF (debugMode) CALL DEBUG_CALL('THE_SECOND_LEVEL_LOOP',myThid) |
192 |
|
|
#endif |
193 |
|
|
CALL THE_SECOND_LEVEL_LOOP( iLev_4, 0, iLev_2, |
194 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
195 |
|
|
+mytime, myiter, mythid ) |
196 |
|
|
enddo |
197 |
|
|
else |
198 |
|
|
#ifdef ALLOW_DEBUG |
199 |
|
|
IF (debugMode) CALL DEBUG_CALL('THE_SECOND_LEVEL_PLAIN',myThid) |
200 |
|
|
#endif |
201 |
|
|
CALL THE_SECOND_LEVEL_PLAIN( iLev_4, 0, |
202 |
|
|
+uCheckLev1, uCheckLev2, uCheckLev3,uCheckLev4, |
203 |
|
|
+mytime, myiter, mythid ) |
204 |
|
|
end if |
205 |
|
|
#ifdef ALLOW_DEBUG |
206 |
|
|
IF (debugMode) CALL DEBUG_LEAVE('THE_THIRD_LEVEL_PLAIN',myThid) |
207 |
|
|
#endif |
208 |
|
|
|
209 |
|
|
END |