From 5c0192d7be0e5aee45373de01d3a309f372df38b Mon Sep 17 00:00:00 2001
From: Swen Jullien <swen.jullien@ifremer.fr>
Date: Thu, 11 Apr 2024 16:18:51 +0200
Subject: [PATCH] Coupling_tools: update for run_wps (solve issue #25) *
 re-organize and improve configure.namelist.wps * add leftraru and wchpc in
 run_wps * move job* names according to MACHINES as in WRF_IN

---
 Coupling_tools/WRF_WPS/configure.namelist.wps | 122 ++++++------------
 .../{job.wps.pbs => job.wps.pbs.DATARMOR}     |   0
 Coupling_tools/WRF_WPS/job.wps.pbs.WCHPC      |   8 ++
 .../WRF_WPS/{job.wps.sh => job.wps.sh.IRENE}  |   0
 .../{job.wps.slurm => job.wps.slurm.JEANZAY}  |   0
 Coupling_tools/WRF_WPS/job.wps.slurm.LEFTRARU |  17 +++
 Coupling_tools/WRF_WPS/run_wps.bash           |  44 ++++---
 7 files changed, 95 insertions(+), 96 deletions(-)
 rename Coupling_tools/WRF_WPS/{job.wps.pbs => job.wps.pbs.DATARMOR} (100%)
 create mode 100644 Coupling_tools/WRF_WPS/job.wps.pbs.WCHPC
 rename Coupling_tools/WRF_WPS/{job.wps.sh => job.wps.sh.IRENE} (100%)
 rename Coupling_tools/WRF_WPS/{job.wps.slurm => job.wps.slurm.JEANZAY} (100%)
 create mode 100644 Coupling_tools/WRF_WPS/job.wps.slurm.LEFTRARU

diff --git a/Coupling_tools/WRF_WPS/configure.namelist.wps b/Coupling_tools/WRF_WPS/configure.namelist.wps
index a2557d71..f22cb17e 100755
--- a/Coupling_tools/WRF_WPS/configure.namelist.wps
+++ b/Coupling_tools/WRF_WPS/configure.namelist.wps
@@ -27,79 +27,8 @@
 # swen.jullien@ifremer.fr
 # --------------------------------------------------
 
-domain_name="BENGUELA"
-# Nb domains (ie nests)
-max_domains=1
-#-------------------------------------------------------------------------
-# Data Sources
-#
-# LBC_type       : data source for initial and boundary conditions
-# LSM_type       : data source for  surface forcing
-# obc_freq_h     : boundary condition frequency        [hour]
-# sst_interval_m : interval between SST updates  [minutes]
-#-------------------------------------------------------------------------
-LBC_type="CFSR_press_pgbh06"
-LSM_type="CFSR_sfc_flxf06"
-obc_freq_h=6
-sst_interval_m=360
-#-------------------------------------------------------------------------
-#  Grid parameters
-#
-#    dx                    : horizontal resolution in [km]
-#    xdim                  : number of points in x
-#    ydim                  : number of points in y
-#    central_lat           : latitude at the center of the domain
-#    central_lon           : longitude at the center of the domain
-#    topo_res_d01          : horizontal resolution of orography data
-#
-#  Nesting
-#
-#    dimensions must check:
-#    xdim_child=N*refine_coef+1
-#    ydim_child=M*refine_coef+1
-#
-#  Variables for real.exe
-#
-#    nbvertlevel           : number of vertical levels
-#    nbmetlevel            : number of boundary data levels
-#-------------------------------------------------------------------------
-#
-dt=150
-nbvertlevel=60
-nbmetlevel=38
-nbmetsoil=4
-ptop=5000
-#
-# Parent domain (d01)
-dx=30
-xdim_d01=56
-ydim_d01=50
-central_lat=-32.0
-central_lon=15.0
-topo_res_d01='30s'
-#topo_res_d01='3s+30s+10m'
-
-# Nest 1 (d02) 
-refine_d02=5
-i_str_d02=32
-j_str_d02=153
-xdim_d02=456
-ydim_d02=476
-topo_res_d02='3s'
-#topo_res_d02='2s+3s+30s'
-#
-# Nest 2 (d03)
-refine_d03=3
-i_str_d03=35
-j_str_d03=24
-xdim_d03=277
-ydim_d03=349
-topo_res_d03='3s+30s'
-
-#-------------------------------------------------------------------------
-# Dates of parent simulation
-#-------------------------------------------------------------------------
-# real-time mode
+# Dates to process
+#-----------------
 start_y=2005
 start_m=01
 start_d=01
@@ -110,12 +39,45 @@ end_m=01
 end_d=31
 end_h=18
 
-start_date_d01=$start_y'-'$start_m'-'$start_d'_'$start_h:00:00
-end_date_d01=$end_y'-'$end_m'-'$end_d'_'$end_h:00:00
-
-start_date_d02=$start_date_d01
-end_date_d02=$end_date_d01
+# Domains
+#---------
+max_domains=1       # Nb domains
+#
+# Parent domain (d01)
+dx=30               # horizonal resolution dx=dy in [kml]
+xdim_d01=56         # number of points in x
+ydim_d01=50         # number of points in y
+#
+# Nest 1 (d02): information read only if max_domains>1
+refine_d02=5        # refinement coefficient from parent
+i_str_d02=32        # starting index in x-dir from the parent domain
+j_str_d02=153       # starting index in y-dir from the parent domain
+xdim_d02=456        # nb of points, must check: xdim_child=N*refine_coef+1
+ydim_d02=476        # nb of points, must check: ydim_child=M*refine_coef+1
+#
+# Nest 2 (d03): information read only if max_domains>2
+refine_d03=3        # refinement coefficient from previous nest
+i_str_d03=35        # starting index in x-dir from the previous nest
+j_str_d03=24        # starting index in y-dir from the previous nest
+xdim_d03=277        # nb of points, must check: xdim_child=N*refine_coef+1
+ydim_d03=349        # nb of points, must check: ydim_child=M*refine_coef+1
 
-start_date_d03=$start_date_d01
-end_date_d03=$end_date_d01
+# Other information for geogrid 
+#-------------------------------
+central_lat=-32.0   # central longitude of the parent domain
+central_lon=15.0    # central latitude of the parent domain
+projection='mercator' # projection used
+#
+# resolution of the topographic data to use for each domain 
+topo_res_d01='30s+10m'
+topo_res_d02='3s+30s'
+topo_res_d03='3s+30s'
 
+# Other information for ungrib
+#------------------------------
+obc_freq_h=6        # boundary condition frequency [hour]
+#
+# suffix for Vtable to use
+LBC_type="CFSR_press_pgbh06" # for initial and boundary forcing
+LSM_type="CFSR_sfc_flxf06"   # for surface data (if different from boundary data)
+ 
diff --git a/Coupling_tools/WRF_WPS/job.wps.pbs b/Coupling_tools/WRF_WPS/job.wps.pbs.DATARMOR
similarity index 100%
rename from Coupling_tools/WRF_WPS/job.wps.pbs
rename to Coupling_tools/WRF_WPS/job.wps.pbs.DATARMOR
diff --git a/Coupling_tools/WRF_WPS/job.wps.pbs.WCHPC b/Coupling_tools/WRF_WPS/job.wps.pbs.WCHPC
new file mode 100644
index 00000000..60b19c20
--- /dev/null
+++ b/Coupling_tools/WRF_WPS/job.wps.pbs.WCHPC
@@ -0,0 +1,8 @@
+#!/bin/bash
+#PBS -l select=1:ncpus=24:mpiprocs=8
+#PBS -P WCHPC
+#PBS -q smp
+#PBS -l walltime=01:00:00
+cd $PBS_O_WORKDIR
+
+./run_wps.bash configure.namelist.wps 8
diff --git a/Coupling_tools/WRF_WPS/job.wps.sh b/Coupling_tools/WRF_WPS/job.wps.sh.IRENE
similarity index 100%
rename from Coupling_tools/WRF_WPS/job.wps.sh
rename to Coupling_tools/WRF_WPS/job.wps.sh.IRENE
diff --git a/Coupling_tools/WRF_WPS/job.wps.slurm b/Coupling_tools/WRF_WPS/job.wps.slurm.JEANZAY
similarity index 100%
rename from Coupling_tools/WRF_WPS/job.wps.slurm
rename to Coupling_tools/WRF_WPS/job.wps.slurm.JEANZAY
diff --git a/Coupling_tools/WRF_WPS/job.wps.slurm.LEFTRARU b/Coupling_tools/WRF_WPS/job.wps.slurm.LEFTRARU
new file mode 100644
index 00000000..aed3310c
--- /dev/null
+++ b/Coupling_tools/WRF_WPS/job.wps.slurm.LEFTRARU
@@ -0,0 +1,17 @@
+#!/bin/bash
+#SBATCH --job-name=Run_wps
+#SBATCH --partition=slims
+#SBATCH --ntasks=1
+#SBATCH --time=12:00:00              # temps d execution maximum demande (HH:MM:SS)
+#SBATCH --output=run_wps.out
+#SBATCH --error=run_wps.err
+
+cd ${SLURM_SUBMIT_DIR}
+
+#===============================================================================
+
+umask 022
+set -u
+
+./run_wps.bash configure.namelist.wps 1
+
diff --git a/Coupling_tools/WRF_WPS/run_wps.bash b/Coupling_tools/WRF_WPS/run_wps.bash
index 9ee5e78c..2158ea45 100755
--- a/Coupling_tools/WRF_WPS/run_wps.bash
+++ b/Coupling_tools/WRF_WPS/run_wps.bash
@@ -107,7 +107,7 @@ source ../../myenv_mypath.sh
 
 # WPS paths
 # WPS source dir
-export WPS_EXE_DIR="${ATM}/../WPS4.2"
+export WPS_EXE_DIR="${ATM}/../WPS"
 # Data dir
 DATA_DIR=${CWORK}/DATA
 #
@@ -120,10 +120,10 @@ export Vtable_ROOT="$PWD"
 #
 # Inputs directory and prefix (initial and boundary data)
 export I_DATAROOT="$DATA_DIR/CFSR_grib"
-export I_DATAprefix="200901*pgbh06.gdas"
+export I_DATAprefix="200501*pgbh06.gdas"
 # Surface Inputs directory and prefix (if different surface file)
 export SFC_DATAROOT="$DATA_DIR/CFSR_grib"
-export SFC_DATAprefix="200901*flxf06.gdas"
+export SFC_DATAprefix="200501*flxf06.gdas"
 #
 # Outputs data directory
 export O_DATAROOT="${ATM_FILES_DIR}/WPS_DATA"
@@ -137,9 +137,9 @@ else
 fi
 #
 # MPI launch commands
-if [ ${MACHINE} == "JEANZAY" ]; then
+if [ ${MACHINE} == "JEANZAY" ] || [ ${MACHINE} == "LEFTRARU" ]; then
     export myMPI="srun -n $NBPROCS "
-elif [ ${MACHINE} == "DATARMOR" ]; then
+elif [ ${MACHINE} == "DATARMOR" ] || [ ${MACHINE} == "WCHPC" ]; then
     export myMPI="$MPI_LAUNCH -np $NBPROCS "
 elif [ ${MACHINE} == "IRENE" ]; then
     export myMPI="ccc_mprun -n $NBPROCS "
@@ -183,7 +183,7 @@ echo "************************************************************"
 cd $MYWORKDIR
 
 #----------------------------------------------
-# Rescale parameters from configure.namelist
+# Rescale parameters from configure.namelist.wps
 #----------------------------------------------
 export interval_s=`expr $obc_freq_h \* 3600`
 export interval_s_SFC=$interval_s
@@ -251,6 +251,18 @@ else
   exit 1
 fi
 
+#--------------------------------------
+# Prepare dates
+#--------------------------------------
+start_date_d01=$start_y'-'$start_m'-'$start_d'_'$start_h:00:00
+end_date_d01=$end_y'-'$end_m'-'$end_d'_'$end_h:00:00
+
+start_date_d02=$start_date_d01
+end_date_d02=$end_date_d01
+
+start_date_d03=$start_date_d01
+end_date_d03=$end_date_d01
+
 # O  O  O  O  O  O  O  O  O        START geogrid      O  O  O  O  O  O  O  O  O
 
 if [ $switch_geogrid -eq 1 ]; then
@@ -265,7 +277,7 @@ if [ $switch_geogrid -eq 1 ]; then
   echo " "
 
   #------------------------------------------------
-  # Create namelist.wps from configure.namelist 
+  # Create namelist.wps from configure.namelist.wps
   #------------------------------------------------
   if [ -e namelist.wps ] ; then
     rm -f namelist.wps
@@ -293,7 +305,7 @@ cat << End_Of_Namelist | sed -e 's/#.*//; s/  *$//' > ./namelist.wps
  geog_data_res     =   $topo_res_d01, $topo_res_d02, $topo_res_d03,
  dx = $dx_d01,
  dy = $dx_d01,
- map_proj = 'mercator',
+ map_proj = $projection,
  ref_lat   = $central_lat
  ref_lon   = $central_lon
  truelat1  = $central_lat,
@@ -304,10 +316,10 @@ cat << End_Of_Namelist | sed -e 's/#.*//; s/  *$//' > ./namelist.wps
 /
 End_Of_Namelist
 
-cp namelist.wps namelist.wps.geogrid.${domain_name}
+cp namelist.wps namelist.wps.geogrid
 
-#${myMPI}geogrid.exe  >& geogrid.log
-./geogrid.exe  >& geogrid.log
+${myMPI}geogrid.exe  >& geogrid.log
+#./geogrid.exe  >& geogrid.log
   echo "%  list geogrid output directory $O_DATAROOT :"
   ls $O_DATAROOT
 fi
@@ -405,7 +417,7 @@ cat << End_Of_Namelist | sed -e 's/#.*//; s/  *$//' > ./namelist.wps
 /
 End_Of_Namelist
 
-cp namelist.wps namelist.wps.ungrib.${LBC_type}.${domain_name}
+cp namelist.wps namelist.wps.ungrib.${LBC_type}
 
   #-----------------------------------
   # check VTABLE for LBC and make link
@@ -478,7 +490,7 @@ cat << End_Of_Namelist | sed -e 's/#.*//; s/  *$//' > ./namelist.wps
 /
 End_Of_Namelist
 
-cp namelist.wps namelist.wps.ungrib.${LSM_type}.${domain_name}
+cp namelist.wps namelist.wps.ungrib.${LSM_type}
 
     #--------------------------
     # Check VTABLE for LSM 
@@ -577,10 +589,10 @@ if [ $switch_metgrid -eq 1 ]; then
 /
 End_Of_Namelist
 
-cp namelist.wps namelist.wps.metgrid.${domain_name}
+cp namelist.wps namelist.wps.metgrid
 
-#${myMPI}metgrid.exe >& metgrid.log
-./metgrid.exe >& metgrid.log
+${myMPI}metgrid.exe >& metgrid.log
+#./metgrid.exe >& metgrid.log
 
   echo "   ls -rtl $O_DATAROOT"
   ls -rtl $O_DATAROOT*
-- 
GitLab