Skip to content

Commit 0db7e7d

Browse files
committed
250403.190308.CST unify the descriptive comment at the top of pyprima/cobyla code files
1 parent 08aeb34 commit 0db7e7d

File tree

22 files changed

+322
-153
lines changed

22 files changed

+322
-153
lines changed

fortran/common/checkexit.f90

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ module checkexit_mod
77
!
88
! Started: September 2021
99
!
10-
! Last Modified: Tuesday, September 26, 2023 AM10:51:16
10+
! Last Modified: Thu 03 Apr 2025 05:43:33 PM CST
1111
!--------------------------------------------------------------------------------------------------!
1212

1313
implicit none
1414
private
15-
public :: checkexit
15+
public:: checkexit
1616

1717
interface checkexit
1818
module procedure checkexit_unc, checkexit_con
@@ -28,25 +28,25 @@ function checkexit_unc(maxfun, nf, f, ftarget, x) result(info)
2828
!--------------------------------------------------------------------------------------------------!
2929

3030
! Common modules
31-
use, non_intrinsic :: consts_mod, only : RP, IK, DEBUGGING
32-
use, non_intrinsic :: debug_mod, only : assert
33-
use, non_intrinsic :: infnan_mod, only : is_nan, is_posinf, is_inf
34-
use, non_intrinsic :: infos_mod, only : INFO_DFT, NAN_INF_X, NAN_INF_F, FTARGET_ACHIEVED, MAXFUN_REACHED
31+
use, non_intrinsic:: consts_mod, only : RP, IK, DEBUGGING
32+
use, non_intrinsic:: debug_mod, only : assert
33+
use, non_intrinsic:: infnan_mod, only : is_nan, is_posinf, is_inf
34+
use, non_intrinsic:: infos_mod, only : INFO_DFT, NAN_INF_X, NAN_INF_F, FTARGET_ACHIEVED, MAXFUN_REACHED
3535

3636
implicit none
3737

3838
! Inputs
39-
integer(IK), intent(in) :: maxfun
40-
integer(IK), intent(in) :: nf
41-
real(RP), intent(in) :: f
42-
real(RP), intent(in) :: ftarget
43-
real(RP), intent(in) :: x(:)
39+
integer(IK), intent(in):: maxfun
40+
integer(IK), intent(in):: nf
41+
real(RP), intent(in):: f
42+
real(RP), intent(in):: ftarget
43+
real(RP), intent(in):: x(:)
4444

4545
! Outputs
46-
integer(IK) :: info
46+
integer(IK):: info
4747

4848
! Local variables
49-
character(len=*), parameter :: srname = 'CHECKEXIT_UNC'
49+
character(len=*), parameter:: srname = 'CHECKEXIT_UNC'
5050

5151
! Preconditions
5252
if (DEBUGGING) then
@@ -66,7 +66,7 @@ function checkexit_unc(maxfun, nf, f, ftarget, x) result(info)
6666
info = INFO_DFT ! Default info, indicating that the solver should not exit.
6767

6868
! Although X should not contain NaN unless there is a bug, we include the following for security.
69-
! X can be Inf, as finite + finite can be Inf numerically.
69+
! X can be Inf, as finite+finite can be Inf numerically.
7070
if (any(is_nan(x) .or. is_inf(x))) then
7171
info = NAN_INF_X
7272
end if
@@ -103,27 +103,27 @@ function checkexit_con(maxfun, nf, cstrv, ctol, f, ftarget, x) result(info)
103103
!--------------------------------------------------------------------------------------------------!
104104

105105
! Common modules
106-
use, non_intrinsic :: consts_mod, only : RP, IK, DEBUGGING
107-
use, non_intrinsic :: debug_mod, only : assert
108-
use, non_intrinsic :: infnan_mod, only : is_nan, is_posinf, is_inf
109-
use, non_intrinsic :: infos_mod, only : INFO_DFT, NAN_INF_X, NAN_INF_F, FTARGET_ACHIEVED, MAXFUN_REACHED
106+
use, non_intrinsic:: consts_mod, only : RP, IK, DEBUGGING
107+
use, non_intrinsic:: debug_mod, only : assert
108+
use, non_intrinsic:: infnan_mod, only : is_nan, is_posinf, is_inf
109+
use, non_intrinsic:: infos_mod, only : INFO_DFT, NAN_INF_X, NAN_INF_F, FTARGET_ACHIEVED, MAXFUN_REACHED
110110

111111
implicit none
112112

113113
! Inputs
114-
integer(IK), intent(in) :: maxfun
115-
integer(IK), intent(in) :: nf
116-
real(RP), intent(in) :: cstrv
117-
real(RP), intent(in) :: ctol
118-
real(RP), intent(in) :: f
119-
real(RP), intent(in) :: ftarget
120-
real(RP), intent(in) :: x(:)
114+
integer(IK), intent(in):: maxfun
115+
integer(IK), intent(in):: nf
116+
real(RP), intent(in):: cstrv
117+
real(RP), intent(in):: ctol
118+
real(RP), intent(in):: f
119+
real(RP), intent(in):: ftarget
120+
real(RP), intent(in):: x(:)
121121

122122
! Outputs
123-
integer(IK) :: info
123+
integer(IK):: info
124124

125125
! Local variables
126-
character(len=*), parameter :: srname = 'CHECKEXIT_CON'
126+
character(len=*), parameter:: srname = 'CHECKEXIT_CON'
127127

128128
! Preconditions
129129
if (DEBUGGING) then
@@ -144,7 +144,7 @@ function checkexit_con(maxfun, nf, cstrv, ctol, f, ftarget, x) result(info)
144144
info = INFO_DFT ! Default info, indicating that the solver should not exit.
145145

146146
! Although X should not contain NaN unless there is a bug, we include the following for security.
147-
! X can be Inf, as finite + finite can be Inf numerically.
147+
! X can be Inf, as finite+finite can be Inf numerically.
148148
if (any(is_nan(x) .or. is_inf(x))) then
149149
info = NAN_INF_X
150150
end if

fortran/common/evaluate.f90

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ module evaluate_mod
66
!
77
! Started: August 2021
88
!
9-
! Last Modified: Monday, September 25, 2023 PM08:52:04
9+
! Last Modified: Thu 03 Apr 2025 05:48:45 PM CST
1010
!--------------------------------------------------------------------------------------------------!
1111

1212
implicit none
1313
private
14-
public :: moderatex
15-
public :: moderatef
16-
public :: moderatec
17-
public :: evaluate
14+
public:: moderatex
15+
public:: moderatef
16+
public:: moderatec
17+
public:: evaluate
1818

1919
interface evaluate
2020
module procedure evaluatef, evaluatefc
@@ -28,15 +28,15 @@ function moderatex(x) result(y)
2828
!--------------------------------------------------------------------------------------------------!
2929
! This function moderates a decision variable. It replaces NaN by 0 and Inf/-Inf by REALMAX/-REALMAX.
3030
!--------------------------------------------------------------------------------------------------!
31-
use, non_intrinsic :: consts_mod, only : RP, ZERO, REALMAX
32-
use, non_intrinsic :: infnan_mod, only : is_nan
33-
use, non_intrinsic :: linalg_mod, only : trueloc
31+
use, non_intrinsic:: consts_mod, only : RP, ZERO, REALMAX
32+
use, non_intrinsic:: infnan_mod, only : is_nan
33+
use, non_intrinsic:: linalg_mod, only : trueloc
3434
implicit none
3535

3636
! Inputs
37-
real(RP), intent(in) :: x(:)
37+
real(RP), intent(in):: x(:)
3838
! Outputs
39-
real(RP) :: y(size(x))
39+
real(RP):: y(size(x))
4040

4141
y = x
4242
y(trueloc(is_nan(x))) = ZERO
@@ -49,14 +49,14 @@ pure elemental function moderatef(f) result(y)
4949
! This function moderates the function value of a MINIMIZATION problem. It replaces NaN and any
5050
! value above FUNCMAX by FUNCMAX.
5151
!--------------------------------------------------------------------------------------------------!
52-
use, non_intrinsic :: consts_mod, only : RP, REALMAX, FUNCMAX
53-
use, non_intrinsic :: infnan_mod, only : is_nan
52+
use, non_intrinsic:: consts_mod, only : RP, REALMAX, FUNCMAX
53+
use, non_intrinsic:: infnan_mod, only : is_nan
5454
implicit none
5555

5656
! Inputs
57-
real(RP), intent(in) :: f
57+
real(RP), intent(in):: f
5858
! Outputs
59-
real(RP) :: y
59+
real(RP):: y
6060

6161
y = f
6262
if (is_nan(y)) then
@@ -71,18 +71,18 @@ end function moderatef
7171
function moderatec(c) result(y)
7272
!--------------------------------------------------------------------------------------------------!
7373
! This function moderates the constraint value, the constraint demanding this value to be NONNEGATIVE.
74-
! It replaces any value below -CONSTRMAX by -CONSTRMAX, and any NaN or value above CONSTRMAX by
74+
! It replaces any value below-CONSTRMAX by-CONSTRMAX, and any NaN or value above CONSTRMAX by
7575
! CONSTRMAX.
7676
!--------------------------------------------------------------------------------------------------!
77-
use, non_intrinsic :: consts_mod, only : RP, CONSTRMAX
78-
use, non_intrinsic :: infnan_mod, only : is_nan
79-
use, non_intrinsic :: linalg_mod, only : trueloc
77+
use, non_intrinsic:: consts_mod, only : RP, CONSTRMAX
78+
use, non_intrinsic:: infnan_mod, only : is_nan
79+
use, non_intrinsic:: linalg_mod, only : trueloc
8080
implicit none
8181

8282
! Inputs
83-
real(RP), intent(in) :: c(:)
83+
real(RP), intent(in):: c(:)
8484
! Outputs
85-
real(RP) :: y(size(c))
85+
real(RP):: y(size(c))
8686

8787
y = c
8888
y(trueloc(is_nan(c))) = CONSTRMAX
@@ -96,21 +96,21 @@ subroutine evaluatef(calfun, x, f)
9696
! handled by a moderated extreme barrier.
9797
!--------------------------------------------------------------------------------------------------!
9898
! Common modules
99-
use, non_intrinsic :: consts_mod, only : RP, DEBUGGING
100-
use, non_intrinsic :: debug_mod, only : assert
101-
use, non_intrinsic :: infnan_mod, only : is_nan, is_posinf
102-
use, non_intrinsic :: pintrf_mod, only : OBJ
99+
use, non_intrinsic:: consts_mod, only : RP, DEBUGGING
100+
use, non_intrinsic:: debug_mod, only : assert
101+
use, non_intrinsic:: infnan_mod, only : is_nan, is_posinf
102+
use, non_intrinsic:: pintrf_mod, only : OBJ
103103
implicit none
104104

105105
! Inputs
106-
procedure(OBJ) :: calfun ! N.B.: INTENT cannot be specified if a dummy procedure is not a POINTER
107-
real(RP), intent(in) :: x(:)
106+
procedure(OBJ):: calfun ! N.B.: INTENT cannot be specified if a dummy procedure is not a POINTER
107+
real(RP), intent(in):: x(:)
108108

109109
! Output
110-
real(RP), intent(out) :: f
110+
real(RP), intent(out):: f
111111

112112
! Local variables
113-
character(len=*), parameter :: srname = 'EVALUATEF'
113+
character(len=*), parameter:: srname = 'EVALUATEF'
114114

115115
! Preconditions
116116
if (DEBUGGING) then
@@ -154,22 +154,22 @@ subroutine evaluatefc(calcfc, x, f, constr)
154154
! constraint value. Nan/Inf are handled by a moderated extreme barrier.
155155
!--------------------------------------------------------------------------------------------------!
156156
! Common modules
157-
use, non_intrinsic :: consts_mod, only : RP, DEBUGGING
158-
use, non_intrinsic :: debug_mod, only : assert
159-
use, non_intrinsic :: infnan_mod, only : is_nan, is_posinf
160-
use, non_intrinsic :: pintrf_mod, only : OBJCON
157+
use, non_intrinsic:: consts_mod, only : RP, DEBUGGING
158+
use, non_intrinsic:: debug_mod, only : assert
159+
use, non_intrinsic:: infnan_mod, only : is_nan, is_posinf
160+
use, non_intrinsic:: pintrf_mod, only : OBJCON
161161
implicit none
162162

163163
! Inputs
164-
procedure(OBJCON) :: calcfc ! N.B.: INTENT cannot be specified if a dummy procedure is not a POINTER
165-
real(RP), intent(in) :: x(:)
164+
procedure(OBJCON):: calcfc ! N.B.: INTENT cannot be specified if a dummy procedure is not a POINTER
165+
real(RP), intent(in):: x(:)
166166

167167
! Outputs
168-
real(RP), intent(out) :: f
169-
real(RP), intent(out) :: constr(:)
168+
real(RP), intent(out):: f
169+
real(RP), intent(out):: constr(:)
170170

171171
! Local variables
172-
character(len=*), parameter :: srname = 'EVALUATEFC'
172+
character(len=*), parameter:: srname = 'EVALUATEFC'
173173

174174
! Preconditions
175175
if (DEBUGGING) then

pyprima/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ If you notice a difference, [raise an issue](https://github.com/libprima/prima/i
88

99
Due to [bug-fixes](https://github.com/libprima/prima#bug-fixes) and [improvements](https://github.com/libprima/prima#improvements),
1010
the modern-Fortran reference implementation by [Zaikun Zhang](https://www.zhangzk.net)
11-
behaves differently from the original Fortran 77 implementation by [M.J.D. Powell](https://www.zhangzk.net/powell.html),
11+
behaves differently from the original Fortran 77 implementation by [M. J. D. Powell](https://www.zhangzk.net/powell.html),
1212
even though the algorithms are essentially the same. Therefore, it is important to point out that you are using
1313
PRIMA rather than the original solvers if you want your results to be reproducible.
1414

0 commit comments

Comments
 (0)