1 |
C $Header: /u/gcmpack/MITgcm/eesupp/src/eeboot.F,v 1.16 2004/03/20 23:51:23 edhill Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_EEOPTIONS.h" |
5 |
#include "PACKAGES_CONFIG.h" |
6 |
|
7 |
CBOP |
8 |
C !ROUTINE: EEBOOT |
9 |
|
10 |
C !INTERFACE: |
11 |
SUBROUTINE EEBOOT |
12 |
IMPLICIT NONE |
13 |
|
14 |
C !DESCRIPTION: |
15 |
C *==========================================================* |
16 |
C | SUBROUTINE EEBOOT |
17 |
C | o Set up execution "environment", particularly perform |
18 |
C | steps to initialise parallel processing. |
19 |
C *==========================================================* |
20 |
C | Note: This routine can also be compiled with CPP |
21 |
C | directives set so that no multi-processing is initialised |
22 |
C | This is OK and works fine. |
23 |
C *==========================================================* |
24 |
|
25 |
C !CALLING SEQUENCE: |
26 |
C eeboot() |
27 |
C | |
28 |
C |-- eeboot_minimal() :: Minimal startup. Just enough to |
29 |
C | allow basic I/O. |
30 |
C | |
31 |
C |-- eeintro_msg() :: Write startup greeting. |
32 |
C | |
33 |
C |-- eeset_parms() :: Set WRAPPER parameters |
34 |
C | |
35 |
C |-- eewrite_eeenv() :: Print WRAPPER parameter settings |
36 |
C | |
37 |
C |-- ini_procs() :: Associate processes with grid regions. |
38 |
C | |
39 |
C |-- ini_threading_environment() :: Associate threads with grid regions. |
40 |
C | |
41 |
C |-- dfile_init() :: Initialise simple multi-process I/O pacakge. |
42 |
|
43 |
C !USES: |
44 |
C == Global variables == |
45 |
#include "SIZE.h" |
46 |
#include "EEPARAMS.h" |
47 |
#include "EESUPPORT.h" |
48 |
|
49 |
C !LOCAL VARIABLES: |
50 |
C == Local variables == |
51 |
C I :: Loop counter |
52 |
INTEGER I |
53 |
CEOP |
54 |
|
55 |
C-- Set error reporting flags and I/O streams |
56 |
C fatalError is a flag used to indicate that the program |
57 |
C ended abnormally. |
58 |
C errorMessageUnit is the Fortran unit number used for |
59 |
C writing error messages. |
60 |
C standardMessageUnit is the Fortran unit number used for |
61 |
C writing textual, informational output. |
62 |
C eeBootError is a flag used to indicate an error in the |
63 |
C "execution environment" startup pahse as opposed |
64 |
C to the simulation pahse of the execution. |
65 |
C eeEndError is used to indicate an "execution environment" shutdown |
66 |
C error. |
67 |
C thError flag used to allow a thread to report an error. |
68 |
C This is only really used during the startup process, |
69 |
C although it could be used elsewhere. |
70 |
C allMyEdgesAreSharedMemory flag which says for a particular |
71 |
C set of blocks the only form of communication |
72 |
C it does is using shared memory. |
73 |
C threadIsRunning used during startup to enable check that all |
74 |
C the threads are running. |
75 |
fatalError = .FALSE. |
76 |
eeBootError = .FALSE. |
77 |
eeEndError = .FALSE. |
78 |
DO I=1, MAX_NO_THREADS |
79 |
thError(I) = .FALSE. |
80 |
allMyEdgesAreSharedMemory(I) = .TRUE. |
81 |
threadIsRunning(I) = .FALSE. |
82 |
threadIsComplete(I) = .FALSE. |
83 |
ioErrorCount(I) = 0 |
84 |
ENDDO |
85 |
standardMessageUnit = 6 |
86 |
scrUnit1 = 11 |
87 |
scrUnit2 = 12 |
88 |
eeDataUnit = 13 |
89 |
modelDataUnit = 14 |
90 |
errorMessageUnit = 15 |
91 |
cph errorMessageUnit = 0 is not allowed on some platforms, e.g. SP3 |
92 |
C |
93 |
C Annoyingly there is no universal way to have the usingMPI |
94 |
C parameter work as one might expect. This is because, on some |
95 |
C systems I/O does not work until MPI_Init has been called. The |
96 |
C solution for now is that the parameter below may need to be changed |
97 |
C manually! |
98 |
#ifdef ALLOW_USE_MPI |
99 |
usingMPI = .TRUE. |
100 |
#endif |
101 |
|
102 |
C-- Start minimal environment so that we can do I/O |
103 |
C-- to report errors. |
104 |
C Notes |
105 |
C ===== |
106 |
C o Here we start MPI and setup the I/O environment |
107 |
C thatis needed for error reporting. |
108 |
C o Under MPI I/O support is very variable until |
109 |
C MPI is started. This makes is hard to trap the case |
110 |
C where mpirun is used to start a non-MPI run or |
111 |
C we try to start MPI when mpirun was not used. |
112 |
C after it is started. |
113 |
C jmc: test: |
114 |
C If necessary ( COMPONENT_MODULE defined ) add a 1rst preliminary |
115 |
C call to eeset_params (in EEBOOT_MINIMAL) to set useCoupler (needed |
116 |
C very early, and the stardard call eeset_params below comes too late) |
117 |
C jmc: This needs to be sorted-out in a cleaner way. |
118 |
CALL EEBOOT_MINIMAL |
119 |
IF ( eeBootError ) GOTO 999 |
120 |
|
121 |
C-- Now we can write a startup message |
122 |
CALL EEINTRO_MSG |
123 |
|
124 |
C-- Initialise parameters associated with execution environment. |
125 |
CALL EESET_PARMS |
126 |
IF ( eeBootError ) GOTO 999 |
127 |
|
128 |
C-- Write summary of execution environment configuration for this run |
129 |
CALL EEWRITE_EEENV |
130 |
|
131 |
C-- Now do the rest of the multi-process startup. |
132 |
C o Here we map processes to the model grid. |
133 |
C o Print tables of process-grid mappings. |
134 |
C o Do other miscellaneous multi-processing set up steps. For |
135 |
C example under MPI we create datatypes for communication |
136 |
C of array edges. |
137 |
CALL INI_PROCS |
138 |
#ifdef LETS_MAKE_JAM |
139 |
CALL INI_JAM |
140 |
#endif |
141 |
IF ( eeBootError ) GOTO 999 |
142 |
|
143 |
C-- Initialise variables to support "nThreads" of computation. |
144 |
C o Note the program is still running with a single thread of |
145 |
C execution at this stage. |
146 |
CALL INI_THREADING_ENVIRONMENT |
147 |
IF ( eeBootError ) GOTO 999 |
148 |
|
149 |
C-- Pass attributes to the coupler |
150 |
#ifdef COMPONENT_MODULE |
151 |
IF ( useCoupler ) CALL CPL_REGISTER |
152 |
#endif |
153 |
|
154 |
#ifdef USE_DFILE |
155 |
C-- Initiialise the multi-process IO package |
156 |
CALL DFILE_INIT |
157 |
#endif |
158 |
|
159 |
#ifdef ALLOW_EXCH2 |
160 |
C-- Initialise WRAPPER2 execution environment |
161 |
CALL W2_EEBOOT |
162 |
#endif /* ALLOW_EXCH2 */ |
163 |
|
164 |
|
165 |
999 CONTINUE |
166 |
RETURN |
167 |
END |