Skip to content

Commit

Permalink
Merge pull request #49 from noaa-ocs-modeling/develop
Browse files Browse the repository at this point in the history
read and write JSON configuration files, remove virtual nodes flag, add cleanup script, write single `fort.14`
  • Loading branch information
zacharyburnett authored Mar 30, 2021
2 parents b9cb60c + 5c45818 commit 0a6d85d
Show file tree
Hide file tree
Showing 88 changed files with 38,171 additions and 5,049 deletions.
126 changes: 83 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 0a6d85d

Please sign in to comment.