Skip to content

Commit 725f5ff

Browse files
committed
250822.215125.CST revise the definition of seed in test_*.f90, as the original one may overflow
1 parent b084857 commit 725f5ff

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

fortran/tests/test_bobyqa.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
173173
n = merge(bign, largen, testdim_loc == 'big')
174174
call construct(prob, probname, n)
175175
do irand = 1, 1 ! The test is expensive
176-
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + n + randseed_loc)
176+
seed = int(sum(istr(solname)) + sum(istr(probname)) + irand * RP + n + randseed_loc)
177177
call setseed(seed)
178178
npt = int(4.0 * rand() * real(n, RP), kind(npt))
179179
iprint = 2_IK
@@ -207,7 +207,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
207207
do irand = 1, max(0_IK, nrand_loc) + 1_IK
208208
! Initialize the random seed using IRAND, RP, and RANDSEED_LOC. Do not include IK so
209209
! that the results for different IK are the same.
210-
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + randseed_loc)
210+
seed = int(sum(istr(solname)) + sum(istr(probname)) + irand * RP + randseed_loc)
211211
call setseed(seed)
212212

213213
! Set the problem dimension N to a random value in the range [MINDIM, MAXDIM].

fortran/tests/test_cobyla.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
180180
probname = bigprob
181181
n = merge(bign, largen, testdim_loc == 'big')
182182
do irand = 1, 1 ! The test is expensive
183-
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + n + randseed_loc)
183+
seed = int(sum(istr(solname)) + sum(istr(probname)) + irand * RP + n + randseed_loc)
184184
call setseed(seed)
185185
m = int(min(int(3.0_RP * rand() * real(n, RP)), 10**min(range(0), range(0_IK))), IK)
186186
m = min(m, floor(real(huge(m)) / 8.0, IK) - n - 2_IK) ! Avoid integer overflow when calculating UNIT_MEMO in PREPROC/HISTORY
@@ -239,7 +239,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
239239
do irand = 1, max(0_IK, nrand_loc) + 1_IK
240240
! Initialize the random seed using IRAND, RP, and RANDSEED_LOC. Do not include IK so
241241
! that the results for different IK are the same.
242-
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + randseed_loc)
242+
seed = int(sum(istr(solname)) + sum(istr(probname)) + irand * RP + randseed_loc)
243243
call setseed(seed)
244244

245245
! Set the problem dimension N to a random value in the range [MINDIM, MAXDIM].

fortran/tests/test_lincoa.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
211211
probname = bigprob
212212
n = merge(bign, largen, testdim_loc == 'big')
213213
do irand = 1, 1 ! The test is expensive
214-
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + n + randseed_loc)
214+
seed = int(sum(istr(solname)) + sum(istr(probname)) + irand * RP + n + randseed_loc)
215215
call setseed(seed)
216216
m = int(min(int(2.0_RP * rand() * real(n, RP)), 10**min(range(0), range(0_IK))), IK)
217217
m = min(m, floor(real(huge(m)) / 8.0, IK) - n - 2_IK) ! Avoid integer overflow when calculating UNIT_MEMO in PREPROC/HISTORY
@@ -267,7 +267,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
267267
do irand = 1, max(0_IK, nrand_loc) + 1_IK
268268
! Initialize the random seed using IRAND, RP, and RANDSEED_LOC. Do not include IK so
269269
! that the results for different IK are the same.
270-
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + randseed_loc)
270+
seed = int(sum(istr(solname)) + sum(istr(probname)) + irand * RP + randseed_loc)
271271
call setseed(seed)
272272

273273
! Set the problem dimension N to a random value in the range [MINDIM, MAXDIM].

fortran/tests/test_newuoa.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
157157
n = merge(bign, largen, testdim_loc == 'big')
158158
call construct(prob, probname, n)
159159
do irand = 1, 1 ! The test is expensive
160-
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + n + randseed_loc)
160+
seed = int(sum(istr(solname)) + sum(istr(probname)) + irand * RP + n + randseed_loc)
161161
call setseed(seed)
162162
npt = int(4.0 * rand() * real(n, RP), kind(npt))
163163
iprint = 2_IK
@@ -190,7 +190,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
190190
do irand = 1, max(0_IK, nrand_loc) + 1_IK
191191
! Initialize the random seed using IRAND, RP, and RANDSEED_LOC. Do not include IK so
192192
! that the results for different IK are the same.
193-
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + randseed_loc)
193+
seed = int(sum(istr(solname)) + sum(istr(probname)) + irand * RP + randseed_loc)
194194
call setseed(seed)
195195

196196
! Set the problem dimension N to a random value in the range [MINDIM, MAXDIM].

fortran/tests/test_uobyqa.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module test_solver_mod
4949
!
5050
! Started: September 2021
5151
!
52-
! Last Modified: Thu 21 Aug 2025 10:13:57 AM CST
52+
! Last Modified: Fri 22 Aug 2025 09:48:23 PM CST
5353
!--------------------------------------------------------------------------------------------------!
5454

5555
implicit none
@@ -155,7 +155,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
155155
n = merge(bign, largen, testdim_loc == 'big')
156156
call construct(prob, probname, n)
157157
do irand = 1, 1 ! The test is expensive
158-
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + n + randseed_loc)
158+
seed = int(sum(istr(solname)) + sum(istr(probname)) + irand * RP + n + randseed_loc)
159159
call setseed(seed)
160160
npt = (n + 2_IK) * (n + 1_IK) / 2_IK
161161
iprint = 2_IK
@@ -187,7 +187,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
187187
do irand = 1, max(0_IK, nrand_loc) + 1_IK
188188
! Initialize the random seed using IRAND, RP, and RANDSEED_LOC. Do not include IK so
189189
! that the results for different IK are the same.
190-
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + randseed_loc)
190+
seed = int(sum(istr(solname)) + sum(istr(probname)) + irand * RP + randseed_loc)
191191
call setseed(seed)
192192

193193
! Set the problem dimension N to a random value in the range [MINDIM, MAXDIM].

0 commit comments

Comments
 (0)