From 84d2b584f03359492fa75eca64762bef4caee34e Mon Sep 17 00:00:00 2001
From: Juan Escobar <escj@aero.obs-mip.fr>
Date: Fri, 24 Feb 2023 16:34:30 +0100
Subject: [PATCH] Juan 24/02/2023:spll*+Makefile.MESONH.mk, add dependence on
 include file for make compilation

---
 bin/spll               | 13 +++++++------
 bin/spll_lst           | 15 ++++++++-------
 bin/spll_new           | 27 +++++++++++++++++----------
 src/Makefile.MESONH.mk |  6 +++---
 4 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/bin/spll b/bin/spll
index 6e395d2f0..2fca7bbac 100755
--- a/bin/spll
+++ b/bin/spll
@@ -32,7 +32,7 @@ ec_meminfo.F90|\
 turb.f90|shallow_mf.f90|rain_ice.f90|lima.f90|\
 lima_adjust_split.f90|lima_precip_scavenging.f90|ini_tiwmx.f90|\
 ini_snow.f90|ini_rain_ice.f90|ini_neb.f90|ini_cst.f90|\
-ice_adjust.f90|gradient_u.f90|gradient_v.f90|gradient_w|\
+ice_adjust.f90|gradient_u.f90|gradient_v.f90|gradient_w.f90|\
 gamma.f90|gamma_inc.f90|general_gamma.f90|condensation.f90"
 #
 
@@ -142,11 +142,12 @@ then
   cp $spllfile $DIRNAME/$spllfile
   touch $DIRNAME/$BASENAME2.D
 fi 
-dep=`egrep -i "^[[:space:]]*use "    $spllfile | sed -e 's/,/ /g' | awk '{ print '${TOCASE}'($2)".mod"}' | sort -u `
-mod=`egrep -i "^[[:space:]]*module " $spllfile | sed -e 's/,/ /g' | awk '{ print '${TOCASE}'($2)".mod"}' | sort -u | grep -iv procedure `
+dep=`egrep -i "^[[:space:]]*use "     $spllfile | sed -e 's/,/ /g' | awk '{ print '${TOCASE}'($2)".mod"}' | sort -u `
+mod=`egrep -i "^[[:space:]]*module "  $spllfile | sed -e 's/,/ /g' | awk '{ print '${TOCASE}'($2)".mod"}' | sort -u | grep -iv procedure `
+inc=`egrep -i "^[[:space:]]*include " $spllfile | sed -e 's/"//g'  | awk '{ print '${TOCASE}'($2)}' | sort -u | egrep -v 'mpif.h|netcdf.inc' `
 
-echo $mod        : $spllbase.o    >> $DIRNAME/$BASENAME2.D
-echo $spllbase.o : $spllfile $dep >> $DIRNAME/$BASENAME2.D
+echo $mod        : $spllbase.o         >> $DIRNAME/$BASENAME2.D
+echo $spllbase.o : $spllfile $dep $inc >> $DIRNAME/$BASENAME2.D
 
 if [ "$SUF" = "f90" ]
 then
@@ -162,7 +163,7 @@ do
 echo "	 -mv  $filemod "' $(OBJDIR)/MOD/. || '"echo OK $filemod " >> $DIRNAME/$BASENAME2.D
 done
 
-unset dep mod
+unset dep inc mod
 
 done
 touch $DIRNAME/$BASENAME2.D
diff --git a/bin/spll_lst b/bin/spll_lst
index a2dd765f5..96bd5b15f 100755
--- a/bin/spll_lst
+++ b/bin/spll_lst
@@ -32,7 +32,7 @@ ec_meminfo.F90|\
 turb.f90|shallow_mf.f90|rain_ice.f90|lima.f90|\
 lima_adjust_split.f90|lima_precip_scavenging.f90|ini_tiwmx.f90|\
 ini_snow.f90|ini_rain_ice.f90|ini_neb.f90|ini_cst.f90|\
-ice_adjust.f90|gradient_u.f90|gradient_v.f90|gradient_w|\
+ice_adjust.f90|gradient_u.f90|gradient_v.f90|gradient_w.f90|\
 gamma.f90|gamma_inc.f90|general_gamma.f90|condensation.f90"
 #
 
@@ -149,15 +149,16 @@ then
   cp $spllfile $DIRNAME/$spllfile
   touch $DIRNAME/$BASENAME2.D
 fi 
-dep=`egrep -i "^[[:space:]]*use "    $spllfile | sed -e 's/,/ /g' | awk '{ print '${TOCASE}'($2)".mod"}' | sort -u `
-mod=`egrep -i "^[[:space:]]*module " $spllfile | sed -e 's/,/ /g' | awk '{ print '${TOCASE}'($2)".mod"}' | sort -u | grep -iv procedure `
+dep=`egrep -i "^[[:space:]]*use "     $spllfile | sed -e 's/,/ /g' | awk '{ print '${TOCASE}'($2)".mod"}' | sort -u `
+mod=`egrep -i "^[[:space:]]*module "  $spllfile | sed -e 's/,/ /g' | awk '{ print '${TOCASE}'($2)".mod"}' | sort -u | grep -iv procedure `
+inc=`egrep -i "^[[:space:]]*include " $spllfile | sed -e 's/"//g'  | awk '{ print '${TOCASE}'($2)}' | sort -u | egrep -v 'mpif.h|netcdf.inc' `
 
 if [ "x$mod" != "x" ]
 then
-echo $spllbase.o :                >> $DIRNAME/$BASENAME2.D
-echo $mod        : $spllfile $dep >> $DIRNAME/$BASENAME2.D
+echo $spllbase.o :                     >> $DIRNAME/$BASENAME2.D
+echo $mod        : $spllfile $dep $inc >> $DIRNAME/$BASENAME2.D
 else
-echo $spllbase.o : $spllfile $dep >> $DIRNAME/$BASENAME2.D    
+echo $spllbase.o : $spllfile $dep $inc >> $DIRNAME/$BASENAME2.D    
 fi
 
 if [ "$SUF" = "f90" ]
@@ -175,7 +176,7 @@ do
 echo "	 -mv  $filemod "' $(OBJDIR)/MOD/. || '"echo OK $filemod " >> $DIRNAME/$BASENAME2.D
 done
 
-unset dep mod
+unset dep inc mod
 
 done
 touch $DIRNAME/$BASENAME2.D
diff --git a/bin/spll_new b/bin/spll_new
index f9f709e78..ba3f84c79 100755
--- a/bin/spll_new
+++ b/bin/spll_new
@@ -32,16 +32,22 @@ ec_meminfo.F90|\
 turb.f90|shallow_mf.f90|rain_ice.f90|lima.f90|\
 lima_adjust_split.f90|lima_precip_scavenging.f90|ini_tiwmx.f90|\
 ini_snow.f90|ini_rain_ice.f90|ini_neb.f90|ini_cst.f90|\
-ice_adjust.f90|gradient_u.f90|gradient_v.f90|gradient_w|\
+ice_adjust.f90|gradient_u.f90|gradient_v.f90|gradient_w.f90|\
 gamma.f90|gamma_inc.f90|general_gamma.f90|condensation.f90"
 #
 
 if [ "$SUF" = "f" ]
 then
 
-echo "!depfile:$BASENAME2.D" > $DIRNAME/spll_$BASENAME
-cat $file                   >> $DIRNAME/spll_$BASENAME
-echo "#" $file > $DIRNAME/$BASENAME2.D
+spllbase="spll_$BASENAME2"
+spllfile="$spllbase.$SUF"
+
+echo "!depfile:$BASENAME2.D" > $DIRNAME/$spllfile
+cat $file                   >> $DIRNAME/$spllfile
+echo "#===========  $BASENAME2.$SUF dependence ==========================" > $DIRNAME/$BASENAME2.D
+echo $spllbase.o : $spllfile >> $DIRNAME/$BASENAME2.D    
+echo "	"' $(F77) -I$(OBJDIR)/MOD  $(INC) -c $(F77FLAGS) $<' >> $DIRNAME/$BASENAME2.D
+echo "	 -mv $spllbase.o "' $(OBJDIR)/. || '"echo OK $spllbase.o " >> $DIRNAME/$BASENAME2.D
 
 else
 
@@ -142,15 +148,16 @@ then
   cp $spllfile $DIRNAME/$spllfile
   touch $DIRNAME/$BASENAME2.D
 fi 
-dep=`egrep -i "^[[:space:]]*use "    $spllfile | sed -e 's/,/ /g' | awk '{ print '${TOCASE}'($2)".mod"}' | sort -u `
-mod=`egrep -i "^[[:space:]]*module " $spllfile | sed -e 's/,/ /g' | awk '{ print '${TOCASE}'($2)".mod"}' | sort -u | grep -iv procedure `
+dep=`egrep -i "^[[:space:]]*use "     $spllfile | sed -e 's/,/ /g' | awk '{ print '${TOCASE}'($2)".mod"}' | sort -u `
+mod=`egrep -i "^[[:space:]]*module "  $spllfile | sed -e 's/,/ /g' | awk '{ print '${TOCASE}'($2)".mod"}' | sort -u | grep -iv procedure `
+inc=`egrep -i "^[[:space:]]*include " $spllfile | sed -e 's/"//g'  | awk '{ print '${TOCASE}'($2)}' | sort -u | egrep -v 'mpif.h|netcdf.inc' `
 
 if [ "x$mod" != "x" ]
 then
-echo $spllbase.o :                >> $DIRNAME/$BASENAME2.D
-echo $mod        : $spllfile $dep >> $DIRNAME/$BASENAME2.D
+echo $spllbase.o :                     >> $DIRNAME/$BASENAME2.D
+echo $mod        : $spllfile $dep $inc >> $DIRNAME/$BASENAME2.D
 else
-echo $spllbase.o : $spllfile $dep >> $DIRNAME/$BASENAME2.D    
+echo $spllbase.o : $spllfile $dep $inc >> $DIRNAME/$BASENAME2.D    
 fi
 
 if [ "$SUF" = "f90" ]
@@ -167,7 +174,7 @@ do
 echo "	 -mv  $filemod "' $(OBJDIR)/MOD/. || '"echo OK $filemod " >> $DIRNAME/$BASENAME2.D
 done
 
-unset dep mod
+unset dep inc mod
 
 done
 touch $DIRNAME/$BASENAME2.D
diff --git a/src/Makefile.MESONH.mk b/src/Makefile.MESONH.mk
index 2f8683142..465888c1c 100644
--- a/src/Makefile.MESONH.mk
+++ b/src/Makefile.MESONH.mk
@@ -67,11 +67,11 @@ OBJS_NOCB +=  spll_dxf.o spll_dxm.o spll_dyf.o spll_dym.o \
         spll_gx_m_m.o spll_gx_m_u.o spll_gy_m_m.o \
         spll_gy_m_v.o spll_gz_m_m.o spll_gz_m_w.o \
         spll_dzf_mf.o spll_dzm_mf.o spll_mzf_mf.o spll_mzm_mf.o \
-        spll_modi_gradient_m_d.o spll_mode_shuman_phy.o
+        spll_mode_shuman_phy.o mode_shuman_phy.mod
 
 $(OBJS_NOCB) : OPT = $(OPT_NOCB)
 
-OBJS0 += spll_switch_sbg_lesn.o spll_mode_mppdb.o
+OBJS0 += spll_switch_sbg_lesn.o spll_mode_mppdb.o mode_mppdb.mod
 
 $(OBJS0)     : OPT = $(OPT0) 
 
@@ -82,8 +82,8 @@ endif
 ##########################################################
 DIR_PHYEX += PHYEX/aux PHYEX/turb PHYEX/micro PHYEX/conv
 INC_PHYEX += -I$(B)PHYEX/micro -I$(B)PHYEX/turb -I$(B)PHYEX/aux
-
 #CPPFLAGS_PHYEX += 
+VPATH     += PHYEX/aux PHYEX/turb PHYEX/micro PHYEX/conv
 #
 DIR_MASTER += $(DIR_PHYEX)
 CPPFLAGS   += $(CPPFLAGS_PHYEX)
-- 
GitLab