source: CIVL/mods/dev.civl.abc/examples/fortran/flash/heat_min/driver.f90

main
Last change on this file was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5664 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 3.4 KB
Line 
1subroutine proc(pid, unk)
2
3#include "Flash.h"
4#include "constants.h"
5
6 implicit none
7
8 integer :: pid
9 real :: unk(:,:,:,:,:)
10
11 integer :: gr_globalNumBlocks, alnblocks, io_meshNumProcs
12 integer :: xx, yy, procBlocks, io_meshMe, localNumBlocks
13 integer :: gr_nToLeft(0:NPROC)
14
15 integer :: mblk
16
17 mblk = MAXBLOCKS
18 gr_globalNumBlocks = NBLOCK
19 io_meshNumProcs = NPROC
20 io_meshMe = pid
21
22!! src: source/IO/IOMain/hdf5/parallel/PM/io_readData.F90 #196--284
23
24 !---------------------------------------------------------------------------
25 ! compute the number of blocks on each processor -- this will be used to
26 ! get the offset into the file for the parallel read
27 !---------------------------------------------------------------------------
28
29
30#ifndef _CIVL
31 ! compute the approximate number of blocks per processor
32 alnblocks = int(gr_globalNumBlocks/io_meshNumProcs) + 1
33
34 ! check for error -- if the number of blocks we want to put on each
35 ! processor is greater than maxblocks, then abort
36 if (alnblocks .GT. MAXBLOCKS) then
37
38 print *
39 print *, '********** ERROR in READ_DATA ************'
40 print *
41 print *,' Number of blocks per processor exceeds maxblocks.'
42 print *,' Suggest you reset maxblocks to a larger number or'
43 print *,' run on a larger number of processors.'
44 print *,' globalNumBlocks, io_meshNumProcs = ', gr_globalNumBlocks, io_meshNumProcs
45 print *
46
47 call Driver_abortFlash('[io_readData] ERROR: num blocks per proc exceeds maxblocks')
48
49 end if
50
51#else
52
53 alnblocks = gr_globalNumBlocks/io_meshNumProcs + 1
54
55!$ CIVL $assert(alnblocks <= mblk)
56
57#endif
58!! end ifndef _CIVL (the 1st one)
59
60 ! figure out the excess blocks
61 yy = (io_meshNumProcs*alnblocks) - gr_globalNumBlocks
62 xx = io_meshNumProcs - yy
63
64 ! loop over all the processor numbers and figure out how many blocks are
65 ! stored to the left of the processor -- this is a little tricky
66
67 gr_nToLeft(0) = 0
68
69 do i = 0, io_meshNumProcs - 2
70 if (i .LT. xx) then
71 procBlocks = alnblocks
72 else
73 procBlocks = alnblocks - 1
74 endif
75
76 if (alnblocks .EQ. 0) then
77 if (i .LT. gr_globalNumBlocks) then
78 procBlocks = 1
79 else
80 procBlocks = 0
81 end if
82 end if
83
84 ! we have the number of blocks on proc i, the number of blocks on i+1 is
85 ! the number of blocks on i + the number of blocks left of i
86 if (i .EQ. 0) then
87 gr_nToLeft(i+1) = procBlocks
88 else
89 gr_nToLeft(i+1) = procBlocks + gr_nToLeft(i)
90 endif
91 enddo
92
93 ! figure out how many blocks are on the current proc.
94 if (io_meshMe < xx) then
95 localNumBlocks = alnblocks
96 else
97 localNumBlocks = alnblocks - 1
98 endif
99
100 if (alnblocks .EQ. 0) then
101 if (io_meshMe < gr_globalNumBlocks) then
102 localNumBlocks = 1
103 else
104 localNumBlocks = 0
105 end if
106 end if
107
108 ! compute the offset into the dataspace in the HDF5 file
109 gr_globalOffset = gr_nToLeft(io_meshMe)
110
111#ifndef _CIVL
112
113 call Grid_putLocalNumBlks(localNumBlocks)
114
115 !find our offset into a potentially split file:
116 if(io_outputSplitNum > 1) then
117 call MPI_ALLREDUCE(gr_globalOffset, splitOffset,1,FLASH_INTEGER,&
118 MPI_MIN, io_comm, ierr)
119 localOffset = gr_globalOffset - splitOffset
120
121 else
122 localOffset = gr_globalOffset
123 end if
124
125#else
126
127 localOffset = gr_globalOffset
128
129#endif
130!! end ifndef _CIVL (the 2nd one)
131
132
Note: See TracBrowser for help on using the repository browser.