Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Dec 10, 2014
2 parents 07547e9 + 28eb1c9 commit a18ec9f
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 35 deletions.
8 changes: 4 additions & 4 deletions build.rtm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ CXX=mpicxx
FC=mpif90
F77=mpif90

EXTRA="--with-phdf5=$PHDF5_DIR"

case $SYSHOST in
ls4)
Expand All @@ -61,10 +62,9 @@ case $SYSHOST in
PHDF5_DIR=$TACC_HDF5_DIR
;;

kraken)
xc30)
PREFIX="$SCRATCH/t3pio"
EXTRA="--enable-static --disable-shared"
PHDF5_DIR=$HDF5_DIR
EXTRA="--enable-static --disable-shared LDFLAGS=-static"
CC=cc
CXX=CC
FC=ftn
Expand All @@ -79,7 +79,7 @@ esac


cmdA=("-make distclean"
"FCFLAGS=\"$FLAGS\" FFLAGS=\"$FLAGS\" CFLAGS=\"$FLAGS\" CXXFLAGS=\"$FLAGS\" FC=$FC F77=$F77 CC=$CC CXX=$CXX ./configure --prefix=$PREFIX --with-phdf5=$PHDF5_DIR $EXTRA"
"FCFLAGS=\"$FLAGS\" FFLAGS=\"$FLAGS\" CFLAGS=\"$FLAGS\" CXXFLAGS=\"$FLAGS\" FC=$FC F77=$F77 CC=$CC CXX=$CXX ./configure --prefix=$PREFIX $EXTRA"
"make"
"make install"
)
Expand Down
4 changes: 4 additions & 0 deletions cubeTest/cmdline.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module cmdline
integer :: GblFileSz ! Global File Size in GB.
integer :: Numvar ! number of variables
integer :: MaxWriters ! the max number of writers.
logical :: PartYZ ! partition processor grid in y-z only.
logical :: UseT3PIO ! if true then use T3PIO (on by default).
logical :: VersionFlag ! if true then report version and quit.
logical :: HelpFlag ! if true then print usage and quit
Expand Down Expand Up @@ -52,6 +53,7 @@ subroutine parse()
HDF5Flag = .false.
LuaOutput = .false.
TableOutput = .true.
PartYZ = .false.

#ifdef USE_HDF5
ROMIO = .false.
Expand Down Expand Up @@ -82,6 +84,8 @@ subroutine parse()
i = i + 1
call getarg(i,optarg)
read(optarg,*, err=11) nDim
elseif (arg == "--yz") then
PartYZ = .true.
elseif (arg == "--lua") then
LuaOutput = .true.
TableOutput = .false.
Expand Down
2 changes: 1 addition & 1 deletion cubeTest/master.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ program main
call exit()
end if

call partitionProc(nDim)
call partitionProc(nDim, PartYZ)

! partition grid to local locations.
call partitionGrid(global, local)
Expand Down
91 changes: 61 additions & 30 deletions cubeTest/parallel.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,79 @@ subroutine msg_init(comm)

end subroutine msg_init

subroutine partitionProc(ndim)
subroutine partitionProc(ndim, yzPart)
implicit none

integer :: ndim
real(8) :: xp
integer :: exponent, npx, npy, npz, npxy, rem
integer :: ndim, npA(2)
logical :: yzPart
integer :: rem

if (yzPart) then
call build2d_partition(npA)
nProcA(1) = 1
nProcA(2) = npA(1)
nProcA(3) = npA(2)
iProcA(3) = p % myProc/(nProcA(1) * nProcA(2))
rem = mod(p % myProc,(nProcA(1) * nProcA(2)))
iProcA(2) = rem / nProcA(1)
iProcA(1) = mod(rem,nProcA(1))
return
end if

if (ndim == 2) then
xp = sqrt(real(p % nProcs))
exponent = int(log(xp)/log(2.0)) + 1
npx = int(2.0**exponent + 1.5)
do while ( npx * (p % nProcs/npx) /= p % nProcs)
npx = npx - 1
end do

nProcA(1) = npx
nProcA(2) = p % nProcs / npx

call build2d_partition(nProcA)
iProcA(1) = mod(p % myProc, nProcA(1))
iProcA(2) = p % myProc/nProcA(1)

else if (ndim == 3) then
xp = p % nProcs
npz = xp**(1.0/3.0) + 1.5
do while ( npz * (p % nProcs/npz) /= p % nProcs )
npz = npz - 1
end do
npxy = p % nProcs/npz
npx = sqrt(real(npxy)) + 1.5
do while ( npx *(npxy/npx) /= npxy)
npx = npx - 1
end do
npy = npxy/npx

nProcA(1) = npx
nProcA(2) = npy
nProcA(3) = npz

call build3d_partition(nProcA)
iProcA(3) = p % myProc/(nProcA(1) * nProcA(2))
rem = mod(p % myProc,(nProcA(1) * nProcA(2)))
iProcA(2) = rem / nProcA(1)
iProcA(1) = mod(rem,nProcA(1))
end if
end subroutine partitionProc

subroutine build2d_partition(np)
integer np(2)
real(8) :: xp
integer :: exponent, npx

xp = sqrt(real(p % nProcs))
exponent = int(log(xp)/log(2.0)) + 1
npx = int(2.0**exponent + 1.5)
do while ( npx * (p % nProcs/npx) /= p % nProcs)
npx = npx - 1
end do

np(1) = npx
np(2) = p % nProcs / npx
end subroutine build2d_partition

subroutine build3d_partition(np)
integer np(3)
real(8) :: xp
integer :: exponent, npx, npy, npz, npxy

xp = p % nProcs
npz = xp**(1.0/3.0) + 1.5
do while ( npz * (p % nProcs/npz) /= p % nProcs )
npz = npz - 1
end do
npxy = p % nProcs/npz
npx = sqrt(real(npxy)) + 1.5
do while ( npx *(npxy/npx) /= npxy)
npx = npx - 1
end do
npy = npxy/npx

np(1) = npx
np(2) = npy
np(3) = npz

end subroutine build3d_partition




end module parallel

0 comments on commit a18ec9f

Please sign in to comment.