| 1 |
C $Header: /u/gcmpack/MITgcm/eesupp/src/eeboot.F,v 1.10 2001/09/21 03:54:34 cnh Exp $ |
| 2 |
C $Name: $ |
| 3 |
|
| 4 |
#include "CPP_EEOPTIONS.h" |
| 5 |
|
| 6 |
CBOP |
| 7 |
C !ROUTINE: EEBOOT |
| 8 |
|
| 9 |
C !INTERFACE: |
| 10 |
SUBROUTINE EEBOOT |
| 11 |
IMPLICIT NONE |
| 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 |-- dfile_init() :: Initialise simple multi-process I/O pacakge. |
| 41 |
|
| 42 |
C !USES: |
| 43 |
C == Global variables == |
| 44 |
#include "SIZE.h" |
| 45 |
#include "EEPARAMS.h" |
| 46 |
#include "EESUPPORT.h" |
| 47 |
|
| 48 |
C !LOCAL VARIABLES: |
| 49 |
C == Local variables == |
| 50 |
C I :: Loop counter |
| 51 |
INTEGER I |
| 52 |
CEOP |
| 53 |
|
| 54 |
C-- Set error reporting flags and I/O streams |
| 55 |
C fatalError is a flag used to indicate that the program |
| 56 |
C ended abnormally. |
| 57 |
C errorMessageUnit is the Fortran unit number used for |
| 58 |
C writing error messages. |
| 59 |
C standardMessageUnit is the Fortran unit number used for |
| 60 |
C writing textual, informational output. |
| 61 |
C eeBootError is a flag used to indicate an error in the |
| 62 |
C "execution environment" startup pahse as opposed |
| 63 |
C to the simulation pahse of the execution. |
| 64 |
C eeEndError is used to indicate an "execution environment" shutdown |
| 65 |
C error. |
| 66 |
C thError flag used to allow a thread to report an error. |
| 67 |
C This is only really used during the startup process, |
| 68 |
C although it could be used elsewhere. |
| 69 |
C allMyEdgesAreSharedMemory flag which says for a particular |
| 70 |
C set of blocks the only form of communication |
| 71 |
C it does is using shared memory. |
| 72 |
C threadIsRunning used during startup to enable check that all |
| 73 |
C the threads are running. |
| 74 |
fatalError = .FALSE. |
| 75 |
eeBootError = .FALSE. |
| 76 |
eeEndError = .FALSE. |
| 77 |
DO I=1, MAX_NO_THREADS |
| 78 |
thError(I) = .FALSE. |
| 79 |
allMyEdgesAreSharedMemory(I) = .TRUE. |
| 80 |
threadIsRunning(I) = .FALSE. |
| 81 |
threadIsComplete(I) = .FALSE. |
| 82 |
ioErrorCount(I) = 0 |
| 83 |
ENDDO |
| 84 |
standardMessageUnit = 6 |
| 85 |
scrUnit1 = 11 |
| 86 |
scrUnit2 = 12 |
| 87 |
eeDataUnit = 13 |
| 88 |
modelDataUnit = 14 |
| 89 |
errorMessageUnit = 15 |
| 90 |
cph errorMessageUnit = 0 is not allowed on some platforms, e.g. SP3 |
| 91 |
C |
| 92 |
C Annoyingly there is no universal way to have the usingMPI |
| 93 |
C parameter work as one might expect. This is because, on some |
| 94 |
C systems I/O does not work until MPI_Init has been called. The |
| 95 |
C solution for now is that the parameter below may need to be changed |
| 96 |
C manually! |
| 97 |
#ifdef ALLOW_USE_MPI |
| 98 |
usingMPI = .TRUE. |
| 99 |
#endif |
| 100 |
|
| 101 |
C-- Start minimal environment so that we can do I/O |
| 102 |
C-- to report errors. |
| 103 |
C Notes |
| 104 |
C ===== |
| 105 |
C o Here we start MPI and setup the I/O environment |
| 106 |
C thatis needed for error reporting. |
| 107 |
C o Under MPI I/O support is very variable until |
| 108 |
C MPI is started. This makes is hard to trap the case |
| 109 |
C where mpirun is used to start a non-MPI run or |
| 110 |
C we try to start MPI when mpirun was not used. |
| 111 |
C after it is started. |
| 112 |
CALL EEBOOT_MINIMAL |
| 113 |
IF ( eeBootError ) GOTO 999 |
| 114 |
|
| 115 |
C-- Now we can write a startup message |
| 116 |
CALL EEINTRO_MSG |
| 117 |
|
| 118 |
C-- Initialise parameters associated with execution environment. |
| 119 |
CALL EESET_PARMS |
| 120 |
IF ( eeBootError ) GOTO 999 |
| 121 |
|
| 122 |
C-- Write summary of execution environment configuration for this run |
| 123 |
CALL EEWRITE_EEENV |
| 124 |
|
| 125 |
C-- Now do the rest of the multi-process startup. |
| 126 |
C o Here we map processes to the model grid. |
| 127 |
C o Print tables of process-grid mappings. |
| 128 |
C o Do other miscellaneous multi-processing set up steps. For |
| 129 |
C example under MPI we create datatypes for communication |
| 130 |
C of array edges. |
| 131 |
CALL INI_PROCS |
| 132 |
#ifdef LETS_MAKE_JAM |
| 133 |
CALL INI_JAM |
| 134 |
#endif |
| 135 |
IF ( eeBootError ) GOTO 999 |
| 136 |
|
| 137 |
C-- Initialise variables to support "nThreads" of computation. |
| 138 |
C o Note the program is still running with a single thread of |
| 139 |
C execution at this stage. |
| 140 |
CALL INI_THREADING_ENVIRONMENT |
| 141 |
IF ( eeBootError ) GOTO 999 |
| 142 |
|
| 143 |
#ifdef USE_DFILE |
| 144 |
C-- Initiialise the multi-process IO package |
| 145 |
CALL DFILE_INIT |
| 146 |
#endif |
| 147 |
|
| 148 |
999 CONTINUE |
| 149 |
RETURN |
| 150 |
END |