def initialize_fv3core(backend: str, disable_halo_exchange: bool) -> None:
    """
    Initializes globalfv3core config to the arguments for single runs
    with the given backend and choice of halo updates
    """
    fv3core.set_backend(backend)
    fv3core.set_rebuild(False)
    fv3core.set_validate_args(False)
示例#2
0
def pytest_generate_tests(metafunc):
    backend = metafunc.config.getoption("backend")
    fv3core.set_backend(backend)
    if MPI is not None and MPI.COMM_WORLD.Get_size() > 1:
        if metafunc.function.__name__ == "test_parallel_savepoint":
            generate_parallel_stencil_tests(metafunc)
    else:
        if metafunc.function.__name__ == "test_sequential_savepoint":
            generate_sequential_stencil_tests(metafunc)
        if metafunc.function.__name__ == "test_mock_parallel_savepoint":
            generate_mock_parallel_stencil_tests(metafunc)
示例#3
0
                         dims=[quantity.dims[0]]),
            origin=[quantity.origin[0]],
            extent=[quantity.extent[0]],
        )
        return_state[field] = quantity_1d
    return return_state


if __name__ == "__main__":

    # read in the namelist
    spec.set_namelist("input.nml")
    dt_atmos = spec.namelist.dt_atmos

    # set backend
    fv3core.set_backend("numpy")

    # get another namelist for the communicator??
    nml2 = yaml.safe_load(
        open("/fv3core/examples/wrapped/config/c12_6ranks_standard.yml",
             "r"))["namelist"]

    sizer = SubtileGridSizer.from_namelist(nml2)
    allocator = QuantityFactory.from_backend(sizer, fv3core.get_backend())

    # MPI stuff
    comm = mpi4py.MPI.COMM_WORLD
    rank = comm.Get_rank()
    cube_comm = CubedSphereCommunicator(
        comm, CubedSpherePartitioner.from_namelist(nml2))
示例#4
0
if __name__ == "__main__":
    timer = util.Timer()
    timer.start("total")
    with timer.clock("initialization"):
        args = parse_args()
        comm = MPI.COMM_WORLD
        rank = comm.Get_rank()

        profiler = None
        if args.profile:
            import cProfile

            profiler = cProfile.Profile()
            profiler.disable()

        fv3core.set_backend(args.backend)
        fv3core.set_rebuild(False)
        fv3core.set_validate_args(False)

        spec.set_namelist(args.data_dir + "/input.nml")

        experiment_name = os.path.basename(os.path.normpath(args.data_dir))

        # set up of helper structures
        serializer = serialbox.Serializer(
            serialbox.OpenModeKind.Read,
            args.data_dir,
            "Generator_rank" + str(rank),
        )
        if args.disable_halo_exchange:
            mpi_comm = NullComm(MPI.COMM_WORLD.Get_rank(),
示例#5
0
def test_set_backend():
    start_backend = fv3core.get_backend()
    new_backend = "new_backend"
    assert new_backend != start_backend
    fv3core.set_backend(new_backend)
    assert fv3core.get_backend() == new_backend
示例#6
0
def backend(pytestconfig):
    backend = pytestconfig.getoption("backend")
    fv3core.set_backend(backend)
    return backend