def update_config(<EOL>self, filename="<STR_LIT>", top_level_key="<STR_LIT>", **kwargs<EOL>):
kwargs = self._format_config(kwargs)<EOL>fname = join(self.run_dir, filename)<EOL>if exists(fname):<EOL><INDENT>conf = f90nml.read(fname)<EOL><DEDENT>else:<EOL><INDENT>conf = {top_level_key: {}}<EOL><DEDENT>conf[top_level_key].update(kwargs)<EOL>f90nml.write(conf, fname, force=True)<EOL>return conf<EOL>
Updates a configuration file for MAGICC

        Updates the contents of a fortran namelist in the run directory,
        creating a new namelist if none exists.

        Parameters
        ----------
        filename : str
            Name of configuration file to write

        top_level_key : str
            Name of namelist to be written in the
            configuration file

        kwargs
            Other parameters to pass to the configuration file. No
            validation on the parameters is performed.

        Returns
        -------
        dict
            The contents of the namelist which was written to file