From e244e13c9a9676dd9c31e570151121820a10d04d Mon Sep 17 00:00:00 2001 From: Jeremie Vandenplas Date: Fri, 18 Oct 2024 09:43:50 +0200 Subject: [PATCH] fix svd --- src/stdlib_linalg_svd.fypp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/stdlib_linalg_svd.fypp b/src/stdlib_linalg_svd.fypp index 8910bd3ce..6fa991d49 100644 --- a/src/stdlib_linalg_svd.fypp +++ b/src/stdlib_linalg_svd.fypp @@ -269,7 +269,11 @@ submodule(stdlib_linalg) stdlib_linalg_svd if (info==0) then !> Prepare working storage - lwork = nint(real(work_dummy(1),kind=${rk}$), kind=ilp) + ! Check if the returned working storage space is smaller than the largest value + ! allowed by lwork + lwork = merge(nint(real(work_dummy(1),kind=${rk}$), kind=ilp) & + , huge(lwork) & + , real(work_dummy(1),kind=${rk}$) < real(huge(lwork),kind=${rk}$) ) allocate(work(lwork)) !> Compute SVD