Sign inSign up

jamespenn/isca

By jamespenn

Updated about 8 years ago

A precompiled (gfortran) container for the Isca codebase

Image
1

227

jamespenn/isca repository overview

Isca in Docker

Contains a precompiled version of the full Isca codebase at /isca. Experiment files should get the codebase object like this:

      cb = IscaCodeBase.from_directory('/isca')
      exp = Experiment('my_exp', codebase=cb)

Output data is stored in volume /data which can be mapped to a local directory on the host machine, see the example below or the Docker documentation for linking data volumes. The /data directory is also a good place to place experiment files and additional input files.

For more information on running isca experiments with the cli module, see https://github.com/jamesp/Isca/blob/7f8bfd20b4c2279f395c533d5fa327a82d5f97e9/src/extra/python/isca/util.py#L216 or run without any options to see the available help.

Running Isca from the container
  1. Copy the experiment file held_suarez.py below to your data storage location
  2. Run the experiment in the container docker run --rm -v /path/to/data/store:/data jamespenn/isca python3 /data/held_suarez.py --up-to -i 10 -n 8 Here we use --rm to delete the container after it has run. As the data is stored in local directory /path/to/data/store, additional runs of the above command will continue where the last successful run completed.
Running within the container

By default, the Isca image doesn't execute a command by default. If you want to create a persistent running image I recommend something like this: docker run -d -v /local/data:/data --name isca jamespenn/isca tail -f /dev/null to create a running container called isca.

You can then connect to it: docker exec -it isca bash and treat it as a ubuntu base machine with isca installed.

If you want to install further software in the image you will need to exec as root: docker exec -it --user root isca bash

The held_suarez.py test script
import numpy as np

from isca import IscaCodeBase, Experiment, DiagTable, Namelist, FailedRunError
from isca.util import exp_progress, run_cli

expname = 'held_suarez_basic'
cb = IscaCodeBase.from_directory('/isca')

NDAYS = 30
RESOLUTION = 'T21', 25

held_suarez_configuration = {
    # TEMPERATURE PROFILE
    't_zero': 315,     # maximum surface temperature forcing
    't_strat': 200,    # statospheric temperature constant
    'delh': 60,        # equator-pole temperature gradient
    'delv': 10.,       # vertical potential temperature gradient

    # RELAXATION TIMESCALES
    'ka': -20,         # Newtonian cooling timescale in atmosphere
    'ks': -5,          # Newtonian cooling timescale at surface
    'kf': -1,          # Rayleigh friction (pos. = seconds, neg. = days)
    }

namelist = Namelist({
    # model settings
    'main_nml': {
        'dt_atmos': 900,
        'days': NDAYS,
        'calendar': 'no_calendar',
    },
    'spectral_dynamics_nml': {
        'damping_order': 2,  # hyperviscosity 2=del4, 4=del8.
        'reference_sea_level_press': 1.0e5,  # default: 101325
        'valid_range_t': [150., 400.],
        # choose coordinate system to set level 7 at ~ 100hPa
        'vert_coord_option': 'uneven_sigma',  # default: 'even_sigma'
        'scale_heights': 6.0,
        'exponent': 7.5,
        'surf_res': 0.5,
    },
    'atmosphere_nml': {
        'idealized_moist_model': False  # run in HS-mode
    },
    'hs_forcing_nml': held_suarez_configuration,

    # framework and IO config
    'diag_manager_nml': {
        # diagmanager gives a warning if you don't set this
        'mix_snapshot_average_fields': False
    },
    'fms_nml': {
        'domains_stack_size': 600000  # default: 0
    },
    'fms_io_nml': {
        'threading_write': 'single',  # default: multi
        'fileset_write': 'single',  # default: multi
    },
})

diag_table = DiagTable()

#diag_table.add_file('6hourly', 6*60*60, 'seconds', time_units='days')
#diag_table.add_file('hourly', 1, 'hours', time_units='days')
diag_table.add_file('daily', 1, 'days', time_units='days')

diag_table.add_field('dynamics', 'ps')
diag_table.add_field('dynamics', 'bk')
diag_table.add_field('dynamics', 'pk')
diag_table.add_field('dynamics', 'ucomp')
diag_table.add_field('dynamics', 'vcomp')
diag_table.add_field('dynamics', 'omega')
diag_table.add_field('dynamics', 'temp')
diag_table.add_field('dynamics', 'vor')
diag_table.add_field('dynamics', 'div')
diag_table.add_field('dynamics', 'height')
diag_table.add_field('dynamics', 'height_half')

diag_table.add_field('hs_forcing', 'teq')
diag_table.add_field('hs_forcing', 'tdt')

exp = Experiment(expname, codebase=cb)
exp.diag_table = diag_table
exp.namelist = namelist
exp.set_resolution(*RESOLUTION)
exp.clear_rundir()
run_cli(exp)

Tag summary

Content type

Image

Digest

Size

328.5 MB

Last updated

about 8 years ago

docker pull jamespenn/isca