/[MITgcm]/MITgcm/verification/adjustment.cs-32x32x1/code_min/main.F
ViewVC logotype

Annotation of /MITgcm/verification/adjustment.cs-32x32x1/code_min/main.F

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


Revision 1.2 - (hide annotations) (download)
Tue Nov 26 01:08:35 2013 UTC (10 years, 6 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint65, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, HEAD
Changes since 1.1: +49 -38 lines
bring up-to-date with standard version (in eesupp/src & model/inc)

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

  ViewVC Help
Powered by ViewVC 1.1.22