/[MITgcm]/MITgcm/model/src/the_model_main.F
ViewVC logotype

Contents of /MITgcm/model/src/the_model_main.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.41 - (show annotations) (download)
Fri Sep 21 03:54:36 2001 UTC (22 years, 8 months ago) by cnh
Branch: MAIN
Changes since 1.40: +76 -22 lines
Starting to bring comments up to date and format comments
for document extraction of "prototypes".

1 C $Header: /u/gcmpack/models/MITgcmUV/model/src/the_model_main.F,v 1.40 2001/07/30 20:39:18 heimbach Exp $
2 C $Name: $
3
4 CBOI
5 C
6 C !TITLE: MITGCM KERNEL CODE SYNOPSIS
7 C !AUTHORS: mitgcm developers ( support@mitgcm.org )
8 C !AFFILIATION: Massachussetts Institute of Technology
9 C !DATE:
10 C !INTRODUCTION: model/ subdirectory
11 C Routines in the subdirectories under model/ ( src/ and inc/ ) are most of
12 C the core routines for the baseline forms of the kernel equations in the
13 C MITgcm algorithm.
14 C Code for auxilliary equations and alternate dicretizations of the fundamental
15 C equations can be found in the pkg/ directory tree.
16 C
17 CEOI
18
19
20 #include "CPP_OPTIONS.h"
21
22 CBOP
23
24 C !ROUTINE: THE_MODEL_MAIN
25
26 C !INTERFACE:
27 SUBROUTINE THE_MODEL_MAIN(myThid)
28 IMPLICIT NONE
29
30 C !DESCRIPTION: \bv
31 C *==========================================================*
32 C | SUBROUTINE THE_MODEL_MAIN
33 C | o Master controlling routine for model using the MITgcm
34 C | UV parallel wrapper.
35 C *==========================================================*
36 C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel
37 C | wrapper with a single integer argument "myThid". This
38 C | variable identifies the thread number of an instance of
39 C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works
40 C | on a particular region of the models domain and
41 C | synchronises with other instances as necessary. The
42 C | routine has to "understand" the MITgcm parallel
43 C | environment and the numerical algorithm. Editing this
44 C | routine is best done with some knowledge of both aspects.
45 C | Notes
46 C | =====
47 C | C*P* comments indicating place holders for which code is
48 C | presently being developed.
49 C *==========================================================*
50 C \ev
51
52 C !CALLING SEQUENCE:
53 C THE_MODEL_MAIN()
54 C |
55 C |
56 C |--INITIALISE_FIXED
57 C | o Set model configuration (fixed arrays)
58 C | Topography, hydrography, timestep, grid, etc..
59 C |
60 C |--CTRL_UNPACK o Derivative mode. Unpack control vector.
61 C |
62 C |--ADTHE_MAIN_LOOP o Main timestepping loop for combined
63 C | prognostic and reverse mode integration.
64 C |
65 C |--CTRL_PACK o Derivative mode. Unpack control vector.
66 C |
67 C |--GRDCHK_MAIN o Gradient check control routine.
68 C |
69 C |--THE_MAIN_LOOP o Main timestepping loop for pure prognostic
70 C | integration.
71 C |
72 C |--WRITE_CHECKPOINT o Write retsart information.
73 C |
74 C |--TIMER_PRINTALL o Print out timing statistics.
75 C |
76 C |--COMM_STATS o Print out communication statistics.
77
78 C !USES:
79 C == Global variables ===
80 #include "SIZE.h"
81 #include "EEPARAMS.h"
82 #include "PARAMS.h"
83 #include "DYNVARS.h"
84 #ifdef ALLOW_NONHYDROSTATIC
85 #include "CG3D.h"
86 #endif
87
88 #ifdef ALLOW_AUTODIFF_TAMC
89 #include "tamc.h"
90 #include "cost.h"
91 #include "adcost.h"
92 #endif
93
94 C !INPUT/OUTPUT PARAMETERS:
95 C == Routine arguments ==
96 C myThid - Thread number for this instance of the routine.
97 INTEGER myThid
98
99 C !LOCAL VARIABLES:
100 C == Local variables ==
101 C Note: Under the multi-threaded model myCurrentIter and
102 C myCurrentTime are local variables passed around as routine
103 C arguments. Although this is fiddly it saves the need to
104 C impose additional synchronisation points when they are
105 C updated.
106 C myCurrentTime - Time counter for this thread
107 C myCurrentIter - Iteration counter for this thread
108 INTEGER myCurrentIter
109 _RL myCurrentTime
110 CEOP
111
112 C-- This timer encompasses the whole code
113 CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid)
114
115
116 C-- Set model configuration (fixed arrays)
117 CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
118 CALL INITIALISE_FIXED( myThid )
119 CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
120
121 myCurrentTime = startTime
122 myCurrentIter = nIter0
123
124 #if ( defined (ALLOW_ADJOINT_RUN) || \
125 defined (ALLOW_GRADIENT_CHECK) || \
126 defined (ALLOW_ECCO_OPTIMIZATION) )
127
128 _BEGIN_MASTER( mythid )
129 IF (myProcId .eq. 0) THEN
130 CALL CTRL_UNPACK( mycurrentiter, mycurrenttime, mythid )
131 ENDIF
132 _END_MASTER( mythid )
133 _BARRIER
134
135 fc = 0.0
136 adfc = 1.0
137 CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
138 CALL ADTHE_MAIN_LOOP ( mythid )
139 CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
140 _BARRIER
141
142 _BEGIN_MASTER( mythid )
143 IF (myProcId .eq. 0) THEN
144 call CTRL_PACK( mycurrentiter, mycurrenttime, mythid )
145 ENDIF
146 _END_MASTER( mythid )
147 _BARRIER
148
149 #ifdef ALLOW_GRADIENT_CHECK
150 if (useGrdchk) then
151 CALL TIMER_START('GRDCHK_MAIN [ADJOINT RUN]', mythid)
152 CALL GRDCHK_MAIN( mythid )
153 CALL TIMER_STOP ('GRDCHK_MAIN [ADJOINT RUN]', mythid)
154 _BARRIER
155 end if
156 #endif
157
158 #else /* ALLOW_ADJOINT_RUN undef */
159
160 C-- Call time stepping loop of full model
161 CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
162 CALL THE_MAIN_LOOP(myCurrentTime, myCurrentIter, myThid )
163 CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
164
165 #endif /* ALLOW_ADJOINT_RUN */
166
167 C-- Final checkpoint (incase the in-loop checkpoint was missed)
168 CALL TIMER_START('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid)
169 CALL WRITE_CHECKPOINT(
170 & .TRUE., myCurrentTime, myCurrentIter, myThid )
171 CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid)
172
173 CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid)
174
175 C-- Write timer statistics
176 IF ( myThid .EQ. 1 ) THEN
177 CALL TIMER_PRINTALL( myThid )
178 CALL COMM_STATS
179 ENDIF
180
181 RETURN
182 END

  ViewVC Help
Powered by ViewVC 1.1.22