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