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