def record_iteration(self, root, metadata, dummy=False):
        """ Gathers variables for non-parallel case recorders and calls
        record for all recorders.

        Args
        ----
        root : `System`
           System containing variables.

        metadata : dict
            Metadata for iteration coordinate

        dummy : bool, optional
            If True, this is a dummy iteration, so no data will be colllected
            from the model, but collective gather call will still be made.
        """
        if not self._recorders:
            return

        metadata['timestamp'] = time.time()
        params = root.params
        unknowns = root.unknowns
        resids = root.resids

        cases = None

        if MPI:
            if dummy and self._casecomm is not None:
                case = (None, None, None, None)
                if trace: debug("DUMMY gathering cases")
                cases = self._casecomm.gather(case, root=0)
                if trace: debug("DUMMY done gathering cases:")
                return

            pnames = self._vars_to_record['pnames']
            unames = self._vars_to_record['unames']
            rnames = self._vars_to_record['rnames']

            # get names and values of all locally owned variables
            params = {p: params[p] for p in pnames}
            unknowns = {u: unknowns[u] for u in unames}
            resids = {r: resids[r] for r in rnames}

            if self._has_serial_recorders:
                params = self._gather_vars(root, params) if self._record_p else {}
                unknowns = self._gather_vars(root, unknowns) if self._record_u else {}
                resids = self._gather_vars(root, resids) if self._record_r else {}

                if self._casecomm is not None:
                    # our parent driver is running a parallel DOE, so we need to
                    # gather all of the cases to this rank and loop over them
                    case = (params, unknowns, resids, metadata)
                    if trace: debug("gathering cases")
                    cases = self._casecomm.gather(case, root=0)
                    if trace: debug("done gathering cases")
                    if cases is None:
                        cases = []

        if cases is None:
            cases = [(params, unknowns, resids, metadata)]

        # If the recorder does not support parallel recording
        # we need to make sure we only record on rank 0.
        for params, unknowns, resids, meta in cases:
            if params is None: # dummy cases have None in place of params, etc.
                continue
            for recorder in self._recorders:
                if recorder._parallel or MPI is None or self.rank == 0:
                    recorder.record_iteration(params, unknowns, resids, meta)
dataset/ETHPy150Open OpenMDAO/OpenMDAO/openmdao/recorders/recording_manager.py/RecordingManager.record_iteration/original