1 |
C $Header$ |
C $Header$ |
2 |
|
C $Name$ |
3 |
|
|
4 |
#include "CPP_EEOPTIONS.h" |
#include "CPP_OPTIONS.h" |
5 |
|
|
6 |
SUBROUTINE THE_MODEL_MAIN(myThid) |
SUBROUTINE THE_MODEL_MAIN(myThid) |
7 |
C /==========================================================\ |
C /==========================================================\ |
23 |
C | C*P* comments indicating place holders for which code is | |
C | C*P* comments indicating place holders for which code is | |
24 |
C | presently being developed. | |
C | presently being developed. | |
25 |
C \==========================================================/ |
C \==========================================================/ |
26 |
|
IMPLICIT NONE |
27 |
|
C |
28 |
C == Global variables === |
C == Global variables === |
29 |
#include "SIZE.h" |
#include "SIZE.h" |
30 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
31 |
#include "PARAMS.h" |
#include "PARAMS.h" |
|
#include "CG2D.h" |
|
32 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
33 |
|
#ifdef ALLOW_NONHYDROSTATIC |
34 |
|
#include "CG3D.h" |
35 |
|
#endif |
36 |
|
|
37 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
38 |
|
#include "tamc.h" |
39 |
|
#include "cost.h" |
40 |
|
#include "adcost.h" |
41 |
|
#endif |
42 |
|
|
43 |
C == Routine arguments == |
C == Routine arguments == |
44 |
C myThid - Thread number for this instance of the routine. |
C myThid - Thread number for this instance of the routine. |
45 |
INTEGER myThid |
INTEGER myThid |
46 |
|
|
47 |
C == Local variables == |
C == Local variables == |
48 |
C Note: Under the multi-threaded model myCurrentIter and myCurrentTime |
C Note: Under the multi-threaded model myCurrentIter and |
49 |
C are local variables passed around as routine arguments. Although |
C myCurrentTime are local variables passed around as routine |
50 |
C this is fiddly it saves the need to impose additional synchronisation |
C arguments. Although this is fiddly it saves the need to |
51 |
C points when they are updated. |
C impose additional synchronisation points when they are |
52 |
C myCurrentIter - Iteration counter for this thread |
C updated. |
53 |
C myCurrentTime - Time counter for this thread |
C myCurrentTime - Time counter for this thread |
54 |
C I - Loop counter |
C myCurrentIter - Iteration counter for this thread |
55 |
INTEGER I, myCurrentIter |
INTEGER myCurrentIter |
56 |
REAL myCurrentTime |
_RL myCurrentTime |
|
|
|
|
C-- Set model initial conditions |
|
|
CALL INITIALISE( myThid ) |
|
|
myCurrentTime = startTime |
|
|
myCurrentIter = nIter0 |
|
57 |
|
|
58 |
C-- Begin time stepping loop |
C-- This timer encompasses the whole code |
59 |
DO I=1, nTimeSteps |
CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid) |
60 |
|
|
|
C-- Do IO if needed. |
|
|
CALL DO_THE_MODEL_IO( myCurrentIter, myThid ) |
|
61 |
|
|
62 |
C-- Load offline tracer fields |
C-- Set model configuration (fixed arrays) |
63 |
IF ( MOD(myCurrentIter,numStepsPerPickup) .EQ. 1 ) THEN |
CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid) |
64 |
C I/O |
CALL INITIALISE_FIXED( myThid ) |
65 |
C o Writes to arrays are performed by their own thread (to ensure |
CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid) |
|
C physical memory allocation will pair with thread). |
|
|
C o Thread 1 reads into a buffer. |
|
|
C CALL LOAD_OFFLINE_FIELDS( myCurrentTime, myCurrentIter, myThid ) |
|
|
ENDIF |
|
|
|
|
|
C-- Step forward fields and calculate time tendency terms |
|
|
CALL DYNAMICS( myThid ) |
|
|
|
|
|
C-- Solve elliptic equation(s). |
|
|
C Two-dimensional only for conventional hydrostatic or three-dimensional |
|
|
C for non-hydrostatic and/or IGW scheme. |
|
|
CALL SOLVE_FOR_PRESSURE( myThid ) |
|
|
|
|
|
C-- Do "blocking" sends and receives for tendency "overlap" terms |
|
|
CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
|
66 |
|
|
67 |
myCurrentIter = myCurrentIter + 1 |
myCurrentTime = startTime |
68 |
myCurrentTime = myCurrentTime + deltaTtracer |
myCurrentIter = nIter0 |
69 |
|
|
70 |
C-- Save state for restarts |
#ifdef ALLOW_ADJOINT_RUN |
|
C*P* CALL CHECKPOINT( myThid ) |
|
71 |
|
|
72 |
ENDDO |
_BEGIN_MASTER( mythid ) |
73 |
|
IF (myProcId .eq. 0) THEN |
74 |
|
CALL CTRL_UNPACK( mycurrentiter, mycurrenttime, mythid ) |
75 |
|
ENDIF |
76 |
|
_END_MASTER( mythid ) |
77 |
|
_BARRIER |
78 |
|
|
79 |
|
fc = 0.0 |
80 |
|
adfc = 1.0 |
81 |
|
CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid) |
82 |
|
CALL ADTHE_MAIN_LOOP ( mythid ) |
83 |
|
CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid) |
84 |
|
_BARRIER |
85 |
|
|
86 |
|
_BEGIN_MASTER( mythid ) |
87 |
|
IF (myProcId .eq. 0) THEN |
88 |
|
call CTRL_PACK( mycurrentiter, mycurrenttime, mythid ) |
89 |
|
ENDIF |
90 |
|
_END_MASTER( mythid ) |
91 |
|
_BARRIER |
92 |
|
|
93 |
|
#ifdef ALLOW_GRADIENT_CHECK |
94 |
|
if (useGrdchk) then |
95 |
|
CALL TIMER_START('GRDCHK_MAIN [ADJOINT RUN]', mythid) |
96 |
|
CALL GRDCHK_MAIN( mythid ) |
97 |
|
CALL TIMER_STOP ('GRDCHK_MAIN [ADJOINT RUN]', mythid) |
98 |
|
_BARRIER |
99 |
|
end if |
100 |
|
#endif |
101 |
|
|
102 |
|
#else /* ALLOW_ADJOINT_RUN undef */ |
103 |
|
|
104 |
|
C-- Call time stepping loop of full model |
105 |
|
CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
106 |
|
CALL THE_MAIN_LOOP(myCurrentTime, myCurrentIter, myThid ) |
107 |
|
CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
108 |
|
|
109 |
|
#endif /* ALLOW_ADJOINT_RUN */ |
110 |
|
|
111 |
|
C-- Final checkpoint (incase the in-loop checkpoint was missed) |
112 |
|
CALL TIMER_START('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid) |
113 |
|
CALL WRITE_CHECKPOINT( |
114 |
|
& .TRUE., myCurrentTime, myCurrentIter, myThid ) |
115 |
|
CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid) |
116 |
|
|
117 |
|
CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid) |
118 |
|
|
119 |
|
C-- Write timer statistics |
120 |
|
IF ( myThid .EQ. 1 ) THEN |
121 |
|
CALL TIMER_PRINTALL( myThid ) |
122 |
|
CALL COMM_STATS |
123 |
|
ENDIF |
124 |
|
|
125 |
RETURN |
RETURN |
126 |
END |
END |