Skip to content

Commit 72500e1

Browse files
committed
stat_dev: add error_stop
1 parent 1272574 commit 72500e1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/stdlib_experimental_stat_mean.f90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
submodule (stdlib_experimental_stat) stdlib_experimental_stat_mean
22

33

4+
use stdlib_experimental_error, only: error_stop
45
use stdlib_experimental_optval, only: optval
56
implicit none
67

@@ -38,6 +39,8 @@ module function mean_2_sp_sp(mat, dim) result(res)
3839

3940
dim_ = optval(dim, 1)
4041

42+
if (dim_ < 0 .or. dim_ > 2 ) call error_stop("ERROR (mean): invalid argument (dim) ")
43+
4144
allocate(res(size(mat, dim_)))
4245

4346
if (dim_ == 1) then
@@ -61,6 +64,8 @@ module function mean_2_dp_dp(mat, dim) result(res)
6164

6265
dim_ = optval(dim, 1)
6366

67+
if (dim_ < 0 .or. dim_ > 2 ) call error_stop("ERROR (mean): invalid argument (dim) ")
68+
6469
allocate(res(size(mat, dim_)))
6570

6671
if (dim_ == 1) then
@@ -84,6 +89,8 @@ module function mean_2_qp_qp(mat, dim) result(res)
8489

8590
dim_ = optval(dim, 1)
8691

92+
if (dim_ < 0 .or. dim_ > 2 ) call error_stop("ERROR (mean): invalid argument (dim) ")
93+
8794
allocate(res(size(mat, dim_)))
8895

8996
if (dim_ == 1) then

src/stdlib_experimental_stat_mean.fypp.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#:set TYPES = ["real({})".format(k) for k in REALKINDS]
66
#:set ikt = list(zip(range(len(KINDS)), KINDS, TYPES))
77

8+
use stdlib_experimental_error, only: error_stop
89
use stdlib_experimental_optval, only: optval
910
implicit none
1011

@@ -31,6 +32,8 @@ module function mean_2_${k1}$_${k1}$(mat, dim) result(res)
3132

3233
dim_ = optval(dim, 1)
3334

35+
if (dim_ < 0 .or. dim_ > 2 ) call error_stop("ERROR (mean): invalid argument (dim) ")
36+
3437
allocate(res(size(mat, dim_)))
3538

3639
if (dim_ == 1) then

0 commit comments

Comments
 (0)