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