def get_var_print_ranks(self):
        """Collect info from all processes indicating what variables
        are local to that process, and record the lowest rank where
        a given variable is local.  Distributed variables will need
        to record all of their active ranks, since each rank will
        contain different data.  This info is used for parallel case
        recording in order to avoid saving redundant data.
        """
        self.print_ranks = print_ranks = {}

        if MPI is None or not self._system.is_active():
            return

        # first, get all of our local vars
        ourvars = self.get_all_local_vars()

        # now distribute this information across all ranks
        allvars = self.mpi.comm.allgather(ourvars)

        # now loop over all vars in each rank and record the
        # rank.  Go in reverse so the lowest rank written will
        # be the last.  If a var name is a tuple, that indicates
        # it's a distributed var, so all ranks will be recorded
        for rank in range(1-self.mpi.comm.size, -1, -1):
            for v in allvars[rank]:
                if isinstance(v, tuple): # it's a distributed var
                    print_ranks.setdefault(v, []).append(rank)
                else:
                    print_ranks[v] = (rank,)

        # for any connected vars, the rank of a destination is changed
        # to match the rank of its source
        cnames = [self.name2collapsed.get(n,n) for n in print_ranks]
        for cname in cnames:
            if isinstance(cname, tuple):
                src = cname[0]
                for dest in cname[1]:
                    print_ranks[dest] = print_ranks[src]
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/assembly.py/Assembly.get_var_print_ranks/swapped operands of `-`