Skip to content

Commit baae234

Browse files
committed
250909.203520.CST correct the definition of maxfun
1 parent b58ac10 commit baae234

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.development

fortran/common/preproc.f90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module preproc_mod
66
!
77
! Started: July 2020
88
!
9-
! Last Modified: Tue 19 Aug 2025 01:55:20 PM CST
9+
! Last Modified: Tue 09 Sep 2025 08:30:45 PM CST
1010
!--------------------------------------------------------------------------------------------------!
1111

1212
! N.B.:
@@ -166,7 +166,7 @@ subroutine preproc(solver, n, iprint, maxfun, maxhist, ftarget, rhobeg, rhoend,
166166
if (maxfun > 0) then
167167
maxfun = int(min_maxfun, kind(maxfun))
168168
else ! We assume that non-positive values of MAXFUN are produced by overflow.
169-
maxfun = 10_IK**min(range(maxfun), 5) !!MATLAB: maxfun = 10^5;
169+
maxfun = max(min_maxfun, 10_IK**min(range(maxfun), 5)) !!MATLAB: maxfun = max(min_maxfun, 10^5);
170170
! N.B.: Do NOT set MAXFUN to HUGE(MAXFUN), as it may cause overflow and infinite cycling
171171
! when used as the upper bound of DO loops. This occurred on 20240225 with gfortran 13. See
172172
! https://fortran-lang.discourse.group/t/loop-variable-reaching-integer-huge-causes-infinite-loop
@@ -418,6 +418,7 @@ subroutine preproc(solver, n, iprint, maxfun, maxhist, ftarget, rhobeg, rhoend,
418418
if (DEBUGGING) then
419419
call validate(abs(iprint) <= 3, 'IPRINT is 0, 1, -1, 2, -2, 3, or -3', solver)
420420
call validate(maxhist >= 0 .and. maxhist <= maxfun, '0 <= MAXHIST <= MAXFUN', solver)
421+
call validate(maxfun >= min_maxfun, 'MAXFUN >= MIN_MAXFUN', solver)
421422
if (present(npt)) then
422423
call validate(maxfun >= npt + 1, 'MAXFUN >= NPT + 1', solver)
423424
call validate(npt >= 3, 'NPT >= 3', solver)

0 commit comments

Comments
 (0)