-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from noaa-ocs-modeling/develop
read and write JSON configuration files, remove virtual nodes flag, add cleanup script, write single `fort.14`
- Loading branch information
Showing
88 changed files
with
38,171 additions
and
5,049 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,83 +36,109 @@ The following code (`examples/hera/hera_shinnecock_ike.py`) creates a configurat | |
on Hera, over a small Shinnecock Inlet mesh: | ||
|
||
```python | ||
#! /usr/bin/env python | ||
|
||
from datetime import datetime, timedelta | ||
from pathlib import Path | ||
import sys | ||
|
||
from adcircpy import Tides | ||
from adcircpy.forcing.tides.tides import TidalSource | ||
from adcircpy.forcing.waves.ww3 import WaveWatch3DataForcing | ||
from adcircpy.forcing.winds.atmesh import AtmosphericMeshForcing | ||
from nemspy import ModelingSystem | ||
from nemspy.model import ADCIRCEntry, AtmosphericMeshEntry, WaveMeshEntry | ||
|
||
sys.path.append((Path(__file__).parent / '..').absolute()) | ||
|
||
from coupledmodeldriver.adcirc import write_adcirc_configurations | ||
from coupledmodeldriver.adcirc.nems_adcirc import ( | ||
ADCIRCCoupledRunConfiguration, | ||
generate_nems_adcirc_configuration, | ||
) | ||
from coupledmodeldriver.platforms import Platform | ||
|
||
# paths to compiled `NEMS.x` and `adcprep` | ||
NEMS_EXECUTABLE = '/scratch2/COASTAL/coastal/save/shared/repositories/ADC-WW3-NWM-NEMS/ALLBIN_INSTALL/NEMS-adcirc_atmesh_ww3data.x' | ||
ADCPREP_EXECUTABLE = '/scratch2/COASTAL/coastal/save/shared/repositories/ADC-WW3-NWM-NEMS/ALLBIN_INSTALL/adcprep' | ||
|
||
# directory containing input ADCIRC mesh nodes (`fort.14`) and (optionally) mesh values (`fort.13`) | ||
MESH_DIRECTORY = Path('/scratch2/COASTAL/coastal/save/shared/models') / 'meshes' / 'shinnecock' / 'grid_v1' | ||
MESH_DIRECTORY = ( | ||
Path('/scratch2/COASTAL/coastal/save/shared/models') / 'meshes' / 'shinnecock' / 'grid_v1' | ||
) | ||
|
||
# directory containing input atmospheric mesh forcings (`wind_atm_fin_ch_time_vec.nc`) and WaveWatch III forcings (`ww3.Constant.20151214_sxy_ike_date.nc`) | ||
FORCINGS_DIRECTORY = Path('/scratch2/COASTAL/coastal/save/shared/models') / 'forcings' / 'shinnecock' / 'ike' | ||
FORCINGS_DIRECTORY = ( | ||
Path('/scratch2/COASTAL/coastal/save/shared/models') / 'forcings' / 'shinnecock' / 'ike' | ||
) | ||
|
||
# directory to which to write configuration | ||
OUTPUT_DIRECTORY = Path(__file__).parent.parent / 'data' / 'configuration' / 'hera_shinnecock_ike' | ||
OUTPUT_DIRECTORY = ( | ||
Path(__file__).parent.parent / 'data' / 'configuration' / 'hera_shinnecock_ike' | ||
) | ||
|
||
HAMTIDE_DIRECTORY = '/scratch2/COASTAL/coastal/save/shared/models/forcings/tides/hamtide' | ||
TPXO_FILENAME = '/scratch2/COASTAL/coastal/save/shared/models/forcings/tides/h_tpxo9.v1.nc' | ||
|
||
platform = Platform.HERA | ||
adcirc_processors = 11 | ||
modeled_start_time = datetime(2008, 8, 23) | ||
modeled_duration = timedelta(days=14.5) | ||
modeled_timestep = timedelta(seconds=2) | ||
tidal_spinup_duration = timedelta(days=12.5) | ||
nems_interval = timedelta(hours=1) | ||
job_duration = timedelta(hours=6) | ||
|
||
# dictionary defining runs with ADCIRC value perturbations - in this case, a single run with no perturbation | ||
runs = {f'test_case_1': (None, None)} | ||
|
||
# initialize `nemspy` configuration object with forcing file locations, start and end times, and processor assignment | ||
nems = ModelingSystem( | ||
start_time=datetime(2008, 8, 23), | ||
end_time=datetime(2008, 8, 23) + timedelta(days=14.5), | ||
interval=timedelta(hours=1), | ||
atm=AtmosphericMeshEntry(filename=FORCINGS_DIRECTORY / 'wind_atm_fin_ch_time_vec.nc', processors=1), | ||
wav=WaveMeshEntry(filename=FORCINGS_DIRECTORY / 'ww3.Constant.20151214_sxy_ike_date.nc', processors=1), | ||
ocn=ADCIRCEntry(processors=11), | ||
) | ||
|
||
# describe connections between coupled components | ||
nems.connect('ATM', 'OCN') | ||
nems.connect('WAV', 'OCN') | ||
nems.sequence = [ | ||
nems_connections = ['ATM -> OCN', 'WAV -> OCN'] | ||
nems_mediations = None | ||
nems_sequence = [ | ||
'ATM -> OCN', | ||
'WAV -> OCN', | ||
'ATM', | ||
'WAV', | ||
'OCN', | ||
] | ||
|
||
slurm_email_address = '[email protected]' | ||
|
||
# initialize `adcircpy` forcing objects | ||
tidal_forcing = Tides(tidal_source=TidalSource.HAMTIDE, resource=HAMTIDE_DIRECTORY) | ||
tidal_forcing.use_all() | ||
wind_forcing = AtmosphericMeshForcing(nws=17, interval_seconds=3600) | ||
wave_forcing = WaveWatch3DataForcing(nrs=5, interval_seconds=3600) | ||
|
||
# send run information to `adcircpy` and write the resulting configuration to output directory | ||
write_adcirc_configurations( | ||
nems, | ||
runs, | ||
MESH_DIRECTORY, | ||
OUTPUT_DIRECTORY, | ||
nems_executable=NEMS_EXECUTABLE, | ||
adcprep_executable=ADCPREP_EXECUTABLE, | ||
email_address='[email protected]', | ||
platform=Platform.HERA, | ||
spinup=timedelta(days=12.5), | ||
forcings=[tidal_forcing, wind_forcing, wave_forcing], | ||
overwrite=True, | ||
use_original_mesh=False, | ||
verbose=True, | ||
wind_forcing = AtmosphericMeshForcing( | ||
filename=FORCINGS_DIRECTORY / 'wind_atm_fin_ch_time_vec.nc', | ||
nws=17, | ||
interval_seconds=3600, | ||
) | ||
wave_forcing = WaveWatch3DataForcing( | ||
filename=FORCINGS_DIRECTORY / 'ww3.Constant.20151214_sxy_ike_date.nc', | ||
nrs=5, | ||
interval_seconds=3600, | ||
) | ||
forcings = [tidal_forcing, wind_forcing, wave_forcing] | ||
|
||
configuration = ADCIRCCoupledRunConfiguration( | ||
fort13=MESH_DIRECTORY / 'fort.13', | ||
fort14=MESH_DIRECTORY / 'fort.14', | ||
modeled_start_time=modeled_start_time, | ||
modeled_end_time=modeled_start_time + modeled_duration, | ||
modeled_timestep=modeled_timestep, | ||
nems_interval=nems_interval, | ||
nems_connections=nems_connections, | ||
nems_mediations=nems_mediations, | ||
nems_sequence=nems_sequence, | ||
tidal_spinup_duration=tidal_spinup_duration, | ||
platform=platform, | ||
runs=runs, | ||
forcings=forcings, | ||
adcirc_processors=adcirc_processors, | ||
slurm_partition=None, | ||
slurm_job_duration=job_duration, | ||
slurm_email_address=slurm_email_address, | ||
nems_executable=None, | ||
adcprep_executable=None, | ||
source_filename=None, | ||
) | ||
|
||
configuration.write_directory(OUTPUT_DIRECTORY, overwrite=True) | ||
generate_nems_adcirc_configuration(OUTPUT_DIRECTORY, overwrite=True) | ||
``` | ||
|
||
This code will generate a directory `hera_shinnecock_ike/` with the following structure: | ||
|
@@ -121,19 +147,27 @@ This code will generate a directory `hera_shinnecock_ike/` with the following st | |
π¦ hera_shinnecock_ike/ | ||
β£ π coldstart/ | ||
β β£ π fort.13 | ||
β β£ π fort.14 | ||
β β£ π fort.14 -> ../fort.14 | ||
β β π fort.15 | ||
β£ π runs/ | ||
β β π test_case_1/ | ||
β β£ π fort.13 | ||
β β£ π fort.14 | ||
β β£ π fort.14 -> ../../fort.14 | ||
β β π fort.15 | ||
β£ π configure_modeldriver.json | ||
β£ π configure_nems.json | ||
β£ π configure_slurm.json | ||
β£ π configure_adcirc.json | ||
β£ π configure_tidal_forcing.json | ||
β£ π configure_atmesh.json | ||
β£ π configure_ww3data.json | ||
β£ π nems.configure.coldstart | ||
β£ π nems.configure.hotstart | ||
β£ π config.rc.coldstart | ||
β£ π config.rc.hotstart | ||
β£ π model_configure.coldstart | ||
β£ π model_configure.hotstart | ||
β£ π fort.14 | ||
β£ π job_adcprep_hera.job | ||
β£ π job_nems_adcirc_hera.job.coldstart | ||
β£ π job_nems_adcirc_hera.job.hotstart | ||
|
@@ -180,7 +214,13 @@ This will first create symbolic links to populate configuration directories (by | |
β β£ π setup.sh -> ../../setup.sh.hotstart | ||
β β£ π hera_adcprep.job -> ../../job_adcprep_hera.job | ||
β β π hera_nems_adcirc.job -> ../../job_nems_adcirc_hera.job.hotstart | ||
β£ π nems.configure.coldstart | ||
β£ π configure_modeldriver.json | ||
β£ π configure_nems.json | ||
β£ π configure_slurm.json | ||
β£ π configure_adcirc.json | ||
β£ π configure_tidal_forcing.json | ||
β£ π configure_atmesh.json | ||
β£ π configure_ww3data.json | ||
β£ π nems.configure.hotstart | ||
β£ π config.rc.coldstart | ||
β£ π config.rc.hotstart | ||
|
Oops, something went wrong.