def readpar(par_file, root):
par_nml = deepcopy(PAR_DEFAULT)<EOL>if PAR_DFLT_FILE.is_file():<EOL><INDENT>_enrich_with_par(par_nml, PAR_DFLT_FILE)<EOL><DEDENT>else:<EOL><INDENT>PAR_DFLT_FILE.parent.mkdir(exist_ok=True)<EOL>f90nml.write(par_nml, str(PAR_DFLT_FILE))<EOL><DEDENT>if not par_file.is_file():<EOL><INDENT>raise NoParFileError(par_file)<EOL><DEDENT>par_main = f90nml.read(str(par_file))<EOL>if '<STR_LIT>' in par_main:<EOL><INDENT>par_dflt = par_main['<STR_LIT>'].get(<EOL>'<STR_LIT>', '<STR_LIT>')<EOL>par_dflt = root / par_dflt<EOL>if not par_dflt.is_file():<EOL><INDENT>raise NoParFileError(par_dflt)<EOL><DEDENT>_enrich_with_par(par_nml, par_dflt)<EOL><DEDENT>_enrich_with_par(par_nml, par_file)<EOL>par_out = root / par_nml['<STR_LIT>']['<STR_LIT>'] / '<STR_LIT>'<EOL>if par_out.is_file():<EOL><INDENT>_enrich_with_par(par_nml, par_out)<EOL><DEDENT>par_out = root / par_nml['<STR_LIT>']['<STR_LIT>'] / '<STR_LIT>'<EOL>if par_out.is_file():<EOL><INDENT>_enrich_with_par(par_nml, par_out)<EOL><DEDENT>return par_nml<EOL>
Read StagYY par file.

    The namelist is populated in chronological order with:

    - :data:`PAR_DEFAULT`, an internal dictionary defining defaults;
    - :data:`PAR_DFLT_FILE`, the global configuration par file;
    - ``par_name_defaultparameters`` if it is defined in ``par_file``;
    - ``par_file`` itself;
    - ``parameters.dat`` if it can be found in the StagYY output directories.

    Args:
        par_file (:class:`pathlib.Path`): path of par file.
        root (:class:`pathlib.Path`): path on which other paths are rooted.
            This is usually par.parent.
    Returns:
        :class:`f90nml.namelist.Namelist`: case insensitive dict of dict of
        values with first key being the namelist and second key the variables'
        name.