1 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/the_model_main.F,v 1.31 1999/08/30 18:29:27 adcroft Exp $ |
2 |
|
3 |
#include "CPP_OPTIONS.h" |
4 |
|
5 |
SUBROUTINE THE_MAIN_LOOP(myThid) |
6 |
C /==========================================================\ |
7 |
C | SUBROUTINE THE_MAIN_LOOP | |
8 |
C | o This contains the principal time loop | |
9 |
C |==========================================================| |
10 |
C | THE_MAIN_LOOP is invoked by THE_MODEL_MAIN | |
11 |
C \==========================================================/ |
12 |
IMPLICIT NONE |
13 |
C |
14 |
C Call Tree |
15 |
C ========= |
16 |
C |
17 |
C |-THE_MODEL_MAIN |
18 |
C | | |
19 |
C | |-THE_MAIN_LOOP |
20 |
C | | | |
21 |
C | | |--INITIALISE_VARIA |
22 |
C | | | o Set initial conditions (variable arrays) |
23 |
C | | | |
24 |
C ==> | | | ** Time stepping loop starts here ** |
25 |
C | | | | |
26 |
C /|\ | | | |
27 |
C | | | |--FORWARD_STEP |
28 |
C /|\ | | | |
29 |
C | | | | |
30 |
C |<== | | | ** Time stepping loop finishes here ** |
31 |
C |
32 |
|
33 |
C == Global variables === |
34 |
#include "SIZE.h" |
35 |
#include "EEPARAMS.h" |
36 |
#include "PARAMS.h" |
37 |
#include "DYNVARS.h" |
38 |
#include "CG2D.h" |
39 |
#ifdef ALLOW_NONHYDROSTATIC |
40 |
#include "CG3D.h" |
41 |
#endif |
42 |
|
43 |
C == Routine arguments == |
44 |
C myThid - Thread number for this instance of the routine. |
45 |
INTEGER myThid |
46 |
|
47 |
C == Local variables == |
48 |
C Note: Under the multi-threaded model myCurrentIter and |
49 |
C myCurrentTime are local variables passed around as routine |
50 |
C arguments. Although this is fiddly it saves the need to |
51 |
C impose additional synchronisation points when they are |
52 |
C updated. |
53 |
C ILOOP - Loop counter |
54 |
C myCurrentIter - Iteration counter for this thread |
55 |
C myCurrentTime - Time counter for this thread |
56 |
INTEGER ILOOP |
57 |
INTEGER myCurrentIter |
58 |
_RL myCurrentTime |
59 |
|
60 |
CALL TIMER_START('SPIN-UP [THE_MAIN_LOOP]',myThid) |
61 |
|
62 |
myCurrentTime = startTime |
63 |
myCurrentIter = nIter0 |
64 |
|
65 |
C-- Set initial conditions (variable arrays) |
66 |
CALL TIMER_START('INITIALISE_VARIA [THE_MAIN_LOOP]',myThid) |
67 |
CALL INITIALISE_VARIA( myThid ) |
68 |
CALL TIMER_STOP ('INITIALISE_VARIA [THE_MAIN_LOOP]',myThid) |
69 |
|
70 |
C-- Dump starting state |
71 |
CALL TIMER_START('I/O (WRITE) [THE_MAIN_LOOP]',myThid) |
72 |
CALL WRITE_STATE( .TRUE., myCurrentTime, myCurrentIter, myThid ) |
73 |
CALL TIMER_STOP ('I/O (WRITE) [THE_MAIN_LOOP]',myThid) |
74 |
|
75 |
CALL TIMER_STOP ('SPIN-UP [THE_MAIN_LOOP]',myThid) |
76 |
|
77 |
C =========================================================== |
78 |
C-- Begin time stepping loop |
79 |
CALL TIMER_START('MAIN LOOP [THE_MAIN_LOOP]',myThid) |
80 |
DO ILOOP=1, nTimeSteps |
81 |
|
82 |
C-- Step forward fields and calculate time tendency terms |
83 |
CALL TIMER_START('FORWARD_STEP [THE_MAIN_LOOP]',myThid) |
84 |
CALL FORWARD_STEP( .FALSE., ILOOP, |
85 |
& myCurrentTime, myCurrentIter, myThid ) |
86 |
CALL TIMER_STOP ('FORWARD_STEP [THE_MAIN_LOOP]',myThid) |
87 |
|
88 |
ENDDO |
89 |
CALL TIMER_STOP ('MAIN LOOP [THE_MAIN_LOOP]',myThid) |
90 |
C =========================================================== |
91 |
|
92 |
CALL TIMER_START('SPIN-DOWN [THE_MAIN_LOOP]',myThid) |
93 |
|
94 |
C-- Final checkpoint (incase the in-loop checkpoint was missed) |
95 |
CALL TIMER_START('I/O (WRITE) [THE_MAIN_LOOP]',myThid) |
96 |
CALL WRITE_CHECKPOINT( |
97 |
& .TRUE., myCurrentTime, myCurrentIter, myThid ) |
98 |
CALL TIMER_STOP ('I/O (WRITE) [THE_MAIN_LOOP]',myThid) |
99 |
|
100 |
C-- Step forward fields for purposes of final I/O processing |
101 |
CALL TIMER_START('FORWARD_STEP [THE_MAIN_LOOP]',myThid) |
102 |
CALL FORWARD_STEP( .TRUE., ILOOP, |
103 |
& myCurrentTime, myCurrentIter, myThid ) |
104 |
CALL TIMER_STOP ('FORWARD_STEP [THE_MAIN_LOOP]',myThid) |
105 |
|
106 |
CALL TIMER_STOP ('SPIN-DOWN [THE_MAIN_LOOP]',myThid) |
107 |
|
108 |
RETURN |
109 |
END |