# Added -ffree-line-length-512 flag to compute Fortran code on
# other systems

#
# Include file for OASIS3 Makefile for a Linux system using 
# Gnu compilers with OpenMPI 4
#
###############################################################################
#
# CHAN  : communication technique used in OASIS3 (MPI1/MPI2/NONE)
CHAN        = MPI1
#
# Paths for libraries, object files and binaries
#
# COUPLE : path for oasis3-mct main directory
curr_path = $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
COUPLE      = $(curr_path)../..
#
# ARCHDIR : directory created when compiling
ARCHDIR     = $(COUPLE)/generated
#
# MPI library
MPIDIR      := /apps/INTEL/2017.4/impi/2017.3.196
ifneq ($(strip $(MPIDIR)),)
MPIBIN      := $(MPIDIR)/bin64
MPI_INCLUDE := $(MPIDIR)$(addprefix /,include64)
MPILIB      := -L$(MPIDIR)$(addprefix /,lib64)
endif
MPILIB      += $(addprefix -l,mpi mpifort mpigi)
MPIRUN      = mpirun
#
# NETCDF library
NETCDF_DIR      := /apps/NETCDF/4.2/INTEL/IMPI
NETCDF_INCLUDE  := $(addprefix $(addsuffix /,$(NETCDF_DIR)),include)
NETCDF_LIBRARY  := $(addprefix -L,$(addprefix $(addsuffix /,$(NETCDF_DIR)),lib))
NETCDF_LIBRARY  += $(addprefix -l,netcdff netcdf)
#
# Compiling and other commands
MAKE        = make
F90         = $(MPIBIN)/mpif90
F           = $(F90)
f90         = $(F90)
f           = $(F90)
CC          = $(MPIBIN)/mpicc
LD          = $(MPIBIN)/mpif90
DYNOPT      = -fPIC
LDDYNOPT    = -shared
AR          = ar
ARFLAGS     = -ruv
#
# CPP keys and compiler options
# 
CPPDEF    = -Duse_comm_$(CHAN) -D__VERBOSE -DTREAT_OVERLAY
#
# 
F90FLAGS_1 := -r8 -O3 -xAVX -mtune=skylake -ip -fp-model precise -traceback -extend-source 132
F90FLAGS_1 += "-132"
f90FLAGS_1  = $(F90FLAGS_1)
FFLAGS_1    = $(F90FLAGS_1)
fFLAGS_1    = $(F90FLAGS_1)
CCFLAGS_1   = 
LDFLAGS     =  -O2
#
###################
#
# 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
# LIBBUILDSHARED : contains a directory for each shared library
LIBBUILDSHARED   = $(ARCHDIR)/build-shared/lib
# INCPSMILE      : includes all *o and *mod for each library
INCPSMILE        = -I$(ARCHDIR)/include

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) 
#
#############################################################################
