1 |
heimbach |
1.3 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/forward_step.F,v 1.2 2000/06/21 19:09:00 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 |
|
|
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 |
|
|
C /|\ | | |
33 |
|
|
C | | |--DO_THE_MODEL_IO |
34 |
|
|
C /|\ | | o Write model state |
35 |
|
|
C | | | |
36 |
|
|
C /|\ | |--SOLVE_FOR_PRESSURE |
37 |
|
|
C | | | o Find pressure field to keep flow non-divergent |
38 |
|
|
C /|\ | | |
39 |
|
|
C | | |--DO_GTERM_BLOCKING_EXCHANGES |
40 |
|
|
C /|\ | | o Update overlap regions |
41 |
|
|
C | | | |
42 |
|
|
C /|\ | |--WRITE_CHECKPOINT |
43 |
|
|
C | | | o Write restart file(s) |
44 |
|
|
C /|\ | |
45 |
|
|
C | | |
46 |
|
|
C |<== | ** Time stepping loop finishes here ** |
47 |
|
|
C |
48 |
|
|
|
49 |
|
|
C == Global variables === |
50 |
|
|
#include "SIZE.h" |
51 |
|
|
#include "EEPARAMS.h" |
52 |
|
|
#include "PARAMS.h" |
53 |
|
|
#include "DYNVARS.h" |
54 |
|
|
#include "CG2D.h" |
55 |
|
|
#ifdef ALLOW_NONHYDROSTATIC |
56 |
|
|
#include "CG3D.h" |
57 |
|
|
#endif |
58 |
|
|
|
59 |
|
|
C == Routine arguments == |
60 |
|
|
C doHalfStep - If .TRUE. then this is the last half step |
61 |
|
|
C iLoop - Invocation count (counter in THE_MAIN_LOOP) |
62 |
|
|
C myCurrentIter - Iteration counter for this thread |
63 |
|
|
C myCurrentTime - Time counter for this thread |
64 |
|
|
C myThid - Thread number for this instance of the routine. |
65 |
|
|
LOGICAL doHalfStep |
66 |
|
|
INTEGER iLoop |
67 |
|
|
INTEGER myCurrentIter |
68 |
|
|
_RL myCurrentTime |
69 |
|
|
INTEGER myThid |
70 |
|
|
|
71 |
|
|
C == Local variables == |
72 |
|
|
|
73 |
|
|
|
74 |
|
|
C-- Load forcing/external data fields |
75 |
|
|
CALL TIMER_START('I/O (READ) [FORWARD_STEP]',myThid) |
76 |
heimbach |
1.3 |
CALL EXTERNAL_FIELDS_LOAD( myCurrentTime, myCurrentIter, myThid ) |
77 |
adcroft |
1.1 |
CALL TIMER_STOP ('I/O (READ) [FORWARD_STEP]',myThid) |
78 |
|
|
|
79 |
|
|
#ifdef INCLUDE_SHAPIRO_FILTER_CODE |
80 |
|
|
C-- Step forward all tiles, filter and exchange. |
81 |
|
|
CALL TIMER_START('SHAP_FILT [FORWARD_STEP]',myThid) |
82 |
|
|
CALL SHAP_FILT( myCurrentTime, myCurrentIter, myThid ) |
83 |
|
|
CALL TIMER_STOP ('SHAP_FILT [FORWARD_STEP]',myThid) |
84 |
|
|
#endif |
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 |
|
|
C-- Do IO if needed. |
101 |
|
|
C Note: |
102 |
|
|
C ===== |
103 |
|
|
C At this point model arrays hold U,V,T,S at "time-level" N |
104 |
|
|
C and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1. |
105 |
|
|
C By convention this is taken to be the model "state". |
106 |
|
|
CALL TIMER_START('I/O (WRITE) [FORWARD_STEP]',myThid) |
107 |
|
|
CALL DO_THE_MODEL_IO( |
108 |
|
|
& doHalfStep, myCurrentTime, myCurrentIter, myThid ) |
109 |
|
|
CALL TIMER_STOP ('I/O (WRITE) [FORWARD_STEP]',myThid) |
110 |
|
|
|
111 |
|
|
|
112 |
|
|
IF (.NOT. doHalfStep) THEN |
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-- Do "blocking" sends and receives for tendency "overlap" terms |
122 |
|
|
CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
123 |
|
|
CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
124 |
|
|
CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
125 |
|
|
|
126 |
|
|
c myCurrentIter = myCurrentIter + 1 |
127 |
|
|
c myCurrentTime = myCurrentTime + deltaTClock |
128 |
|
|
myCurrentIter = nIter0 + iLoop |
129 |
|
|
myCurrentTime = startTime + deltaTClock * float(iLoop) |
130 |
|
|
|
131 |
|
|
C-- Save state for restarts |
132 |
|
|
C Note: |
133 |
|
|
C ===== |
134 |
|
|
C Because of the ordering of the timestepping code and |
135 |
|
|
C tendency term code at end of loop model arrays hold |
136 |
|
|
C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,... |
137 |
|
|
C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is |
138 |
|
|
C gu at "time-level" N-1/2) and cg2d_x at "time-level" N+1/2. |
139 |
|
|
C where N = I+timeLevBase-1 |
140 |
|
|
C Thus a checkpoint contains U.0000000000, GU.0000000001 and |
141 |
|
|
C cg2d_x.0000000001 in the indexing scheme used for the model |
142 |
|
|
C "state" files. This example is referred to as a checkpoint |
143 |
|
|
C at time level 1 |
144 |
|
|
CALL TIMER_START('I/O (WRITE) [FORWARD_STEP]',myThid) |
145 |
|
|
CALL WRITE_CHECKPOINT( |
146 |
|
|
& .FALSE., myCurrentTime, myCurrentIter, myThid ) |
147 |
|
|
CALL TIMER_STOP ('I/O (WRITE) [FORWARD_STEP]',myThid) |
148 |
|
|
|
149 |
|
|
ENDIF |
150 |
|
|
|
151 |
|
|
RETURN |
152 |
|
|
END |