setup_test.py 2 KB
Newer Older
mashun1's avatar
veros  
mashun1 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import pytest


@pytest.fixture(autouse=True)
def set_options():
    from veros import runtime_settings

    object.__setattr__(runtime_settings, "diskless_mode", True)
    try:
        yield
    finally:
        object.__setattr__(runtime_settings, "diskless_mode", False)


@pytest.mark.parametrize("float_type", ("float32", "float64"))
def test_setup_acc(float_type):
    from veros import runtime_settings

    object.__setattr__(runtime_settings, "float_type", float_type)

    from veros.setups.acc import ACCSetup

    sim = ACCSetup()
    sim.setup()

    with sim.state.settings.unlock():
        sim.state.settings.runlen = sim.state.settings.dt_tracer * 20

    sim.run()


def test_setup_acc_basic():
    from veros.setups.acc_basic import ACCBasicSetup

    sim = ACCBasicSetup()
    sim.setup()

    with sim.state.settings.unlock():
        sim.state.settings.runlen = sim.state.settings.dt_tracer * 20

    sim.run()


def test_setup_4deg():
    from veros.setups.global_4deg import GlobalFourDegreeSetup

    sim = GlobalFourDegreeSetup()
    sim.setup()

    with sim.state.settings.unlock():
        sim.state.settings.runlen = sim.state.settings.dt_tracer * 20

    sim.run()


def test_setup_flexible():
    from veros.setups.global_flexible import GlobalFlexibleResolutionSetup

    sim = GlobalFlexibleResolutionSetup(
        override=dict(
            nx=100,
            ny=50,
            dt_tracer=3600,
            dt_mom=3600,
        )
    )
    sim.setup()

    with sim.state.settings.unlock():
        sim.state.settings.runlen = sim.state.settings.dt_tracer * 20

    sim.run()


def test_setup_1deg():
    from veros.setups.global_1deg import GlobalOneDegreeSetup

    # too big to test
    GlobalOneDegreeSetup()


def test_setup_north_atlantic():
    from veros.setups.north_atlantic import NorthAtlanticSetup

    sim = NorthAtlanticSetup(override=dict(nx=100, ny=100, nz=50))
    sim.setup()

    with sim.state.settings.unlock():
        sim.state.settings.runlen = sim.state.settings.dt_tracer

    sim.run()