Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
program ziz
!
!
! @' ..
! @#@@ @'' :@
! @. : @@: #
! :@ ' @@: .
! @@ @@
! '@ .@.
! #: .@. :@'@
! . @@@' @@@ '.@#.:'#:@@ .@#
! @@@ .@@@@ @@@@: @#::.@@:'@#@.@@
! @@@ @@@@: #@@@@ #@@.@@@.@@ @ @@.
! @.@@@ '@@@@@@#.@@@@ .:@@:@.@.@'
! @@@@@ @@:@@@@:'@@@@ '@@@:@ @@'@@.
! @@.@@@ @@@#@@@@#@@@@. @@@#:..:@'#@ @@
! :# @'@@@@@ .@@@.@@@@:@@@@@ @@##@@@@@#@''
! @@@ @@.@.#.@ .@@@@@@@@.@@@@ @@ @@@:..#.':@@@@@@'
! @@@# @@@@@@ . :@@'@@.@@@@.@@@@ @@ @@.@@@@@ '@@@@:@@'@@
! ..@@@:'@:#.@@@ '@@#@@@@@#@@@@@@ @@ @@.@@.@@.@@@@@. @@@@@
! @@ @@@ @@@@@@ . .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..#@@@@@@# @@@@@@#@
! @@@ # #@ . @@@@@@#@
! @@' .. # :@@@#@'@
! @@@ @ #:@:@::
! : @@.@@@ ' ::.:@
! @:@@'@@ @:@@@.@
! @#: @#@@@.@
! @@.@#@@
! @@@@@:
! .'@@ @
! @@'@@
! @.@@::
! .'@#.'
! @ :#
! @ @'@@@# ##
! #'@@@.@@@@'..
! .@@@@:@.@@@:
! @@@@@@':
! Is really (in disguise, with some modifications and simplifications)...
!--------------------------------------------------------------------------
!
! MM MM VV VV HH HH 3333333
! MMMM MMMM VV VV HH HH 333 333
! MM MM MM MM VV VV HH HH 333
! MM MMMM MM VV VV HH HH 333
! MM MM MM VV VV HHHHHHHHHHH 333
! MM MM VV VV HH HH 333
! MM MM VV VV HH HH 333
! MM MM VVVV HH HH 333 333
! MM MM VV HH HH 3333333
!
!
! MPI - VIRGINIA HYDRODYNAMICS - 3D
!
!--------------------------------------------------------------------------
! The Virginia Numerical Bull Session ideal hydrodynamics PPMLR
!
! Output channels:
! 4 = aaaaadaa.####, binary dump files for restarting
! 8 = aaaaa.hst, history file
!-------------------------------------------------------------------------------
! GLOBALS
use global
use zone
use sweepsize
use mpi
IMPLICIT NONE
! LOCALS
CHARACTER(len=50) :: hstfile
CHARACTER(len=8) :: dmpfile
CHARACTER(len=4) :: tmp4
CHARACTER(len=2) :: rstrt
CHARACTER(len=8) :: todayis
CHARACTER(len=MPI_MAX_PROCESSOR_NAME) :: myname
CHARACTER(len=20) :: imaxstring, jmaxstring, kmaxstring, peystring, pezstring
INTEGER :: jcol, krow, n, nfile_start
INTEGER :: ncycend, nprin, ndump, nmovie, tmpcyc, mpierr,start_cycl, namelength
REAL :: endtime,tprin,tmovie, olddt
REAL(8) :: start_time,end_time,run_time,zones
NAMELIST / hinput / rstrt, prefix, ncycend, ndump, endtime
CALL get_command_argument(1, imaxstring)
CALL get_command_argument(2, jmaxstring)
CALL get_command_argument(3, kmaxstring)
CALL get_command_argument(4, peystring)
CALL get_command_argument(5, pezstring)
read(imaxstring,*) imax
read(jmaxstring,*) jmax
read(kmaxstring,*) kmax
read(peystring,*) pey
read(pezstring,*) pez
write(*,*) imax, jmax, kmax, pey, pez
!-----------------------------------------------------------------------------------------
! Initialize MPI
call MPI_INIT(mpierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, npe, mpierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, mype, mpierr)
! Set VH1_DATATYPE for MPI calls
if (SIZEOF(endtime)==8) then
VH1_DATATYPE = MPI_DOUBLE_PRECISION
elseif (SIZEOF(endtime)==4) then
VH1_DATATYPE = MPI_REAL
else
if(mype==0) write(*,*) 'Mode not recognized. MPI commands will fail.'
stop
endif
! set dimensions of local simulation grid (imax X js X ks)
js = jmax / pey
ks = kmax / pez
isy = imax / pey
isz = imax / pez
ndim = 3; if (kmax==1) ndim = 2
! set size of send/receive buffers for alltoall calls
Za2abuff_size = ks * isz * js * nvar
Ya2abuff_size = ks * isy * js * nvar
jcol = mod(mype,pey) ! processor rank in the Y direction
krow = mype / pey ! processor rank in the Z direction
ALLOCATE (zro(imax,jmax/pey,kmax/pez))
ALLOCATE (zpr(imax,jmax/pey,kmax/pez))
ALLOCATE (zux(imax,jmax/pey,kmax/pez))
ALLOCATE (zuy(imax,jmax/pey,kmax/pez))
ALLOCATE (zuz(imax,jmax/pey,kmax/pez))
ALLOCATE (zfl(imax,jmax/pey,kmax/pez))
ALLOCATE (zxa(imax))
ALLOCATE (zdx(imax))
ALLOCATE (zxc(imax))
ALLOCATE (zya(jmax))
ALLOCATE (zdy(jmax))
ALLOCATE (zyc(jmax))
ALLOCATE (zza(kmax))
ALLOCATE (zdz(kmax))
ALLOCATE (zzc(kmax))
ALLOCATE (send1(nvar,ks,js,imax))
ALLOCATE (send2(nvar,ks,isy,jmax))
ALLOCATE (send3(nvar,js,ks,imax))
ALLOCATE (send4(nvar,js,isz,kmax))
ALLOCATE (recv1(nvar,ks,js,isy,pey))
ALLOCATE (recv2(nvar,ks,isy,js,pey))
ALLOCATE (recv3(nvar,js,ks,isz,pez))
ALLOCATE (recv4(nvar,js,isz,ks,pez))
! Create communicators for each value of krow (for XY transpose)
call MPI_COMM_SPLIT(MPI_COMM_WORLD, krow, mype, MPI_COMM_ROW, mpierr)
call MPI_COMM_RANK(MPI_COMM_ROW, mypey, mpierr)
call MPI_COMM_SIZE(MPI_COMM_ROW, npey, mpierr)
! Create communicators for each value of jcol (for XZ transpose)
call MPI_COMM_SPLIT(MPI_COMM_WORLD, jcol, mype, MPI_COMM_COL, mpierr)
call MPI_COMM_SIZE(MPI_COMM_COL, npez, mpierr)
call MPI_COMM_RANK(MPI_COMM_COL, mypez, mpierr)
! should have npey = pey, npez = pez, mypey = jcol, mypez = krow
! Check that code is running with desired number of PE's
if (pey*pez /= npe) then
write(*,*) 'sorry, I was compiled for ',pey*pez,' PEs, but npe= ', npe
stop
endif
! Check that arrays are large enough for desired number of physical zones
if (max(imax,jmax,kmax)+12 > maxsweep) then
write(*,*) 'maxsweep too small'
stop
endif
! Check that imax and jmax are multiples of npey
if (isy*npey /= imax) then
write(*,*) 'imax is not an integer multiple of pey', imax, pey
stop
endif
if (js*npey /= jmax) then
write(*,*) 'jmax is not an integer multiple of pey', jmax, pey
stop
endif
! Check that imax and kmax are multiples of npez
if (isz*npez /= imax) then
write(*,*) 'imax is not an integer multiple of pez', imax, pez
stop
endif
if (ks*npez /= kmax) then
write(*,*) 'kmax is not an integer multiple of pez', kmax, pez
stop
endif
! Begin by reading input deck, and defining file names
open (unit=15,file='indat',status='old',form='formatted')
read (15,nml=hinput)
close(15)
write(tmp4,"(i4)") mype
do n = 1, 4
if ((tmp4(n:n)) == ' ') tmp4(n:n) = '0'
enddo
dmpfile = 'dad.' // tmp4
if ((rstrt == 'NO').or.(rstrt == 'no')) then ! Initialize variables for new problem;
if (mype == 0) then
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
open (unit=8,file=hstfile,form='formatted')
call date_and_time(todayis)
write (8,*) 'History File for Ziz run on ', todayis(5:6), ' / ', todayis(7:8), ' / ', todayis(1:4)
call MPI_GET_PROCESSOR_NAME(myname, namelength, mpierr)
write (8,"(' machine id: ',a25)") myname
if (ndim==3) then
write (8,"(' Running 3 dimensions on ',i4,' processors, split ',i3, ' X ', i3)") npe,npey,npez
else
write (8,"(' Running 2 dimensions on ',i3,' processors' )") npe
endif
if(VH1_DATATYPE==MPI_DOUBLE_PRECISION) then
write(8,*) 'Running in double precision mode'
else
write(8,*) 'Running in single precision mode'
endif
write (8,*)
endif
call init
nfile_start = nfile
else ! Restart from old dumpfile... This is here only for completeness: Most performance runs should start from t=0
dmpfile = 'd' // rstrt(1:2) // dmpfile(4:8)
if (mype == 0) then
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
open (unit=8,file=hstfile,form='formatted',position='append')
call date_and_time(todayis)
write (8,*) 'Restarting run on ', todayis(5:6), ' / ', todayis(7:8), ' / ', todayis(1:4)
endif
call undump(dmpfile)
if(timep >= tprin) timep = tprin -2.0*dt ! adjust so that dt is not set to zero on first step
if(timem >= tmovie) timem = tmovie-2.0*dt
nfile_start = nfile
endif
if(mype == 0) then
start_time = MPI_WTIME()
start_cycl = ncycle
write(8,*) 'Starting on cycle number ',ncycle
endif
!############################################################################
! MAIN COMPUTATIONAL LOOP
do while (ncycle < ncycend)
! if(mype == 0) write(*,*) 'STEP = ',ncycle
ncycle = ncycle + 2
ncycp = ncycp + 2
ncycd = ncycd + 2
ncycm = ncycm + 2
olddt = dt
svel = 0.
if ( time + 2*dt > endtime ) then ! set dt to land on endtime
if(mype==0) write(8,*) 'cutting to the end...', ncycle, ncycend
dt = 0.5*(endtime - time)
ncycend = ncycle-1
ncycp = nprin
ncycd = ndump
else if ( timep+2.0*dt > tprin ) then ! set dt to land on tprin
dt = 0.5*(tprin - timep)
ncycp = nprin
else if ( timem+2*dt > tmovie ) then ! set dt to land on tmovie
dt = 0.5*(tmovie - timem)
ncycm = nmovie
endif
! Alternate sweeps to approximate 2nd order operator splitting
call sweepx1
call sweepy
if (ndim==3) then
call sweepz
call sweepy
endif
call sweepx2
time = time + 2.0*dt
timep = timep + 2.0*dt
timem = timem + 2.0*dt
dt = olddt
call dtcon ! Check constraints on the timestep
if ( ncycp >= nprin .or. timep >= tprin ) then
timep = 0.
ncycp = 0
endif
if ( ncycd >= ndump ) then
ncycd = 0
call dump(dmpfile)
endif
enddo
! END OF MAIN LOOP
!#########################################################################
if(mype == 0) then
end_time = MPI_WTIME()
zones = (imax*js*ks)*(ncycle - start_cycl)
run_time = end_time - start_time
write(8,*) 'successful stop at cycle number', ncycle
if (run_time>4000.0) then
write(8,*) 'elapsed time = ',run_time/3600., ' hours'
else
write(8,*) 'elapsed time = ',run_time/60., ' minutes'
endif
write(8,"('speed = ',f5.1,' kz/s/pe')") 1.0e-3*zones/run_time
close( 8 )
if (ndim==3) then ! open up a file to store data needed for post-processing