How to use the f90nml.read function in f90nml

To help you get started, we’ve selected a few f90nml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github COSIMA / access-om2 / test / test_bit_reproducibility.py View on Github external
exp_2x1day.build_and_run()
        exp_2x1day.force_run()

        # Now do a single 2 day run
        exp_2day = setup_exp_from_base('1deg_jra55_iaf', '1deg_jra55_iaf_2day')
        # Reconfigure
        with open(exp_2day.accessom2_config) as f:
            nml = f90nml.read(f)

        nml['date_manager_nml']['restart_period'] = [0, 0, 172800]
        nml.write(exp_2day.accessom2_config, force=True)

        # Don't use Redsea fix - this breaks reproducibility
        # https://github.com/COSIMA/access-om2/issues/124
        with open(exp_2day.ocean_config) as f:
            nml = f90nml.read(f)

        nml['auscom_ice_nml']['redsea_gulfbay_sfix'] = False
        nml.write(exp_2day.ocean_config, force=True)

        # Run once.
        exp_2day.build_and_run()

        # Now compare the output between our two short and one long run.
        two_shrt = self.checksums_to_list(exp_2x1day.accessom2_out_000)
        two_shrt = two_shrt + self.checksums_to_list(exp_2x1day.accessom2_out_001)

        one_long = self.checksums_to_list(exp_2day.accessom2_out_000)

        assert len(one_long) > 0
        for line in one_long:
            if line not in two_shrt:
github marshallward / f90nml / tests / test_f90nml.py View on Github external
def test_uppercase(self):
        test_nml = f90nml.read('types.nml')
        test_nml.uppercase = True
        self.assert_write(test_nml, 'types_uppercase.nml')

        self.assertRaises(TypeError, setattr, test_nml, 'uppercase', 'xyz')
github marshallward / f90nml / tests / test_f90nml.py View on Github external
def test_extern_cmt(self):
        test_nml = f90nml.read('extern_cmt.nml')
        self.assertEqual(self.extern_cmt_nml, test_nml)
github marshallward / f90nml / tests / test_f90nml.py View on Github external
def test_index_syntax(self):
        self.assertRaises(ValueError, f90nml.read, 'index_empty.nml')
        self.assertRaises(ValueError, f90nml.read, 'index_bad.nml')
        self.assertRaises(ValueError, f90nml.read, 'index_bad_start.nml')
        self.assertRaises(ValueError, f90nml.read, 'index_empty_end.nml')
        self.assertRaises(ValueError, f90nml.read, 'index_bad_end.nml')
        self.assertRaises(ValueError, f90nml.read, 'index_empty_stride.nml')
        self.assertRaises(ValueError, f90nml.read, 'index_bad_stride.nml')
        self.assertRaises(ValueError, f90nml.read, 'index_zero_stride.nml')
github marshallward / f90nml / tests / test_f90nml.py View on Github external
def test_print_group(self):
        nml = f90nml.read('types.nml')

        stdout = StringIO()
        print(nml['types_nml'], file=stdout)
        stdout.seek(0)
        source_str = stdout.read().rstrip('\n')
        stdout.close()

        target_str = repr(nml['types_nml'])

        self.assertEqual(source_str, target_str)
github marshallward / f90nml / tests / test_f90nml.py View on Github external
def test_float_format(self):
        test_nml = f90nml.read('float.nml')
        test_nml.float_format = '.3f'
        self.assert_write(test_nml, 'float_format.nml')

        self.assertRaises(TypeError, setattr, test_nml, 'float_format', 123)
github marshallward / f90nml / tests / test_f90nml.py View on Github external
def test_vector_default_index(self):
        test_nml = f90nml.read('vector.nml')
        test_nml.default_start_index = 2
        self.assertEqual(self.vector_nml, test_nml)
        self.assert_write(test_nml, 'vector_default_idx.nml')
github payu-org / payu / payu / models / oasis.py View on Github external
if ice_ts:
                    model.set_oasis_timestep(ice_ts)

                # Set ACCESS coupler timesteps

                input_ice_path = os.path.join(model.work_path, 'input_ice.nml')
                input_ice = f90nml.read(input_ice_path)

                input_ice['coupling_nml']['dt_cpl_io'] = t_step

                input_ice.write(input_ice_path, force=True)

            elif model.model_type == 'matm':

                input_atm_path = os.path.join(model.work_path, 'input_atm.nml')
                input_atm = f90nml.read(input_atm_path)

                input_atm['coupling']['dt_atm'] = t_step

                input_atm.write(input_atm_path, force=True)

            elif model.model_type == 'mom':

                input_nml_path = os.path.join(model.work_path, 'input.nml')
                input_nml = f90nml.read(input_nml_path)

                input_nml['auscom_ice_nml']['dt_cpl'] = t_step
                input_nml['ocean_solo_nml']['dt_cpld'] = t_step

                input_nml.write(input_nml_path, force=True)
github noaa-oar-arl / MONET / scripts / comparesim.py View on Github external
###for WCOSS
### /naqfc/noscrub/Barry.Baker/anaconda2/bin/python
import f90nml
from numpy import sort
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
from numpy import unique,sort
from datetime import datetime, timedelta
import pandas as pd
from glob import glob
from verify_airnow import verify_airnow
import sys
import utils
#Read the Namelist
nml = f90nml.read('comparesim.namelist')
base = nml['files']['basename']
gridcro = nml['files']['gridcro']
datapath = nml['files']['data_dir']
interp = nml['interp']['method']
neighbors = nml['interp']['neighbors']
radius = nml['interp']['radius_of_influence']

#airnow user and pass
usr = 'Barry.Baker'
p = 'p00pST!ck123'

#INTERP SIMULATIONS TO OBSERVATIONS
if nml['files']['sim1'].lower() != 'none':
    print 'Pairing Sim1...'
    print ' '
    if nml['files']['sim1'].lower()[-4:] =='.hdf':
github payu-org / payu / payu / models / cice.py View on Github external
def set_access_timestep(self, t_step):
        # TODO: Figure out some way to move this to the ACCESS driver
        # Re-read ice timestep and move this over there
        self.set_local_timestep(t_step)

        input_ice_path = os.path.join(self.work_path, 'input_ice.nml')
        input_ice = f90nml.read(input_ice_path)

        input_ice['coupling_nml']['dt_cice'] = t_step

        input_ice.write(input_ice_path, force=True)