#
#  change compiler, options and libraries according to your needs
#
#########
#  Lomonosov (IBM) Vladimir Platonov
#########
#
# modules and libraries
#
# COSMO variant of paths and libraries
# shared keys of compilation
CKEYS        =    -c -fpp  -fno-alias -unroll0 -heap-arrays 1000

NETCDF_PATH = /mnt/data/users/dm3/vol8/vplatonov/soft/package_new
#MPI_PATH    =  /opt/mpi/openmpi-1.8.4-icc

#  include external library { -DGRIBDWD | -DNETCDF | -DNUDGING | -DGRIB_API }
PRAGMA_LIB   = -DGRIBDWD -DNETCDF

# additional header files
INC_DIR   = -I$(NETCDF_PATH)/include 
# -I$(MPI_PATH)/include

COMPILER=mpif90

## COSMO_CLM variant
#MPIINC  = -I/usr/lpp/ppe.poe/include
#LPATH   = -L/usr/lib -L /sw/aix61/netcdf-4.2.1.1/lib
#OTHLIBS1= -L/usr/lib -lessl -lmass -L/sw/aix53/lapack-3.2.0/lib -llapack -lblas
#
# might be possible that the following libs are needed in context of hdf5 format and data compression within this format
#
#OTHLIBS2= -lhdf5_hl -lhdf5 -lm -lz -L/sw/aix61/hdf5-1.8.8/lib -L/sw/aix53/zlib-1.2.6/lib -L/sw/aix53/szip-2.1/lib -lsz
#LIBS    =   -lnetcdff -lnetcdf
#
#NC_INCLUDE  =  -I/sw/aix61/netcdf-4.2.1.1/include
#
# GRIB_LIB defines a working GRIBLIB
#
#GRIB_LIB = ../grib/lib/libgrib1.a
##

# standard binary
PROGRAM      = cosmoclm_v5_new
#
# compiler, options and libraries
#
F90          = $(COMPILER)  $(CKEYS)  $(PRAGMA_LIB)  $(INC_DIR)

## COSMO_CLM variant
# it is recommended to use optimization level -O2 instead of -O3 or even higher; an unexplainable crash of CCLM might occur with -O3 or higher
# experience shows that there is no loss of performnce when -O2 is used
#
#COMFLG        = -c -q64 -qsuffix=cpp=f90 -qmaxmem=-1 -O2 -qstrict -qarch=pwr6 -qtune=pwr6 -qextname -WF,-D__AIX,-D_AIX,-DIBM,-D__ibm__,-Dextname,-D_EXTNAME

COMFLG1      = -02
COMFLG2      = -02
COMFLG3      = -02
COMFLG4      = -02
#
# Compile src_setup_vartab.f90 with optimization level -O0; speeds up the compilation very much!!
#
#COMFLG4       = -c -q64 -qsuffix=cpp=f90 -qmaxmem=-1 -O0 -qarch=pwr6 -qtune=pwr6 -qextname -WF,-D__AIX,-D_AIX,-DIBM,-D__ibm__,-Dextname,-D_EXTNAME
#

LDSEQ        = $(COMPILER) -static
LDPAR        = $(COMPILER)

# library
DWDLIB_PATH= /mnt/data/users/dm3/vol8/vplatonov/COSMO/lib

## COSMO_CLM variant
#LDFLG        = -q64 -qextname  -I$(SRCDIR)
#LIB          = ${LPATH} ${GRIB_LIB} ${LIBS} ${OTHLIBS1} ${OTHLIBS2}
##

##COSMO variant
#LIB1         = -L$(MPI_PATH)/lib                       -lmpi -lmpi_f90 -lmpi_f77
LIB2         = -L$(DWDLIB_PATH)                        -lgrib1
LIB3         = -L$(NETCDF_PATH)/lib                    -lnetcdff -lnetcdf

LIB          = $(LIB1) $(LIB2) $(LIB3)