Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
second version of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvain.laizet committed Jun 21, 2013
1 parent 53e5f54 commit 8d50530
Show file tree
Hide file tree
Showing 10 changed files with 780 additions and 2,115 deletions.
73 changes: 41 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,32 @@

# Choose pre-processing options
# -DSHM - enable shared-memory implementation
# -DDOUBLE_PREC - use double-precision (default single)
# -DDOUBLE_PREC - use double-precision
OPTIONS =

# Choose an FFT engine, available options are:
# fftw3 - FFTW version 3.x
# generic - A general FFT algorithm (no 3rd-party library needed)
FFT=generic
FFT= generic

# Paths to FFTW 3
FFTW3_PATH=/home/lining/software/fftw-alpha
FFTW3_PATH= # full path of FFTW installation if using fftw3 engine above
FFTW3_INCLUDE = -I$(FFTW3_PATH)/include
FFTW3_LIB = -L$(FFTW3_PATH)/lib -lfftw3
FFTW3_LIB = -L$(FFTW3_PATH)/lib -lfftw3 -lfftw3f

# include PATH
ifeq ($(FFT),generic)
INC=
else ifeq ($(FFT),fftw3)
INC=$(FFTW3_INCLUDE)
endif

# library path
ifeq ($(FFT),generic)
LIBFFT=
else ifeq ($(FFT),fftw3)
LIBFFT=$(FFTW3_LIB)
endif
# Specify Fortran and C compiler names and flags here
# Normally, use MPI wrappers rather than compilers themselves
# Supply a Fortran pre-processing flag together with optimisation level flags
# Some examples are given below:

# Compiler
#FC =
#OPTFC =
#CC =
#CFLAGS =

# PGI
#FC = ftn
#OPTFC = -O3 -fast -Mpreprocess
#OPTFC = -fast -O3 -Mpreprocess
#CC = cc
#CFLAGS = -O3

Expand All @@ -46,31 +40,43 @@ endif
#CFLAGS = -O3

# GNU
#PREP=/home/lining/build/scalasca/bin/scalasca -inst
#PREP=
FC = $(PREP) mpif90
OPTFC = -g -cpp
FC = mpif90
OPTFC = -O3 -funroll-loops -ftree-vectorize -fcray-pointer -cpp
CC = mpicc
CFLAGS = -g
CFLAGS = -O3

#Cray
# Cray
#FC = ftn
#OPTFC = -O3 -F
#OPTFC = -e Fm
#CC = cc
#CFLAGS = -O3
#CFLAGS =

#-----------------------------------------------------------------------
# Normally no need to change anything below

# include PATH
ifeq ($(FFT),generic)
INC=
else ifeq ($(FFT),fftw3)
INC=$(FFTW3_INCLUDE)
endif

# NAG
#FC = f95
#OPTFC = -O3 -kind=byte -I/usr/local/packages/nag/NAGWare5.1_496/NAGWare_f95-amd64/lib
# library path
ifeq ($(FFT),generic)
LIBFFT=
else ifeq ($(FFT),fftw3)
LIBFFT=$(FFTW3_LIB)
endif

# List of source files
SRC = decomp_2d.f90 glassman.f90 fft_$(FFT).f90 module_param.f90 io.f90 variables.f90 poisson.f90 schemes.f90 convdiff.f90 incompact3d.f90 navier.f90 derive.f90 parameters.f90 tools.f90 visu.f90

#-----------------------------------------------------------------------
# Normally no need to change anything below

ifneq (,$(findstring DSHM,$(OPTIONS)))
OBJ = $(SRC:.f90=.o) alloc_shm.o
ifneq (,$(findstring DSHM,$(OPTIONS)))
SRC := FreeIPC.f90 $(SRC)
OBJ = $(SRC:.f90=.o) alloc_shm.o FreeIPC_c.o
else
OBJ = $(SRC:.f90=.o)
endif
Expand All @@ -80,6 +86,9 @@ all: incompact3d
alloc_shm.o: alloc_shm.c
$(CC) $(CFLAGS) -c $<

FreeIPC_c.o: FreeIPC_c.c
$(CC) $(CFLAGS) -c $<

incompact3d : $(OBJ)
$(FC) -O3 -o $@ $(OBJ) $(LIBFFT)

Expand Down
277 changes: 277 additions & 0 deletions alloc.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
!=======================================================================
! This is part of the 2DECOMP&FFT library
!
! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil)
! decomposition. It also implements a highly scalable distributed
! three-dimensional Fast Fourier Transform (FFT).
!
! Copyright (C) 2009-2012 Ning Li, the Numerical Algorithms Group (NAG)
!
!=======================================================================

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Utility routine to help allocate 3D arrays
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! X-pencil real arrays
subroutine alloc_x_real(var, opt_decomp, opt_global)

implicit none

real(mytype), allocatable, dimension(:,:,:) :: var
TYPE(DECOMP_INFO), intent(IN), optional :: opt_decomp
logical, intent(IN), optional :: opt_global

TYPE(DECOMP_INFO) :: decomp
logical :: global
integer :: alloc_stat, errorcode

if (present(opt_decomp)) then
decomp = opt_decomp
else
decomp = decomp_main
end if

if (present(opt_global)) then
global = opt_global
else
global = .false.
end if

if (global) then
allocate(var(decomp%xst(1):decomp%xen(1), &
decomp%xst(2):decomp%xen(2), decomp%xst(3):decomp%xen(3)), &
stat=alloc_stat)
else
allocate(var(decomp%xsz(1),decomp%xsz(2),decomp%xsz(3)), &
stat=alloc_stat)
end if

if (alloc_stat /= 0) then
errorcode = 8
call decomp_2d_abort(errorcode, &
'Memory allocation failed when creating new arrays')
end if

return
end subroutine alloc_x_real


! X-pencil complex arrays
subroutine alloc_x_complex(var, opt_decomp, opt_global)

implicit none

complex(mytype), allocatable, dimension(:,:,:) :: var
TYPE(DECOMP_INFO), intent(IN), optional :: opt_decomp
logical, intent(IN), optional :: opt_global

TYPE(DECOMP_INFO) :: decomp
logical :: global
integer :: alloc_stat, errorcode

if (present(opt_decomp)) then
decomp = opt_decomp
else
decomp = decomp_main
end if

if (present(opt_global)) then
global = opt_global
else
global = .false.
end if

if (global) then
allocate(var(decomp%xst(1):decomp%xen(1), &
decomp%xst(2):decomp%xen(2), decomp%xst(3):decomp%xen(3)), &
stat=alloc_stat)
else
allocate(var(decomp%xsz(1),decomp%xsz(2),decomp%xsz(3)), &
stat=alloc_stat)
end if

if (alloc_stat /= 0) then
errorcode = 8
call decomp_2d_abort(errorcode, &
'Memory allocation failed when creating new arrays')
end if

return
end subroutine alloc_x_complex


! Y-pencil real arrays
subroutine alloc_y_real(var, opt_decomp, opt_global)

implicit none

real(mytype), allocatable, dimension(:,:,:) :: var
TYPE(DECOMP_INFO), intent(IN), optional :: opt_decomp
logical, intent(IN), optional :: opt_global

TYPE(DECOMP_INFO) :: decomp
logical :: global
integer :: alloc_stat, errorcode

if (present(opt_decomp)) then
decomp = opt_decomp
else
decomp = decomp_main
end if

if (present(opt_global)) then
global = opt_global
else
global = .false.
end if

if (global) then
allocate(var(decomp%yst(1):decomp%yen(1), &
decomp%yst(2):decomp%yen(2), decomp%yst(3):decomp%yen(3)), &
stat=alloc_stat)
else
allocate(var(decomp%ysz(1),decomp%ysz(2),decomp%ysz(3)), &
stat=alloc_stat)
end if

if (alloc_stat /= 0) then
errorcode = 8
call decomp_2d_abort(errorcode, &
'Memory allocation failed when creating new arrays')
end if

return
end subroutine alloc_y_real


! Y-pencil complex arrays
subroutine alloc_y_complex(var, opt_decomp, opt_global)

implicit none

complex(mytype), allocatable, dimension(:,:,:) :: var
TYPE(DECOMP_INFO), intent(IN), optional :: opt_decomp
logical, intent(IN), optional :: opt_global

TYPE(DECOMP_INFO) :: decomp
logical :: global
integer :: alloc_stat, errorcode

if (present(opt_decomp)) then
decomp = opt_decomp
else
decomp = decomp_main
end if

if (present(opt_global)) then
global = opt_global
else
global = .false.
end if

if (global) then
allocate(var(decomp%yst(1):decomp%yen(1), &
decomp%yst(2):decomp%yen(2), decomp%yst(3):decomp%yen(3)), &
stat=alloc_stat)
else
allocate(var(decomp%ysz(1),decomp%ysz(2),decomp%ysz(3)), &
stat=alloc_stat)
end if

if (alloc_stat /= 0) then
errorcode = 8
call decomp_2d_abort(errorcode, &
'Memory allocation failed when creating new arrays')
end if

return
end subroutine alloc_y_complex


! Z-pencil real arrays
subroutine alloc_z_real(var, opt_decomp, opt_global)

implicit none

real(mytype), allocatable, dimension(:,:,:) :: var
TYPE(DECOMP_INFO), intent(IN), optional :: opt_decomp
logical, intent(IN), optional :: opt_global

TYPE(DECOMP_INFO) :: decomp
logical :: global
integer :: alloc_stat, errorcode

if (present(opt_decomp)) then
decomp = opt_decomp
else
decomp = decomp_main
end if

if (present(opt_global)) then
global = opt_global
else
global = .false.
end if

if (global) then
allocate(var(decomp%zst(1):decomp%zen(1), &
decomp%zst(2):decomp%zen(2), decomp%zst(3):decomp%zen(3)), &
stat=alloc_stat)
else
allocate(var(decomp%zsz(1),decomp%zsz(2),decomp%zsz(3)), &
stat=alloc_stat)
end if

if (alloc_stat /= 0) then
errorcode = 8
call decomp_2d_abort(errorcode, &
'Memory allocation failed when creating new arrays')
end if

return
end subroutine alloc_z_real


! Z-pencil complex arrays
subroutine alloc_z_complex(var, opt_decomp, opt_global)

implicit none

complex(mytype), allocatable, dimension(:,:,:) :: var
TYPE(DECOMP_INFO), intent(IN), optional :: opt_decomp
logical, intent(IN), optional :: opt_global

TYPE(DECOMP_INFO) :: decomp
logical :: global
integer :: alloc_stat, errorcode

if (present(opt_decomp)) then
decomp = opt_decomp
else
decomp = decomp_main
end if

if (present(opt_global)) then
global = opt_global
else
global = .false.
end if

if (global) then
allocate(var(decomp%zst(1):decomp%zen(1), &
decomp%zst(2):decomp%zen(2), decomp%zst(3):decomp%zen(3)), &
stat=alloc_stat)
else
allocate(var(decomp%zsz(1),decomp%zsz(2),decomp%zsz(3)), &
stat=alloc_stat)
end if

if (alloc_stat /= 0) then
errorcode = 8
call decomp_2d_abort(errorcode, &
'Memory allocation failed when creating new arrays')
end if

return
end subroutine alloc_z_complex
Loading

0 comments on commit 8d50530

Please sign in to comment.