from UtilsRPE.Functions import load_vault
import math

ceil = math.ceil


def set_precision_to(value, _vault):
    for variable in _vault.variables:
        if variable.id is not None:
            variable.precision = value


if __name__ == "__main__":
        vault = load_vault()

        if not vault:
            print("vault.pkl not found!\nUnable to create namelist!")
            exit(1)

        variables = sorted([var for var in vault.variables if var.id is not None], key=lambda x: x.id)

        set_precision_to(52, vault)

        filename = "namelist_precisions"
        vault.generate_namelist_precisions(filename=filename, exclude_double_precision=False)
