• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Atmospheric-Dynamics-GUF / PinCFlow.jl / 18561934460

16 Oct 2025 12:54PM UTC coverage: 65.961% (-0.03%) from 65.988%
18561934460

push

github

web-flow
Removed `test_case` and made several dispatches more precise (#104)

* Removed `test_case`.

* Made several dispatches more precise.

* Removed `examples.md` (was comitted by accident).

* Renamed `AbstractVariable` to `AbstractPredictand` and removed some of its subtypes (these are direct subtypes of `Any` now).

* Some simplifications and additional comments in initialize_rays!.

* Corrected a few typos.

* Moved the namelist parameter "model" to AtmosphereNamelist and removed SettingNamelist. Reformatted the code.

104 of 119 new or added lines in 44 files covered. (87.39%)

4 existing lines in 4 files now uncovered.

4951 of 7506 relevant lines covered (65.96%)

1423740.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Output/read_input!.jl
1
"""
2
```julia
3
read_input!(state::State)
4
```
5

6
Read initial values for all prognostic variables from an HDF5 input file.
7

8
# Arguments
9

10
  - `state`: Model state.
11
"""
12
function read_input! end
13

14
function read_input!(state::State)
×
15
    (; x_size, y_size) = state.namelists.domain
×
16
    (; iin, input_file) = state.namelists.output
×
NEW
17
    (; model) = state.namelists.atmosphere
×
NEW
18
    (; wkb_mode) = state.namelists.wkb
×
19
    (; comm, nx, ny, nz, io, jo, ko, i0, i1, j0, j1, k0, k1) = state.domain
×
20
    (; lref, tref, rhoref, uref, thetaref) = state.constants
×
21
    (; rho, rhop, u, v, w, pip, p) = state.variables.predictands
×
22
    (; nray_max, nray, rays) = state.wkb
×
23
    (; rhobar) = state.atmosphere
×
24

25
    # Determine dimensionality.
26
    dim = 1
×
27
    if x_size > 1
×
28
        dim += 1
×
29
    end
30
    if y_size > 1
×
31
        dim += 1
×
32
    end
33

34
    # Define slices.
35
    dk0 = ko == 0 ? 1 : 0
×
36
    (rr, ii, jj, kk, kkr) = (1:nray_max, i0:i1, j0:j1, k0:k1, (k0 - dk0):k1)
×
37
    (iid, jjd, kkd, kkrd) = (
×
38
        (io + 1):(io + nx),
39
        (jo + 1):(jo + ny),
40
        (ko + 1):(ko + nz),
41
        (ko + 2 - dk0):(ko + nz + 1),
42
    )
43

44
    # Open the file. Note: Fused in-place assignments cannot be used here!
45
    @ivy time = h5open(input_file, "r", comm) do file
×
46

47
        # Read the time.
48
        time = file["t"][iin] / tref
×
49

50
        # Read the density fluctuations.
51
        rhop[ii, jj, kk] = file["rhop"][iid, jjd, kkd, iin] ./ rhoref
×
52
        if model != Boussinesq()
×
53
            rho[ii, jj, kk] .= rhop[ii, jj, kk]
×
54
        end
55

56
        # Read the staggered zonal wind.
57
        u[ii, jj, kk] = file["us"][iid, jjd, kkd, iin] ./ uref
×
58

59
        # Read the staggered meridional wind.
60
        v[ii, jj, kk] = file["vs"][iid, jjd, kkd, iin] ./ uref
×
61

62
        # Read the staggered transformed vertical wind.
63
        w[ii, jj, kk] = file["wts"][iid, jjd, kkd, iin] ./ uref
×
64

65
        # Read the Exner-pressure fluctuations.
66
        pip[ii, jj, kk] = file["pip"][iid, jjd, kkd, iin]
×
67

68
        # Read the mass-weighted potential temperature.
69
        if model == Compressible()
×
70
            p[ii, jj, kk] = file["p"][iid, jjd, kkd, iin] ./ rhoref ./ thetaref
×
71
        end
72

73
        if !(typeof(state.namelists.tracer.tracer_setup) <: NoTracer)
×
74
            for field in fieldnames(TracerPredictands)
×
75
                getfield(state.tracer.tracerpredictands, field)[ii, jj, kk] =
×
76
                    file[string(field)][iid, jjd, kkd, iin] .*
77
                    (rhobar[ii, jj, kk] .+ rho[ii, jj, kk])
78
            end
×
79
        end
80

81
        # Read ray-volume properties.
NEW
82
        if wkb_mode != NoWKB()
×
83
            for (output_name, field_name) in zip(
×
84
                ("xr", "yr", "zr", "dxr", "dyr", "dzr"),
85
                (:x, :y, :z, :dxray, :dyray, :dzray),
86
            )
87
                getfield(rays, field_name)[rr, ii, jj, kkr] =
×
88
                    file[output_name][rr, iid, jjd, kkrd, iin] ./ lref
89
            end
×
90

91
            for (output_name, field_name) in zip(
×
92
                ("kr", "lr", "mr", "dkr", "dlr", "dmr"),
93
                (:k, :l, :m, :dkray, :dlray, :dmray),
94
            )
95
                getfield(rays, field_name)[rr, ii, jj, kkr] =
×
96
                    file[output_name][rr, iid, jjd, kkrd, iin] .* lref
97
            end
×
98

99
            rays.dens[rr, ii, jj, kkr] =
×
100
                file["nr"][rr, iid, jjd, kkrd, iin] ./ rhoref ./ uref .^ 2 ./ tref ./ lref .^ dim
101

102
            # Determine nray.
103
            for k in kkr, j in jj, i in ii
×
104
                local_count = 0
×
105
                for r in rr
×
106
                    if rays.dens[r, i, j, k] == 0
×
107
                        continue
×
108
                    end
109
                    local_count += 1
×
110
                end
×
111
                nray[i, j, k] = local_count
×
112
            end
×
113
        end
114

115
        return time
×
116
    end
117

118
    return time
×
119
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc