/[MITgcm]/MITgcm_contrib/eh3_spgr/hs94.cs-32x32x5/code_v2/main.F
ViewVC logotype

Annotation of /MITgcm_contrib/eh3_spgr/hs94.cs-32x32x5/code_v2/main.F

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


Revision 1.1 - (hide annotations) (download)
Fri Sep 23 20:52:00 2005 UTC (19 years, 10 months ago) by edhill
Branch: MAIN
CVS Tags: HEAD
 o initial working version

1 edhill 1.1 C $Header: /u/gcmpack/MITgcm/eesupp/src/main.F,v 1.17 2005/09/11 18:52:26 edhill Exp $
2     C $Name: $
3    
4     CBOI
5     C
6     C !TITLE: WRAPPER CODE SYNOPSIS
7     C !AUTHORS: mitgcm developers ( MITgcm-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_SETRLSTK
133     IF (useSETRLSTK) THEN
134     CALL setrlstk
135     ENDIF
136     #endif
137    
138     #ifdef HAVE_PTHREADS
139     C IF (usePTHREADS) THEN
140     CALL PTINIT(nThreads)
141     C ELSE
142     #else
143    
144     C-- Start nThreads concurrent threads.
145     C Note: We do a fiddly check here. The check is performed
146     C by CHECK_THREADS. CHECK_THREADS does a count
147     C of all the threads. If after ten seconds it has not
148     C found nThreads threads are running it flags an
149     C error. This traps the case in which the input
150     C parameter nThreads is different from the actual
151     C number of concurrent threads the OS gives us. This
152     C case causes a deadlock if we do not trap it here.
153     #include "MAIN_PDIRECTIVES1.h"
154     DO I=1,nThreads
155     myThid = I
156    
157     C-- Do check to see if there are nThreads threads running
158     IF ( .NOT. eeBootError ) THEN
159     CALL CHECK_THREADS( myThid )
160     ENDIF
161    
162     C-- Invoke nThreads instances of the numerical model
163     IF ( .NOT. eeBootError ) THEN
164     #ifdef ALLOW_ADMTLM
165     CALL ADMTLM_DSVD(myThid)
166     #else
167     CALL THE_MODEL_MAIN(myThid)
168     #endif
169     ENDIF
170    
171     C-- Each threads sets flag indicating it is done
172     threadIsComplete(myThid) = .TRUE.
173     IF ( .NOT. eeBootError ) THEN
174     _BARRIER
175     ENDIF
176     ENDDO
177     #include "MAIN_PDIRECTIVES2.h"
178    
179     #endif /* HAVE_PTHREADS */
180    
181     999 CONTINUE
182     C-- Shut down execution environment
183     CALL EEDIE
184    
185     C-- Write closedown status
186     IF ( fatalError ) THEN
187     STOP 'ABNORMAL END: PROGRAM MAIN'
188     ELSE
189     STOP 'NORMAL END'
190     ENDIF
191     C
192     END
193    
194    
195     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
196    
197     CBOP 0
198     C !ROUTINE: PTREENTRY
199    
200     C !INTERFACE:
201     SUBROUTINE PTREENTRY(
202     I myThid )
203    
204     C !DESCRIPTION:
205     C Re-entry point for a pthreads-based threading mechanism. The
206     C intent is to produce a threading hack that will work with gcc/g77.
207    
208     C !USES:
209     implicit none
210     #include "SIZE.h"
211     #include "EEPARAMS.h"
212     #include "EESUPPORT.h"
213     #include "PARAMS.h"
214     #include "GRID.h"
215     #include "DYNVARS.h"
216     #include "FFIELDS.h"
217     #include "SURFACE.h"
218     #ifdef ALLOW_TIMEAVE
219     #include "TIMEAVE_STATV.h"
220     #endif
221    
222     C !INPUT PARAMETERS:
223     integer myThid
224     CEOP
225    
226     write(*,*) 'myThid = ', myThid
227     CALL CHECK_THREADS( myThid )
228    
229     C CALL THE_MODEL_MAIN(myThid)
230    
231     threadIsComplete(myThid) = .TRUE.
232    
233     RETURN
234     END
235    
236     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|

  ViewVC Help
Powered by ViewVC 1.1.22