/[MITgcm]/MITgcm/model/src/ini_model_io.F
ViewVC logotype

Contents of /MITgcm/model/src/ini_model_io.F

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


Revision 1.29 - (show annotations) (download)
Tue May 12 19:54:28 2009 UTC (15 years ago) by jmc
Branch: MAIN
Changes since 1.28: +2 -3 lines
new header files "W2_EXCH2_SIZE.h" with new W2-Exch2 topology code

1 C $Header: /u/gcmpack/MITgcm/model/src/ini_model_io.F,v 1.28 2009/05/11 02:29:32 jmc Exp $
2 C $Name: $
3
4 #include "PACKAGES_CONFIG.h"
5 #include "CPP_OPTIONS.h"
6
7 CBOP
8 C !ROUTINE: INI_MODEL_IO
9
10 C !INTERFACE:
11 SUBROUTINE INI_MODEL_IO( myThid )
12
13 C !DESCRIPTION:
14 C Pass specific setup data for mdsio/rw.
15
16 C !USES:
17 IMPLICIT NONE
18 #include "SIZE.h"
19 #include "EEPARAMS.h"
20 #include "EESUPPORT.h"
21 #include "PARAMS.h"
22 #include "RESTART.h"
23 #ifdef ALLOW_EXCH2
24 # include "W2_EXCH2_SIZE.h"
25 # include "W2_EXCH2_TOPOLOGY.h"
26 #endif /* ALLOW_EXCH2 */
27 #ifdef ALLOW_MDSIO
28 # include "MDSIO_SCPU.h"
29 #endif /* ALLOW_MDSIO */
30
31 C !INPUT/OUTPUT PARAMETERS:
32 C myThid :: my Thread Id number
33 INTEGER myThid
34
35 C !FUNCTIONS
36 INTEGER ILNBLNK
37 EXTERNAL ILNBLNK
38
39 C !LOCAL VARIABLES:
40 C msgBuf :: Informational/error meesage buffer
41 CHARACTER*(MAX_LEN_MBUF) msgBuf
42 CHARACTER*(MAX_LEN_FNAM) namBuf
43 INTEGER iL, pIL
44 #ifdef ALLOW_EXCH2
45 INTEGER xySize
46 #endif /* ALLOW_EXCH2 */
47 #ifdef ALLOW_USE_MPI
48 INTEGER iG,jG,np
49 #endif /* ALLOW_USE_MPI */
50 #ifdef ALLOW_MDSIO
51 INTEGER i
52 #endif /* ALLOW_MDSIO */
53 CEOP
54
55 C- Safety check:
56 IF ( nPx*nPy.NE.1 .AND. globalFiles ) THEN
57 _BEGIN_MASTER( myThid )
58 c WRITE(msgBuf,'(2A)')
59 c & 'INI_MODEL_IO: globalFiles=TRUE is not safe',
60 c & ' in Multi-processors (MPI) run'
61 c CALL PRINT_ERROR( msgBuf , myThid)
62 c WRITE(msgBuf,'(2A)')
63 c & 'INI_MODEL_IO: use instead "useSingleCpuIO=.TRUE."'
64 c CALL PRINT_ERROR( msgBuf , myThid)
65 c STOP 'ABNORMAL END: S/R INI_MODEL_IO'
66 C------
67 C GlobalFiles option with Multi-processors execution (with MPI) is not
68 C safe: dependending on the platform & compiler, it may produce:
69 C - incomplete output files (wrong size)
70 C - wrong isolated values in some output files
71 C - missing tiles (all zeros) in some output files.
72 C A safe alternative is to set "useSingleCpuIO=.TRUE." in file "data",
73 C namelist PARAM01 (and to keep the default value of globalFiles=FALSE)
74 C or if you are really sure that the globalFile works well on our platform
75 C & compiler, comment out the above "stop"
76 C-----
77 WRITE(msgBuf,'(2A)')
78 & '** WARNING ** INI_MODEL_IO: globalFiles=TRUE is not safe',
79 & ' in Multi-processors (MPI) run'
80 CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
81 & SQUEEZE_RIGHT , myThid)
82 WRITE(msgBuf,'(2A)') '** WARNING ** INI_MODEL_IO:',
83 & ' use instead "useSingleCpuIO=.TRUE."'
84 CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
85 & SQUEEZE_RIGHT , myThid)
86 _END_MASTER( myThid )
87 ENDIF
88
89 C- Check size of IO buffers:
90 IF ( useSingleCpuIO ) THEN
91 c xySize = Nx*Ny
92 #if defined(ALLOW_EXCH2) && !defined(MISSING_TILE_IO)
93 xySize = exch2_global_Nx*exch2_global_Ny
94 IF ( xySize.GT.W2_ioBufferSize ) THEN
95 WRITE(msgBuf,'(A,I10)')
96 & 'INI_MODEL_IO: W2_ioBufferSize=',W2_ioBufferSize
97 CALL PRINT_ERROR( msgBuf, myThid )
98 WRITE(msgBuf,'(A,I10,A)')
99 & ' <', xySize,' = Size of Global 2-D map'
100 CALL PRINT_ERROR( msgBuf, myThid )
101 WRITE(msgBuf,'(2A)') ' Must increase "W2_ioBufferSize"',
102 & ' in "W2_EXCH2_SIZE.h" + recompile'
103 CALL PRINT_ERROR( msgBuf, myThid )
104 STOP 'ABNORMAL END: S/R INI_MODEL_IO (buffer size)'
105 ENDIF
106 #else /* defined(ALLOW_EXCH2) && !defined(MISSING_TILE_IO) */
107 #ifdef ALLOW_USE_MPI
108 C- Although using mpi_myX,YGlobalLo is more general, if they happen
109 C to be different from iG,jG then mapping into global 2D array is
110 C very likely to go wrong ; check and stop.
111 DO np = 1,nPx*nPy
112 iG = MOD(np-1,nPx)
113 jG = (np-1)/nPx
114 iG = 1+iG*nSx*sNx
115 jG = 1+jG*nSy*sNy
116 IF ( mpi_myXGlobalLo(np).NE.iG ) THEN
117 WRITE(msgBuf,'(2A,I4,A,I8,A,I8,A)') 'INI_MODEL_IO: ',
118 & 'myXGlobalLo(np=',np,')=', mpi_myXGlobalLo(np),
119 & ' <>',iG,' =iGLo'
120 CALL PRINT_ERROR( msgBuf, myThid )
121 ENDIF
122 IF ( mpi_myYGlobalLo(np).NE.jG ) THEN
123 WRITE(msgBuf,'(2A,I4,A,I8,A,I8,A)') 'INI_MODEL_IO: ',
124 & 'myYGlobalLo(np=',np,')=', mpi_myYGlobalLo(np),
125 & ' <>',jG,' =jGLo'
126 CALL PRINT_ERROR( msgBuf, myThid )
127 ENDIF
128 IF ( mpi_myXGlobalLo(np).NE.iG .OR.
129 & mpi_myYGlobalLo(np).NE.jG ) THEN
130 STOP 'ABNORMAL END: S/R INI_MODEL_IO wrong iGLo,jGLo'
131 ENDIF
132 ENDDO
133 #endif /* ALLOW_USE_MPI */
134 #endif /* defined(ALLOW_EXCH2) && !defined(MISSING_TILE_IO) */
135 ENDIF
136 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
137
138 C- Only Master-thread updates IO-parameter in Common blocks:
139 _BEGIN_MASTER( myThid )
140
141 C- Initialise AB starting level
142 C notes: those could be modified when reading a pickup that does
143 C correspond to what is actually needed.
144 tempStartAB = nIter0
145 saltStartAB = nIter0
146 mom_StartAB = nIter0
147 nHydStartAB = nIter0
148 IF ( startFromPickupAB2 ) tempStartAB = MIN( nIter0 , 1 )
149 saltStartAB = tempStartAB
150 mom_StartAB = tempStartAB
151
152 C- Initialise Alternating pickup-suffix
153 nCheckLev = 1
154 checkPtSuff(1) = 'ckptA'
155 checkPtSuff(2) = 'ckptB'
156
157 C- Flags specific to RW and MDSIO
158
159 C- now we make local directories with myProcessStr appended
160 IF ( mdsioLocalDir .NE. ' ' ) THEN
161 iL = ILNBLNK( mdsioLocalDir )
162 WRITE(namBuf,'(3A)')
163 & ' mkdir -p ', mdsioLocalDir(1:iL),myProcessStr(1:4)
164 pIL = 1 + ILNBLNK( namBuf )
165 WRITE(standardMessageUnit,'(3A)')
166 & '==> SYSTEM CALL (from INI_MODEL_IO): >',namBuf(1:pIL),'<'
167 CALL SYSTEM( namBuf(1:pIL) )
168 namBuf(1:iL) = mdsioLocalDir(1:iL)
169 WRITE(mdsioLocalDir,'(3A)') namBuf(1:iL),myProcessStr(1:4),'/'
170 ENDIF
171
172 C- Initialise MFLDS variables in common block
173 CALL READ_MFLDS_INIT( myThid )
174
175 C Set globalFiles flag for READ_WRITE_FLD package
176 CALL SET_WRITE_GLOBAL_FLD( globalFiles )
177 C Set globalFiles flag for READ_WRITE_REC package
178 CALL SET_WRITE_GLOBAL_REC( globalFiles )
179 C Set globalFiles flag for READ_WRITE_PICKUP
180 CALL SET_WRITE_GLOBAL_PICKUP( globalFiles )
181
182 _END_MASTER( myThid )
183 C- Everyone else must wait for the IO-parameters to be set
184 _BARRIER
185
186 C- MDSIO IO-buffers initialisation
187 #ifdef ALLOW_MDSIO
188 IF ( useSingleCpuIO ) THEN
189 _BEGIN_MASTER( myThid )
190 DO i=1,xyBuffer_size
191 xy_buffer_r8(i) = 0. _d 0
192 xy_buffer_r4(i) = 0.
193 ENDDO
194 _END_MASTER( myThid )
195 ENDIF
196 #endif /* ALLOW_MDSIO */
197
198 C- MNC model-io initialisation
199
200 #ifdef ALLOW_MNC
201 IF (useMNC) THEN
202
203 C Write units/set precision/etc for I/O of variables/arrays
204 C belonging to the core dynamical model
205 CALL INI_MNC_VARS( myThid )
206
207 #ifdef ALLOW_AUTODIFF
208 CALL AUTODIFF_INI_MODEL_IO( myThid )
209 #endif
210
211 ENDIF
212 #endif /* ALLOW_MNC */
213
214 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
215
216 RETURN
217 END

  ViewVC Help
Powered by ViewVC 1.1.22