/[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.15 - (show annotations) (download)
Fri Aug 3 19:06:11 2001 UTC (22 years, 10 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint40pre6
Changes since 1.14: +7 -2 lines
Split dynamics.F into dynamics.F and thermodynamics.F
 - idea is to make algorithm more transparent???
 - probably less efficient
 - has exchanges at end of thermodynamics.F (which are needed
   if using staggered time-stepping with the cube OR using AIM.

1 C $Header: /u/gcmpack/models/MITgcmUV/model/src/forward_step.F,v 1.14 2001/08/01 22:12:12 heimbach 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 C-- Load forcing/external data fields.
65 #ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE
66 C NOTE, that although the exf package is part of the
67 C distribution, it is not currently maintained, i.e.
68 C exf is disabled by default in genmake.
69 CALL EXF_GETFORCING( mytime, myiter, mythid )
70 #else
71 CALL TIMER_START('EXTERNAL_FIELDS_LOAD[THE_MAIN_LOOP]',mythid)
72 CALL EXTERNAL_FIELDS_LOAD( mytime, myiter, mythid )
73 CALL TIMER_STOP ('EXTERNAL_FIELDS_LOAD[THE_MAIN_LOOP]',mythid)
74 #endif
75
76 C-- Step forward fields and calculate time tendency terms.
77 CALL TIMER_START('THERMODYNAMICS [THE_MAIN_LOOP]',mythid)
78 CALL THERMODYNAMICS( myTime, myIter, myThid )
79 CALL TIMER_STOP ('THERMODYNAMICS [THE_MAIN_LOOP]',mythid)
80
81 C-- Step forward fields and calculate time tendency terms.
82 CALL TIMER_START('DYNAMICS [THE_MAIN_LOOP]',mythid)
83 CALL DYNAMICS( myTime, myIter, myThid )
84 CALL TIMER_STOP ('DYNAMICS [THE_MAIN_LOOP]',mythid)
85
86 #ifndef ALLOW_AUTODIFF_TAMC
87 #ifdef ALLOW_NONHYDROSTATIC
88 C-- Step forward W field in N-H algorithm
89 IF ( nonHydrostatic ) THEN
90 CALL TIMER_START('CALC_GW [THE_MAIN_LOOP]',myThid)
91 CALL CALC_GW(myThid)
92 CALL TIMER_STOP ('CALC_GW [THE_MAIN_LOOP]',myThid)
93 ENDIF
94 #endif
95 #endif /* ALLOW_AUTODIFF_TAMC */
96
97 C-- This block has been moved to the_correction_step(). We have
98 C left this code here to indicate where the filters used to be
99 C in the algorithm before JMC moved them to after the pressure
100 C solver.
101 C
102 C#ifdef ALLOW_SHAP_FILT
103 CC-- Step forward all tiles, filter and exchange.
104 C CALL TIMER_START('SHAP_FILT [THE_MAIN_LOOP]',myThid)
105 C CALL SHAP_FILT_APPLY(
106 C I gUnm1, gVnm1, gTnm1, gSnm1,
107 C I myTime, myIter, myThid )
108 C IF (implicDiv2Dflow.LT.1.) THEN
109 CC-- Explicit+Implicit part of the Barotropic Flow Divergence
110 CC => Filtering of uVel,vVel is necessary
111 C CALL SHAP_FILT_UV( uVel, vVel, myTime, myThid )
112 C ENDIF
113 C CALL TIMER_STOP ('SHAP_FILT [THE_MAIN_LOOP]',myThid)
114 C#endif
115 C
116 C#ifdef ALLOW_ZONAL_FILT
117 C IF (zonal_filt_lat.LT.90.) THEN
118 C CALL TIMER_START('ZONAL_FILT_APPLY [THE_MAIN_LOOP]',myThid)
119 C CALL ZONAL_FILT_APPLY(
120 C U gUnm1, gVnm1, gTnm1, gSnm1,
121 C I myThid )
122 C CALL TIMER_STOP ('ZONAL_FILT_APPLY [THE_MAIN_LOOP]',myThid)
123 C ENDIF
124 C#endif
125
126 C-- Solve elliptic equation(s).
127 C Two-dimensional only for conventional hydrostatic or
128 C three-dimensional for non-hydrostatic and/or IGW scheme.
129 CALL TIMER_START('SOLVE_FOR_PRESSURE [THE_MAIN_LOOP]',myThid)
130 CALL SOLVE_FOR_PRESSURE( myThid )
131 CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [THE_MAIN_LOOP]',myThid)
132
133 C-- Correct divergence in flow field and cycle time-stepping
134 C arrays (for all fields) ; update time-counter
135 myIter = nIter0 + iLoop
136 myTime = startTime + deltaTClock * float(iLoop)
137 CALL TIMER_START('THE_CORRECTION_STEP [THE_MAIN_LOOP]',myThid)
138 CALL THE_CORRECTION_STEP(myTime, myIter, myThid)
139 CALL TIMER_STOP ('THE_CORRECTION_STEP [THE_MAIN_LOOP]',myThid)
140
141 C-- Do "blocking" sends and receives for tendency "overlap" terms
142 c CALL TIMER_START('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid)
143 c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )
144 c CALL TIMER_STOP ('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid)
145
146 C-- Do "blocking" sends and receives for field "overlap" terms
147 CALL TIMER_START('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid)
148 CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )
149 CALL TIMER_STOP ('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid)
150
151 #ifndef EXCLUDE_MONITOR
152 C-- Check status of solution (statistics, cfl, etc...)
153 CALL MONITOR( myIter, myTime, myThid )
154 #endif /* EXCLUDE_MONITOR */
155
156 #ifdef ALLOW_AUTODIFF_TAMC
157 C Include call to a dummy routine. Its adjoint will be
158 C called at the proper place in the adjoint code.
159 C The adjoint routine will print out adjoint values
160 C if requested. The location of the call is important,
161 C it has to be after the adjoint of the exchanges
162 C (DO_GTERM_BLOCKING_EXCHANGES).
163 CALL DUMMY_IN_STEPPING( myTime, myIter, myThid )
164 #else
165 C-- Do IO if needed.
166 CALL TIMER_START('DO_THE_MODEL_IO [THE_MAIN_LOOP]',myThid)
167 CALL DO_THE_MODEL_IO( myTime, myIter, myThid )
168 CALL TIMER_STOP ('DO_THE_MODEL_IO [THE_MAIN_LOOP]',myThid)
169
170 C-- Save state for restarts
171 C Note: (jmc: is it still the case after ckp35 ?)
172 C =====
173 C Because of the ordering of the timestepping code and
174 C tendency term code at end of loop model arrays hold
175 C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,...
176 C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is
177 C gu at "time-level" N-1/2) and etaN at "time-level" N+1/2.
178 C where N = I+timeLevBase-1
179 C Thus a checkpoint contains U.0000000000, GU.0000000001 and
180 C etaN.0000000001 in the indexing scheme used for the model
181 C "state" files. This example is referred to as a checkpoint
182 C at time level 1
183 CALL TIMER_START('WRITE_CHECKPOINT [THE_MAIN_LOOP]',myThid)
184 CALL WRITE_CHECKPOINT(
185 & .FALSE., myTime, myIter, myThid )
186 CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MAIN_LOOP]',myThid)
187
188 #endif /* ALLOW_AUTODIFF_TAMC */
189
190 END

  ViewVC Help
Powered by ViewVC 1.1.22