1 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/the_model_main.F,v 1.2 1998/04/24 02:05:42 cnh Exp $ |
2 |
|
3 |
#include "CPP_EEOPTIONS.h" |
4 |
|
5 |
SUBROUTINE THE_MODEL_MAIN(myThid) |
6 |
C /==========================================================\ |
7 |
C | SUBROUTINE THE_MODEL_MAIN | |
8 |
C | o Master controlling routine for model using the MITgcm | |
9 |
C | UV parallel wrapper. | |
10 |
C |==========================================================| |
11 |
C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel | |
12 |
C | wrapper with a single integer argument "myThid". This | |
13 |
C | variable identifies the thread number of an instance of | |
14 |
C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works | |
15 |
C | on a particular region of the models domain and | |
16 |
C | synchronises with other instances as necessary. The | |
17 |
C | routine has to "understand" the MITgcm parallel | |
18 |
C | environment and the numerical algorithm. Editing this | |
19 |
C | routine is best done with some knowledge of both aspects.| |
20 |
C | Notes | |
21 |
C | ===== | |
22 |
C | C*P* comments indicating place holders for which code is | |
23 |
C | presently being developed. | |
24 |
C \==========================================================/ |
25 |
|
26 |
C == Global variables === |
27 |
#include "SIZE.h" |
28 |
#include "EEPARAMS.h" |
29 |
#include "PARAMS.h" |
30 |
#include "CG2D.h" |
31 |
#include "DYNVARS.h" |
32 |
|
33 |
C == Routine arguments == |
34 |
C myThid - Thread number for this instance of the routine. |
35 |
INTEGER myThid |
36 |
|
37 |
C == Local variables == |
38 |
C Note: Under the multi-threaded model myCurrentIter and myCurrentTime |
39 |
C are local variables passed around as routine arguments. Although |
40 |
C this is fiddly it saves the need to impose additional synchronisation |
41 |
C points when they are updated. |
42 |
C myCurrentIter - Iteration counter for this thread |
43 |
C myCurrentTime - Time counter for this thread |
44 |
C I - Loop counter |
45 |
INTEGER I, myCurrentIter |
46 |
REAL myCurrentTime |
47 |
|
48 |
C-- Set model initial conditions |
49 |
CALL INITIALISE( myThid ) |
50 |
myCurrentTime = startTime |
51 |
myCurrentIter = nIter0 |
52 |
|
53 |
C-- Begin time stepping loop |
54 |
DO I=1, nTimeSteps |
55 |
C-- Do IO if needed. |
56 |
CALL DO_THE_MODEL_IO( myCurrentIter, myThid ) |
57 |
|
58 |
C-- Load offline tracer fields |
59 |
IF ( MOD(myCurrentIter,numStepsPerPickup) .EQ. 1 ) THEN |
60 |
C I/O |
61 |
C o Writes to arrays are performed by their own thread (to ensure |
62 |
C physical memory allocation will pair with thread). |
63 |
C o Thread 1 reads into a buffer. |
64 |
C CALL LOAD_OFFLINE_FIELDS( myCurrentTime, myCurrentIter, myThid ) |
65 |
ENDIF |
66 |
|
67 |
C-- Step forward fields and calculate time tendency terms |
68 |
CALL DYNAMICS( myThid ) |
69 |
|
70 |
C-- Solve elliptic equation(s). |
71 |
C Two-dimensional only for conventional hydrostatic or three-dimensional |
72 |
C for non-hydrostatic and/or IGW scheme. |
73 |
CALL SOLVE_FOR_PRESSURE( myThid ) |
74 |
|
75 |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
76 |
CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
77 |
|
78 |
myCurrentIter = myCurrentIter + 1 |
79 |
myCurrentTime = myCurrentTime + deltaTtracer |
80 |
|
81 |
C-- Save state for restarts |
82 |
C*P* CALL CHECKPOINT( myThid ) |
83 |
|
84 |
ENDDO |
85 |
|
86 |
RETURN |
87 |
END |