Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add topo gen workflow #1

Merged
merged 15 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# make_OM3_025deg_topo
# make_OM3_025deg_topo

Make 0.25 degree topog.nc MOM bathymetry file from GEBCO 2024 dataset.

./gen_topog.sh will generate topography and associated files. For 0.25deg resolution and higher this will require qsub.

When the output files are to your satisfaction, commit and push your changes and add the git commit hash as metadata in the output .nc files by running finalise.sh.

Use the qsub command to submit the script, passing the required input files as arguments, For example:

qsub -v INPUT_HGRID="/path/to/ocean_hgrid.nc",INPUT_VGRID="/path/to/ocean_vgrid.nc",INPUT_GBCO="/path/to/GEBCO_2024.nc" gen_topo.sh

19 changes: 19 additions & 0 deletions build.sh
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module purge
module load intel-compiler
anton-seaice marked this conversation as resolved.
Show resolved Hide resolved
module load netcdf

cd ./domain-tools/


# Check if the build directory exists before cleaning
if [ -d "build" ]; then
cmake --build build --target clean
fi

cmake -B build -DCMAKE_BUILD_TYPE=Release -DNetCDF_Fortran_LIBRARY=$NETCDF_ROOT/lib/Intel/libnetcdff.so -DNetCDF_C_LIBRARY=$NETCDF_ROOT/lib/libnetcdf.so -DNetCDF_Fortran_INCLUDE_DIRS=$NETCDF_ROOT/include/Intel
anton-seaice marked this conversation as resolved.
Show resolved Hide resolved

cmake --build build

cmake --install build --prefix=./

cd ../
2 changes: 1 addition & 1 deletion domain-tools
11 changes: 11 additions & 0 deletions edit_topog_new_fillfraction.txt
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
editTopo.py edits file version 1
#
# This file can be used as an argument for editTopo.py --apply
#
# created: Fri Nov 1 12:56:59 2024
# by: ek4684
# via: editTopo.py /g/data/tm70/ek4684/domain-tools/C-grid-workflow/fill_fraction_0.5/topog_new_fillfraction.nc --overwrite
#
# i j old new
1235 737 0.0 65.28469848632812
1227 734 0.0 56.118499755859375
26 changes: 26 additions & 0 deletions finalise.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env sh
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved
# Commit changes and push, then add metadata to note how changes were made

module load nco
module load git

echo "About to commit all changes to git repository and push to remote."
read -p "Proceed? (y/n) " yesno
case $yesno in
[Yy] ) ;;
* ) echo "Cancelled."; exit 0;;
esac

set -x
set -e

git commit -am "update" || true
git push || true

ncatted -O -h -a history,global,a,c," | Created on $(date) using https://github.com/ACCESS-NRI/make_OM3_025deg_topo/tree/$(git rev-parse --short HEAD)" topog.nc
ncatted -O -h -a history,global,a,c," | Updated on $(date) using https://github.com/ACCESS-NRI/make_OM3_025deg_topo/tree/$(git rev-parse --short HEAD)" ocean_mask.nc
ncatted -O -h -a history,global,a,c," | Created on $(date) using https://github.com/ACCESS-NRI/make_OM3_025deg_topo/tree/$(git rev-parse --short HEAD)" kmt.nc
ncatted -O -h -a history,global,a,c," | Updated on $(date) using https://github.com/ACCESS-NRI/make_OM3_025deg_topo/tree/$(git rev-parse --short HEAD)" ocean_vgrid.nc

ncatted -O -h -a history,global,a,c," and based on GEBCO_2024 topography" topog.nc

88 changes: 88 additions & 0 deletions gen_topo.sh
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env sh
#PBS -q normal
#PBS -l walltime=4:00:00,mem=4GB
#PBS -l wd
#PBS -lstorage=gdata/hh5+gdata/ik11

# Ensure build.sh is executable
if [ ! -x "./build.sh" ]; then
chmod +x ./build.sh
fi

# Build domain-tools
./build.sh

module use /g/data/hh5/public/modules
module load conda/analysis3
module load nco

set -x
set -e

# Using the environment variables passed via -v
INPUT_HGRID=$INPUT_HGRID
INPUT_VGRID=$INPUT_VGRID
INPUT_GBCO=$INPUT_GBCO
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved

# Copy and link input files
cp -L --preserve=timestamps "$INPUT_HGRID" ./ocean_hgrid.nc
cp -L --preserve=timestamps "$INPUT_VGRID" ./ocean_vgrid.nc
ln -sf "$INPUT_GBCO" ./GEBCO_2024.nc

# Convert double precision vgrid to single
./domain-tools/bin/float_vgrid --vgrid ocean_vgrid.nc --vgrid_type mom6
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved

# Interpolate topography on horizontal grid:
./domain-tools/bin/topogtools gen_topo -i GEBCO_2024.nc -o topog_new.nc --hgrid ocean_hgrid.nc --tripolar --longitude-offset -100
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved

# Cut off T cells of size less than 6kms (6000 m)
./domain-tools/bin/topogtools min_dy -i topog_new.nc -o topog_new_min_dy.nc --cutoff 6000 --hgrid ocean_hgrid.nc

# Fill cells that have a sea area fraction smaller than 0.5:
./domain-tools/bin/topogtools fill_fraction -i topog_new_min_dy.nc -o topog_new_fillfraction.nc --fraction 0.5

# edit_topo.py
python ./topogtools/editTopo.py --overwrite --nogui --apply edit_topog_new_fillfraction.txt --output topog_new_fillfraction_edited.nc topog_new_fillfraction.nc

# Remove seas:
./domain-tools/bin/topogtools deseas -i topog_new_fillfraction_edited.nc -o topog_new_fillfraction_edited_deseas.nc --grid_type C

# Set maximum/minimum depth
./domain-tools/bin/topogtools min_max_depth -i topog_new_fillfraction_edited_deseas.nc -o topog_new_fillfraction_edited_deseas_mindepth.nc --level 4 --vgrid ocean_vgrid.nc --vgrid_type mom6

# Create land/sea mask
cp topog_new_fillfraction_edited_deseas_mindepth.nc topog.nc
./domain-tools/bin/topogtools mask -i topog.nc -o ocean_mask.nc
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved

# Calculate MD5 checksum for topog.nc
MD5SUM_topog=$(md5sum topog.nc | awk '{print $1}')

# Add MD5 checksum as a global attribute to topog.nc
ncatted -O -h -a md5_checksum,global,a,c,"$MD5SUM_topog" topog.nc
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved

# Calculate MD5 checksum for ocean_mask.nc
MD5SUM_mask=$(md5sum ocean_mask.nc | awk '{print $1}')

# Add MD5 checksum as a global attribute to ocean_mask.nc
ncatted -O -h -a md5_checksum,global,a,c,"$MD5SUM_mask" ocean_mask.nc

# Make CICE mask file (`kmt.nc`)
ncrename -O -v mask,kmt ocean_mask.nc kmt.nc
anton-seaice marked this conversation as resolved.
Show resolved Hide resolved
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved

#Move intermediate files to a separate directory
OUTPUT_DIR="topography_output"
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved
mkdir -p $OUTPUT_DIR

# Move all intermediate files to topography_output directory
mv topog_new.nc $OUTPUT_DIR/
mv topog_new_min_dy.nc $OUTPUT_DIR/
mv topog_new_fillfraction.nc $OUTPUT_DIR/
mv topog_new_fillfraction_edited.nc $OUTPUT_DIR/
mv topog_new_fillfraction_edited_deseas.nc $OUTPUT_DIR/
mv topog_new_fillfraction_edited_deseas_mindepth.nc $OUTPUT_DIR/

# Create ESMF mesh from hgrid and ocean_mask.nc
python3 ./om3-scripts/mesh_generation/generate_mesh.py --grid-type=mom --grid-filename=ocean_hgrid.nc --mesh-filename=access-om3-025deg-ESMFmesh.nc --mask-filename=ocean_mask.nc --wrap-lons
ezhilsabareesh8 marked this conversation as resolved.
Show resolved Hide resolved

# Create ESMF mesh without mask
python3 ./om3-scripts/mesh_generation/generate_mesh.py --grid-type=mom --grid-filename=ocean_hgrid.nc --mesh-filename=access-om3-025deg-nomask-ESMFmesh.nc --wrap-lons