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

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

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


Revision 1.41 - (hide 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 cnh 1.41 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 cnh 1.1
20 adcroft 1.18 #include "CPP_OPTIONS.h"
21 cnh 1.1
22 cnh 1.41 CBOP
23    
24     C !ROUTINE: THE_MODEL_MAIN
25    
26     C !INTERFACE:
27 cnh 1.1 SUBROUTINE THE_MODEL_MAIN(myThid)
28 adcroft 1.24 IMPLICIT NONE
29 cnh 1.41
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 cnh 1.1 C == Global variables ===
80     #include "SIZE.h"
81     #include "EEPARAMS.h"
82     #include "PARAMS.h"
83 adcroft 1.26 #include "DYNVARS.h"
84 adcroft 1.27 #ifdef ALLOW_NONHYDROSTATIC
85 adcroft 1.26 #include "CG3D.h"
86 adcroft 1.27 #endif
87 cnh 1.1
88 heimbach 1.37 #ifdef ALLOW_AUTODIFF_TAMC
89     #include "tamc.h"
90     #include "cost.h"
91     #include "adcost.h"
92     #endif
93    
94 cnh 1.41 C !INPUT/OUTPUT PARAMETERS:
95 cnh 1.1 C == Routine arguments ==
96     C myThid - Thread number for this instance of the routine.
97 cnh 1.6 INTEGER myThid
98 cnh 1.1
99 cnh 1.41 C !LOCAL VARIABLES:
100 cnh 1.1 C == Local variables ==
101 cnh 1.7 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 jmc 1.34 C myCurrentTime - Time counter for this thread
107     C myCurrentIter - Iteration counter for this thread
108     INTEGER myCurrentIter
109     _RL myCurrentTime
110 cnh 1.41 CEOP
111 cnh 1.1
112 adcroft 1.19 C-- This timer encompasses the whole code
113 adcroft 1.32 CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid)
114 adcroft 1.19
115    
116 adcroft 1.32 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 adcroft 1.26
121 jmc 1.34 myCurrentTime = startTime
122     myCurrentIter = nIter0
123    
124 heimbach 1.40 #if ( defined (ALLOW_ADJOINT_RUN) || \
125     defined (ALLOW_GRADIENT_CHECK) || \
126     defined (ALLOW_ECCO_OPTIMIZATION) )
127 heimbach 1.37
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 heimbach 1.38 CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
138 heimbach 1.39 CALL ADTHE_MAIN_LOOP ( mythid )
139     CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
140 heimbach 1.37 _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 heimbach 1.39 #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 heimbach 1.37
160 adcroft 1.32 C-- Call time stepping loop of full model
161     CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
162 heimbach 1.38 CALL THE_MAIN_LOOP(myCurrentTime, myCurrentIter, myThid )
163 adcroft 1.32 CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
164 adcroft 1.12
165 heimbach 1.39 #endif /* ALLOW_ADJOINT_RUN */
166 heimbach 1.38
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 adcroft 1.19
173 adcroft 1.32 CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid)
174 cnh 1.7
175 adcroft 1.19 C-- Write timer statistics
176 cnh 1.20 IF ( myThid .EQ. 1 ) THEN
177     CALL TIMER_PRINTALL( myThid )
178     CALL COMM_STATS
179     ENDIF
180 cnh 1.1
181     RETURN
182     END

  ViewVC Help
Powered by ViewVC 1.1.22