Skip to content

Commit

Permalink
Add temporary assertion messages
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Jul 23, 2024
1 parent 5696a7a commit 74e48e1
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/DataLayouts/DataLayouts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ function IJFH{S, Nij, Nh}(array::AbstractArray{T, 4}) where {S, Nij, Nh, T}
@assert size(array, 1) == Nij
@assert size(array, 2) == Nij
@assert size(array, 3) == typesize(T, S)
@assert size(array, 4) == Nh
@assert size(array, 4) == Nh "Nh is $Nh and array size is $(size(array))"
IJFH{S, Nij, Nh, typeof(array)}(array)
end

Expand All @@ -340,10 +340,6 @@ function IJFH{S, Nij, Nh}(::Type{ArrayType}) where {S, Nij, Nh, ArrayType}
IJFH{S, Nij, Nh}(ArrayType(undef, Nij, Nij, typesize(T, S), Nh))
end

# # TODO: deprecate
# IJFH{S, Nij}(::Type{ArrayType}, Nh) where {S, Nij, ArrayType} =
# IJFH{S, Nij, Nh}(ArrayType)

function replace_basetype(
data::IJFH{S, Nij, Nh},
::Type{T},
Expand Down Expand Up @@ -439,10 +435,11 @@ end

function gather(
ctx::ClimaComms.AbstractCommsContext,
data::IJFH{S, Nij, Nh},
) where {S, Nij, Nh}
data::IJFH{S, Nij},
) where {S, Nij}
gatherdata = ClimaComms.gather(ctx, parent(data))
if ClimaComms.iamroot(ctx)
Nh = size(gatherdata, 4)
IJFH{S, Nij, Nh}(gatherdata)
else
nothing
Expand All @@ -456,8 +453,8 @@ end
Base.length(data::Data1D) = size(parent(data), 3)

"""
IFH{S, Ni, A} <: Data1D{S, Ni}
IFH{S,Ni}(ArrayType, nelements)
IFH{S,Ni,Nh,A} <: Data1D{S, Ni}
IFH{S,Ni,Nh}(ArrayType)
Backing `DataLayout` for 1D spectral element slabs.
Expand All @@ -468,7 +465,7 @@ datatype `S` struct field (F), for each 1D mesh element (H).
The `ArrayType`-constructor makes a IFH 1D Spectral
DataLayout given the backing `ArrayType`, quadrature
degrees of freedom `Ni`, and the number of mesh elements
`nelements`.
`Nh`.
"""
struct IFH{S, Ni, Nh, A} <: Data1D{S, Ni}
array::A
Expand All @@ -495,10 +492,6 @@ function IFH{S, Ni, Nh}(::Type{ArrayType}) where {S, Ni, Nh, ArrayType}
IFH{S, Ni, Nh}(ArrayType(undef, Ni, typesize(T, S), Nh))
end

# # TODO: deprecate
# IFH{S, Ni}(::Type{ArrayType}, Nh) where {S, Ni, ArrayType} =
# IFH{S, Ni, Nh}(ArrayType)

rebuild(data::IFH{S, Ni, Nh}, array::AbstractArray{T, 3}) where {S, Ni, Nh, T} =
IFH{S, Ni, Nh}(array)

Expand Down Expand Up @@ -1076,7 +1069,7 @@ function VIJFH{S, Nv, Nij, Nh}(
check_basetype(T, S)
@assert size(array, 2) == size(array, 3) == Nij
@assert size(array, 4) == typesize(T, S)
@assert size(array, 5) == Nh
@assert size(array, 5) == Nh "Nh is $Nh and array size is $(size(array))"
VIJFH{S, Nv, Nij, Nh, typeof(array)}(array)
end

Expand Down Expand Up @@ -1198,10 +1191,11 @@ end

function gather(
ctx::ClimaComms.AbstractCommsContext,
data::VIJFH{S, Nv, Nij, Nh},
) where {S, Nv, Nij, Nh}
data::VIJFH{S, Nv, Nij},
) where {S, Nv, Nij}
gatherdata = ClimaComms.gather(ctx, parent(data))
if ClimaComms.iamroot(ctx)
Nh = size(gatherdata, 5)
VIJFH{S, Nv, Nij, Nh}(gatherdata)
else
nothing
Expand Down

0 comments on commit 74e48e1

Please sign in to comment.