/[MITgcm]/MITgcm/model/src/forward_step.F
ViewVC logotype

Contents of /MITgcm/model/src/forward_step.F

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


Revision 1.16 - (show annotations) (download)
Mon Aug 13 23:28:40 2001 UTC (22 years, 10 months ago) by heimbach
Branch: MAIN
Changes since 1.15: +12 -10 lines
Modification for adjoint.

1 C $Header: /u/gcmpack/models/MITgcmUV/model/src/forward_step.F,v 1.15 2001/08/03 19:06:11 adcroft Exp $
2 C $Name: $
3
4 #include "CPP_OPTIONS.h"
5
6 SUBROUTINE FORWARD_STEP( iloop, myTime, myIter, myThid )
7 IMPLICIT NONE
8
9 c ==================================================================
10 c SUBROUTINE forward_step
11 c ==================================================================
12 c
13 c o Run the ocean model and evaluate the specified cost function.
14 c
15 c *the_main_loop* is the toplevel routine for the Tangent Linear and
16 c Adjoint Model Compiler (TAMC). For this purpose the initialization
17 c of the model was split into two parts. Those parameters that do
18 c not depend on a specific model run are set in *initialise_fixed*,
19 c whereas those that do depend on the specific realization are
20 c initialized in *initialise_varia*.
21
22 C == global variables ==
23 #include "SIZE.h"
24 #include "EEPARAMS.h"
25 #include "PARAMS.h"
26 #include "DYNVARS.h"
27 #include "FFIELDS.h"
28 #include "TR1.h"
29
30 #ifdef ALLOW_NONHYDROSTATIC
31 #include "CG3D.h"
32 #endif
33
34 #ifdef ALLOW_AUTODIFF_TAMC
35 #include "tamc.h"
36 #include "ctrl.h"
37 #include "ctrl_dummy.h"
38 #include "cost.h"
39 #endif
40
41 C == routine arguments ==
42 C note: under the multi-threaded model myiter and
43 C mytime are local variables passed around as routine
44 C arguments. Although this is fiddly it saves the need to
45 C impose additional synchronisation points when they are
46 C updated.
47 C myiter - iteration counter for this thread
48 C mytime - time counter for this thread
49 C mythid - thread number for this instance of the routine.
50 integer iloop
51 integer mythid
52 integer myiter
53 _RL mytime
54
55 C == local variables ==
56
57
58 #ifdef ALLOW_AUTODIFF_TAMC
59 C-- Reset the model iteration counter and the model time.
60 myiter = nIter0 + (iloop-1)
61 mytime = startTime + float(iloop-1)*deltaTclock
62 #endif
63
64 #ifdef ALLOW_AUTODIFF_TAMC
65 C Include call to a dummy routine. Its adjoint will be
66 C called at the proper place in the adjoint code.
67 C The adjoint routine will print out adjoint values
68 C if requested. The location of the call is important,
69 C it has to be after the adjoint of the exchanges
70 C (DO_GTERM_BLOCKING_EXCHANGES).
71 CALL DUMMY_IN_STEPPING( myTime, myIter, myThid )
72 #endif
73
74 C-- Load forcing/external data fields.
75 #ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE
76 C NOTE, that although the exf package is part of the
77 C distribution, it is not currently maintained, i.e.
78 C exf is disabled by default in genmake.
79 CALL EXF_GETFORCING( mytime, myiter, mythid )
80 #else
81 CALL TIMER_START('EXTERNAL_FIELDS_LOAD[THE_MAIN_LOOP]',mythid)
82 CALL EXTERNAL_FIELDS_LOAD( mytime, myiter, mythid )
83 CALL TIMER_STOP ('EXTERNAL_FIELDS_LOAD[THE_MAIN_LOOP]',mythid)
84 #endif
85
86 C-- Step forward fields and calculate time tendency terms.
87 CALL TIMER_START('THERMODYNAMICS [THE_MAIN_LOOP]',mythid)
88 CALL THERMODYNAMICS( myTime, myIter, myThid )
89 CALL TIMER_STOP ('THERMODYNAMICS [THE_MAIN_LOOP]',mythid)
90
91 C-- Step forward fields and calculate time tendency terms.
92 CALL TIMER_START('DYNAMICS [THE_MAIN_LOOP]',mythid)
93 CALL DYNAMICS( myTime, myIter, myThid )
94 CALL TIMER_STOP ('DYNAMICS [THE_MAIN_LOOP]',mythid)
95
96 #ifndef ALLOW_AUTODIFF_TAMC
97 #ifdef ALLOW_NONHYDROSTATIC
98 C-- Step forward W field in N-H algorithm
99 IF ( nonHydrostatic ) THEN
100 CALL TIMER_START('CALC_GW [THE_MAIN_LOOP]',myThid)
101 CALL CALC_GW(myThid)
102 CALL TIMER_STOP ('CALC_GW [THE_MAIN_LOOP]',myThid)
103 ENDIF
104 #endif
105 #endif /* ALLOW_AUTODIFF_TAMC */
106
107 C-- This block has been moved to the_correction_step(). We have
108 C left this code here to indicate where the filters used to be
109 C in the algorithm before JMC moved them to after the pressure
110 C solver.
111 C
112 C#ifdef ALLOW_SHAP_FILT
113 CC-- Step forward all tiles, filter and exchange.
114 C CALL TIMER_START('SHAP_FILT [THE_MAIN_LOOP]',myThid)
115 C CALL SHAP_FILT_APPLY(
116 C I gUnm1, gVnm1, gTnm1, gSnm1,
117 C I myTime, myIter, myThid )
118 C IF (implicDiv2Dflow.LT.1.) THEN
119 CC-- Explicit+Implicit part of the Barotropic Flow Divergence
120 CC => Filtering of uVel,vVel is necessary
121 C CALL SHAP_FILT_UV( uVel, vVel, myTime, myThid )
122 C ENDIF
123 C CALL TIMER_STOP ('SHAP_FILT [THE_MAIN_LOOP]',myThid)
124 C#endif
125 C
126 C#ifdef ALLOW_ZONAL_FILT
127 C IF (zonal_filt_lat.LT.90.) THEN
128 C CALL TIMER_START('ZONAL_FILT_APPLY [THE_MAIN_LOOP]',myThid)
129 C CALL ZONAL_FILT_APPLY(
130 C U gUnm1, gVnm1, gTnm1, gSnm1,
131 C I myThid )
132 C CALL TIMER_STOP ('ZONAL_FILT_APPLY [THE_MAIN_LOOP]',myThid)
133 C ENDIF
134 C#endif
135
136 C-- Solve elliptic equation(s).
137 C Two-dimensional only for conventional hydrostatic or
138 C three-dimensional for non-hydrostatic and/or IGW scheme.
139 CALL TIMER_START('SOLVE_FOR_PRESSURE [THE_MAIN_LOOP]',myThid)
140 CALL SOLVE_FOR_PRESSURE( myThid )
141 CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [THE_MAIN_LOOP]',myThid)
142
143 C-- Correct divergence in flow field and cycle time-stepping
144 C arrays (for all fields) ; update time-counter
145 myIter = nIter0 + iLoop
146 myTime = startTime + deltaTClock * float(iLoop)
147 CALL TIMER_START('THE_CORRECTION_STEP [THE_MAIN_LOOP]',myThid)
148 CALL THE_CORRECTION_STEP(myTime, myIter, myThid)
149 CALL TIMER_STOP ('THE_CORRECTION_STEP [THE_MAIN_LOOP]',myThid)
150
151 C-- Do "blocking" sends and receives for tendency "overlap" terms
152 c CALL TIMER_START('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid)
153 c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )
154 c CALL TIMER_STOP ('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid)
155
156 C-- Do "blocking" sends and receives for field "overlap" terms
157 CALL TIMER_START('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid)
158 CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )
159 CALL TIMER_STOP ('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid)
160
161 #ifndef EXCLUDE_MONITOR
162 C-- Check status of solution (statistics, cfl, etc...)
163 CALL MONITOR( myIter, myTime, myThid )
164 #endif /* EXCLUDE_MONITOR */
165
166 #ifndef ALLOW_AUTODIFF_TAMC
167 C-- Do IO if needed.
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 C-- Save state for restarts
173 C Note: (jmc: is it still the case after ckp35 ?)
174 C =====
175 C Because of the ordering of the timestepping code and
176 C tendency term code at end of loop model arrays hold
177 C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,...
178 C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is
179 C gu at "time-level" N-1/2) and etaN at "time-level" N+1/2.
180 C where N = I+timeLevBase-1
181 C Thus a checkpoint contains U.0000000000, GU.0000000001 and
182 C etaN.0000000001 in the indexing scheme used for the model
183 C "state" files. This example is referred to as a checkpoint
184 C at time level 1
185 CALL TIMER_START('WRITE_CHECKPOINT [THE_MAIN_LOOP]',myThid)
186 CALL WRITE_CHECKPOINT(
187 & .FALSE., myTime, myIter, myThid )
188 CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MAIN_LOOP]',myThid)
189
190 #endif /* ALLOW_AUTODIFF_TAMC */
191
192 END

  ViewVC Help
Powered by ViewVC 1.1.22