/[MITgcm]/MITgcm/eesupp/src/eeboot_minimal.F
ViewVC logotype

Contents of /MITgcm/eesupp/src/eeboot_minimal.F

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


Revision 1.10 - (show annotations) (download)
Mon May 12 19:45:17 2003 UTC (20 years, 11 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint51k_post, checkpoint50c_post, checkpoint52d_pre, checkpoint51o_pre, checkpoint51l_post, checkpoint51, checkpoint52, checkpoint50d_post, checkpoint51f_post, checkpoint51d_post, checkpoint51t_post, checkpoint51n_post, checkpoint51s_post, checkpoint51j_post, checkpoint51n_pre, checkpoint52b_pre, checkpoint51l_pre, checkpoint51q_post, checkpoint51b_pre, checkpoint52b_post, checkpoint52c_post, checkpoint51h_pre, checkpoint50f_post, checkpoint50f_pre, branchpoint-genmake2, checkpoint51r_post, checkpoint51i_post, checkpoint51b_post, checkpoint51c_post, checkpoint50g_post, checkpoint52a_pre, checkpoint50h_post, checkpoint50e_pre, checkpoint50i_post, checkpoint51i_pre, checkpoint50e_post, branch-netcdf, checkpoint50d_pre, checkpoint51e_post, checkpoint51o_post, checkpoint51f_pre, checkpoint52a_post, checkpoint51g_post, ecco_c52_e35, checkpoint51m_post, checkpoint51a_post, checkpoint51p_post, checkpoint51u_post
Branch point for: branch-genmake2, branch-nonh, tg2-branch, netcdf-sm0, checkpoint51n_branch
Changes since 1.9: +4 -2 lines
FORMAT seemed to cause trouble on some platforms.

1 C $Header: /u/gcmpack/MITgcm/eesupp/src/eeboot_minimal.F,v 1.8.6.1 2002/04/04 10:19:15 heimbach Exp $
2 C $Name: $
3
4 #include "CPP_EEOPTIONS.h"
5
6 CBOP
7 C !ROUTINE: EEBOOT_MINIMAL
8
9 C !INTERFACE:
10 SUBROUTINE EEBOOT_MINIMAL
11 IMPLICIT NONE
12
13 C !DESCRIPTION:
14 C *==========================================================*
15 C | SUBROUTINE EEBOOT_MINIMAL
16 C | o Set an initial environment that is predictable i.e.
17 C | behaves in a similar way on all machines and stable.
18 C *==========================================================*
19 C | Under MPI this routine calls MPI_INIT to setup the
20 C | mpi environment ( on some systems the code is running as
21 C | a single process prior to MPI_INIT, on others the mpirun
22 C | script has already created multiple processes). Until
23 C | MPI_Init is called it is unclear what state the
24 C | application is in. Once this routine has been run it is
25 C | "safe" to do things like I/O to report erros and to get
26 C | run parameters.
27 C | Note: This routine can also be compiled with CPP
28 C | directives set so that no multi-processing is initialise.
29 C | This is OK and will work fine.
30 C *==========================================================*
31
32 C !USES:
33 C == Global data ==
34 #include "SIZE.h"
35 #include "EEPARAMS.h"
36 #include "EESUPPORT.h"
37
38 C !LOCAL VARIABLES:
39 C == Local variables ==
40 C myThid :: Temp. dummy thread number.
41 INTEGER myThid
42 #ifdef ALLOW_USE_MPI
43 C mpiRC :: Error code reporting variable used
44 C with MPI.
45 C fNam :: Used to build name of file for standard
46 C output and error output.
47 C msgBuffer :: Used to build messages for printing.
48 CHARACTER*(MAX_LEN_MBUF) msgBuffer
49 INTEGER mpiRC
50 CHARACTER*13 fNam
51 INTEGER nptmp
52 #endif /* ALLOW_USE_MPI */
53 CEOP
54
55 C-- Default values set to single processor case
56 numberOfProcs = 1
57 myProcId = 0
58 pidIO = myProcId
59 myProcessStr = '------'
60 C Set a dummy value for myThid because we are not multi-threading
61 C yet.
62 myThid = 1
63 #ifdef ALLOW_USE_MPI
64 C--
65 C-- MPI style multiple-process initialisation
66 C-- =========================================
67 #ifndef ALWAYS_USE_MPI
68 IF ( usingMPI ) THEN
69 #endif
70 C-- Initialise MPI multi-process parallel environment.
71 C On some systems program forks at this point. Others have already
72 C forked within mpirun - now thats an open standard!
73 CALL MPI_INIT( mpiRC )
74 IF ( mpiRC .NE. MPI_SUCCESS ) THEN
75 eeBootError = .TRUE.
76 WRITE(msgBuffer,'(A,I5)')
77 & 'S/R INI_PROCS: MPI_INIT return code',
78 & mpiRC
79 CALL PRINT_ERROR( msgBuffer , myThid)
80 GOTO 999
81 ENDIF
82 C-- MPI has now been initialized but now we need to either
83 C ask for a communicator or pretend that we have:
84 C Pretend that we have asked for a communicator
85 MPI_COMM_MODEL = MPI_COMM_WORLD
86 C Ask coupler interface for a communicator
87 c hook call MITCOMPONENT_init( 'MITgcmUV', MPI_COMM_MODEL )
88
89 C-- Get my process number
90 CALL MPI_COMM_RANK( MPI_COMM_MODEL, mpiMyId, mpiRC )
91 IF ( mpiRC .NE. MPI_SUCCESS ) THEN
92 eeBootError = .TRUE.
93 WRITE(msgBuffer,'(A,I5)')
94 & 'S/R INI_PROCS: MPI_COMM_RANK return code',
95 & mpiRC
96 CALL PRINT_ERROR( msgBuffer , myThid)
97 GOTO 999
98 ENDIF
99 myProcId = mpiMyId
100 WRITE(myProcessStr,'(I4.4)') myProcId
101 mpiPidIo = myProcId
102 pidIO = mpiPidIo
103 IF ( mpiPidIo .EQ. myProcId ) THEN
104 WRITE(fNam,'(A,A)') 'STDERR.', myProcessStr(1:4)
105 OPEN(errorMessageUnit,FILE=fNam,STATUS='unknown')
106 WRITE(fNam,'(A,A)') 'STDOUT.', myProcessStr(1:4)
107 OPEN(standardMessageUnit,FILE=fNam,STATUS='unknown')
108 ENDIF
109
110 C-- Synchronise all processes
111 C Strictly this is superfluous, but by using it we can guarantee to
112 C find out about processes that did not start up.
113 CALL MPI_BARRIER( MPI_COMM_MODEL, mpiRC )
114 IF ( mpiRC .NE. MPI_SUCCESS ) THEN
115 eeBootError = .TRUE.
116 WRITE(msgBuffer,'(A,I5)')
117 & 'S/R INI_PROCS: MPI_BARRIER return code',
118 & mpiRC
119 CALL PRINT_ERROR( msgBuffer , myThid)
120 GOTO 999
121 ENDIF
122
123 C-- Get number of MPI processes
124 CALL MPI_COMM_SIZE ( MPI_COMM_MODEL, mpiNProcs, mpiRC )
125 IF ( mpiRC .NE. MPI_SUCCESS ) THEN
126 eeBootError = .TRUE.
127 WRITE(msgBuffer,'(A,I5)')
128 & 'S/R INI_PROCS: MPI_COMM_SIZE return code',
129 & mpiRC
130 CALL PRINT_ERROR( msgBuffer , myThid)
131 GOTO 999
132 ENDIF
133 numberOfProcs = mpiNProcs
134
135 C-- Can not have more processes than compile time MAX_NO_PROCS
136 IF ( numberOfProcs .GT. MAX_NO_PROCS ) THEN
137 eeBootError = .TRUE.
138 WRITE(msgBuffer,'(A)')
139 & 'S/R INI_PROCS: No. of processes too large'
140 CALL PRINT_ERROR( msgBuffer , myThid)
141 GOTO 999
142 ENDIF
143 C-- Under MPI only allow same number of processes as proc.
144 C-- grid size.
145 C Strictly we are allowed more procs. but knowing there
146 C is an exact match makes things easier.
147 IF ( numberOfProcs .NE. nPx*nPy ) THEN
148 eeBootError = .TRUE.
149 nptmp = nPx*nPy
150 WRITE(msgBuffer,'(A,2I5)')
151 & 'S/R INI_PROCS: No. of processes not equal to nPx*nPy',
152 & numberOfProcs, nptmp
153 CALL PRINT_ERROR( msgBuffer , myThid)
154 GOTO 999
155 ENDIF
156
157 #ifndef ALWAYS_USE_MPI
158 ENDIF
159 #endif
160 #endif /* ALLOW_USE_MPI */
161
162 999 CONTINUE
163
164 RETURN
165 END
166

  ViewVC Help
Powered by ViewVC 1.1.22