|
| 1 | +import os |
| 2 | + |
| 3 | +import numpy as np |
| 4 | + |
| 5 | +from isca import BarotropicCodeBase, DiagTable, Experiment, Namelist, GFDL_BASE |
| 6 | + |
| 7 | +NCORES = 8 |
| 8 | +base_dir = os.path.dirname(os.path.realpath(__file__)) |
| 9 | +# a CodeBase can be a directory on the computer, |
| 10 | +# useful for iterative development |
| 11 | +cb = BarotropicCodeBase.from_directory(GFDL_BASE) |
| 12 | + |
| 13 | +# or it can point to a specific git repo and commit id. |
| 14 | +# This method should ensure future, independent, reproducibility of results. |
| 15 | +# cb = DryCodeBase.from_repo(repo='https://github.com/isca/isca', commit='isca1.1') |
| 16 | + |
| 17 | +# compilation depends on computer specific settings. The $GFDL_ENV |
| 18 | +# environment variable is used to determine which `$GFDL_BASE/src/extra/env` file |
| 19 | +# is used to load the correct compilers. The env file is always loaded from |
| 20 | +# $GFDL_BASE and not the checked out git repo. |
| 21 | + |
| 22 | +# create an Experiment object to handle the configuration of model parameters |
| 23 | +# and output diagnostics |
| 24 | +exp = Experiment('barotropic_stirring_test_experiment', codebase=cb) |
| 25 | + |
| 26 | +#Tell model how to write diagnostics |
| 27 | +diag = DiagTable() |
| 28 | +diag.add_file('atmos_monthly', 30, 'days', time_units='days') |
| 29 | + |
| 30 | +#Tell model which diagnostics to write |
| 31 | +diag.add_field('barotropic_diagnostics', 'ucomp', time_avg=True) |
| 32 | +diag.add_field('barotropic_diagnostics', 'vcomp', time_avg=True) |
| 33 | +diag.add_field('barotropic_diagnostics', 'vor', time_avg=True) |
| 34 | +diag.add_field('barotropic_diagnostics', 'pv', time_avg=True) |
| 35 | +diag.add_field('barotropic_diagnostics', 'stream', time_avg=True) |
| 36 | +diag.add_field('barotropic_diagnostics', 'trs', time_avg=True) |
| 37 | +diag.add_field('barotropic_diagnostics', 'tr', time_avg=True) |
| 38 | +diag.add_field('barotropic_diagnostics', 'eddy_vor', time_avg=True) |
| 39 | +diag.add_field('barotropic_diagnostics', 'delta_u', time_avg=True) |
| 40 | +diag.add_field('stirring_mod', 'stirring', time_avg=True) |
| 41 | +diag.add_field('stirring_mod', 'stirring_amp', time_avg=True) |
| 42 | +diag.add_field('stirring_mod', 'stirring_sqr', time_avg=True) |
| 43 | + |
| 44 | +exp.diag_table = diag |
| 45 | + |
| 46 | +#Empty the run directory ready to run |
| 47 | +exp.clear_rundir() |
| 48 | + |
| 49 | +#Define values for the 'core' namelist |
| 50 | +exp.namelist = namelist = Namelist({ |
| 51 | + 'main_nml':{ |
| 52 | + 'days' : 30, |
| 53 | + 'hours' : 0, |
| 54 | + 'minutes': 0, |
| 55 | + 'seconds': 0, |
| 56 | + 'dt_atmos': 1200, |
| 57 | + 'calendar': 'no_calendar', |
| 58 | + }, |
| 59 | + |
| 60 | + 'atmosphere_nml':{ |
| 61 | + 'print_interval': 86400, |
| 62 | + }, |
| 63 | + |
| 64 | +'fms_io_nml':{ |
| 65 | + 'threading_write' :'single', |
| 66 | + 'fileset_write': 'single' |
| 67 | + }, |
| 68 | + |
| 69 | + 'fms_nml':{ |
| 70 | + 'print_memory_usage':True, |
| 71 | + 'domains_stack_size': 200000, |
| 72 | + }, |
| 73 | + |
| 74 | + 'barotropic_dynamics_nml':{ |
| 75 | + 'triang_trunc' : True, |
| 76 | + 'num_lat' : 128, |
| 77 | + 'num_lon' : 256, |
| 78 | + 'num_fourier' : 85, |
| 79 | + 'num_spherical' : 86, |
| 80 | + 'fourier_inc' : 1, |
| 81 | + 'damping_option' : 'resolution_dependent', |
| 82 | + 'damping_order' : 2, |
| 83 | + 'damping_coeff' : 1.157E-4, |
| 84 | + 'damping_coeff_r': 1.929E-6, |
| 85 | + 'grid_tracer' : True, |
| 86 | + 'spec_tracer' : True, |
| 87 | + 'm_0' : 6, |
| 88 | + 'zeta_0' : 0.0, |
| 89 | + 'eddy_lat' : 45.0, |
| 90 | + 'eddy_width' : 10.0, |
| 91 | + 'robert_coeff' : 0.04, |
| 92 | + 'initial_zonal_wind' : 'zero', |
| 93 | + }, |
| 94 | + |
| 95 | + 'barotropic_physics_nml':{ |
| 96 | + }, |
| 97 | + |
| 98 | + 'stirring_nml': { |
| 99 | + 'decay_time':172800, |
| 100 | + 'amplitude':3.e-11, |
| 101 | + 'lat0':45., |
| 102 | + 'lon0':180., |
| 103 | + 'widthy':12., |
| 104 | + 'widthx':45., |
| 105 | + 'B':1.0, |
| 106 | + }, |
| 107 | + |
| 108 | +}) |
| 109 | + |
| 110 | +#Lets do a run! |
| 111 | +if __name__=="__main__": |
| 112 | + |
| 113 | + cb.compile() # compile the source code to working directory $GFDL_WORK/codebase |
| 114 | + |
| 115 | + exp.run(1, use_restart=False, num_cores=NCORES) |
| 116 | + for i in range(2,121): |
| 117 | + exp.run(i, num_cores=NCORES) |
0 commit comments