/[MITgcm]/MITgcm_contrib/CS_ADJOINT_TESTS/diffuse/code/the_main_loop.F
ViewVC logotype

Annotation of /MITgcm_contrib/CS_ADJOINT_TESTS/diffuse/code/the_main_loop.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Wed Jul 7 03:12:36 2004 UTC (21 years, 1 month ago) by cnh
Branch: MAIN
Test code for use in developing and maintaining exch2 adjoints

1 cnh 1.1 C $Header: /u/gcmpack/MITgcm/model/src/the_main_loop.F,v 1.51 2004/05/21 21:45:35 heimbach Exp $
2     C $Name: $
3    
4     #include "PACKAGES_CONFIG.h"
5     #include "CPP_OPTIONS.h"
6     #ifdef ALLOW_PTRACERS
7     # include "PTRACERS_OPTIONS.h"
8     #endif
9     #ifdef ALLOW_OBCS
10     # include "OBCS_OPTIONS.h"
11     #endif
12    
13     CBOP
14     C !ROUTINE: THE_MAIN_LOOP
15     C !INTERFACE:
16     SUBROUTINE THE_MAIN_LOOP( myTime, myIter, myThid )
17    
18     C !DESCRIPTION: \bv
19     C *================================================================*
20     C | SUBROUTINE the_main_loop
21     C | o Run the ocean model and evaluate the specified cost function.
22     C *================================================================*
23     C |
24     C | THE_MAIN_LOOP is the toplevel routine for the Tangent Linear and
25     C | Adjoint Model Compiler (TAMC). For this purpose the initialization
26     C | of the model was split into two parts. Those parameters that do
27     C | not depend on a specific model run are set in INITIALISE_FIXED,
28     C | whereas those that do depend on the specific realization are
29     C | initialized in INITIALISE_VARIA.
30     C | This routine is to be used in conjuction with the MITgcmuv
31     C | checkpoint 37.
32     C *================================================================*
33     C \ev
34    
35     C !USES:
36     IMPLICIT NONE
37     C == Global variables ==
38     #include "SIZE.h"
39     #include "EEPARAMS.h"
40     #include "PARAMS.h"
41     #include "DYNVARS.h"
42     #include "GRID.h"
43    
44     c**************************************
45     #ifdef ALLOW_AUTODIFF_TAMC
46    
47     c These includes are needed for
48     c AD-checkpointing.
49     c They provide the fields to be stored.
50    
51     # include "GRID.h"
52     # include "DYNVARS.h"
53     # include "FFIELDS.h"
54     # include "EOS.h"
55     # ifdef ALLOW_GENERIC_ADVDIFF
56     # include "GAD.h"
57     # endif
58     # ifdef ALLOW_CD_CODE
59     # include "CD_CODE_VARS.h"
60     # endif
61     # ifdef ALLOW_PASSIVE_TRACER
62     # include "TR1.h"
63     # endif
64     # ifdef ALLOW_PTRACERS
65     # include "PTRACERS.h"
66     # endif
67     # ifdef ALLOW_NONHYDROSTATIC
68     # include "CG3D.h"
69     # endif
70     # ifdef EXACT_CONSERV
71     # include "SURFACE.h"
72     # endif
73     # ifdef ALLOW_OBCS
74     # include "OBCS.h"
75     # endif
76     # ifdef ALLOW_EXF
77     # include "exf_fields.h"
78     # include "exf_clim_fields.h"
79     # ifdef ALLOW_BULKFORMULAE
80     # include "exf_constants.h"
81     # endif
82     # endif /* ALLOW_EXF */
83     # ifdef ALLOW_SEAICE
84     # include "SEAICE.h"
85     # endif
86     # ifdef ALLOW_EBM
87     # include "EBM.h"
88     # endif
89     # ifdef ALLOW_DIVIDED_ADJOINT_MPI
90     # include "mpif.h"
91     # endif
92    
93     # include "tamc.h"
94     # include "ctrl.h"
95     # include "ctrl_dummy.h"
96     # include "cost.h"
97    
98     #endif /* ALLOW_AUTODIFF_TAMC */
99     c**************************************
100    
101     C !INPUT/OUTPUT PARAMETERS:
102     C == Routine arguments ==
103     C note: under the multi-threaded model myiter and
104     C mytime are local variables passed around as routine
105     C arguments. Although this is fiddly it saves the need to
106     C impose additional synchronisation points when they are
107     C updated.
108     C myIter - iteration counter for this thread
109     C myTime - time counter for this thread
110     C myThid - thread number for this instance of the routine.
111     INTEGER myThid
112     INTEGER myIter
113     _RL myTime
114    
115     C !LOCAL VARIABLES:
116     C == Local variables ==
117     integer iloop
118     INTEGER I,J,K,bi,bj
119     #ifdef ALLOW_TAMC_CHECKPOINTING
120     integer ilev_1
121     integer ilev_2
122     integer ilev_3
123     integer max_lev2
124     integer max_lev3
125     #endif
126     CEOP
127    
128     #ifdef ALLOW_DEBUG
129     IF (debugMode) CALL DEBUG_ENTER('THE_MAIN_LOOP',myThid)
130     #endif
131    
132     #ifdef ALLOW_AUTODIFF_TAMC
133     c-- Initialize storage for the cost function evaluation.
134     CADJ INIT dummytape = common, 1
135     c-- Initialize storage for the outermost loop.
136     CADJ INIT tapelev3 = USER
137     CADJ INIT tapelev_ini_bibj_k = USER
138     #ifdef ALLOW_TAMC_CHECKPOINTING
139     nIter0 = INT( startTime/deltaTClock )
140     ikey_dynamics = 1
141     #endif
142     CALL TIMER_START('ADJOINT SPIN-UP', mythid)
143     #endif
144    
145     #ifdef ALLOW_DEBUG
146     IF (debugMode) CALL DEBUG_CALL('INITIALISE_VARIA',myThid)
147     #endif
148    
149     C-- Set initial conditions (variable arrays)
150     CALL TIMER_START('INITIALISE_VARIA [THE_MAIN_LOOP]', mythid)
151     CALL INITIALISE_VARIA( mythid )
152     CALL TIMER_STOP ('INITIALISE_VARIA [THE_MAIN_LOOP]', mythid)
153    
154     #ifdef ALLOW_MONITOR
155     #ifdef ALLOW_DEBUG
156     IF (debugMode) CALL DEBUG_CALL('MONITOR',myThid)
157     #endif
158     C-- Check status of solution (statistics, cfl, etc...)
159     CALL TIMER_START('MONITOR [THE_MAIN_LOOP]', mythid)
160     CALL MONITOR( myIter, myTime, myThid )
161     CALL TIMER_STOP ('MONITOR [THE_MAIN_LOOP]', mythid)
162     #endif /* ALLOW_MONITOR */
163    
164     C-- Do IO if needed (Dump for start state).
165     #ifdef ALLOW_DEBUG
166     IF (debugMode) CALL DEBUG_CALL('DO_THE_MODEL_IO',myThid)
167     #endif
168     CALL TIMER_START('DO_THE_MODEL_IO [THE_MAIN_LOOP]', mythid)
169     CALL DO_THE_MODEL_IO( myTime, myIter, mythid )
170     CALL TIMER_STOP ('DO_THE_MODEL_IO [THE_MAIN_LOOP]', mythid)
171    
172     #ifdef ALLOW_AUTODIFF_TAMC
173     CALL TIMER_STOP ('ADJOINT SPIN-UP', mythid)
174     _BARRIER
175     #endif
176    
177     C CALL CTRL_MAP_INI(mythid)
178    
179     DO bj=myByLo(myThid),myByHi(myThid)
180     DO bi=myBxLo(myThid),myBxHi(myThid)
181     DO K=1,Nr
182     DO J=1-OLy,sNy+OLy
183     DO I=1-OLx,sNx+OLx
184     theta(i,j,k,bi,bj) = 0.
185     gT (i,j,k,bi,bj) = 0.
186     gTNM1(i,j,k,bi,bj) = 0.
187     ENDDO
188     ENDDO
189     ENDDO
190     ENDDO
191     ENDDO
192     theta(7,17,1,2,1) = 1.
193    
194     DO iLoop=1,10000
195     CALL DIFFUSE_THETA(myTime, myIter, myThid)
196     ENDDO
197    
198     CALL DO_FIELDS_BLOCKING_EXCHANGES( mythid )
199    
200     CALL DO_FIELDS_BLOCKING_EXCHANGES( mythid )
201    
202     CALL DO_FIELDS_BLOCKING_EXCHANGES( mythid )
203    
204     CALL DO_FIELDS_BLOCKING_EXCHANGES( mythid )
205    
206     #ifdef ALLOW_COST
207     c-- Sum all cost function contributions.
208     call TIMER_START('COST_FINAL [ADJOINT SPIN-DOWN]', mythid)
209     call COST_FINAL ( mythid )
210     call TIMER_STOP ('COST_FINAL [ADJOINT SPIN-DOWN]', mythid)
211     #endif
212    
213     _BARRIER
214     CALL TIMER_STOP ('MAIN LOOP [THE_MAIN_LOOP]', mythid)
215    
216     #ifdef ALLOW_DEBUG
217     IF (debugMode) CALL DEBUG_LEAVE('THE_MAIN_LOOP',myThid)
218     #endif
219    
220     END

  ViewVC Help
Powered by ViewVC 1.1.22