Skip to content

Commit 462590f

Browse files
committed
250820.202017.CST revise the definition of (r)seed in test_SOLVER.f90
1 parent 32e5a64 commit 462590f

File tree

6 files changed

+30
-308
lines changed

6 files changed

+30
-308
lines changed

fortran/tests/test_bobyqa.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module test_solver_mod
5757
!
5858
! Started: September 2021
5959
!
60-
! Last Modified: Wed 20 Aug 2025 06:42:49 PM CST
60+
! Last Modified: Wed 20 Aug 2025 07:54:20 PM CST
6161
!--------------------------------------------------------------------------------------------------!
6262

6363
implicit none
@@ -98,7 +98,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
9898
character(len=PNLEN) :: probname
9999
character(len=PNLEN) :: probs_loc(100) ! Maximal number of problems to test: 100
100100
integer :: randseed_loc
101-
integer :: rseed
101+
integer :: seed
102102
integer(IK) :: iprint
103103
integer(IK) :: iprob
104104
integer(IK) :: irand
@@ -173,8 +173,8 @@ 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-
rseed = int(sum(istr(solname)) + sum(istr(probname)) + n + irand + RP + randseed_loc)
177-
call setseed(rseed)
176+
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + n + randseed_loc)
177+
call setseed(seed)
178178
npt = max(n + 2_IK, int(4.0 * rand() * real(n, RP), kind(npt)))
179179
iprint = 2_IK
180180
maxfun = npt + int(min(1000.0_RP, real(2_IK*npt, RP)) * rand(), IK)
@@ -207,8 +207,8 @@ 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-
rseed = int(sum(istr(solname)) + sum(istr(probname)) + irand + RP + randseed_loc)
211-
call setseed(rseed)
210+
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + randseed_loc)
211+
call setseed(seed)
212212

213213
! Set the problem dimension N to a random value in the range [MINDIM, MAXDIM].
214214
n = mindim_loc + floor(rand() * real(maxdim_loc - mindim_loc + 1_IK, RP), kind(n))

fortran/tests/test_cobyla.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module test_solver_mod
5353
!
5454
! Started: September 2021
5555
!
56-
! Last Modified: Wed 20 Aug 2025 06:44:42 PM CST
56+
! Last Modified: Wed 20 Aug 2025 07:54:48 PM CST
5757
!--------------------------------------------------------------------------------------------------!
5858

5959
implicit none
@@ -95,7 +95,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
9595
character(len=PNLEN) :: probname
9696
character(len=PNLEN) :: probs_loc(100) ! Maximal number of problems to test: 100
9797
integer :: randseed_loc
98-
integer :: rseed
98+
integer :: seed
9999
integer(IK) :: iprint
100100
integer(IK) :: iprob
101101
integer(IK) :: irand
@@ -180,8 +180,8 @@ 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-
rseed = int(sum(istr(solname)) + sum(istr(probname)) + n + irand + RP + randseed_loc)
184-
call setseed(rseed)
183+
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + n + randseed_loc)
184+
call setseed(seed)
185185
m = int(min(int(5.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
187187
call construct(prob, probname, n, m)
@@ -239,8 +239,8 @@ 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-
rseed = int(sum(istr(solname)) + sum(istr(probname)) + irand + RP + randseed_loc)
243-
call setseed(rseed)
242+
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + randseed_loc)
243+
call setseed(seed)
244244

245245
! Set the problem dimension N to a random value in the range [MINDIM, MAXDIM].
246246
n = mindim_loc + floor(rand() * real(maxdim_loc - mindim_loc + 1_IK, RP), kind(n))

fortran/tests/test_lincoa.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module test_solver_mod
8383
!
8484
! Started: September 2021
8585
!
86-
! Last Modified: Wed 20 Aug 2025 06:43:51 PM CST
86+
! Last Modified: Wed 20 Aug 2025 07:56:14 PM CST
8787
!--------------------------------------------------------------------------------------------------!
8888

8989
implicit none
@@ -126,7 +126,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
126126
character(len=PNLEN) :: probname
127127
character(len=PNLEN) :: probs_loc(100) ! Maximal number of problems to test: 100
128128
integer :: randseed_loc
129-
integer :: rseed
129+
integer :: seed
130130
integer(IK) :: iprint
131131
integer(IK) :: iprob
132132
integer(IK) :: irand
@@ -211,8 +211,8 @@ 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-
rseed = int(sum(istr(solname)) + sum(istr(probname)) + n + irand + RP + randseed_loc)
215-
call setseed(rseed)
214+
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + n + randseed_loc)
215+
call setseed(seed)
216216
m = int(min(int(5.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
218218
call construct(prob, probname, n, m)
@@ -267,8 +267,8 @@ 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-
rseed = int(sum(istr(solname)) + sum(istr(probname)) + irand + RP + randseed_loc)
271-
call setseed(rseed)
270+
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + randseed_loc)
271+
call setseed(seed)
272272

273273
! Set the problem dimension N to a random value in the range [MINDIM, MAXDIM].
274274
n = mindim_loc + floor(rand() * real(maxdim_loc - mindim_loc + 1_IK, RP), kind(n))

fortran/tests/test_newuoa.f90

Lines changed: 6 additions & 6 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: Wed 20 Aug 2025 06:41:36 PM CST
52+
! Last Modified: Wed 20 Aug 2025 07:57:05 PM CST
5353
!--------------------------------------------------------------------------------------------------!
5454

5555
implicit none
@@ -87,7 +87,7 @@ subroutine test_solver(probs, mindim, maxdim, nrand, randseed, testdim)
8787
character(len=PNLEN) :: probname
8888
character(len=PNLEN) :: probs_loc(100) ! Maximal number of problems to test: 100
8989
integer :: randseed_loc
90-
integer :: rseed
90+
integer :: seed
9191
integer(IK) :: iprint
9292
integer(IK) :: iprob
9393
integer(IK) :: irand
@@ -157,8 +157,8 @@ 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-
rseed = int(sum(istr(solname)) + sum(istr(probname)) + n + irand + RP + randseed_loc)
161-
call setseed(rseed)
160+
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + n + randseed_loc)
161+
call setseed(seed)
162162
npt = max(n + 2_IK, int(4.0 * rand() * real(n, RP), kind(npt)))
163163
iprint = 2_IK
164164
maxfun = npt + int(min(1000.0_RP, real(2_IK*npt, RP)) * rand(), IK)
@@ -190,8 +190,8 @@ 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-
rseed = int(sum(istr(solname)) + sum(istr(probname)) + irand + RP + randseed_loc)
194-
call setseed(rseed)
193+
seed = int(sum(istr(solname)) * sum(istr(probname)) + irand * RP + randseed_loc)
194+
call setseed(seed)
195195

196196
! Set the problem dimension N to a random value in the range [MINDIM, MAXDIM].
197197
n = mindim_loc + floor(rand() * real(maxdim_loc - mindim_loc + 1_IK, RP), kind(n))

0 commit comments

Comments
 (0)