
#
#     Copyright (c) 2017, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
#

NXSIZE=101
NYSIZE=641
NPROCS=2
NTHREADS=1

# NZSIZE = NPROCS*NZSLICE
NZSLICE=64

MPIFC=mpif90
OPT=-fast
ACC=-acc=verystrict -Minfo=accel
RUNNER=$(RUN) mpirun
OBJ=o
EXE=out
TIME=/usr/bin/time
UNAME := $(shell uname -a)
ifeq ($(findstring CYGWIN_NT, $(UNAME)), CYGWIN_NT)
   OBJ=obj
   EXE=exe
   CC      = pgcc -Mmpi=msmpi
   MPIFC      = pgf90 -Mmpi=msmpi
   RUNNER     = mpiexec
   MSLIB   = Ws2_32.lib
   TIME =
endif
all: build run verify

build: seismic_CPML_3D_isotropic_MPI_OACC_5.F90
	@echo ------------ building seismic_CPML_3D_isotropic_MPI_OACC_5.$(EXE)
	$(MPIFC) $(OPT) $(ACC) -DNXSIZE=$(NXSIZE) -DNYSIZE=$(NYSIZE) -DNZSLICE=$(NZSLICE) -DNUM_PROCS=$(NPROCS) -o seismic_cpml.$(EXE) seismic_CPML_3D_isotropic_MPI_OACC_5.F90

run: seismic_cpml.$(EXE)
	@echo '------------- executing seismic_cpml.$(EXE)'
	$(TIME) $(RUNNER) -np $(NPROCS) ./seismic_cpml.$(EXE)

verify: ../check.F
	@pgfortran -o check.$(EXE) ../check.F
	./check.$(EXE)

clean:
	@echo 'Cleaning up...'
	@rm -rf seismic_cpml.$(EXE) *.dwf *.pdb prof image* timestamp* Vx* Vy* plot* *.eps *.dat check.$(EXE)
