Initialize and load the Fortran library (and model, if applicable).

        The Fortran library is loaded and ctypes is used to annotate functions
        inside the library. The Fortran library's initialization is called.

        Normally a path to an ``*.ini`` model file is passed to the
        :meth:`__init__`. If so, that model is loaded. Note that
        :meth:`_load_model` changes the working directory to that of the model.

def initialize(self, configfile=None):
        """Initialize and load the Fortran library (and model, if applicable).

        The Fortran library is loaded and ctypes is used to annotate functions
        inside the library. The Fortran library's initialization is called.

        Normally a path to an ``*.ini`` model file is passed to the
        :meth:`__init__`. If so, that model is loaded. Note that
        :meth:`_load_model` changes the working directory to that of the model.

        """

        if configfile is not None:
            self.configfile = configfile
        try:
            self.configfile
        except AttributeError:
            raise ValueError("Specify configfile during construction or during initialize")
        abs_name = os.path.abspath(self.configfile)
        os.chdir(os.path.dirname(self.configfile) or '.')
        logmsg = "Loading model {} in directory {}".format(
            self.configfile,
            os.path.abspath(os.getcwd())
        )
        logger.info(logmsg)
        # Fortran init function.
        self.library.initialize.argtypes = [c_char_p]
        self.library.initialize.restype = None
        # initialize by abs_name because we already chdirred
        # if configfile is a relative path  we would have a problem
        ierr = wrap(self.library.initialize)(abs_name)
        if ierr:
            errormsg = "Loading model {config} failed with exit code {code}"
            raise RuntimeError(errormsg.format(config=self.configfile,
                                               code=ierr))