This function should be called when the entire `Flow` has been built.
        It tries to reduce the pressure on the hard disk by using Abinit smart-io
        capabilities for those files that are not needed by other nodes.
        Smart-io means that big files (e.g. WFK) are written only if the calculation
        is unconverged so that we can restart from it. No output is produced if
        convergence is achieved.

        Return:
            self

def use_smartio(self):
        """
        This function should be called when the entire `Flow` has been built.
        It tries to reduce the pressure on the hard disk by using Abinit smart-io
        capabilities for those files that are not needed by other nodes.
        Smart-io means that big files (e.g. WFK) are written only if the calculation
        is unconverged so that we can restart from it. No output is produced if
        convergence is achieved.

        Return:
            self
        """
        if not self.allocated:
            #raise RuntimeError("You must call flow.allocate() before invoking flow.use_smartio()")
            self.allocate()

        for task in self.iflat_tasks():
            children = task.get_children()
            if not children:
                # Change the input so that output files are produced
                # only if the calculation is not converged.
                task.history.info("Will disable IO for task")
                task.set_vars(prtwf=-1, prtden=0) # TODO: prt1wf=-1,
            else:
                must_produce_abiexts = []
                for child in children:
                    # Get the list of dependencies. Find that task
                    for d in child.deps:
                        must_produce_abiexts.extend(d.exts)

                must_produce_abiexts = set(must_produce_abiexts)
                #print("must_produce_abiexts", must_produce_abiexts)

                # Variables supporting smart-io.
                smart_prtvars = {
                    "prtwf": "WFK",
                }

                # Set the variable to -1 to disable the output
                for varname, abiext in smart_prtvars.items():
                    if abiext not in must_produce_abiexts:
                        print("%s: setting %s to -1" % (task, varname))
                        task.set_vars({varname: -1})

        return self