New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 4131 for branches/2013 – NEMO

Changeset 4131 for branches/2013


Ignore:
Timestamp:
2013-10-25T11:21:52+02:00 (11 years ago)
Author:
andrewryan
Message:

changed blank line convention in namelist parser to specify blank lines at the end of a namelist instead of the beginning.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2013/dev_r3987_UKMO4_OBS/NEMOGCM/TOOLS/OBSTOOLS/OOO/ooo/nml.py

    r4129 r4131  
    2424    >>> text = nml.update(namid, text, data) 
    2525    >>> print text 
    26     <BLANKLINE> 
    2726    &namfoo 
    2827       x = 1 2 3 
    2928    / 
     29    <BLANKLINE> 
    3030 
    3131    In the above snippet :func:`tostring` has been used to sanitize the input 
     
    3838 
    3939    >>> print nml.new("namfoo", data={"x": range(3)}) 
    40     <BLANKLINE> 
    4140    &namfoo 
    4241       x = 0 1 2 
    4342    / 
     43    <BLANKLINE> 
    4444 
    4545    Parse existing namelist 
     
    133133    >>> # new line join 
    134134    >>> print "\\n".join([namoff, namcl4]) 
    135     <BLANKLINE> 
    136135    &namoff 
    137136    / 
     
    139138    &namcl4 
    140139    / 
     140    <BLANKLINE> 
    141141 
    142142    >>> # Or addition 
    143143    >>> print namoff + namcl4 
    144     <BLANKLINE> 
    145144    &namoff 
    146145    / 
    147146    &namcl4 
    148147    / 
     148    <BLANKLINE> 
    149149 
    150150    Module functions 
     
    453453 
    454454    >>> new("namobs") 
    455     '\\n&namobs\\n/' 
     455    '&namobs\\n/\\n' 
    456456    >>> print new("namobs") 
    457     <BLANKLINE> 
    458457    &namobs 
    459458    / 
     459    <BLANKLINE> 
    460460 
    461461    :param namid: Name for the new namelist 
     
    468468    :returns: string representation of a Fortran namelist 
    469469    """ 
    470     text = "\n&{namid}\n/".format(namid=namid) 
     470    text = "&{namid}\n/\n".format(namid=namid) 
    471471    if data is not None: 
    472472        text = update(namid, text, data, convert=convert) 
Note: See TracChangeset for help on using the changeset viewer.