Skip to content

Commit 5f0591d

Browse files
Merge branch 'main' into alexolinhager/hiRes_ocean_GIS_mesh
2 parents b3d1fab + d504bc0 commit 5f0591d

97 files changed

Lines changed: 2344 additions & 1159 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ updates:
1010
- "xylar"
1111
reviewers:
1212
- "xylar"
13+
- "andrewdnolan"

.github/workflows/build_workflow.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ jobs:
2828

2929
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
3030
name: Checkout Code Repository
31-
uses: actions/checkout@v4
31+
uses: actions/checkout@v5
3232

3333
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
3434
name: Set up Python ${{ env.PYTHON_VERSION }}
35-
uses: actions/setup-python@v5
35+
uses: actions/setup-python@v6
3636
with:
3737
python-version: ${{ env.PYTHON_VERSION }}
3838

@@ -60,7 +60,7 @@ jobs:
6060
shell: bash -l {0}
6161
strategy:
6262
matrix:
63-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
63+
python-version: ["3.10", "3.11", "3.12", "3.13"]
6464
fail-fast: false
6565
steps:
6666
- id: skip_check
@@ -70,19 +70,21 @@ jobs:
7070
paths_ignore: ${{ env.PATHS_IGNORE }}
7171

7272
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
73-
uses: actions/checkout@v4
73+
uses: actions/checkout@v5
7474

7575
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
7676
name: Set up Conda Environment
77-
uses: conda-incubator/setup-miniconda@v3
77+
uses: mamba-org/setup-micromamba@v2
7878
with:
79-
activate-environment: "compass_ci"
80-
miniforge-version: latest
81-
channels: conda-forge,e3sm/label/compass
82-
channel-priority: strict
83-
use-mamba: false
84-
auto-update-conda: true
85-
python-version: ${{ matrix.python-version }}
79+
environment-name: compass_test
80+
init-shell: bash
81+
condarc: |
82+
channel_priority: strict
83+
channels:
84+
- conda-forge
85+
- e3sm/label/compass
86+
create-args: >-
87+
python=${{ matrix.python-version }}
8688
8789
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
8890
name: Install compass

.github/workflows/docs_workflow.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,24 @@ jobs:
2020
docs_version: "latest"
2121
timeout-minutes: 20
2222
steps:
23-
- uses: actions/checkout@v4
23+
- uses: actions/checkout@v5
2424
with:
2525
persist-credentials: false
2626
fetch-depth: 0
2727

2828
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
2929
name: Set up Conda Environment
30-
uses: conda-incubator/setup-miniconda@v3
30+
uses: mamba-org/setup-micromamba@v2
3131
with:
32-
activate-environment: "compass_ci"
33-
miniforge-version: latest
34-
channels: conda-forge,e3sm/label/compass
35-
channel-priority: strict
36-
use-mamba: false
37-
auto-update-conda: true
38-
python-version: ${{ env.PYTHON_VERSION }}
32+
environment-name: compass_test
33+
init-shell: bash
34+
condarc: |
35+
channel_priority: strict
36+
channels:
37+
- conda-forge
38+
- e3sm/label/compass
39+
create-args: >-
40+
python=${{ env.PYTHON_VERSION }}
3941
4042
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
4143
name: Install compass
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: CI/CD Build Workflow
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
paths:
7+
- compass/landice/mesh.py
8+
- compass/landice/tests/greenland/mesh.py
9+
10+
jobs:
11+
gis-coarse-meshgen:
12+
name: GIS Coarse Mesh Generation
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v5
16+
with:
17+
submodules: recursive
18+
path: compass
19+
- name: setup_and_run_step
20+
run: |
21+
# create top level working directory
22+
root=$PWD
23+
pushd compass
24+
25+
# create the compass environment
26+
./conda/configure_compass_env.py --conda $root/mambaForge --env_name compass_test --mpi mpich
27+
28+
# enable the compass environment
29+
source load_compass_test_mpich.sh
30+
31+
popd
32+
33+
# download the input GIS coarse mesh
34+
wget https://rpi.app.box.com/public/static/qytr3c49h1xbucxz594df327qatiu8ds.tgz
35+
tar xf qytr3c49h1xbucxz594df327qatiu8ds.tgz
36+
37+
# create the config file describing the system
38+
cat << EOF > system.cfg
39+
# This file contains some common config options you might want to set
40+
# The paths section describes paths to databases and shared compass environments
41+
[paths]
42+
database_root =
43+
# The parallel section describes options related to running tests in parallel
44+
[parallel]
45+
# parallel system of execution: slurm or single_node
46+
system = single_node
47+
# whether to use mpirun or srun to run the model
48+
parallel_executable = mpirun
49+
# cores per node on the machine, detected automatically by default
50+
cores_per_node = 4
51+
[mesh]
52+
#run quicker - gis takes 20mins on 128 perlmutter cores
53+
min_spac = 10.e3
54+
[greenland]
55+
nprocs = 4
56+
data_path = $root/gis4kmSubSampled_01302025
57+
measures_filename = greenland_vel_mosaic500_extrap_stride8.nc
58+
bedmachine_filename = BedMachineGreenland-v5_edits_floodFill_extrap_stride25.nc
59+
EOF
60+
61+
# setup the greenland mesh generation test case
62+
testDir=$root/gis_mesh_gen
63+
compass setup -w $testDir -t landice/greenland/mesh_gen -f system.cfg
64+
65+
# run the test case
66+
cd $testDir
67+
compass run
68+

.github/workflows/pre_commit_update_workflow.yml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@ on:
99
# 4. Entry: Month of the year when the process will be started [1-12]
1010
# 5. Entry: Weekday when the process will be started [0-6] [0 is Sunday]
1111
- cron: '0 8 * * 3'
12+
# Allow manual triggering of the workflow
13+
workflow_dispatch:
1214

1315
env:
1416
UP_TO_DATE: false
1517
PYTHON_VERSION: "3.13"
18+
REVIEWERS: "xylar,andrewdnolan"
1619

1720
jobs:
1821
auto-update:
1922
runs-on: ubuntu-latest
2023
steps:
21-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@v5
2225

2326
- name: Set up Python
24-
uses: actions/setup-python@v5
27+
uses: actions/setup-python@v6
2528
with:
2629
python-version: ${{ env.PYTHON_VERSION }}
2730

@@ -38,10 +41,12 @@ jobs:
3841
git checkout -b update-pre-commit-deps
3942
pre-commit autoupdate
4043
git add .
41-
# The second command will fail if no changes were present, so we ignore it
42-
git commit -m "Update pre-commit dependencies" || ( echo "UP_TO_DATE=true" >> "$GITHUB_ENV")
44+
# Either there are changes, in which case we commit them, or there are no changes,
45+
# in which case we can skip the push & pr-create jobs
46+
git commit -m "Update pre-commit dependencies" \
47+
|| ( echo "UP_TO_DATE=true" >> "$GITHUB_ENV")
4348
44-
- name: Push Changes
49+
- name: Push Changes with github-actions bot
4550
if: ${{ env.UP_TO_DATE == 'false' }}
4651
uses: ad-m/github-push-action@master
4752
with:
@@ -52,16 +57,30 @@ jobs:
5257
env:
5358
GH_TOKEN: ${{ github.token }}
5459

55-
- name: Make PR and add reviewers and labels
60+
- name: Create PR with github-actions bot
5661
if: ${{ env.UP_TO_DATE == 'false' }}
5762
run: |
5863
cd update-pre-commit-deps
5964
gh pr create \
60-
--title "Update pre-commit and its dependencies" \
61-
--body "This PR was auto-generated to update pre-commit and its dependencies." \
62-
--head update-pre-commit-deps \
63-
--reviewer altheaden,xylar \
64-
--label ci
65+
--title "Update pre-commit and its dependencies" \
66+
--body "This PR was auto-generated to update pre-commit and its dependencies." \
67+
--head update-pre-commit-deps
6568
env:
6669
GH_TOKEN: ${{ github.token }}
6770

71+
- name: Add reviewers and labels with PAT
72+
if: ${{ env.UP_TO_DATE == 'false' }}
73+
run: |
74+
cd update-pre-commit-deps
75+
76+
gh pr edit --add-label ci
77+
78+
IFS=',' read -ra reviewers <<< "${REVIEWERS}"
79+
for reviewer in "${reviewers[@]}"; do
80+
echo "Adding reviewer: $reviewer"
81+
gh pr edit --add-reviewer "$reviewer"
82+
done
83+
84+
env:
85+
REVIEWERS: ${{ env.REVIEWERS }}
86+
GH_TOKEN: ${{ secrets.GH_CLI_TOKEN }}

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ fail_fast: true
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v5.0.0
7+
rev: v6.0.0
88
hooks:
99
- id: trailing-whitespace
1010
- id: end-of-file-fixer
1111

1212
# Can run individually with `pre-commit run isort --all-files`
1313
- repo: https://github.com/PyCQA/isort
14-
rev: 6.0.0
14+
rev: 7.0.0
1515
hooks:
1616
- id: isort
1717

1818
# Can run individually with `pre-commit run flake8 --all-files`
1919
# Need to use flake8 GitHub mirror due to CentOS git issue with GitLab
2020
# https://github.com/pre-commit/pre-commit/issues/1206
2121
- repo: https://github.com/pycqa/flake8
22-
rev: 7.1.2
22+
rev: 7.3.0
2323
hooks:
2424
- id: flake8
2525
args: ["--config=setup.cfg"]

E3SM-Project

Submodule E3SM-Project updated 1642 files

MALI-Dev

Submodule MALI-Dev updated 1793 files

compass/landice/mesh.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -697,22 +697,22 @@ def build_mali_mesh(self, cell_width, x1, y1, geom_points,
697697
logger.info('writing grid_converted.nc')
698698
write_netcdf(dsMesh, 'grid_converted.nc')
699699
levels = section.get('levels')
700-
args = ['create_landice_grid_from_generic_MPAS_grid.py',
700+
args = ['create_landice_grid_from_generic_mpas_grid',
701701
'-i', 'grid_converted.nc',
702702
'-o', 'grid_preCull.nc',
703703
'-l', levels, '-v', 'glimmer']
704704

705705
check_call(args, logger=logger)
706706

707-
args = ['interpolate_to_mpasli_grid.py', '-s',
707+
args = ['interpolate_to_mpasli_grid', '-s',
708708
gridded_dataset, '-d',
709709
'grid_preCull.nc', '-m', 'b', '-t']
710710

711711
check_call(args, logger=logger)
712712

713713
cullDistance = section.get('cull_distance')
714714
if float(cullDistance) > 0.:
715-
args = ['define_cullMask.py', '-f',
715+
args = ['define_landice_cull_mask', '-f',
716716
'grid_preCull.nc', '-m',
717717
'distance', '-d', cullDistance]
718718

@@ -724,7 +724,7 @@ def build_mali_mesh(self, cell_width, x1, y1, geom_points,
724724
if geojson_file is not None:
725725
# This step is only necessary because the GeoJSON region
726726
# is defined by lat-lon.
727-
args = ['set_lat_lon_fields_in_planar_grid.py', '-f',
727+
args = ['set_lat_lon_fields_in_planar_grid', '-f',
728728
'grid_preCull.nc', '-p', projection]
729729

730730
check_call(args, logger=logger)
@@ -751,7 +751,7 @@ def build_mali_mesh(self, cell_width, x1, y1, geom_points,
751751
write_netcdf(dsMesh, 'culled.nc')
752752

753753
logger.info('Marking horns for culling')
754-
args = ['mark_horns_for_culling.py', '-f', 'culled.nc']
754+
args = ['mark_horns_for_culling', '-f', 'culled.nc']
755755

756756
check_call(args, logger=logger)
757757

@@ -762,24 +762,24 @@ def build_mali_mesh(self, cell_width, x1, y1, geom_points,
762762
dsMesh = sort_mesh(dsMesh)
763763
write_netcdf(dsMesh, 'dehorned.nc')
764764

765-
args = ['create_landice_grid_from_generic_MPAS_grid.py', '-i',
765+
args = ['create_landice_grid_from_generic_mpas_grid', '-i',
766766
'dehorned.nc', '-o',
767767
mesh_name, '-l', levels, '-v', 'glimmer',
768768
'--beta', '--thermal', '--obs', '--diri']
769769

770770
check_call(args, logger=logger)
771771

772-
args = ['interpolate_to_mpasli_grid.py', '-s',
772+
args = ['interpolate_to_mpasli_grid', '-s',
773773
gridded_dataset, '-d', mesh_name, '-m', 'b']
774774

775775
check_call(args, logger=logger)
776776

777777
logger.info('Marking domain boundaries dirichlet')
778-
args = ['mark_domain_boundaries_dirichlet.py',
778+
args = ['mark_domain_boundaries_dirichlet',
779779
'-f', mesh_name]
780780
check_call(args, logger=logger)
781781

782-
args = ['set_lat_lon_fields_in_planar_grid.py', '-f',
782+
args = ['set_lat_lon_fields_in_planar_grid', '-f',
783783
mesh_name, '-p', projection]
784784
check_call(args, logger=logger)
785785

@@ -1016,8 +1016,8 @@ def preprocess_ais_data(self, source_gridded_dataset,
10161016
return preprocessed_gridded_dataset
10171017

10181018

1019-
def interp_gridded2mali(self, source_file, mali_scrip, nProcs, dest_file, proj,
1020-
variables="all"):
1019+
def interp_gridded2mali(self, source_file, mali_scrip, parallel_executable,
1020+
nProcs, dest_file, proj, variables="all"):
10211021
"""
10221022
Interpolate gridded dataset (e.g. MEASURES, BedMachine) onto a MALI mesh
10231023
@@ -1029,6 +1029,9 @@ def interp_gridded2mali(self, source_file, mali_scrip, nProcs, dest_file, proj,
10291029
mali_scrip : str
10301030
name of scrip file corresponding to destination MALI mesh
10311031
1032+
parallel_executable : str
1033+
executable needed to launch a parallel job
1034+
10321035
nProcs : int
10331036
number of processors to use for generating remapping weights
10341037
@@ -1070,7 +1073,7 @@ def __guess_scrip_name(filename):
10701073

10711074
logger.info('creating scrip file for source dataset')
10721075
# Note: writing scrip file to workdir
1073-
args = ['create_SCRIP_file_from_planar_rectangular_grid.py',
1076+
args = ['create_scrip_file_from_planar_rectangular_grid',
10741077
'-i', source_file,
10751078
'-s', source_scrip,
10761079
'-p', proj,
@@ -1079,7 +1082,7 @@ def __guess_scrip_name(filename):
10791082

10801083
# Generate remapping weights
10811084
logger.info('generating gridded dataset -> MPAS weights')
1082-
args = ['srun', '-n', nProcs, 'ESMF_RegridWeightGen',
1085+
args = [parallel_executable, '-n', nProcs, 'ESMF_RegridWeightGen',
10831086
'--source', source_scrip,
10841087
'--destination', mali_scrip,
10851088
'--weight', weights_filename,
@@ -1089,8 +1092,8 @@ def __guess_scrip_name(filename):
10891092
check_call(args, logger=logger)
10901093

10911094
# Perform actual interpolation using the weights
1092-
logger.info('calling interpolate_to_mpasli_grid.py')
1093-
args = ['interpolate_to_mpasli_grid.py',
1095+
logger.info('calling interpolate_to_mpasli_grid')
1096+
args = ['interpolate_to_mpasli_grid',
10941097
'-s', source_file,
10951098
'-d', dest_file,
10961099
'-m', 'e',

0 commit comments

Comments
 (0)