1 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/forward_step.F,v 1.6 2001/02/04 14:38:47 cnh Exp $ |
2 |
C $Name: checkpoint35 $ |
3 |
|
4 |
#include "CPP_OPTIONS.h" |
5 |
|
6 |
SUBROUTINE FORWARD_STEP( |
7 |
I iLoop, |
8 |
U myCurrentTime, myCurrentIter, |
9 |
& myThid) |
10 |
C /==========================================================\ |
11 |
C | SUBROUTINE FORWARD_STEP | |
12 |
C | o Does one instance of the model time stepping | |
13 |
C | The time stepping loop in THE_MAIN_LOOP() calls | |
14 |
C | this routine | |
15 |
C |==========================================================| |
16 |
C \==========================================================/ |
17 |
IMPLICIT NONE |
18 |
C |
19 |
C Call Tree |
20 |
C ========= |
21 |
C |
22 |
C THE_MAIN_LOOP() |
23 |
C | |
24 |
C ==> | ** Time stepping loop starts here ** |
25 |
C | | |
26 |
C /|\ |-FORWARD_STEP |
27 |
C | | | |
28 |
C /|\ | |--LOAD_EXTERNAL_DATA |
29 |
C | | | o Load and/or set time dependent forcing fields |
30 |
C /|\ | | |
31 |
C | | |--DYNAMICS |
32 |
C /|\ | | o Evaluate "forward" terms |
33 |
C | | | |
34 |
C /|\ | | |
35 |
C | | |--SOLVE_FOR_PRESSURE |
36 |
C /|\ | | o Find pressure field to keep flow non-divergent |
37 |
C | | | |
38 |
C /|\ | | |
39 |
C | | |--THE_CORRECTION_STEP |
40 |
C /|\ | | o Correct flow field with pressure gradient |
41 |
C | | | and cycle time-stepping arrays (for all fields) |
42 |
C /|\ | | |
43 |
C | | |--DO_GTERM_BLOCKING_EXCHANGES |
44 |
C /|\ | | o Update overlap regions |
45 |
C | | | |
46 |
C /|\ | | |
47 |
C | | |--DO_THE_MODEL_IO |
48 |
C /|\ | | o Write model state |
49 |
C | | | |
50 |
C /|\ | | |
51 |
C | | |--WRITE_CHECKPOINT |
52 |
C /|\ | | o Write restart file(s) |
53 |
C | | |
54 |
C /|\ | |
55 |
C |<== | ** Time stepping loop finishes here ** |
56 |
C |
57 |
|
58 |
C == Global variables === |
59 |
#include "SIZE.h" |
60 |
#include "EEPARAMS.h" |
61 |
#include "PARAMS.h" |
62 |
#include "DYNVARS.h" |
63 |
#include "CG2D.h" |
64 |
#ifdef ALLOW_NONHYDROSTATIC |
65 |
#include "CG3D.h" |
66 |
#endif |
67 |
|
68 |
C == Routine arguments == |
69 |
C iLoop - Invocation count (counter in THE_MAIN_LOOP) |
70 |
C myCurrentIter - Iteration counter for this thread |
71 |
C myCurrentTime - Time counter for this thread |
72 |
C myThid - Thread number for this instance of the routine. |
73 |
INTEGER iLoop |
74 |
INTEGER myCurrentIter |
75 |
_RL myCurrentTime |
76 |
INTEGER myThid |
77 |
|
78 |
C == Local variables == |
79 |
|
80 |
C-- Load forcing/external data fields |
81 |
CALL TIMER_START('I/O (READ) [FORWARD_STEP]',myThid) |
82 |
CALL EXTERNAL_FIELDS_LOAD( myCurrentTime, myCurrentIter, myThid ) |
83 |
CALL TIMER_STOP ('I/O (READ) [FORWARD_STEP]',myThid) |
84 |
|
85 |
C-- Step forward fields and calculate time tendency terms |
86 |
CALL TIMER_START('DYNAMICS [FORWARD_STEP]',myThid) |
87 |
CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid ) |
88 |
CALL TIMER_STOP ('DYNAMICS [FORWARD_STEP]',myThid) |
89 |
|
90 |
#ifdef ALLOW_NONHYDROSTATIC |
91 |
C-- Step forward W field in N-H algorithm |
92 |
IF ( nonHydrostatic ) THEN |
93 |
CALL TIMER_START('CALC_GW [FORWARD_STEP]',myThid) |
94 |
CALL CALC_GW( myThid) |
95 |
CALL TIMER_STOP ('CALC_GW [FORWARD_STEP]',myThid) |
96 |
ENDIF |
97 |
#endif |
98 |
|
99 |
#ifdef ALLOW_SHAP_FILT |
100 |
C-- Step forward all tiles, filter and exchange. |
101 |
CALL TIMER_START('SHAP_FILT [FORWARD_STEP]',myThid) |
102 |
CALL SHAP_FILT_APPLY( |
103 |
I gUnm1, gVnm1, gTnm1, gSnm1, |
104 |
I myCurrentTime, myCurrentIter, myThid ) |
105 |
CALL TIMER_STOP ('SHAP_FILT [FORWARD_STEP]',myThid) |
106 |
#endif |
107 |
|
108 |
#ifdef ALLOW_ZONAL_FILT |
109 |
CALL ZONAL_FILT_APPLY( |
110 |
U gUnm1, gVnm1, gTnm1, gSnm1, |
111 |
I myThid ) |
112 |
#endif |
113 |
|
114 |
C-- Solve elliptic equation(s). |
115 |
C Two-dimensional only for conventional hydrostatic or |
116 |
C three-dimensional for non-hydrostatic and/or IGW scheme. |
117 |
CALL TIMER_START('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
118 |
CALL SOLVE_FOR_PRESSURE( myThid ) |
119 |
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
120 |
|
121 |
C-- Correct divergence in flow field and cycle time-stepping |
122 |
C arrays (for all fields) ; update time-counter |
123 |
myCurrentIter = nIter0 + iLoop |
124 |
myCurrentTime = startTime + deltaTClock * float(iLoop) |
125 |
CALL THE_CORRECTION_STEP(myCurrentTime, myCurrentIter, myThid) |
126 |
|
127 |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
128 |
c CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
129 |
c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
130 |
c CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
131 |
|
132 |
C-- Do "blocking" sends and receives for field "overlap" terms |
133 |
CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
134 |
CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
135 |
CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
136 |
|
137 |
C-- Do IO if needed. |
138 |
CALL TIMER_START('I/O (WRITE) [FORWARD_STEP]',myThid) |
139 |
CALL DO_THE_MODEL_IO(.FALSE., |
140 |
& myCurrentTime, myCurrentIter, myThid ) |
141 |
CALL TIMER_STOP ('I/O (WRITE) [FORWARD_STEP]',myThid) |
142 |
|
143 |
C-- Save state for restarts |
144 |
C Note: (jmc: is it still the case after ckp35 ?) |
145 |
C ===== |
146 |
C Because of the ordering of the timestepping code and |
147 |
C tendency term code at end of loop model arrays hold |
148 |
C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,... |
149 |
C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is |
150 |
C gu at "time-level" N-1/2) and cg2d_x at "time-level" N+1/2. |
151 |
C where N = I+timeLevBase-1 |
152 |
C Thus a checkpoint contains U.0000000000, GU.0000000001 and |
153 |
C cg2d_x.0000000001 in the indexing scheme used for the model |
154 |
C "state" files. This example is referred to as a checkpoint |
155 |
C at time level 1 |
156 |
CALL TIMER_START('I/O (WRITE) [FORWARD_STEP]',myThid) |
157 |
CALL WRITE_CHECKPOINT( |
158 |
& .FALSE., myCurrentTime, myCurrentIter, myThid ) |
159 |
CALL TIMER_STOP ('I/O (WRITE) [FORWARD_STEP]',myThid) |
160 |
|
161 |
|
162 |
RETURN |
163 |
END |