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

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

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


Revision 1.12 - (hide annotations) (download)
Tue Jan 27 15:59:23 2004 UTC (20 years, 5 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint52l_pre, hrcube4, hrcube5, checkpoint52j_pre, checkpoint52l_post, checkpoint52k_post, hrcube_3, checkpoint52j_post
Changes since 1.11: +13 -4 lines
always open errorUnit file + write to unit zero if single processor job

1 jmc 1.12 C $Header: /u/gcmpack/MITgcm/eesupp/src/eeboot_minimal.F,v 1.11 2003/12/15 02:02:38 jmc Exp $
2 cnh 1.8 C $Name: $
3 cnh 1.1
4     #include "CPP_EEOPTIONS.h"
5    
6 cnh 1.8 CBOP
7     C !ROUTINE: EEBOOT_MINIMAL
8    
9     C !INTERFACE:
10 cnh 1.1 SUBROUTINE EEBOOT_MINIMAL
11 adcroft 1.6 IMPLICIT NONE
12 cnh 1.1
13 cnh 1.8 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 cnh 1.1 #include "SIZE.h"
35     #include "EEPARAMS.h"
36     #include "EESUPPORT.h"
37    
38 cnh 1.8 C !LOCAL VARIABLES:
39     C == Local variables ==
40     C myThid :: Temp. dummy thread number.
41 jmc 1.12 C fNam :: Used to build name of file for standard
42     C output and error output.
43 cnh 1.1 INTEGER myThid
44 jmc 1.12 CHARACTER*13 fNam
45 cnh 1.1 #ifdef ALLOW_USE_MPI
46 cnh 1.8 C mpiRC :: Error code reporting variable used
47     C with MPI.
48     C msgBuffer :: Used to build messages for printing.
49 cnh 1.1 CHARACTER*(MAX_LEN_MBUF) msgBuffer
50     INTEGER mpiRC
51 heimbach 1.10 INTEGER nptmp
52 cnh 1.1 #endif /* ALLOW_USE_MPI */
53 cnh 1.8 CEOP
54 cnh 1.1
55     C-- Default values set to single processor case
56     numberOfProcs = 1
57     myProcId = 0
58     pidIO = myProcId
59 adcroft 1.6 myProcessStr = '------'
60 cnh 1.4 C Set a dummy value for myThid because we are not multi-threading
61 cnh 1.1 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 adcroft 1.6 WRITE(msgBuffer,'(A,I5)')
77 cnh 1.1 & 'S/R INI_PROCS: MPI_INIT return code',
78     & mpiRC
79     CALL PRINT_ERROR( msgBuffer , myThid)
80     GOTO 999
81     ENDIF
82 jmc 1.11
83 adcroft 1.5 C-- MPI has now been initialized but now we need to either
84     C ask for a communicator or pretend that we have:
85     C Pretend that we have asked for a communicator
86     MPI_COMM_MODEL = MPI_COMM_WORLD
87 jmc 1.11 #ifdef COMPONENT_MODULE
88     C- jmc: test:
89     C add a 1rst preliminary call EESET_PARAMS to set useCoupler
90     C (needed to decide either to call CPL_INIT or not)
91     CALL EESET_PARMS
92     IF ( eeBootError ) GOTO 999
93     C- jmc: test end ; otherwise, uncomment next line:
94     c useCoupler = .TRUE.
95     C-- Ask coupler interface for a communicator
96     IF ( useCoupler) CALL CPL_INIT
97     #endif
98 adcroft 1.5
99 cnh 1.1 C-- Get my process number
100 adcroft 1.5 CALL MPI_COMM_RANK( MPI_COMM_MODEL, mpiMyId, mpiRC )
101 cnh 1.1 IF ( mpiRC .NE. MPI_SUCCESS ) THEN
102     eeBootError = .TRUE.
103 adcroft 1.6 WRITE(msgBuffer,'(A,I5)')
104 cnh 1.1 & 'S/R INI_PROCS: MPI_COMM_RANK return code',
105     & mpiRC
106     CALL PRINT_ERROR( msgBuffer , myThid)
107     GOTO 999
108     ENDIF
109     myProcId = mpiMyId
110     WRITE(myProcessStr,'(I4.4)') myProcId
111     mpiPidIo = myProcId
112     pidIO = mpiPidIo
113     IF ( mpiPidIo .EQ. myProcId ) THEN
114     WRITE(fNam,'(A,A)') 'STDERR.', myProcessStr(1:4)
115     OPEN(errorMessageUnit,FILE=fNam,STATUS='unknown')
116     WRITE(fNam,'(A,A)') 'STDOUT.', myProcessStr(1:4)
117     OPEN(standardMessageUnit,FILE=fNam,STATUS='unknown')
118     ENDIF
119    
120     C-- Synchronise all processes
121     C Strictly this is superfluous, but by using it we can guarantee to
122 cnh 1.4 C find out about processes that did not start up.
123 adcroft 1.5 CALL MPI_BARRIER( MPI_COMM_MODEL, mpiRC )
124 cnh 1.1 IF ( mpiRC .NE. MPI_SUCCESS ) THEN
125     eeBootError = .TRUE.
126 adcroft 1.6 WRITE(msgBuffer,'(A,I5)')
127 cnh 1.1 & 'S/R INI_PROCS: MPI_BARRIER return code',
128     & mpiRC
129     CALL PRINT_ERROR( msgBuffer , myThid)
130     GOTO 999
131     ENDIF
132    
133     C-- Get number of MPI processes
134 adcroft 1.5 CALL MPI_COMM_SIZE ( MPI_COMM_MODEL, mpiNProcs, mpiRC )
135 cnh 1.1 IF ( mpiRC .NE. MPI_SUCCESS ) THEN
136     eeBootError = .TRUE.
137 adcroft 1.6 WRITE(msgBuffer,'(A,I5)')
138 cnh 1.1 & 'S/R INI_PROCS: MPI_COMM_SIZE return code',
139     & mpiRC
140     CALL PRINT_ERROR( msgBuffer , myThid)
141     GOTO 999
142     ENDIF
143     numberOfProcs = mpiNProcs
144    
145 cnh 1.4 C-- Can not have more processes than compile time MAX_NO_PROCS
146 cnh 1.1 IF ( numberOfProcs .GT. MAX_NO_PROCS ) THEN
147     eeBootError = .TRUE.
148     WRITE(msgBuffer,'(A)')
149     & 'S/R INI_PROCS: No. of processes too large'
150     CALL PRINT_ERROR( msgBuffer , myThid)
151     GOTO 999
152     ENDIF
153     C-- Under MPI only allow same number of processes as proc.
154     C-- grid size.
155     C Strictly we are allowed more procs. but knowing there
156     C is an exact match makes things easier.
157     IF ( numberOfProcs .NE. nPx*nPy ) THEN
158     eeBootError = .TRUE.
159 heimbach 1.10 nptmp = nPx*nPy
160     WRITE(msgBuffer,'(A,2I5)')
161 heimbach 1.9 & 'S/R INI_PROCS: No. of processes not equal to nPx*nPy',
162 heimbach 1.10 & numberOfProcs, nptmp
163 cnh 1.1 CALL PRINT_ERROR( msgBuffer , myThid)
164     GOTO 999
165     ENDIF
166    
167     #ifndef ALWAYS_USE_MPI
168     ENDIF
169     #endif
170 jmc 1.12
171     #else /* ALLOW_USE_MPI */
172    
173     WRITE(myProcessStr,'(I4.4)') myProcId
174     WRITE(fNam,'(A,A)') 'STDERR.', myProcessStr(1:4)
175     OPEN(errorMessageUnit,FILE=fNam,STATUS='unknown')
176     c WRITE(fNam,'(A,A)') 'STDOUT.', myProcessStr(1:4)
177     c OPEN(standardMessageUnit,FILE=fNam,STATUS='unknown')
178    
179 cnh 1.1 #endif /* ALLOW_USE_MPI */
180    
181     999 CONTINUE
182    
183     RETURN
184     END
185    

  ViewVC Help
Powered by ViewVC 1.1.22