From 6eaf8d17c07dbc67617716a649b7129589ff6b39 Mon Sep 17 00:00:00 2001
From: Gaelle TANGUY <gaelle.tanguy@meteo.fr>
Date: Tue, 11 Oct 2016 14:52:06 +0200
Subject: [PATCH] Gaelle : 11/10/2016 add WAVE cupling

---
 src/Makefile           | 25 +++++++++++++++++++++--
 src/Makefile.MESONH.mk | 46 ++++++++++++++++++++++++++++++++++++++++++
 src/configure          |  8 ++++++++
 3 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index baeec252b..40d239c57 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -187,6 +187,10 @@ ifeq "$(VER_CDF)" "CDFAUTO"
 depmaster : cdf
 endif
 
+ifeq "$(VER_OASIS)" "OASISAUTO"
+depmaster : oasis
+endif
+
 depmaster : gribapi
 
 filedepallmaster :  $(DEP_ALL_MASTER)
@@ -336,13 +340,30 @@ cdf : $(CDF_INC)
 $(CDF_INC) : 
 	cd ${DIR_HDF} && ./configure --disable-shared --prefix=${CDF_PATH} --libdir=${CDF_PATH}/lib64 --with-zlib=no \
 	FC="$(FC)" FCFLAGS="$(HDF_OPT)" CPPFLAGS="-DpgiFortran" ${HDF_CONF} && make && make install && $(MAKE) -j 1 clean
-	cd ${DIR_CDF} && ./configure --disable-shared --prefix=${CDF_PATH} --libdir=${CDF_PATH}/lib64 --disable-cxx --disable-f90 --disable-dap \
-	FC="$(FC)" FCFLAGS="$(NETCDF_OPT)" CPPFLAGS="-DpgiFortran ${INC_NETCDF}" ${CDF_CONF} LDFLAGS=" -L${CDF_PATH}/lib64" && make && make install && $(MAKE) -j 1 clean
+	cd ${DIR_CDF} && ./configure --disable-shared --prefix=${CDF_PATH} --libdir=${CDF_PATH}/lib64 --disable-cxx --disable-dap \
+        FC="$(FC)" FCFLAGS="$(NETCDF_OPT)" CPPFLAGS="-DpgiFortran ${INC_NETCDF}" ${CDF_CONF} LDFLAGS=" -L${CDF_PATH}/lib64" && make && make install && $(MAKE) -j 1 clean
 
 cleanmaster : cleancdf
 cleancdf :
 	- [ -d ${CDF_PATH} ] && rm -fr  ${CDF_PATH}
 endif
+##########################################################
+#                                                        #
+# EXTRA LIB : OASIS                                      #
+#                                                        #
+##########################################################
+ifeq "$(VER_OASIS)" "OASISAUTO"
+#
+oasis : $(OASIS_KEY)
+$(OASIS_KEY): 
+	cd ${SRC_MESONH}/src/LIB/oasis3-mct_v3/util/make_dir && make realclean -f TopMakefileOasis3 && make -f TopMakefileOasis3 && cd ${SRC_MESONH}/src/LIB/toy_v1-0 && make clean && make
+
+cleanmaster : cleanoasis
+cleanoasis :
+	- [ -d ${OASIS_PATH} ] && rm -fr  ${OASIS_PATH}
+endif
+
+
 ##########################################################
 #                                                        #
 # PROGRAM RULES                                          #
diff --git a/src/Makefile.MESONH.mk b/src/Makefile.MESONH.mk
index cffcb1548..a6008a37c 100644
--- a/src/Makefile.MESONH.mk
+++ b/src/Makefile.MESONH.mk
@@ -30,6 +30,12 @@ endif
 ##########################################################
 #           Source MNH                                   #
 ##########################################################
+ifdef CPLOASIS
+DIR_SURFEX    += ARCH_SRC/CPL_WAVE/SURFEX
+DIR_MNH       += ARCH_SRC/CPL_WAVE/MNH
+DIR_SURCOUCHE += ARCH_SRC/CPL_WAVE/SURCOUCHE
+CPPFLAGS       += -DCPLOASIS
+endif
 # PRE_BUG TEST !!!
 #DIR_MNH += ARCH_SRC/bug_mnh
 # PRE_BUG TEST !!!
@@ -355,6 +361,34 @@ LIBS          += $(LIB_GRIBAPI)
 VPATH         += $(GRIBAPI_PATH)/include
 R64_GRIBAPI=R64
 endif
+##########################################################
+#           Librairie OASIS                              #
+##########################################################
+#
+ifeq "$(VER_OASIS)" "OASISAUTO"
+OASIS_PATH ?= ${SRC_MESONH}/src/LIB/work_oasis3-mct
+OASIS_KEY ?= ${OASIS_PATH}/build/lib/psmile.MPI1/mod_oasis.mod
+# INC_OASIS     : includes all *o and *mod for each library
+INC_OASIS      ?= -I${OASIS_PATH}/build/lib/psmile.MPI1 -I$(OASIS_PATH)/build/lib/mct -I$(OASIS_PATH)/build/lib/scrip
+LIB_OASIS      ?= -L${OASIS_PATH}/lib -lpsmile.MPI1 -lmct -lmpeu -lscrip
+INC            += $(INC_OASIS)
+LIBS           += $(LIB_OASIS)
+VPATH          += ${OASIS_PATH}/build/lib/psmile.MPI1
+CPPFLAGS       += -DCPLOASIS
+endif
+
+ifeq "$(VER_OASIS)" "OASISBASHRC"
+OASIS_PATH ?= ${OASISDIR}
+OASIS_KEY ?= ${OASIS_PATH}/build/lib/psmile.MPI1/mod_oasis.mod
+# INC_OASIS     : includes all *o and *mod for each library
+INC_OASIS      ?= -I${OASIS_PATH}/build/lib/psmile.MPI1 -I$(OASIS_PATH)/build/lib/mct -I$(OASIS_PATH)/build/lib/scrip
+LIB_OASIS      ?= -L${OASIS_PATH}/lib -lpsmile.MPI1 -lmct -lmpeu -lscrip
+INC            += $(INC_OASIS)
+LIBS           += $(LIB_OASIS)
+VPATH          += ${OASIS_PATH}/build/lib/psmile.MPI1
+CPPFLAGS       += -DCPLOASIS
+endif
+
 ##########################################################
 #           Librairie NETCDF4                            #
 ##########################################################
@@ -379,6 +413,18 @@ LIBS           += $(LIB_NETCDF)
 DIR_HDF?=${SRC_MESONH}/src/LIB/hdf5-${VERSION_HDF}
 endif
 #
+# NetCDF : CDF LaReunion Local
+#
+ifeq "$(VER_CDF)" "CDFBASHRC"
+#
+INC_NETCDF     ?= $(shell $(NETCDF_CONFIG) --fflags)
+LIB_NETCDF     ?= $(shell $(NETCDF_CONFIG) --flibs)
+#
+INC            += $(INC_NETCDF)
+LIBS           += $(LIB_NETCDF)
+#
+endif
+#
 # NetCDF in beaufix (bull meteo-france)
 ifeq "$(VER_CDF)" "CDFBFIX"
 CDF_PATH?=/opt/softs/libraries/ICC13.1.4.183/netcdf-4.3.0
diff --git a/src/configure b/src/configure
index 10bf5e311..7da5929de 100755
--- a/src/configure
+++ b/src/configure
@@ -18,6 +18,7 @@ export VERSION_GRIBAPI=${VERSION_GRIBAPI:-"1.13.1"}
 export MNH_INT=${MNH_INT:-"4"}
 export LFI_INT=${LFI_INT:-8}
 export MNH_IOCDF4=${MNH_IOCDF4:-1}
+export VER_OASIS=${VER_OASIS:-NO}
 #
 export NEED_TOOLS=YES
 #
@@ -416,6 +417,12 @@ if [ "x${VER_CDF}" == "xCDFAUTO" ] ;then
 ( cd $LOCAL/src/LIB ; [ ! -d hdf5-${VERSION_HDF} ] && tar xvfz hdf5-${VERSION_HDF}.tar.gz )
 fi
 #
+#  Install OASIS if VER_OASIS=OASISAUTO
+#
+if [ "x${VER_OASIS}" == "xOASISAUTO" ] ; then
+( cd $LOCAL/src/LIB ; [ ! -d oasis3-mct ] && tar xvfz oasis3-mct_v3.tar.gz ; [ ! -d toy ] && tar xvfz toy_v1-0.tar.gz )
+fi
+#
 #  Install GRIBAPI
 #
 cd $LOCAL/src/LIB ; [ ! -d grib_api-${VERSION_GRIBAPI} ] && [ -f grib_api-${VERSION_GRIBAPI}.tar.gz ] && gunzip -c grib_api-${VERSION_GRIBAPI}.tar.gz |tar -xvf -
@@ -431,6 +438,7 @@ echo  VER_USER=${VER_USER-" pas de version user ..."}
 echo  OPTLEVEL=${OPTLEVEL}
 echo  CONF_DOLLAR=${CONF_DOLLAR}
 echo  VER_CDF=${VER_CDF}
+echo  VER_OASIS=${VER_OASIS}
 echo  BIN_TOOLS=${BIN_TOOLS}
 echo
 echo  "---> XYZ=${XYZ}"
-- 
GitLab