Skip to content

Commit f83a935

Browse files
committed
make x arrays assumed-shape w/ runtime size check
1 parent 59abe88 commit f83a935

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/stdlib_experimental_quadrature.fypp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module stdlib_experimental_quadrature
2727
#:for k1, t1 in REAL_KINDS_TYPES
2828
pure module function trapz_x_${k1}$(y, x) result(integral)
2929
${t1}$, dimension(:), intent(in) :: y
30-
${t1}$, dimension(size(y)), intent(in) :: x
30+
${t1}$, dimension(:), intent(in) :: x
3131
${t1}$ :: integral
3232
end function trapz_x_${k1}$
3333
#:endfor
@@ -61,7 +61,7 @@ module stdlib_experimental_quadrature
6161
#:for k1, t1 in REAL_KINDS_TYPES
6262
pure recursive module function simps_x_${k1}$(y, x, even) result(integral)
6363
${t1}$, dimension(:), intent(in) :: y
64-
${t1}$, dimension(size(y)), intent(in) :: x
64+
${t1}$, dimension(:), intent(in) :: x
6565
integer, intent(in), optional :: even
6666
${t1}$ :: integral
6767
end function simps_x_${k1}$

src/stdlib_experimental_quadrature_simps.fypp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ contains
9090

9191
pure recursive module function simps_x_${k1}$(y, x, even) result(integral)
9292
${t1}$, dimension(:), intent(in) :: y
93-
${t1}$, dimension(size(y)), intent(in) :: x
93+
${t1}$, dimension(:), intent(in) :: x
9494
integer, intent(in), optional :: even
9595
${t1}$ :: integral
9696

@@ -101,6 +101,7 @@ contains
101101
${t1}$ :: a, b, c, d
102102

103103
n = size(y)
104+
if (size(x) /= n) error stop "simps: Arguments `x` and `y` must be the same size."
104105

105106
select case (n)
106107
case (0:1)

src/stdlib_experimental_quadrature_trapz.fypp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ contains
3232

3333
pure module function trapz_x_${KIND}$(y, x) result(integral)
3434
real(${KIND}$), dimension(:), intent(in) :: y
35-
real(${KIND}$), dimension(size(y)), intent(in) :: x
35+
real(${KIND}$), dimension(:), intent(in) :: x
3636
real(${KIND}$) :: integral
3737

3838
integer :: i
3939
integer :: n
4040

4141
n = size(y)
42+
if (size(x) /= n) error stop "trapz: Arguments `x` and `y` must be the same size."
4243

4344
select case (n)
4445
case (0:1)

0 commit comments

Comments
 (0)