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

Enable starting driver from Fortran restart files for TC case #339

Merged
merged 145 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
056d0ec
initial commit
Jun 21, 2022
efc69b5
first attempt at functions to restart from Fortran
Jun 21, 2022
c0e933a
added code in _restart_driver_state to call _overwrite_state_from_for…
Jun 28, 2022
c819291
fixed state traversal
Jun 28, 2022
c92702d
Merge branch 'main' into feature/fortran_restart
ajdas1 Aug 18, 2022
a01292c
restartconfig now runs, but model crashes after
ajdas1 Aug 26, 2022
6c56f28
lots of print statements
ajdas1 Aug 30, 2022
4e53988
removed print statements - mostly
ajdas1 Aug 31, 2022
d40d8bc
modifying properties
ajdas1 Aug 31, 2022
10677b1
small changes
ajdas1 Aug 31, 2022
8970f5d
updated properties
ajdas1 Aug 31, 2022
72c326d
updated RESTART_PROPERTIES
ajdas1 Aug 31, 2022
00ba2c8
updated gt4py, buildenv
ajdas1 Aug 31, 2022
0dfeec5
Merge branch 'main' into feature/fortran_restart
ajdas1 Aug 31, 2022
6b2ada9
renamed pace physics
ajdas1 Aug 31, 2022
5f1a1c2
pre-commit
ajdas1 Aug 31, 2022
309ed12
writing test for restart
ajdas1 Sep 2, 2022
19f72f3
check only dycore, tests
ajdas1 Sep 6, 2022
2d0f4e6
modified properties
ajdas1 Sep 6, 2022
14c3949
begin generating grid from metric terms
ajdas1 Sep 6, 2022
1b83fcf
git pull on main
ajdas1 Sep 6, 2022
4ba9d75
Merge branch 'main' of github.com:ai2cm/pace into main
ajdas1 Sep 6, 2022
de74a75
add from_lat_lon method to MetricTerms
ajdas1 Sep 7, 2022
5b04203
metric_terms look good
ajdas1 Sep 7, 2022
ab93000
testing metric terms
ajdas1 Sep 7, 2022
46f9121
gitignore
ajdas1 Sep 7, 2022
9dcaa88
Merge branch 'feature/metric_terms_from_lat_lon' into feature/fortran…
ajdas1 Sep 7, 2022
14b88d2
next step
ajdas1 Sep 8, 2022
5e041ce
Merge branch 'main' of github.com:ai2cm/pace into main
ajdas1 Sep 8, 2022
02f4df6
added grid transformation - Schmidt
ajdas1 Sep 8, 2022
dd7a506
updated history
ajdas1 Sep 8, 2022
e4fdc6f
lint
ajdas1 Sep 8, 2022
0f24cc2
testing ak, bk
ajdas1 Sep 8, 2022
1e8d3fc
gitignore removed nc, png
ajdas1 Sep 8, 2022
9f665f1
added grid config to driver
ajdas1 Sep 8, 2022
82ebb87
pre-commit
ajdas1 Sep 8, 2022
eb04446
changed default to None
ajdas1 Sep 8, 2022
37dad82
added grid_config to test_driver.
ajdas1 Sep 8, 2022
9556fde
Merge branch 'feature/transform_grid_stretch' into feature/fortran_re…
ajdas1 Sep 8, 2022
6c22105
this doesn't work
ajdas1 Sep 9, 2022
a249176
reads tc restart - no grid transform
ajdas1 Sep 9, 2022
9035ef7
small changes
ajdas1 Sep 9, 2022
363c8d9
stretched grid testing
ajdas1 Sep 10, 2022
a213310
next steps
ajdas1 Sep 13, 2022
c1f2399
moved offset factor to function
ajdas1 Sep 13, 2022
a06d54a
consolidate driver functions
ajdas1 Sep 13, 2022
bd47c32
config
ajdas1 Sep 14, 2022
9deebf8
main gitignore
ajdas1 Sep 14, 2022
b5fb50d
Merge branch 'main' of github.com:ai2cm/pace into main
ajdas1 Sep 14, 2022
0b75412
update
ajdas1 Sep 16, 2022
979c6db
fix origin and extent on lon/lat variables in MetricTerms
mcgibbon Sep 16, 2022
5baa256
test
ajdas1 Sep 19, 2022
26edfdb
Merge branch 'main' into feature/fortran_restart
ajdas1 Sep 20, 2022
16f9522
empty
ajdas1 Sep 20, 2022
ed960ed
Merge branch 'main' of github.com:ai2cm/pace into main
ajdas1 Sep 20, 2022
a3db0d1
Merge branch 'main' into feature/fortran_restart
ajdas1 Sep 20, 2022
efec08d
second try
ajdas1 Sep 20, 2022
69fc91b
Fix/restart gpu backend (#329)
elynnwu Sep 20, 2022
c522001
typing
ajdas1 Sep 20, 2022
17969b4
cleaned up
ajdas1 Sep 20, 2022
9ba8df9
pre-commit
ajdas1 Sep 20, 2022
d1837b8
removed some notebooks
ajdas1 Sep 20, 2022
b34ef47
Update .gitignore
ajdas1 Sep 20, 2022
891499d
updated path to google bucket with restart files
ajdas1 Sep 20, 2022
a3cfd72
updated stretch_transform with np, removed sign
ajdas1 Sep 20, 2022
930ff38
exchanged numpy_module for np
ajdas1 Sep 20, 2022
b7fd11c
updated type hints on stretch_transform
ajdas1 Sep 20, 2022
9f78ebe
added np to doc string
ajdas1 Sep 20, 2022
448ac5f
removed empty lines from _legacy_restart
ajdas1 Sep 20, 2022
124d0b6
removed stretch_grid from fv3core config
ajdas1 Sep 20, 2022
90a084f
added fortran restart config
ajdas1 Sep 21, 2022
5005442
restart_driver_state determines if fortran or not
ajdas1 Sep 21, 2022
7a8b6a1
started working on GridInitializer for generated
ajdas1 Sep 21, 2022
5815689
in driver, separate grid and restart in, beginning
ajdas1 Sep 21, 2022
828ba1a
self.config.grid?
ajdas1 Sep 21, 2022
03741a5
get grid init separate from driver state init
ajdas1 Sep 21, 2022
abb5e7c
removed ptop from vertical grid data
ajdas1 Sep 21, 2022
3fd723f
removing fortran_restart flag
ajdas1 Sep 21, 2022
c4dc55d
RESTART_PROPERTIES reverted, added to driver
ajdas1 Sep 21, 2022
c04afc2
undid google cloud bucket path
ajdas1 Sep 21, 2022
bc2a4b0
making legacy_restart work ...
ajdas1 Sep 22, 2022
4b717b3
pre-commit
ajdas1 Sep 22, 2022
e39949c
another pre-commit
ajdas1 Sep 22, 2022
e497736
changed namelist to not dycore only
ajdas1 Sep 22, 2022
e8386ad
gitignore
ajdas1 Sep 22, 2022
75bbd63
Merge branch 'feature/fortran_restart' of github.com:ai2cm/pace into …
ajdas1 Sep 22, 2022
bd072bb
allows to download data from google bucket
ajdas1 Sep 22, 2022
00d94a9
grid_init changed to grid_config
ajdas1 Sep 22, 2022
288ac4b
grid config
ajdas1 Sep 22, 2022
dd37763
docstrings
ajdas1 Sep 22, 2022
06a3acd
refactor grid functions to take in more arguments
ajdas1 Sep 22, 2022
fbc55cd
hardcode default stretch_factor, lon, lat target
ajdas1 Sep 22, 2022
2f41457
serialized_grid boolean removed
ajdas1 Sep 22, 2022
7369b1d
more vertical grid data changes
ajdas1 Sep 22, 2022
2005ed5
removed gridconfig
ajdas1 Sep 22, 2022
9ba0515
docstring for update fortran restart pe_peln
ajdas1 Sep 22, 2022
db8e1d9
update for different np
ajdas1 Sep 22, 2022
ba3df72
renoved return statement from dict_state_to_driver
ajdas1 Sep 22, 2022
2f9fc6c
removed return for metric terms
ajdas1 Sep 22, 2022
d093513
removed some return statements
ajdas1 Sep 22, 2022
9e8a2b2
cool new syntax if file has string
ajdas1 Sep 22, 2022
b3bd8ab
for more than 6 ranks, scatter state
ajdas1 Sep 22, 2022
0185824
minor
ajdas1 Sep 22, 2022
288ac16
moved fortran restart from state to initialization
ajdas1 Sep 23, 2022
ba955b4
tracer properties
ajdas1 Sep 23, 2022
7b53ff9
refactor baroclinic_init to take in grid data
ajdas1 Sep 23, 2022
18a3501
pre-commit
ajdas1 Sep 23, 2022
73c96c7
moved fortran stuff back to state
ajdas1 Sep 23, 2022
ae3b759
gitignore
ajdas1 Sep 23, 2022
3533cfb
pace util tests for test_legacy_restart
ajdas1 Sep 23, 2022
37682e0
tests and baroclinic restart work
ajdas1 Sep 23, 2022
0b012a7
baroclinic init change from metric terms
ajdas1 Sep 23, 2022
512032a
fix fortran restart initialization
mcgibbon Sep 30, 2022
e32b304
Merge branch 'main' into feature/fortran_restart
mcgibbon Sep 30, 2022
bb6b9ad
fix driver tests, convert fv3core grid dataclasses to use Quantity
mcgibbon Sep 30, 2022
73d49d8
fix remaining main tests
mcgibbon Sep 30, 2022
84102f2
fix some translate tests
mcgibbon Sep 30, 2022
ff3a7c1
fixes from read-through of code
mcgibbon Sep 30, 2022
707f363
small fixes to driver to use quantity in grid data
mcgibbon Sep 30, 2022
f6431ba
start fixing translate tests by updating grid to use quantity (broken…
mcgibbon Oct 1, 2022
8498aed
Merge branch 'main' into feature/fortran_restart
mcgibbon Oct 6, 2022
a136e16
Merge branch 'main' into fix/grid_origins
mcgibbon Oct 7, 2022
8b1ecba
add workaround for grid still using storage in translate tests
mcgibbon Oct 7, 2022
cd0b401
start fixing tests
mcgibbon Oct 7, 2022
c0e59e8
Merge branch 'main' into fix/grid_origins
mcgibbon Oct 7, 2022
f7fb0da
Merge branch 'fix/grid_origins' into feature/fortran_restart
mcgibbon Oct 7, 2022
892f358
fix restart mpi test
mcgibbon Oct 7, 2022
4394baa
fix driver main test
mcgibbon Oct 7, 2022
52cece8
fix grid init 54rank test
mcgibbon Oct 7, 2022
c258dd5
add cpu orchestration main test
mcgibbon Oct 7, 2022
4d9758c
attempt to fix dace_gpu failure on jenkins
mcgibbon Oct 7, 2022
63d973e
Merge branch 'main' into feature/fortran_restart
mcgibbon Oct 7, 2022
b7ddb85
update test_main circleci plan to use gt4py caching
mcgibbon Oct 17, 2022
7c34196
write version of split_quantity for storages
mcgibbon Oct 17, 2022
f3e06eb
fix config validation
mcgibbon Oct 17, 2022
0862dd1
Merge branch 'main' into feature/fortran_restart
mcgibbon Oct 17, 2022
8bee945
better fix for memoryview type error
mcgibbon Oct 17, 2022
58cf5dd
add gcloud_encoded_key context to test_main
mcgibbon Oct 17, 2022
38f5269
Update driver/pace/driver/initialization.py
mcgibbon Oct 17, 2022
4b72f99
response to review comments
mcgibbon Oct 17, 2022
42e6b66
use smaller data for test_main
mcgibbon Oct 17, 2022
7bede1c
Merge branch 'feature/fortran_restart' of github.com:ai2cm/pace into …
mcgibbon Oct 17, 2022
5a17b70
Merge branch 'main' into feature/fortran_restart
mcgibbon Oct 18, 2022
9ec891e
remove system-dependent non-working test
mcgibbon Oct 18, 2022
07b0240
update pace-util HISTORY
mcgibbon Oct 18, 2022
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
24 changes: 13 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ commands:
description: "make target to run"
type: enum
enum:
- "test_main"
- "test_savepoint"
- "savepoint_tests"
- "savepoint_tests_mpi"
Expand Down Expand Up @@ -395,20 +396,19 @@ jobs:
python3 -m mpi4py -m pace.driver.run examples/configs/baroclinic_c12_orch_cpu.yaml

test_main:
docker:
- image: cimg/python:3.8
machine:
image: ubuntu-2004:202111-02
resource_class: medium
environment:
GOOGLE_APPLICATION_CREDENTIALS: /tmp/key.json
working_directory: ~/repo
steps:
- checkout
- run:
name: Install Submodules
command: git submodule update --init
- setup_environment_mpi
- run:
name: run tests
command: |
. venv/bin/activate
pytest tests/main
- make_savepoints:
backend: numpy
experiment: c12_6ranks_standard
target: test_main
num_ranks: 1

test_mpi_54rank:
docker:
Expand Down Expand Up @@ -564,6 +564,8 @@ workflows:
tags:
only: /^v.*/
- test_main:
context:
- GCLOUD_ENCODED_KEY
filters:
tags:
only: /^v.*/
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,5 @@ RESTART/
_dacegraphs

**/testing/output/*
*.png
*.nc
Comment on lines +165 to +166
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually want to ignore all png and nc files?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically no, I think we do have one of each committed into the repo that should be there. But adding to the gitignore doesn't prevent from adding files manually, and our scripts produce a fair bit of these that we don't want to commit. I could go either way but I'd lean towards having this in the gitignore, what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with leaving it like this, just wanted to be careful when we do actually want to commit a png/nc file.

3 changes: 1 addition & 2 deletions driver/examples/configs/baroclinic_c12_orch_cpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ stencil_config:
initialization:
type: baroclinic
performance_config:
performance_mode: true
experiment_name: c12_baroclinic
performance_mode: false
nx_tile: 12
nz: 79
dt_atmos: 225
Expand Down
93 changes: 93 additions & 0 deletions driver/examples/configs/baroclinic_c12_read_restart_fortran.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
stencil_config:
compilation_config:
backend: numpy
rebuild: false
validate_args: true
format_source: false
device_sync: false
initialization:
config:
path: /home/ajdas/pace/restart_data/1.0
type: fortran_restart
performance_config:
performance_mode: true
experiment_name: c12_baroclinic_restart
grid_config:
type: generated
nx_tile: 12
nz: 79
dt_atmos: 225
minutes: 15
layout:
- 1
- 1
diagnostics_config:
path: "output.zarr"
names:
- u
- v
- ua
- va
- pt
- delp
- qvapor
- qliquid
- qice
- qrain
- qsnow
- qgraupel
dycore_config:
a_imp: 1.0
beta: 0.
consv_te: 0.
d2_bg: 0.
d2_bg_k1: 0.2
d2_bg_k2: 0.1
d4_bg: 0.15
d_con: 1.0
d_ext: 0.0
dddmp: 0.5
delt_max: 0.002
do_sat_adj: true
do_vort_damp: true
fill: true
hord_dp: 6
hord_mt: 6
hord_tm: 6
hord_tr: 8
hord_vt: 6
hydrostatic: false
k_split: 1
ke_bg: 0.
kord_mt: 9
kord_tm: -9
kord_tr: 9
kord_wz: 9
n_split: 1
nord: 3
nwat: 6
p_fac: 0.05
rf_cutoff: 3000.
rf_fast: true
tau: 10.
vtdm4: 0.06
z_tracer: true
do_qa: true
tau_i2s: 1000.
tau_g2v: 1200.
ql_gen: 0.001
ql_mlt: 0.002
qs_mlt: 0.000001
qi_lim: 1.0
dw_ocean: 0.1
dw_land: 0.15
icloud_f: 0
tau_l2v: 300.
tau_v2l: 90.
fv_sg_adj: 0
n_sponge: 48

physics_config:
hydrostatic: false
nwat: 6
do_qa: true
3 changes: 2 additions & 1 deletion driver/examples/configs/baroclinic_c12_write_restart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ seconds: 225
layout:
- 1
- 1
save_restart: true
restart_config:
save_restart: true
diagnostics_config:
path: "output.zarr"
names:
Expand Down
98 changes: 98 additions & 0 deletions driver/examples/configs/tropical_read_restart_fortran.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
dycore_only: true
disable_step_physics: true
stencil_config:
compilation_config:
backend: numpy
rebuild: false
validate_args: true
format_source: false
device_sync: false
initialization:
config:
path: gs://vcm-ml-public/dsl/initial_conditions/c128_6ranks_tc
type: fortran_restart
grid_config:
config:
stretch_factor: 3.0
lon_target: 172.5
lat_target: 17.5
ks: 0
vertical_grid_from_restart: True
type: generated
performance_config:
performance_mode: true
experiment_name: c128_tropical
nx_tile: 128
nz: 79
dt_atmos: 60
minutes: 20
layout:
- 1
- 1
diagnostics_config:
path: "output.zarr"
names:
- u
- v
- ua
- va
- pt
- delp
- qvapor
output_initial_state: true
dycore_config:
a_imp: 1.0
beta: 0.
consv_te: 0.
d2_bg: 0.
d2_bg_k1: 0.2
d2_bg_k2: 0.15
d4_bg: 0.14
d_con: 1.0
d_ext: 0.0
dddmp: 0.5
delt_max: 0.002
do_sat_adj: false
do_vort_damp: true
fill: false
hord_dp: 6
hord_mt: 6
hord_tm: 6
hord_tr: 8
hord_vt: 6
hydrostatic: false
k_split: 2
ke_bg: 0.
kord_mt: 9
kord_tm: -9
kord_tr: 9
kord_wz: 9
n_split: 3
nord: 3
nwat: 6
p_fac: 0.1
rf_cutoff: 5000.
rf_fast: true
tau: 5.
vtdm4: 0.06
z_tracer: true
do_qa: true
tau_i2s: 1000.
tau_g2v: 900.
ql_gen: 0.001
ql_mlt: 0.001
qs_mlt: 0.000001
qi_lim: 1.0
dw_ocean: 0.1
dw_land: 0.16
icloud_f: 0
tau_l2v: 225.
tau_v2l: 150.
fv_sg_adj: 600
n_sponge: 48
p_ref: 101500.

physics_config:
hydrostatic: false
nwat: 6
do_qa: true
7 changes: 4 additions & 3 deletions driver/pace/driver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
CreatesComm,
CreatesCommSelector,
MPICommConfig,
NullCommConfig,
ReaderCommConfig,
WriterCommConfig,
)
from .diagnostics import Diagnostics, DiagnosticsConfig
from .driver import Driver, DriverConfig
from .initialization import BaroclinicConfig, PredefinedStateConfig, RestartConfig
from .driver import Driver, DriverConfig, RestartConfig
from .grid import GeneratedGridConfig, SerialboxGridConfig
from .initialization import BaroclinicInit, PredefinedStateInit, RestartInit
from .performance import PerformanceConfig
from .registry import Registry
from .restart import Restart
from .state import DriverState, TendencyState


Expand Down
27 changes: 7 additions & 20 deletions driver/pace/driver/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import pace.util
import pace.util.grid
from pace.dsl.dace.orchestration import dace_inhibitor
from pace.util.quantity import QuantityMetadata

from .state import DriverState

Expand All @@ -27,9 +26,7 @@ def store(self, time: Union[datetime, timedelta], state: DriverState):
...

@abc.abstractmethod
def store_grid(
self, grid_data: pace.util.grid.GridData, metadata: QuantityMetadata
):
def store_grid(self, grid_data: pace.util.grid.GridData):
...


Expand Down Expand Up @@ -133,19 +130,11 @@ def _get_derived_state(self, state: DriverState):
warnings.warn(f"{name} is not a supported diagnostic variable.")
return output

def store_grid(
self, grid_data: pace.util.grid.GridData, metadata: QuantityMetadata
):
zarr_grid = {}
for name in ["lat", "lon"]:
grid_quantity = pace.util.Quantity(
getattr(grid_data, name),
dims=("x_interface", "y_interface"),
origin=metadata.origin,
extent=(metadata.extent[0] + 1, metadata.extent[1] + 1),
units="rad",
)
zarr_grid[name] = grid_quantity
def store_grid(self, grid_data: pace.util.grid.GridData):
zarr_grid = {
"lat": grid_data.lat,
"lon": grid_data.lon,
Comment on lines +135 to +136
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

}
self.monitor.store_constant(zarr_grid)


Expand All @@ -155,9 +144,7 @@ class NullDiagnostics(Diagnostics):
def store(self, time: Union[datetime, timedelta], state: DriverState):
pass

def store_grid(
self, grid_data: pace.util.grid.GridData, metadata: QuantityMetadata
):
def store_grid(self, grid_data: pace.util.grid.GridData):
pass


Expand Down
Loading