/[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.23 - (show annotations) (download)
Thu Dec 6 16:30:05 2007 UTC (16 years, 6 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint62c, checkpoint62p, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint60, checkpoint61, checkpoint62, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint62b, checkpoint61f, checkpoint61n, checkpoint61q, checkpoint61e, checkpoint61g, checkpoint61d, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61z, checkpoint61x, checkpoint61y
Changes since 1.22: +2 -1 lines
Testing cvs messaging after loginfo change

1 C $Header: /u/u0/gcmpack/MITgcm/eesupp/src/main.F,v 1.22 2006/01/12 03:24:09 edhill 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 C
54 CEOI
55
56
57 C-- Get C preprocessor options
58 #include "PACKAGES_CONFIG.h"
59 #include "CPP_OPTIONS.h"
60 #include "CPP_EEOPTIONS.h"
61
62 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
63 CBOP
64 C !ROUTINE: MAIN
65
66 C !INTERFACE:
67 PROGRAM MAIN
68 IMPLICIT NONE
69
70 C !DESCRIPTION:
71 C *==========================================================*
72 C | PROGRAM MAIN
73 C | o MAIN wrapper for MITgcm UV implementation.
74 C *==========================================================*
75 C | MAIN controls the "execution environment".
76 C | Its main functions are
77 C | 1. call procedure EEBOOT to perform execution environment
78 C | initialisation.
79 C | 2. call procedure THE\_MODEL\_MAIN once for each concurrent
80 C | thread. THE\_MODEL\_MAIN is the user supplied top-level
81 C | routine.
82 C | 3. call procedure EEDIE to perform execution environment
83 C | shutdown.
84 C *==========================================================*
85
86 C !CALLING SEQUENCE:
87 C
88 C main()
89 C |
90 C |--eeboot() :: WRAPPER initilization
91 C |
92 C |--check_threads() :: Validate multiple thread start up.
93 C |
94 C |--the_model_main() :: Numerical code top-level driver routine
95 C |
96 C |--eedie() :: WRAPPER termination
97
98 C !USES:
99 C == Global variables ==
100 C Include all the "shared" data here. That means all common
101 C blocks used in the model. On many implementations this is not
102 C necessary but doing this is the safest method.
103 #include "SIZE.h"
104 #include "EEPARAMS.h"
105 #include "EESUPPORT.h"
106 #include "PARAMS.h"
107 #include "GRID.h"
108 #include "DYNVARS.h"
109 #include "FFIELDS.h"
110 #include "SURFACE.h"
111 #ifdef ALLOW_TIMEAVE
112 #include "TIMEAVE_STATV.h"
113 #endif
114 #ifdef HAVE_SIGREG
115 #include "SIGREG.h"
116 #endif
117
118 C !LOCAL VARIABLES:
119 C-- Local variables
120 INTEGER myThid
121 INTEGER I
122
123 #ifdef USE_OMP_THREADING
124 INTEGER OMP_GET_THREAD_NUM
125 EXTERNAL OMP_GET_THREAD_NUM
126 #endif
127
128 CEOP
129
130 #ifdef USE_GSL_IEEE
131 call fgsl_ieee_env_setup ()
132 #endif
133
134 C-- Set up the execution environment
135 C EEBOOT loads a execution environment parameter file
136 C ( called "eedata" by default ) and sets variables
137 C accordingly.
138 CALL EEBOOT
139
140 C-- Trap errors
141 IF ( eeBootError ) THEN
142 fatalError = .TRUE.
143 GOTO 999
144 ENDIF
145
146 #ifdef HAVE_SETRLSTK
147 IF (useSETRLSTK) THEN
148 CALL setrlstk
149 ENDIF
150 #endif
151
152 #ifdef HAVE_SIGREG
153 IF (useSIGREG) THEN
154 i_got_signal = 0
155 CALL sigreg( i_got_signal )
156 ENDIF
157 #endif
158
159 #ifdef HAVE_PTHREADS
160 C IF (usePTHREADS) THEN
161 CALL PTINIT(nThreads)
162 C ELSE
163 #else
164
165 C-- Start nThreads concurrent threads.
166 C Note: We do a fiddly check here. The check is performed
167 C by CHECK_THREADS. CHECK_THREADS does a count
168 C of all the threads. If after ten seconds it has not
169 C found nThreads threads are running it flags an
170 C error. This traps the case in which the input
171 C parameter nThreads is different from the actual
172 C number of concurrent threads the OS gives us. This
173 C case causes a deadlock if we do not trap it here.
174 #include "MAIN_PDIRECTIVES1.h"
175 DO I=1,nThreads
176 #ifdef USE_OMP_THREADING
177 IF ( OMP_GET_THREAD_NUM() .EQ. I-1 ) THEN
178 #endif
179 myThid = I
180
181 C-- Do check to see if there are nThreads threads running
182 IF ( .NOT. eeBootError ) THEN
183 CALL CHECK_THREADS( myThid )
184 ENDIF
185
186 C-- Invoke nThreads instances of the numerical model
187 IF ( .NOT. eeBootError ) THEN
188 #ifdef ALLOW_ADMTLM
189 CALL ADMTLM_DSVD(myThid)
190 #else
191 CALL THE_MODEL_MAIN(myThid)
192 #endif
193 ENDIF
194
195 C-- Each threads sets flag indicating it is done
196 threadIsComplete(myThid) = .TRUE.
197 IF ( .NOT. eeBootError ) THEN
198 _BARRIER
199 ENDIF
200 #ifdef USE_OMP_THREADING
201 ENDIF
202 #endif
203 ENDDO
204 #include "MAIN_PDIRECTIVES2.h"
205
206 #endif /* HAVE_PTHREADS */
207
208 999 CONTINUE
209 C-- Shut down execution environment
210 CALL EEDIE
211
212 C-- Write closedown status
213 IF ( fatalError ) THEN
214 STOP 'ABNORMAL END: PROGRAM MAIN'
215 ELSE
216 STOP 'NORMAL END'
217 ENDIF
218 C
219 END
220
221
222 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
223
224 CBOP 0
225 C !ROUTINE: PTREENTRY
226
227 C !INTERFACE:
228 SUBROUTINE PTREENTRY(
229 I myThid )
230
231 C !DESCRIPTION:
232 C Re-entry point for a pthreads-based threading mechanism. The
233 C intent is to produce a threading hack that will work with gcc/g77.
234
235 C !USES:
236 implicit none
237 #include "SIZE.h"
238 #include "EEPARAMS.h"
239 #include "EESUPPORT.h"
240 #include "PARAMS.h"
241 #include "GRID.h"
242 #include "DYNVARS.h"
243 #include "FFIELDS.h"
244 #include "SURFACE.h"
245 #ifdef ALLOW_TIMEAVE
246 #include "TIMEAVE_STATV.h"
247 #endif
248
249 C !INPUT PARAMETERS:
250 integer myThid
251 CEOP
252
253 write(*,*) 'myThid = ', myThid
254 CALL CHECK_THREADS( myThid )
255
256 C CALL THE_MODEL_MAIN(myThid)
257
258 threadIsComplete(myThid) = .TRUE.
259
260 RETURN
261 END
262
263 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|

  ViewVC Help
Powered by ViewVC 1.1.22