#
# Include file for OASIS3 Makefile for a Linux system using 
# Portland Group Fortran Compiler and MPICH
# module load pgi/20.4
# module load pgimpi/openmpi3.1.3_pgi20
# module load lib/netcdf-c/4.6.1_pgi20.4
# module load lib/netcdf-fortran/4.4.4_pgi20.4
#
###############################################################################
#
# CHAN	: communication technique used in OASIS3 (MPI1/MPI2)
CHAN            = MPI1
#
# Paths for libraries, object files and binaries
#
# COUPLE	: path for oasis3-mct main directory
COUPLE          = $(HOME)/oasis3-mct
#
# ARCHDIR       : directory created when compiling
ARCHDIR         = $(COUPLE)/compile_oa3-mct_pgi_openmpi_openmp
#
# MPI library
MPIDIR      = /usr/local/pgi/linux86-64/20.4/mpi/openmpi-3.1.3
MPIBIN      = $(MPIDIR)/bin
MPI_INCLUDE = $(MPIDIR)/include
MPILIB      = -L$(MPIDIR)/lib
MPIRUN      = $(MPIBIN)/mpirun --oversubscribe
#
# NETCDF library
NETCDF_INCLUDE  = /usr/local/netcdf-fortran/4.4.4_pgi20.4/include
NETCDF_LIBRARY  = -L/usr/local/netcdf-fortran/4.4.4_pgi20.4/lib -lnetcdff -L/usr/local/netcdf-c/4.6.1_pgi20.4/lib -lnetcdf -Wl,-rpath,/usr/local/netcdf-fortran/4.4.4_pgi20.4/lib -Wl,-rpath,/usr/local/netcdf-c/4.6.1_pgi20.4/lib
#
# Compiling and other commands
MAKE        = gmake
F90         = $(MPIBIN)/mpif90 -I$(MPI_INCLUDE) 
F           = $(F90)
f90         = $(F90)
f           = $(F90)
CC          = $(MPIBIN)/mpicc -I$(MPI_INCLUDE) -pgf90libs
LD          = $(MPIBIN)/mpif90 $(MPILIB) 
# Static libraries compilation options
STATOPT     =
# Shared libraries options
DYNOPT      = -fPIC
LDDYNOPT    = -shared
AR          = ar
ARFLAGS     = -ruv
# Fortran libraries for C linking
F2C_LIBS    =
#
# CPP keys and compiler options
# 
CPPDEF    = -Duse_comm_$(CHAN) -D__VERBOSE -DTREAT_OVERLAY -D__NO_16BYTE_REALS
#
# -g is necessary in F90FLAGS and LDFLAGS for pgf90 versions lower than 6.1
# 
FCBASEFLAGS = -C -g -Mbounds -byteswapio -mp -lpthread
CCBASEFLAGS = -mp
#
# INC_DIR : includes all *mod for each library
INC_DIR = -I$(ARCHDIR)/include
# FLIBS : for toys when linking in local Makefile
FLIBS=${NETCDF_LIBRARY}
###################
#
F90FLAGS    = $(FCBASEFLAGS) $(INC_DIR) $(CPPDEF) -I$(NETCDF_INCLUDE)
f90FLAGS    = $(FCBASEFLAGS) $(INC_DIR) $(CPPDEF) -I$(NETCDF_INCLUDE)
FFLAGS      = $(FCBASEFLAGS) $(INC_DIR) $(CPPDEF) -I$(NETCDF_INCLUDE)
fFLAGS      = $(FCBASEFLAGS) $(INC_DIR) $(CPPDEF) -I$(NETCDF_INCLUDE)
CCFLAGS     = $(CCBASEFLAGS) $(INC_DIR) $(CPPDEF) -I$(NETCDF_INCLUDE)
LDFLAGS     = $(FCBASEFLAGS)
F2C_LDFLAGS = $(F2C_LIBS)
#
#############################################################################
