diff --git a/tools/sponge/README.md b/tools/sponge/README.md new file mode 100644 index 000000000..dba203d97 --- /dev/null +++ b/tools/sponge/README.md @@ -0,0 +1,67 @@ +## Sponges + +This folder contains tools for creating temperature and salinity sponges for use in MOM6 based on the GLORYS reanalysis. + +## preproc_scripts + +Scripts to subset, average, and fill the GLORYS data on the uda to preprocess it for the python scripts. + +# Regional Subsetting + +Regional subsets of the GLORYS reanalysis are created using `ncks` in `get_so_monthly.csh` and `get_thetao_monthly.csh`. +You should adjust the regional subset in the script to match the region of interest. + +For example: +``` +ncks -d latitude,40.,90. -d longitude,0.,360 filein.nc fileout.nc +``` + +# Scripts + +As written these preprocessing scripts must be run in three stages. +1. First, subset the temperature and salinity and create monthly averages +``` +sbatch get_thetao_monthly.csh +sbatch get_so_monthly.csh +``` + +2. Next, fill the data +``` +sbatch fill_glorys_nn_monthly.csh +``` + +3. Finally, once the filled data for every month in a given year has been created, the merge script can be used. +``` +sbatch merge_so_thetao_year.csh +``` + +This should produce data that is compatible with `write_nudging_data.py` + +## Using these files in MOM6 + +To use the sponges generated by these scripts in MOM6 we recommend the following settings: +``` +#override SPONGE = True +#override SPONGE_UV = False +#override SPONGE_DAMPING_FILE = "damping_full_t_90d.nc" +#override SPONGE_IDAMP_VAR = "Idamp" +#override SPONGE_STATE_FILE = "glorys_sponge_monthly_bnd_${fyear}.nc" +#override SPONGE_PTEMP_VAR = "thetao" +#override SPONGE_SALT_VAR = "so" +#override SPONGE_ETA_VAR = "depth" +#override INTERPOLATE_SPONGE_TIME_SPACE = True +#override SPONGE_DATA_ONGRID = True +``` +These should be added to `MOM_override` in the experiment of the xml. + +In the xml, add the paths to the files needed for sponges so that they are include in the `INPUT` directory. +``` + + + $(YOUR_PATH)/damping_full_t_90d.nc + + + $(YOUR_PATH)/glorys_sponge_monthly_${fyear}.nc + +``` + diff --git a/tools/sponge/preproc_scripts/fill_glorys_nn_monthly.csh b/tools/sponge/preproc_scripts/fill_glorys_nn_monthly.csh new file mode 100644 index 000000000..1dc46c7e6 --- /dev/null +++ b/tools/sponge/preproc_scripts/fill_glorys_nn_monthly.csh @@ -0,0 +1,39 @@ +#!/bin/tcsh +#SBATCH --ntasks=1 +#SBATCH --job-name=fill_glorys_arctic +#SBATCH --time=2880 +#SBATCH --partition=batch + +# Usage: sbatch fill_glorys_nn_monthly.sh +# Original Author: Andrew Ross, modified by Theresa Morrison + +module load cdo +module load nco/5.0.1 +module load gcp + +set year=$1 +set month=`printf "%02d" $2` + +set apath='/archive/Theresa.Morrison/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly' + +# Regionally-slice and convert daily to monthly GLORYS reanalysis on archive beforehand. + +# dmget all of the files for this month from archive. +dmget ${apath}/so/GLORYS_so_arctic_${year}_${month}.nc ${apath}/thetao/GLORYS_thetao_arctic_${year}_${month}.nc + +# copy from archive to vftmp for speed? +#gcp /archive/acr/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/daily/GLORYS_REANALYSIS_${year}-${month}-*.nc $TMPDIR +gcp /archive/tnm/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/so/GLORYS_so_arctic_${year}_${month}.nc $TMPDIR +gcp /archive/tnm/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/thetao/GLORYS_thetao_arctic_${year}_${month}.nc $TMPDIR + +# create a directory to store the filled files. +mkdir $TMPDIR/filled + +# look for all of the daily files. +# loop over them, using cdo setmisstonn to fill the missing data +# and then ncks to compress the resulting file. +find ${TMPDIR}/GLORYS_so_arctic_${year}_${month}.nc -type f -exec sh -c 'file="$1"; filename="${file##*/}"; cdo setmisstonn "$1" "${TMPDIR}/filled/${filename}"; ncks -4 -L 5 "${TMPDIR}/filled/${filename}" -O "${TMPDIR}/filled/${filename}"' find-sh {} \; +find ${TMPDIR}/GLORYS_thetao_arctic_${year}_${month}.nc -type f -exec sh -c 'file="$1"; filename="${file##*/}"; cdo setmisstonn "$1" "${TMPDIR}/filled/${filename}"; ncks -4 -L 5 "${TMPDIR}/filled/${filename}" -O "${TMPDIR}/filled/${filename}"' find-sh {} \; + +# copy the filled data for this month to /work. +gcp $TMPDIR/filled/*.nc /work/tnm/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/filled diff --git a/tools/sponge/preproc_scripts/get_so_monthly.csh b/tools/sponge/preproc_scripts/get_so_monthly.csh new file mode 100644 index 000000000..00f910d9c --- /dev/null +++ b/tools/sponge/preproc_scripts/get_so_monthly.csh @@ -0,0 +1,29 @@ +#!/bin/tcsh +#SBATCH --ntasks=1 +#SBATCH --job-name=fill_glorys_arctic +#SBATCH --time=2880 +#SBATCH --partition=batch + +# Usage: sbatch get_so_monthly.csh + +module load cdo +module load nco/5.0.1 +module load gcp + +set year=$1 +set month=`printf "%02d" $2` +set var='so' +set apath='/archive/Theresa.Morrison/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/'${var} +# create a directory to store the filled files. +mkdir $TMPDIR/${var}_${year}_${month} + +set day=1 +foreach filename (/uda/Global_Ocean_Physics_Reanalysis/global/daily/${var}/${year}/${var}_mercatorglorys12v1_gl12_mean_${year}${month}*.nc) + echo $filename + set short_name=${var}'_arctic_'$day + ncks -d latitude,39.,91. --mk_rec_dmn time $filename $TMPDIR/${var}_${year}_${month}/${short_name}'_bd.nc' + cdo -setreftime,1993-01-01,00:00:00,1day $TMPDIR/${var}_${year}_${month}/${short_name}'_bd.nc' $TMPDIR/${var}_${year}_${month}/${short_name}'.nc' + set day = `expr $day + 1` + echo $day +end +ncra -O $TMPDIR/${var}_${year}_${month}/${var}_arctic_*.nc ${apath}/GLORYS_${var}_arctic_${year}_${month}.nc diff --git a/tools/sponge/preproc_scripts/get_thetao_monthly.csh b/tools/sponge/preproc_scripts/get_thetao_monthly.csh new file mode 100644 index 000000000..825b6d7b6 --- /dev/null +++ b/tools/sponge/preproc_scripts/get_thetao_monthly.csh @@ -0,0 +1,29 @@ +#!/bin/tcsh +#SBATCH --ntasks=1 +#SBATCH --job-name=fill_glorys_arctic +#SBATCH --time=2880 +#SBATCH --partition=batch + +# Usage: sbatch get_thetao_monthly.csh + +module load cdo +module load nco/5.0.1 +module load gcp + +set year=$1 +set month=`printf "%02d" $2` +set var='thetao' +set apath='/archive/Theresa.Morrison/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/'${var} +# create a directory to store the filled files. +mkdir $TMPDIR/${var}_${year}_${month} + +set day=1 +foreach filename (/uda/Global_Ocean_Physics_Reanalysis/global/daily/${var}/${year}/${var}_mercatorglorys12v1_gl12_mean_${year}${month}*.nc) + echo $filename + set short_name=${var}'_arctic_'$day + ncks -d latitude,39.,91. --mk_rec_dmn time $filename $TMPDIR/${var}_${year}_${month}/${short_name}'_bd.nc' + cdo -setreftime,1993-01-01,00:00:00,1day $TMPDIR/${var}_${year}_${month}/${short_name}'_bd.nc' $TMPDIR/${var}_${year}_${month}/${short_name}'.nc' + set day = `expr $day + 1` + echo $day +end +ncra -O $TMPDIR/${var}_${year}_${month}/${var}_arctic_*.nc ${apath}/GLORYS_${var}_arctic_${year}_${month}.nc diff --git a/tools/sponge/preproc_scripts/merge_so_thetao_year.csh b/tools/sponge/preproc_scripts/merge_so_thetao_year.csh new file mode 100644 index 000000000..222ac6add --- /dev/null +++ b/tools/sponge/preproc_scripts/merge_so_thetao_year.csh @@ -0,0 +1,31 @@ +#!/bin/tcsh +#SBATCH --ntasks=1 +#SBATCH --job-name=merge_so_thetao +#SBATCH --time=2880 +#SBATCH --partition=batch + +# Usage: sbatch merge_so_thetao_year.csh + +module load cdo +module load nco/5.0.1 +module load gcp + +set year=$1 +set wpath='/work/Theresa.Morrison/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/filled' + + +# Define the file variables for salinity and temperature +set so_file = "${wpath}/GLORYS_so_arctic_${year}.nc" +set thetao_file = "${wpath}/GLORYS_thetao_arctic_${year}.nc" +set final_file = "${wpath}/GLORYS_arctic_${year}.nc" + +# Concatenate monthly averages into single files for salinity and temperature +foreach var (so thetao) + ncrcat -O ${wpath}/GLORYS_${var}_arctic_${year}_*.nc ${wpath}/GLORYS_${var}_arctic_${year}.nc + end + + # Append temperature data to salinity file directly without copying + ncks -A ${thetao_file} ${so_file} + + # Rename the combined file to final name + mv -f ${so_file} ${final_file}