Skip to content

Commit

Permalink
Merge pull request #268 from sit23/shallow_and_baro_clean_gfort_input…
Browse files Browse the repository at this point in the history
…_file

Finally adding shallow and barotropic models to the Isca master
  • Loading branch information
sit23 authored Aug 5, 2024
2 parents f77ba4e + e601caa commit 8e45135
Show file tree
Hide file tree
Showing 47 changed files with 5,940 additions and 125 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ coverage.xml
.pytest_cache/
test/.cache
test/results.xml
*.sh.e*
*.sh.o*

# Translations
*.mo
Expand Down
5 changes: 3 additions & 2 deletions exp/test_cases/MiMA/MiMA_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# is used to load the correct compilers. The env file is always loaded from
# $GFDL_BASE and not the checked out git repo.

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

# create an Experiment object to handle the configuration of model parameters
# and output diagnostics
exp = Experiment('mima_test_experiment', codebase=cb)
Expand Down Expand Up @@ -174,6 +172,9 @@
})
#Lets do a run!
if __name__=="__main__":

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

exp.run(1, use_restart=False, num_cores=NCORES)
for i in range(2,121):
exp.run(i, num_cores=NCORES)
5 changes: 3 additions & 2 deletions exp/test_cases/axisymmetric/axisymmetric_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# is used to load the correct compilers. The env file is always loaded from
# $GFDL_BASE and not the checked out git repo.

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

# create an Experiment object to handle the configuration of model parameters
# and output diagnostics
exp = Experiment('axisymmetric_test_case', codebase=cb)
Expand Down Expand Up @@ -182,6 +180,9 @@

#Lets do a run!
if __name__=="__main__":

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

exp.run(1, use_restart=False, num_cores=NCORES)
for i in range(2,121):
exp.run(i, num_cores=NCORES)
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import os

import numpy as np

from isca import BarotropicCodeBase, DiagTable, Experiment, Namelist, GFDL_BASE

NCORES = 8
base_dir = os.path.dirname(os.path.realpath(__file__))
# a CodeBase can be a directory on the computer,
# useful for iterative development
cb = BarotropicCodeBase.from_directory(GFDL_BASE)

# or it can point to a specific git repo and commit id.
# This method should ensure future, independent, reproducibility of results.
# cb = DryCodeBase.from_repo(repo='https://github.com/isca/isca', commit='isca1.1')

# compilation depends on computer specific settings. The $GFDL_ENV
# environment variable is used to determine which `$GFDL_BASE/src/extra/env` file
# is used to load the correct compilers. The env file is always loaded from
# $GFDL_BASE and not the checked out git repo.

# create an Experiment object to handle the configuration of model parameters
# and output diagnostics
exp = Experiment('barotropic_stirring_test_experiment', codebase=cb)

#Tell model how to write diagnostics
diag = DiagTable()
diag.add_file('atmos_monthly', 30, 'days', time_units='days')

#Tell model which diagnostics to write
diag.add_field('barotropic_diagnostics', 'ucomp', time_avg=True)
diag.add_field('barotropic_diagnostics', 'vcomp', time_avg=True)
diag.add_field('barotropic_diagnostics', 'vor', time_avg=True)
diag.add_field('barotropic_diagnostics', 'pv', time_avg=True)
diag.add_field('barotropic_diagnostics', 'stream', time_avg=True)
diag.add_field('barotropic_diagnostics', 'trs', time_avg=True)
diag.add_field('barotropic_diagnostics', 'tr', time_avg=True)
diag.add_field('barotropic_diagnostics', 'eddy_vor', time_avg=True)
diag.add_field('barotropic_diagnostics', 'delta_u', time_avg=True)
diag.add_field('stirring_mod', 'stirring', time_avg=True)
diag.add_field('stirring_mod', 'stirring_amp', time_avg=True)
diag.add_field('stirring_mod', 'stirring_sqr', time_avg=True)

exp.diag_table = diag

#Empty the run directory ready to run
exp.clear_rundir()

#Define values for the 'core' namelist
exp.namelist = namelist = Namelist({
'main_nml':{
'days' : 30,
'hours' : 0,
'minutes': 0,
'seconds': 0,
'dt_atmos': 1200,
'calendar': 'no_calendar',
},

'atmosphere_nml':{
'print_interval': 86400,
},

'fms_io_nml':{
'threading_write' :'single',
'fileset_write': 'single'
},

'fms_nml':{
'print_memory_usage':True,
'domains_stack_size': 200000,
},

'barotropic_dynamics_nml':{
'triang_trunc' : True,
'num_lat' : 128,
'num_lon' : 256,
'num_fourier' : 85,
'num_spherical' : 86,
'fourier_inc' : 1,
'damping_option' : 'resolution_dependent',
'damping_order' : 2,
'damping_coeff' : 1.157E-4,
'damping_coeff_r': 1.929E-6,
'grid_tracer' : True,
'spec_tracer' : True,
'm_0' : 6,
'zeta_0' : 0.0,
'eddy_lat' : 45.0,
'eddy_width' : 10.0,
'robert_coeff' : 0.04,
'initial_zonal_wind' : 'zero',
},

'barotropic_physics_nml':{
},

'stirring_nml': {
'decay_time':172800,
'amplitude':3.e-11,
'lat0':45.,
'lon0':180.,
'widthy':12.,
'widthx':45.,
'B':1.0,
},

})

#Lets do a run!
if __name__=="__main__":

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

exp.run(1, use_restart=False, num_cores=NCORES)
for i in range(2,121):
exp.run(i, num_cores=NCORES)
101 changes: 101 additions & 0 deletions exp/test_cases/barotropic_vorticity_equation/barotropic_vor_eq_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import os

import numpy as np

from isca import BarotropicCodeBase, DiagTable, Experiment, Namelist, GFDL_BASE

NCORES = 8
base_dir = os.path.dirname(os.path.realpath(__file__))
# a CodeBase can be a directory on the computer,
# useful for iterative development
cb = BarotropicCodeBase.from_directory(GFDL_BASE)

# or it can point to a specific git repo and commit id.
# This method should ensure future, independent, reproducibility of results.
# cb = DryCodeBase.from_repo(repo='https://github.com/isca/isca', commit='isca1.1')

# compilation depends on computer specific settings. The $GFDL_ENV
# environment variable is used to determine which `$GFDL_BASE/src/extra/env` file
# is used to load the correct compilers. The env file is always loaded from
# $GFDL_BASE and not the checked out git repo.

# create an Experiment object to handle the configuration of model parameters
# and output diagnostics
exp = Experiment('barotropic_test_experiment', codebase=cb)

#Tell model how to write diagnostics
diag = DiagTable()
diag.add_file('atmos_monthly', 30, 'days', time_units='days')

#Tell model which diagnostics to write
diag.add_field('barotropic_diagnostics', 'ucomp', time_avg=True)
diag.add_field('barotropic_diagnostics', 'vcomp', time_avg=True)
diag.add_field('barotropic_diagnostics', 'vor', time_avg=True)
diag.add_field('barotropic_diagnostics', 'pv', time_avg=True)
diag.add_field('barotropic_diagnostics', 'stream', time_avg=True)
diag.add_field('barotropic_diagnostics', 'trs', time_avg=True)
diag.add_field('barotropic_diagnostics', 'tr', time_avg=True)
diag.add_field('barotropic_diagnostics', 'eddy_vor', time_avg=True)
diag.add_field('barotropic_diagnostics', 'delta_u', time_avg=True)

exp.diag_table = diag

#Empty the run directory ready to run
exp.clear_rundir()

#Define values for the 'core' namelist
exp.namelist = namelist = Namelist({
'main_nml':{
'days' : 30,
'hours' : 0,
'minutes': 0,
'seconds': 0,
'dt_atmos': 1200,
'calendar': 'no_calendar',
},

'atmosphere_nml':{
'print_interval': 86400,
},

'fms_io_nml':{
'threading_write' :'single',
'fileset_write': 'single'
},

'fms_nml':{
'print_memory_usage':True,
'domains_stack_size': 200000,
},

'barotropic_dynamics_nml':{
'triang_trunc' : True,
'num_lat' : 128,
'num_lon' : 256,
'num_fourier' : 85,
'num_spherical' : 86,
'fourier_inc' : 1,
'damping_option' : 'resolution_dependent',
'damping_order' : 4,
'damping_coeff' : 1.e-04,
'grid_tracer' : True,
'spec_tracer' : True,
'm_0' : 4,
'zeta_0' : 8.e-05,
'eddy_lat' : 45.0,
'eddy_width' : 15.0,
'robert_coeff' : 0.04,
},

'barotropic_physics_nml':{
},
})

#Lets do a run!
if __name__=="__main__":

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

exp.run(1, use_restart=False, num_cores=NCORES)
for i in range(2,121):
exp.run(i, num_cores=NCORES)
4 changes: 2 additions & 2 deletions exp/test_cases/bucket_hydrology/bucket_model_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# is used to load the correct compilers. The env file is always loaded from
# $GFDL_BASE and not the checked out git repo.

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

# create an Experiment object to handle the configuration of model parameters
# and output diagnostics
exp = Experiment('bucket_test_experiment', codebase=cb)
Expand Down Expand Up @@ -179,6 +177,8 @@

#Lets do a run!
if __name__=="__main__":
cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

exp.run(1, use_restart=False, num_cores=NCORES)
for i in range(2,121):
exp.run(i, num_cores=NCORES)
4 changes: 2 additions & 2 deletions exp/test_cases/frierson/frierson_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# is used to load the correct compilers. The env file is always loaded from
# $GFDL_BASE and not the checked out git repo.

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

# create an Experiment object to handle the configuration of model parameters
# and output diagnostics
exp = Experiment('frierson_test_experiment', codebase=cb)
Expand Down Expand Up @@ -173,6 +171,8 @@

#Lets do a run!
if __name__=="__main__":
cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

exp.run(1, use_restart=False, num_cores=NCORES)
for i in range(2,121):
exp.run(i, num_cores=NCORES)
4 changes: 2 additions & 2 deletions exp/test_cases/giant_planet/giant_planet_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# is used to load the correct compilers. The env file is always loaded from
# $GFDL_BASE and not the checked out git repo.

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

# create an Experiment object to handle the configuration of model parameters
# and output diagnostics
exp = Experiment('giant_planet_test_experiment', codebase=cb)
Expand Down Expand Up @@ -207,6 +205,8 @@

#Lets do a run!
if __name__=="__main__":
cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

exp.run(1, use_restart=False, num_cores=NCORES)
for i in range(2,121):
exp.run(i, num_cores=NCORES)
5 changes: 3 additions & 2 deletions exp/test_cases/held_suarez/held_suarez_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
# is used to load the correct compilers. The env file is always loaded from
# $GFDL_BASE and not the checked out git repo.

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

# create an Experiment object to handle the configuration of model parameters
# and output diagnostics

Expand Down Expand Up @@ -104,6 +102,9 @@

#Lets do a run!
if __name__ == '__main__':

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

exp.run(1, num_cores=NCORES, use_restart=False)
for i in range(2, 13):
exp.run(i, num_cores=NCORES) # use the restart i-1 by default
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
# is used to load the correct compilers. The env file is always loaded from
# $GFDL_BASE and not the checked out git repo.

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

# create an Experiment object to handle the configuration of model parameters
# and output diagnostics
exp = Experiment('realistic_continents_fixed_sst_test_experiment', codebase=cb)
Expand Down Expand Up @@ -72,6 +70,8 @@

#Lets do a run!
if __name__=="__main__":
cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

exp.run(1, use_restart=False, num_cores=NCORES)
for i in range(2,121):
exp.run(i, num_cores=NCORES)
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
# is used to load the correct compilers. The env file is always loaded from
# $GFDL_BASE and not the checked out git repo.

cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

# create an Experiment object to handle the configuration of model parameters
# and output diagnostics
exp = Experiment('realistic_continents_qflux_test_experiment', codebase=cb)
Expand Down Expand Up @@ -72,6 +70,8 @@

#Lets do a run!
if __name__=="__main__":
cb.compile() # compile the source code to working directory $GFDL_WORK/codebase

exp.run(1, use_restart=False, num_cores=NCORES)
for i in range(2,121):
exp.run(i, num_cores=NCORES)
Loading

0 comments on commit 8e45135

Please sign in to comment.