#
# Include file for OASIS3 Makefile for a Linux system using 
# Intel compilers and MPI
#
###############################################################################
#
# 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_intelmpi_training
#
# MPI library ((see the file /etc/modulefiles/mpi/openmpi-x86_64)
MPIDIR      = /usr/local/intel/impi/2018.1.163
MPIBIN      = $(MPIDIR)/bin64
MPI_INCLUDE = $(MPIDIR)/include64 
MPILIB      = -L$(MPIDIR)/lib64
MPIRUN      = $(MPIBIN)/mpirun
#
# NETCDF library of the system
NETCDF_LIB_DIR1=/softs/local_intel/netcdf-fortran/4.4.4_phdf5/lib
NETCDF_LIB_DIR2=/softs/local_intel/netcdf-c/4.6.1_phdf5/lib
NETCDF_INCLUDE1=/softs/local_intel/netcdf-fortran/4.4.4_phdf5/include
NETCDF_INCLUDE2=/softs/local_intel/netcdf-c/4.6.1_phdf5/include
NETCDF_LIBRARY  =  -Wl,-rpath,/softs/local_intel/netcdf-fortran/4.4.4_phdf5/lib -L/softs/local_intel/netcdf-fortran/4.4.4_phdf5/lib -Wl,-rpath,/softs/local_intel/netcdf-c/4.6.1_phdf5/lib -L/softs/local_intel/netcdf-c/4.6.1_phdf5/lib -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)
# Shared libraries options
DYNOPT      = -fPIC
LDDYNOPT    = -shared
# Static archiver
AR          = ar
ARFLAGS     = -ruv
#
# CPP keys and compiler options
#  
CPPDEF    = -Duse_comm_$(CHAN) -D__VERBOSE -DTREAT_OVERLAY
#
# 
#F90FLAGS_1  = -g -ffree-line-length-0 -fbounds-check -fopenmp
F90FLAGS_1  = -g -traceback -O2 -xAVX -I. -assume byterecl -mt_mpi -qopenmp
f90FLAGS_1  = $(F90FLAGS_1)
FFLAGS_1    = $(F90FLAGS_1)
fFLAGS_1    = $(F90FLAGS_1)
CCFLAGS_1   = 
LDFLAGS     = $(F90FLAGS_1)
#
#
###################
#
# 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$(ARCHDIR)/include

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