# -*-Python-*-
# Created by bgrierson at 25 Dec 2016 18:51
# Set up the OMFIT tree to store the output from this script
root['OUTPUTS'].setdefault('NAMELISTS', OMFITtree())
# Easy to make a namelist from a block of text
nml_txt = '''
! A namelist comment
! A float
FLOAT = 1.0
'''
main_nml = OMFITnamelist('main.nml', fromString=nml_txt)
# Now create a sub-namelist block
sub_nml = OMFITnamelist(
'sub.nml',
fromString='''
INT = 1
''',
)
main_nml['SUB'] = NamelistName()
main_nml['SUB'].update(sub_nml)
# If we want to change out an entire sub-namelist we can do so here
# Now create a sub-namelist block
subnew_nml = OMFITnamelist(
'subnew.nml',
fromString='''
INT = 2
''',
)
main_nml['SUB'].update(subnew_nml)
# Store the namelist
root['OUTPUTS']['NAMELISTS']['main'] = main_nml