/[MITgcm]/MITgcm/eesupp/src/main.F
ViewVC logotype

Contents of /MITgcm/eesupp/src/main.F

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


Revision 1.16 - (show annotations) (download)
Fri Aug 19 23:13:05 2005 UTC (18 years, 10 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint57r_post, checkpoint57q_post
Changes since 1.15: +17 -3 lines
Changes needed for COMMON to MODULE conversion.

1 C $Header: /u/gcmpack/MITgcm/eesupp/src/main.F,v 1.15 2004/10/22 11:50:18 heimbach Exp $
2 C $Name: $
3
4 CBOI
5 C
6 C !TITLE: WRAPPER CODE SYNOPSIS
7 C !AUTHORS: mitgcm developers ( support@mitgcm.org )
8 C !AFFILIATION: Massachussetts Institute of Technology
9 C !DATE:
10 C !INTRODUCTION:
11 C Wrapper synopsis and code Routines in the subdirectories under
12 C eesupp/ ( src/ and inc/ ) provide the core framework within which
13 C numerical and ancilliary software of MITgcm operates. The eesupp/
14 C directories provide a collection of software we call {\bf WRAPPER}
15 C ( ({\bf W}rappable {\bf A}pplication {\bf P}aralell {\bf
16 C P}rogramming {\bf E}nvironment {\bf R}esource). The {bf WRAPPER}
17 C provides a generic bootstrapping capability to start applications
18 C in a manner that allows them to exploit single and
19 C multi-processing environments on all present day hardware
20 C platforms (spanning vector SMP systems to distributed memory and
21 C processing cluster systems). Numerical applications must be coded
22 C to fit within the {\bf WRAPPER}. This entails applications
23 C adopting a particular style for declaring data structures
24 C representing grids and values on grids. The {\bf WRAPPER}
25 C currently provides support for grid point models using a single
26 C global indexing system. This is sufficient for latitude-logitude,
27 C cylindrical, and cartesian coordinate configurations. There is
28 C also limited support for composing grids in which no single,
29 C sructured global index can be defined. At present, this support is
30 C limited to specific configurations of projections of a cube onto
31 C the sphere.
32 C
33 C The main functions supported by the current {\bf WRAPPER} code are
34 C \begin{itemize}
35 C \item program startup and termination including
36 C creation/management of multiple threads and/or processes
37 C \item communication and synchronisatioin operations between
38 C multiple processes and/or threads
39 C \item multi-process input and output operations to disk and to
40 C other applications
41 C \end{itemize}
42 C
43 C Multi-process execution assumes the existence of MPI for process
44 C startup and termination. However, MPI does not have to be used for
45 C performance critical operations. Instead, {\bf WRAPPER}
46 C performance critical parallel primitives are implemented to allow
47 C them to bind to different low-level system software
48 C layers. Bindings exist for using {\bf WRAPPER} with portable
49 C systems such as MPI and UNIX System V IPC memory mapping, as well
50 C bindings for high-performance propreitary systems such as Myrinet
51 C GM software and Compaq IMC memory channel technology.
52 C
53 CEOI
54
55
56 C-- Get C preprocessor options
57 #include "PACKAGES_CONFIG.h"
58 #include "CPP_OPTIONS.h"
59 #include "CPP_EEOPTIONS.h"
60
61 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
62 CBOP
63 C !ROUTINE: MAIN
64
65 C !INTERFACE:
66 PROGRAM MAIN
67 IMPLICIT NONE
68
69 C !DESCRIPTION:
70 C *==========================================================*
71 C | PROGRAM MAIN
72 C | o MAIN wrapper for MITgcm UV implementation.
73 C *==========================================================*
74 C | MAIN controls the "execution environment".
75 C | Its main functions are
76 C | 1. call procedure EEBOOT to perform execution environment
77 C | initialisation.
78 C | 2. call procedure THE\_MODEL\_MAIN once for each concurrent
79 C | thread. THE\_MODEL\_MAIN is the user supplied top-level
80 C | routine.
81 C | 3. call procedure EEDIE to perform execution environment
82 C | shutdown.
83 C *==========================================================*
84
85 C !CALLING SEQUENCE:
86 C
87 C main()
88 C |
89 C |--eeboot() :: WRAPPER initilization
90 C |
91 C |--check_threads() :: Validate multiple thread start up.
92 C |
93 C |--the_model_main() :: Numerical code top-level driver routine
94 C |
95 C |--eedie() :: WRAPPER termination
96
97 C !USES:
98 C == Global variables ==
99 C Include all the "shared" data here. That means all common
100 C blocks used in the model. On many implementations this is not
101 C necessary but doing this is the safest method.
102 #include "SIZE.h"
103 #include "EEPARAMS.h"
104 #include "EESUPPORT.h"
105 #include "PARAMS.h"
106 #include "GRID.h"
107 #include "DYNVARS.h"
108 #include "FFIELDS.h"
109 #include "SURFACE.h"
110 #ifdef ALLOW_TIMEAVE
111 #include "TIMEAVE_STATV.h"
112 #endif
113
114 C !LOCAL VARIABLES:
115 C-- Local variables
116 INTEGER myThid
117 INTEGER I
118 CEOP
119
120 C-- Set up the execution environment
121 C EEBOOT loads a execution environment parameter file
122 C ( called "eedata" by default ) and sets variables
123 C accordingly.
124 CALL EEBOOT
125
126 C-- Trap errors
127 IF ( eeBootError ) THEN
128 fatalError = .TRUE.
129 GOTO 999
130 ENDIF
131
132 #ifdef HAVE_PTHREADS
133 C IF (usePTHREADS) THEN
134 CALL PTINIT(nThreads)
135 C ELSE
136 #else
137
138 C-- Start nThreads concurrent threads.
139 C Note: We do a fiddly check here. The check is performed
140 C by CHECK_THREADS. CHECK_THREADS does a count
141 C of all the threads. If after ten seconds it has not
142 C found nThreads threads are running it flags an
143 C error. This traps the case in which the input
144 C parameter nThreads is different from the actual
145 C number of concurrent threads the OS gives us. This
146 C case causes a deadlock if we do not trap it here.
147 #include "MAIN_PDIRECTIVES1.h"
148 DO I=1,nThreads
149 myThid = I
150
151 C-- Do check to see if there are nThreads threads running
152 IF ( .NOT. eeBootError ) THEN
153 CALL CHECK_THREADS( myThid )
154 ENDIF
155
156 C-- Invoke nThreads instances of the numerical model
157 IF ( .NOT. eeBootError ) THEN
158 #ifdef ALLOW_ADMTLM
159 CALL ADMTLM_DSVD(myThid)
160 #else
161 CALL THE_MODEL_MAIN(myThid)
162 #endif
163 ENDIF
164
165 C-- Each threads sets flag indicating it is done
166 threadIsComplete(myThid) = .TRUE.
167 IF ( .NOT. eeBootError ) THEN
168 _BARRIER
169 ENDIF
170 ENDDO
171 #include "MAIN_PDIRECTIVES2.h"
172
173 #endif /* HAVE_PTHREADS */
174
175 999 CONTINUE
176 C-- Shut down execution environment
177 CALL EEDIE
178
179 C-- Write closedown status
180 IF ( fatalError ) THEN
181 STOP 'ABNORMAL END: PROGRAM MAIN'
182 ELSE
183 STOP 'NORMAL END'
184 ENDIF
185 C
186 END
187
188
189 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
190
191 CBOP 0
192 C !ROUTINE: PTREENTRY
193
194 C !INTERFACE:
195 SUBROUTINE PTREENTRY(
196 I myThid )
197
198 C !DESCRIPTION:
199 C Re-entry point for a pthreads-based threading mechanism. The
200 C intent is to produce a threading hack that will work with gcc/g77.
201
202 C !USES:
203 implicit none
204 #include "SIZE.h"
205 #include "EEPARAMS.h"
206 #include "EESUPPORT.h"
207 #include "PARAMS.h"
208 #include "GRID.h"
209 #include "DYNVARS.h"
210 #include "FFIELDS.h"
211 #include "SURFACE.h"
212 #ifdef ALLOW_TIMEAVE
213 #include "TIMEAVE_STATV.h"
214 #endif
215
216 C !INPUT PARAMETERS:
217 integer myThid
218 CEOP
219
220 write(*,*) 'myThid = ', myThid
221 CALL CHECK_THREADS( myThid )
222
223 C CALL THE_MODEL_MAIN(myThid)
224
225 threadIsComplete(myThid) = .TRUE.
226
227 RETURN
228 END
229
230 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|

  ViewVC Help
Powered by ViewVC 1.1.22