/[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.39 - (show annotations) (download)
Fri Jul 13 14:26:57 2001 UTC (22 years, 10 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint40pre3, checkpoint40pre2
Changes since 1.38: +16 -78 lines
o Added grdchk package handling
o Added passive tracer handling

1 C $Header: /u/gcmpack/models/MITgcmUV/model/src/the_model_main.F,v 1.38 2001/04/10 22:35:26 heimbach Exp $
2 C $Name: checkpoint39 $
3
4 #include "CPP_OPTIONS.h"
5
6 SUBROUTINE THE_MODEL_MAIN(myThid)
7 C /==========================================================\
8 C | SUBROUTINE THE_MODEL_MAIN |
9 C | o Master controlling routine for model using the MITgcm |
10 C | UV parallel wrapper. |
11 C |==========================================================|
12 C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel |
13 C | wrapper with a single integer argument "myThid". This |
14 C | variable identifies the thread number of an instance of |
15 C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works |
16 C | on a particular region of the models domain and |
17 C | synchronises with other instances as necessary. The |
18 C | routine has to "understand" the MITgcm parallel |
19 C | environment and the numerical algorithm. Editing this |
20 C | routine is best done with some knowledge of both aspects.|
21 C | Notes |
22 C | ===== |
23 C | C*P* comments indicating place holders for which code is |
24 C | presently being developed. |
25 C \==========================================================/
26 IMPLICIT NONE
27 C
28 C == Global variables ===
29 #include "SIZE.h"
30 #include "EEPARAMS.h"
31 #include "PARAMS.h"
32 #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 ==
44 C myThid - Thread number for this instance of the routine.
45 INTEGER myThid
46
47 C == Local variables ==
48 C Note: Under the multi-threaded model myCurrentIter and
49 C myCurrentTime are local variables passed around as routine
50 C arguments. Although this is fiddly it saves the need to
51 C impose additional synchronisation points when they are
52 C updated.
53 C myCurrentTime - Time counter for this thread
54 C myCurrentIter - Iteration counter for this thread
55 INTEGER myCurrentIter
56 _RL myCurrentTime
57
58 C-- This timer encompasses the whole code
59 CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid)
60
61
62 C-- Set model configuration (fixed arrays)
63 CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
64 CALL INITIALISE_FIXED( myThid )
65 CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
66
67 myCurrentTime = startTime
68 myCurrentIter = nIter0
69
70 #ifdef ALLOW_ADJOINT_RUN
71
72 _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
126 END

  ViewVC Help
Powered by ViewVC 1.1.22