Parcourir la source

rebuild nemo scripts

Pierre-Yves Barriat il y a 3 ans
Parent
commit
48a0384519
2 fichiers modifiés avec 208 ajouts et 32 suppressions
  1. 100 32
      rebuild.sh
  2. 108 0
      rebuild_pbs.sh

+ 100 - 32
rebuild.sh

@@ -1,40 +1,108 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
-module purge
-#module load releases/2018b netCDF-Fortran/4.4.4-intel-2018b
-module load netCDF-Fortran/4.5.3-gompi-2020b
+#SBATCH --job-name=nemreb
+#SBATCH --time=47:55:00
+#SBATCH --ntasks=24
+#SBATCH --mem-per-cpu=2048
+##SBATCH --partition=debug
+#
+##SBATCH --mail-user=noname@uclouvain.be
+##SBATCH --mail-type=ALL
+##SBATCH --open-mode=append
+set -ueo pipefail
+
+stdout_file=${SLURM_SUBMIT_DIR-$PWD}/${SLURM_JOB_NAME-"local"}_${SLURM_JOB_ID-"id"}.log
+exec > ${stdout_file}
+echo "------------------ Job Info --------------------"
+echo "jobid : ${SLURM_JOB_ID-"id"}"
+echo "jobname : ${SLURM_JOB_NAME-"local"}"
+echo "submit dir : ${SLURM_SUBMIT_DIR-$PWD}"
 
-exp="NE4_08"
-start_year="1960"
-cores="8"
-xios_split="24"
-path_out="/scratch/ucl/elic/pbarriat/nemo/archive/${exp}/output"
-#path_exe="/home/ucl/elic/pbarriat/modeles/nemo/4.0.6/tools/REBUILD_NEMO"
+set -ue 
+
+exp="NE4_SP"
+cores="24"
+path_out="/scratch/ucl/elic/pbarriat/nemo/archive/${exp}"
 path_exe="/home/ucl/elic/pbarriat/modeles/nemo/nemo_dev_4/tools/REBUILD_NEMO"
 
-files=${path_out}/0*
-year=${start_year}
+###
+
+# Configure and load modules
+module purge
+module load netCDF-Fortran/4.5.3-gompi-2020b
+
+files=${path_out}/output/*
+dir=`echo $files | cut -d' ' -f1`
+cd ${dir}
+#
+file=`ls ${exp}_1m_*_grid_T_*.nc | tail -n 1`
+xios_split=`echo ${file%.nc} | rev | cut -d'_' -f1 | rev`
+xios_split=`expr $xios_split + 1`
+#
 for dir in ${files}
 do
   cd ${dir}
-  echo "In ${dir} processing ${exp}_1m_${year}0101_${year}1231 ..."
-
-  #[[ ! -s ${exp}_1m_${year}0101_19610101_grid_T.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${year}0101_19610101_grid_T ${xios_split}
-  #mv ${exp}_1m_${year}0101_19610101_grid_T.nc ${exp}_1m_${year}0101_${year}1231_grid_T.nc
-  #[[ ! -s ${exp}_1m_${year}0101_19610101_grid_U.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${year}0101_19610101_grid_U ${xios_split}
-  #mv ${exp}_1m_${year}0101_19610101_grid_U.nc ${exp}_1m_${year}0101_${year}1231_grid_U.nc
-  #[[ ! -s ${exp}_1m_${year}0101_19610101_grid_V.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${year}0101_19610101_grid_V ${xios_split}
-  #mv ${exp}_1m_${year}0101_19610101_grid_V.nc ${exp}_1m_${year}0101_${year}1231_grid_V.nc
-  #[[ ! -s ${exp}_1m_${year}0101_19610101_SBC.nc ]]    && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${year}0101_19610101_SBC    ${xios_split}
-  #mv ${exp}_1m_${year}0101_19610101_SBC.nc ${exp}_1m_${year}0101_${year}1231_SBC.nc
-  #[[ ! -s ${exp}_1m_${year}0101_19610101_icemod.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${year}0101_19610101_icemod ${xios_split}
-  #mv ${exp}_1m_${year}0101_19610101_icemod.nc ${exp}_1m_${year}0101_${year}1231_icemod.nc
-
-  [[ ! -s ${exp}_1m_${year}0101_${year}1231_grid_T.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${year}0101_${year}1231_grid_T ${xios_split}
-  [[ ! -s ${exp}_1m_${year}0101_${year}1231_grid_U.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${year}0101_${year}1231_grid_U ${xios_split}
-  [[ ! -s ${exp}_1m_${year}0101_${year}1231_grid_V.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${year}0101_${year}1231_grid_V ${xios_split}
-  [[ ! -s ${exp}_1m_${year}0101_${year}1231_SBC.nc ]]    && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${year}0101_${year}1231_SBC    ${xios_split}
-  [[ ! -s ${exp}_1m_${year}0101_${year}1231_icemod.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${year}0101_${year}1231_icemod ${xios_split}
-  year=$((${year}+1))
-  cd ..
+  #
+  file=`ls ${exp}_1m_*_grid_T_0000.nc`
+  to_year=`echo ${file%_grid_T_0000.nc} | rev | cut -d'_' -f1 | rev`
+  from_year=`echo ${file%_grid_T_0000.nc} | rev | cut -d'_' -f2 | rev`
+  #
+  echo "In ${dir} :"
+  echo "Processing ${exp}_1m_${from_year}_${to_year} ..."
+
+  rm -f nam_rebuild_*
+  rm -f ${exp}_1m_${from_year}_${to_year}_grid_T.nc 
+  rm -f ${exp}_1m_${from_year}_${to_year}_grid_U.nc 
+  rm -f ${exp}_1m_${from_year}_${to_year}_grid_V.nc 
+  rm -f ${exp}_1m_${from_year}_${to_year}_SBC.nc 
+  rm -f ${exp}_1m_${from_year}_${to_year}_icemod.nc  
+
+  if [ -s ${exp}_1m_${from_year}_${to_year}_grid_T_0000.nc ]
+  then
+    [[ ! -s ${exp}_1m_${from_year}_${to_year}_grid_T.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${from_year}_${to_year}_grid_T ${xios_split}
+  fi
+  if [ -s ${exp}_1m_${from_year}_${to_year}_grid_U_0000.nc ]
+  then
+    [[ ! -s ${exp}_1m_${from_year}_${to_year}_grid_U.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${from_year}_${to_year}_grid_U ${xios_split}
+  fi  
+  if [ -s ${exp}_1m_${from_year}_${to_year}_grid_V_0000.nc ]
+  then
+    [[ ! -s ${exp}_1m_${from_year}_${to_year}_grid_V.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${from_year}_${to_year}_grid_V ${xios_split}
+  fi  
+  if [ -s ${exp}_1m_${from_year}_${to_year}_SBC_0000.nc ]
+  then
+    [[ ! -s ${exp}_1m_${from_year}_${to_year}_SBC.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${from_year}_${to_year}_SBC ${xios_split}
+  fi  
+  if [ -s ${exp}_1m_${from_year}_${to_year}_icemod_0000.nc ]
+  then
+    [[ ! -s ${exp}_1m_${from_year}_${to_year}_icemod.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${from_year}_${to_year}_icemod ${xios_split}
+  fi 
+
 done
+
+###
+
+files=`ls ${path_out}/restart/ | tail -n 1`
+dir=${path_out}/restart/${files}
+cd ${dir}
+
+file=`ls ${exp}_*_restart_ice* | tail -n 1`
+nemo_split=`echo ${file%.nc} | rev | cut -d'_' -f1 | rev`
+nemo_split=`expr $nemo_split + 1`
+restart_step=`echo ${file%.nc} | rev | cut -d'_' -f4 | rev`
+
+echo "In ${dir} processing ${exp}_${restart_step}_restart_ice ..."
+
+rm -f ${exp}_${restart_step}_restart_ice.nc
+rm -f ${exp}_${restart_step}_restart_oce.nc
+
+if [ -s ${exp}_${restart_step}_restart_ice_0000.nc ]
+then
+  [[ ! -s ${exp}_${restart_step}_restart_ice.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_${restart_step}_restart_ice ${nemo_split}
+fi
+if [ -s ${exp}_${restart_step}_restart_oce_0000.nc ]
+then
+  [[ ! -s ${exp}_${restart_step}_restart_oce.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_${restart_step}_restart_oce ${nemo_split}
+fi
+
+echo ----- REBUILD post finished

+ 108 - 0
rebuild_pbs.sh

@@ -0,0 +1,108 @@
+#!/usr/bin/env bash
+
+#PBS -q main
+#PBS -r y
+#PBS -W group_list=cclm
+#PBS -l walltime=23:50:00
+#PBS -l select=1:ncpus=24:ompthreads=24:mem=63000mb
+#PBS -M pierre-yves.barriat@uclouvain.be
+#PBS -m abe
+
+exec > ${PBS_O_WORKDIR-$PWD}/${PBS_JOBNAME-"local"}_${PBS_JOBID-"id"}.log
+echo "------------------ Job Info --------------------"
+echo "jobid : $PBS_JOBID"
+echo "jobname : $PBS_JOBNAME"
+echo "job type : $PBS_ENVIRONMENT"
+echo "submit dir : $PBS_O_WORKDIR"
+echo "queue : $PBS_O_QUEUE"
+echo "user : $PBS_O_LOGNAME"
+echo "threads : $OMP_NUM_THREADS"
+
+set -ue
+
+exp="NE4_00"
+cores="24"
+path_out="/SCRATCH/acad/cclm/pbarriat/nemo/archive/${exp}"
+path_exe="/home/acad/ucl-elic/pbarriat/modeles/nemo/nemo_dev_4/tools/REBUILD_NEMO"
+
+###
+
+# Configure and load modules
+module purge
+module load netCDF-Fortran/4.4.4-foss-2016c
+
+files=${path_out}/output/*
+dir=`echo $files | cut -d' ' -f1`
+cd ${dir}
+#
+file=`ls ${exp}_1m_*_grid_T_*.nc | tail -n 1`
+xios_split=`echo ${file%.nc} | rev | cut -d'_' -f1 | rev`
+xios_split=`expr $xios_split + 1`
+#
+for dir in ${files}
+do
+  cd ${dir}
+  #
+  file=`ls ${exp}_1m_*_grid_T_0000.nc`
+  to_year=`echo ${file%_grid_T_0000.nc} | rev | cut -d'_' -f1 | rev`
+  from_year=`echo ${file%_grid_T_0000.nc} | rev | cut -d'_' -f2 | rev`
+  #
+  echo "In ${dir} :"
+  echo "Processing ${exp}_1m_${from_year}_${to_year} ..."
+
+  rm -f nam_rebuild_*
+  rm -f ${exp}_1m_${from_year}_${to_year}_grid_T.nc 
+  rm -f ${exp}_1m_${from_year}_${to_year}_grid_U.nc 
+  rm -f ${exp}_1m_${from_year}_${to_year}_grid_V.nc 
+  rm -f ${exp}_1m_${from_year}_${to_year}_SBC.nc 
+  rm -f ${exp}_1m_${from_year}_${to_year}_icemod.nc  
+
+  if [ -s ${exp}_1m_${from_year}_${to_year}_grid_T_0000.nc ]
+  then
+    [[ ! -s ${exp}_1m_${from_year}_${to_year}_grid_T.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${from_year}_${to_year}_grid_T ${xios_split}
+  fi
+  if [ -s ${exp}_1m_${from_year}_${to_year}_grid_U_0000.nc ]
+  then
+    [[ ! -s ${exp}_1m_${from_year}_${to_year}_grid_U.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${from_year}_${to_year}_grid_U ${xios_split}
+  fi  
+  if [ -s ${exp}_1m_${from_year}_${to_year}_grid_V_0000.nc ]
+  then
+    [[ ! -s ${exp}_1m_${from_year}_${to_year}_grid_V.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${from_year}_${to_year}_grid_V ${xios_split}
+  fi  
+  if [ -s ${exp}_1m_${from_year}_${to_year}_SBC_0000.nc ]
+  then
+    [[ ! -s ${exp}_1m_${from_year}_${to_year}_SBC.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${from_year}_${to_year}_SBC ${xios_split}
+  fi  
+  if [ -s ${exp}_1m_${from_year}_${to_year}_icemod_0000.nc ]
+  then
+    [[ ! -s ${exp}_1m_${from_year}_${to_year}_icemod.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_1m_${from_year}_${to_year}_icemod ${xios_split}
+  fi 
+
+done
+
+###
+
+files=`ls ${path_out}/restart/ | tail -n 1`
+dir=${path_out}/restart/${files}
+cd ${dir}
+
+file=`ls ${exp}_*_restart_ice* | tail -n 1`
+nemo_split=`echo ${file%.nc} | rev | cut -d'_' -f1 | rev`
+nemo_split=`expr $nemo_split + 1`
+restart_step=`echo ${file%.nc} | rev | cut -d'_' -f4 | rev`
+
+echo "In ${dir} processing ${exp}_${restart_step}_restart_ice ..."
+
+rm -f ${exp}_${restart_step}_restart_ice.nc
+rm -f ${exp}_${restart_step}_restart_oce.nc
+
+if [ -s ${exp}_${restart_step}_restart_ice_0000.nc ]
+then
+  [[ ! -s ${exp}_${restart_step}_restart_ice.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_${restart_step}_restart_ice ${nemo_split}
+fi
+if [ -s ${exp}_${restart_step}_restart_oce_0000.nc ]
+then
+  [[ ! -s ${exp}_${restart_step}_restart_oce.nc ]] && ${path_exe}/rebuild_nemo -t ${cores} ${exp}_${restart_step}_restart_oce ${nemo_split}
+fi
+
+echo ----- REBUILD post finished