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

Commit

Permalink
Adding basic initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
pbartholomew08 committed Oct 2, 2017
1 parent 7fb4678 commit 7c4a3e5
Show file tree
Hide file tree
Showing 12 changed files with 4,746 additions and 4 deletions.
47 changes: 44 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,57 @@ FC = mpif90
OPTFC = -O3 -funroll-loops -ftree-vectorize -fcray-pointer -cpp
CC = mpicc
CFLAGS = -O3
OPTIONS += -Wall -Werror
#OPTIONS += -Wall -Werror

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

all:
$(FC) $(OPTIONS) -o incompact3dlmn incompact3dlmn.f90
#-----------------------------------------------------------------------
# Normally no need to change anything below

# 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

# List of source files
SRC = decomp_2d.f90 incompact3dlmn.f90

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

ifneq (,$(findstring DSHM,$(OPTIONS)))
SRC := FreeIPC.f90 $(SRC)
OBJ = $(SRC:.f90=.o) alloc_shm.o FreeIPC_c.o
else
OBJ = $(SRC:.f90=.o)
endif

all: incompact3d

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

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

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

%.o : %.f90
$(FC) $(OPTFC) $(OPTIONS) $(INC) -c $<

run:
./incompact3dlmn
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 7c4a3e5

Please sign in to comment.