#
# Include file for OASIS3 Makefile for a Linux system using 
# Portland Group Fortran Compiler and MPICH
#
###############################################################################
#
# 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)/MARCONI_INTEL
#
# MPI library
#MPIDIR           = ${MPICOMPILER}
MPIDIR           = /cineca/prod/opt/compilers/intel/pe-xe-2017/binary/impi/2017.3.196/
MPIBIN           = $(MPIDIR)/bin64
MPI_INCLUDE      = $(MPIDIR)/include64
MPILIB           = -L$(MPIDIR)/lib64
#
# NETCDF library
NETCDF_LIB_DIR=/cineca/prod/opt/libraries/netcdf/4.4.1/intel--pe-xe-2017--binary/lib/ -L/cineca/prod/opt/libraries/netcdff/4.4.4/intel--pe-xe-2017--binary/lib
NETCDF_INC_DIR=/cineca/prod/opt/libraries/netcdf/4.4.1/intel--pe-xe-2017--binary/include -I/cineca/prod/opt/libraries/netcdff/4.4.4/intel--pe-xe-2017--binary/include/
NETCDF_INCLUDE  = ${NETCDF_INC_DIR}
NETCDF_LIBRARY  = -L${NETCDF_LIB_DIR} -lnetcdff -lnetcdf -lz -lcurl

##NETCDF_LIB_DIR=/marconi/home/userexternal/aporter0/MyInstalls/lib
##NETCDF_INC_DIR=/marconi/home/userexternal/aporter0/MyInstalls/include
##NETCDF_INCLUDE  = ${NETCDF_INC_DIR}
##NETCDF_LIBRARY  = -L${NETCDF_LIB_DIR} -lnetcdff -lnetcdf 


#
# Compiling and other commands
MAKE        = gmake
F90         = $(MPIBIN)/mpiifort -I$(MPI_INCLUDE)
F           = $(F90)
f90         = $(F90)
f           = $(F90)
CC          = $(MPIBIN)/mpiicc -I$(MPI_INCLUDE)
LD          = $(MPIBIN)/mpiifort $(MPILIB)
AR          = ar
ARFLAGS     = -ruv
#
# CPP keys and compiler options
# 
CPPDEF    = -Duse_netCDF -Duse_comm_$(CHAN) -D__VERBOSE  -DTREAT_OVERLAY
CCPPDEF   = -Duse_netCDF -Duse_comm_$(CHAN) -D__VERBOSE  -DTREAT_OVERLAY
#
# -g is necessary in F90FLAGS and LDFLAGS for pgf90 versions lower than 6.1
# 
F90FLAGS_1  = 
#F90FLAGS_1  = -g -traceback -O0 -check all -I. -assume byterecl
f90FLAGS_1  = $(F90FLAGS_1)
FFLAGS_1    = $(F90FLAGS_1)
fFLAGS_1    = $(F90FLAGS_1)
CCFLAGS_1   = 
LDFLAGS     = 
#
###################
#

# Additional definitions that should not be changed
#
FLIBS		= $(NETCDF_LIBRARY)
# BINDIR        : directory for executables
BINDIR          = $(ARCHDIR)/bin
# LIBBUILD      : contains a directory for each library
LIBBUILD        = $(ARCHDIR)/build/lib
# INCPSMILE     : includes all *o and *mod for each library
INCPSMILE       = -I$(LIBBUILD)/psmile.$(CHAN) -I$(LIBBUILD)/scrip  -I$(LIBBUILD)/mct

F90FLAGS  = $(F90FLAGS_1) $(INCPSMILE) $(CPPDEF) -I$(NETCDF_INCLUDE)
f90FLAGS  = $(f90FLAGS_1) $(INCPSMILE) $(CPPDEF) -I$(NETCDF_INCLUDE)
FFLAGS    = $(FFLAGS_1) $(INCPSMILE) $(CPPDEF) -I$(NETCDF_INCLUDE)
fFLAGS    = $(fFLAGS_1) $(INCPSMILE) $(CPPDEF) -I$(NETCDF_INCLUDE)
CCFLAGS   = $(CCFLAGS_1) $(INCPSMILE) $(CPPDEF) -I$(NETCDF_INCLUDE)
#
#############################################################################
