1 |
C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/main.F,v 1.8 2001/09/21 03:54:35 cnh 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: Wrapper synopsis and code |
11 |
C Routines in the subdirectories under eesupp/ ( src/ and inc/ ) provide the core |
12 |
C framework within which numerical and ancilliary software of MITgcm operates. |
13 |
C The eesupp/ directories provide a collection of software we call {\bf WRAPPER} ( |
14 |
C ({\bf W}rappable {\bf A}pplication {\bf P}aralell {\bf P}rogramming {\bf E}nvironment {\bf R}esource). |
15 |
C The {bf WRAPPER} provides a generic bootstrapping capability to start applications |
16 |
C in a manner that allows them to exploit single and multi-processing environments on all present |
17 |
C day hardware platforms (spanning vector SMP systems to distributed memory and processing cluster |
18 |
C systems). Numerical applications must be coded to fit within the {\bf WRAPPER}. This entails |
19 |
C applications adopting a particular style for declaring data structures representing |
20 |
C grids and values on grids. The {\bf WRAPPER} currently provides support for grid point |
21 |
C models using a single global indexing system. This is sufficient for latitude-logitude, |
22 |
C cylindrical, and cartesian coordinate configurations. There is also limited support for |
23 |
C composing grids in which no single, sructured global index can be defined. At present, this |
24 |
C support is limited to specific configurations of projections of a cube onto the sphere. |
25 |
C |
26 |
C The main functions supported by the current {\bf WRAPPER} code are |
27 |
C \begin{itemize} |
28 |
C \item program startup and termination including creation/management of multiple |
29 |
C threads and/or processes |
30 |
C \item communication and synchronisatioin operations between multiple processes and/or threads |
31 |
C \item multi-process input and output operations to disk and to other |
32 |
C applications |
33 |
C \end{itemize} |
34 |
C |
35 |
C Multi-process execution assumes the existence of MPI for process startup and termination. However, |
36 |
C MPI does not have to be used for performance critical operations. Instead, |
37 |
C {\bf WRAPPER} performance critical parallel primitives are implemented to allow them to bind to |
38 |
C different low-level system software layers. Bindings exist for using {\bf WRAPPER} with portable |
39 |
C systems such as MPI and UNIX System V IPC memory mapping, as well bindings for high-performance |
40 |
C propreitary systems such as Myrinet GM software and Compaq IMC memory channel technology. |
41 |
C |
42 |
CEOI |
43 |
|
44 |
|
45 |
C-- Get C preprocessor options |
46 |
#include "CPP_OPTIONS.h" |
47 |
#include "CPP_EEOPTIONS.h" |
48 |
|
49 |
CBOP |
50 |
C !ROUTINE: MAIN |
51 |
|
52 |
C !INTERFACE: |
53 |
PROGRAM MAIN |
54 |
IMPLICIT NONE |
55 |
|
56 |
C !DESCRIPTION: |
57 |
C *==========================================================* |
58 |
C | PROGRAM MAIN |
59 |
C | o MAIN wrapper for MITgcm UV implementation. |
60 |
C *==========================================================* |
61 |
C | MAIN controls the "execution environment". |
62 |
C | Its main functions are |
63 |
C | 1. call procedure EEBOOT to perform execution environment |
64 |
C | initialisation. |
65 |
C | 2. call procedure THE_MODEL_MAIN once for each concurrent |
66 |
C | thread. THE_MODEL_MAIN is the user supplied top-level |
67 |
C | routine. |
68 |
C | 3. call procedure EEDIE to perform execution environment |
69 |
C | shutdown. |
70 |
C *==========================================================* |
71 |
|
72 |
C !CALLING SEQUENCE: |
73 |
C |
74 |
C main() |
75 |
C | |
76 |
C |--eeboot() :: WRAPPER initilization |
77 |
C | |
78 |
C |--check_threads() :: Validate multiple thread start up. |
79 |
C | |
80 |
C |--the_model_main() :: Numerical code top-level driver routine |
81 |
C | |
82 |
C |--eedie() :: WRAPPER termination |
83 |
|
84 |
C !USES: |
85 |
C == Global variables == |
86 |
C Include all the "shared" data here. That means all common |
87 |
C blocks used in the model. On many implementations this is not |
88 |
C necessary but doing this is the safest method. |
89 |
#include "SIZE.h" |
90 |
#include "EEPARAMS.h" |
91 |
#include "EESUPPORT.h" |
92 |
#include "THE_MODEL_COMMON_BLOCKS.h" |
93 |
|
94 |
C !LOCAL VARIABLES: |
95 |
C-- Local variables |
96 |
INTEGER myThid |
97 |
INTEGER I |
98 |
CEOP |
99 |
|
100 |
C-- Set up the execution environment |
101 |
C EEBOOT loads a execution environment parameter file |
102 |
C ( called "eedata" by default ) and sets variables |
103 |
C accordingly. |
104 |
CALL EEBOOT |
105 |
|
106 |
C-- Trap errors |
107 |
IF ( eeBootError ) THEN |
108 |
fatalError = .TRUE. |
109 |
GOTO 999 |
110 |
ENDIF |
111 |
|
112 |
C-- Start nThreads concurrent threads. |
113 |
C Note: We do a fiddly check here. The check is performed |
114 |
C by CHECK_THREADS. CHECK_THREADS does a count |
115 |
C of all the threads. If after ten seconds it has not |
116 |
C found nThreads threads are running it flags an |
117 |
C error. This traps the case in which the input |
118 |
C parameter nThreads is different from the actual |
119 |
C number of concurrent threads the OS gives us. This |
120 |
C case causes a deadlock if we do not trap it here. |
121 |
#include "MAIN_PDIRECTIVES1.h" |
122 |
DO I=1,nThreads |
123 |
myThid = I |
124 |
|
125 |
C-- Do check to see if there are nThreads threads running |
126 |
IF ( .NOT. eeBootError ) THEN |
127 |
CALL CHECK_THREADS( myThid ) |
128 |
ENDIF |
129 |
|
130 |
C-- Invoke nThreads instances of the numerical model |
131 |
IF ( .NOT. eeBootError ) THEN |
132 |
CALL THE_MODEL_MAIN(myThid) |
133 |
ENDIF |
134 |
|
135 |
C-- Each threads sets flag indicating it is done |
136 |
threadIsComplete(myThid) = .TRUE. |
137 |
IF ( .NOT. eeBootError ) THEN |
138 |
_BARRIER |
139 |
ENDIF |
140 |
ENDDO |
141 |
#include "MAIN_PDIRECTIVES2.h" |
142 |
|
143 |
999 CONTINUE |
144 |
C-- Shut down execution environment |
145 |
CALL EEDIE |
146 |
|
147 |
C-- Write closedown status |
148 |
IF ( fatalError ) THEN |
149 |
STOP 'ABNORMAL END: PROGRAM MAIN' |
150 |
ELSE |
151 |
STOP 'NORMAL END' |
152 |
ENDIF |
153 |
C |
154 |
END |