def _compute_type(self, proctype):
        """Computes tendencies due to all subprocesses of given type
        ``'proctype'``. Also pass all diagnostics up to parent process."""
        tendencies = {}
        for varname in self.state:
            tendencies[varname] = 0. * self.state[varname]
        for proc in self.process_types[proctype]:
            #  Asynchronous coupling
            #  if subprocess has longer timestep than parent
            #  We compute subprocess tendencies once
            #   and apply the same tendency at each substep
            step_ratio = int(proc.timestep / self.timestep)
            #  Does the number of parent steps divide evenly by the ratio?
            #  If so, it's time to do a subprocess step.
            if self.time['steps'] % step_ratio == 0:
                proc.time['active_now'] = True
                tenddict = proc.compute()
            else:
                # proc.tendencies is unchanged from last subprocess timestep if we didn't recompute it above
                proc.time['active_now'] = False
                tenddict = proc.tendencies
            for name, tend in tenddict.items():
                tendencies[name] += tend
            for diagname, value in proc.diagnostics.items():
                self.__setattr__(diagname, value)
        return tendencies
def _compute_type ( self , proctype ) : tendencies = { } for varname in self . state : tendencies [ varname ] = 0. * self . state [ varname ] for proc in self . process_types [ proctype ] : step_ratio = int ( proc . timestep / self . timestep ) if self . time [ 'steps' ] % step_ratio == 0 : proc . time [ 'active_now' ] = True tenddict = proc . compute ( ) else : proc . time [ 'active_now' ] = False tenddict = proc . tendencies for name , tend in tenddict . items ( ) : tendencies [ name ] += tend for diagname , value in proc . diagnostics . items ( ) : self . __setattr__ ( diagname , value ) return tendencies
Computes tendencies due to all subprocesses of given type
        ``'proctype'``. Also pass all diagnostics up to parent process.