Skip to content

Commit

Permalink
a bunch of minor real <-> integer conversions formalised
Browse files Browse the repository at this point in the history
  • Loading branch information
dalekopera committed Jan 27, 2024
1 parent adbb561 commit a3ca003
Show file tree
Hide file tree
Showing 43 changed files with 398 additions and 430 deletions.
8 changes: 8 additions & 0 deletions include/galahad_blas.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifdef GALAHAD_64BIT_INTEGER
#define GALAHAD_BLAS_interface GALAHAD_BLAS_interface_64
#ifdef GALAHAD_NO_UNDERSCORE_64BIT_INTEGER
#define LSAME LSAME64
#define XERBLA XERBLA64
#define DASUM DASUM64
#define DCABS1 DCABS164
#define DDOT DDOT64
Expand Down Expand Up @@ -66,6 +68,8 @@
#define ZTRMV ZTRMV64
#define ZTRSM ZTRSM64
#elif GALAHAD_DOUBLE_UNDERSCORE_64BIT_INTEGER
#define LSAME LSAME__64
#define XERBLA XERBLA__64
#define DASUM DASUM__64
#define DCABS1 DCABS1__64
#define DDOT DDOT__64
Expand Down Expand Up @@ -131,6 +135,8 @@
#define ZTRMV ZTRMV__64
#define ZTRSM ZTRSM__64
#elif GALAHAD_NO_SYMBOL_64BIT_INTEGER
#define LSAME LSAME
#define XERBLA XERBLA
#define DASUM DASUM
#define DCABS1 DCABS1
#define DDOT DDOT
Expand Down Expand Up @@ -196,6 +202,8 @@
#define ZTRMV ZTRMV
#define ZTRSM ZTRSM
#else
#define LSAME LSAME_64
#define XERBLA XERBLA_64
#define DASUM DASUM_64
#define DCABS1 DCABS1_64
#define DDOT DDOT_64
Expand Down
4 changes: 4 additions & 0 deletions include/galahad_lapack.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifdef GALAHAD_64BIT_INTEGER
#define GALAHAD_LAPACK_interface GALAHAD_LAPACK_interface_64
#ifdef GALAHAD_NO_UNDERSCORE_64BIT_INTEGER
#define ILAENV ILAENV64
#define DISNAN DISNAN64
#define DLADIV DLADIV64
#define DLAISN DLAISN64
Expand Down Expand Up @@ -267,6 +268,7 @@
#define ZLARFG ZLARFG64
#define ZLARFT ZLARFT64
#elif GALAHAD_DOUBLE_UNDERSCORE_64BIT_INTEGER
#define ILAENV ILAENV__64
#define DISNAN DISNAN__64
#define DLADIV DLADIV__64
#define DLAISN DLAISN__64
Expand Down Expand Up @@ -533,6 +535,7 @@
#define ZLARFG ZLARFG__64
#define ZLARFT ZLARFT__64
#elif GALAHAD_NO_SYMBOL_64BIT_INTEGER
#define ILAENV ILAENV
#define DISNAN DISNAN
#define DLADIV DLADIV
#define DLAISN DLAISN
Expand Down Expand Up @@ -799,6 +802,7 @@
#define ZLARFG ZLARFG
#define ZLARFT ZLARFT
#else
#define ILAENV ILAENV_64
#define DISNAN DISNAN_64
#define DLADIV DLADIV_64
#define DLAISN DLAISN_64
Expand Down
29 changes: 16 additions & 13 deletions src/clls/clls.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
! THIS VERSION: GALAHAD 4.3 - 2024-01-17 AT 16:10 GMT.
! THIS VERSION: GALAHAD 4.3 - 2024-01-27 AT 16:10 GMT.

#include "galahad_modules.h"

Expand Down Expand Up @@ -2595,7 +2595,7 @@ SUBROUTINE CLLS_solve_main( dims, n, o, m, weight, Ao_val, Ao_row, &
REAL ( KIND = rp_ ) :: one_plus_2_sigma_mu, two_sigma_mu2, two_sigma_mu
REAL ( KIND = rp_ ) :: opt_alpha_guarantee, opt_merit_guarantee
REAL ( KIND = rp_ ) :: stop_p, stop_d, stop_c, two_mu

REAL ( KIND = rp_ ) :: rnbnds, rnbnds_x, rnbnds_c
LOGICAL :: set_printt, set_printi, set_printw, set_printd, set_printe
LOGICAL :: printt, printi, printe, printd, printw, set_printp, printp
LOGICAL :: maxpiv, guarantee, optimal, present_weight
Expand Down Expand Up @@ -3316,6 +3316,9 @@ SUBROUTINE CLLS_solve_main( dims, n, o, m, weight, Ao_val, Ao_row, &
! find the max-norm of the residual

nbnds = nbnds_x + nbnds_c
rnbnds_x = REAL( nbnds_x, KIND = rp_ )
rnbnds_c = REAL( nbnds_c, KIND = rp_ )
rnbnds = REAL( nbnds, KIND = rp_ )
IF ( printi .AND. use_scale_c .AND. m > 0 .AND. &
dims%c_l_start <= dims%c_u_end ) &
WRITE( out, "( A, ' largest/smallest scale factor', 2ES11.4 )" ) &
Expand Down Expand Up @@ -3391,13 +3394,13 @@ SUBROUTINE CLLS_solve_main( dims, n, o, m, weight, Ao_val, Ao_row, &
! record the slackness and the deviation from the central path

IF ( nbnds_x > 0 ) THEN
slknes_x = slknes_x / nbnds_x
slknes_x = slknes_x / rnbnds_x
ELSE
slknes_x = zero
END IF

IF ( nbnds_c > 0 ) THEN
slknes_c = slknes_c / nbnds_c
slknes_c = slknes_c / rnbnds_c
ELSE
slknes_c = zero
END IF
Expand All @@ -3408,7 +3411,7 @@ SUBROUTINE CLLS_solve_main( dims, n, o, m, weight, Ao_val, Ao_row, &
ELSE
gamma_f = one
END IF
slknes = slknes / nbnds
slknes = slknes / rnbnds
gamma_c = control%gamma_c * slkmin / slknes
ELSE
gamma_f = zero ; slknes = zero ; gamma_c = zero
Expand Down Expand Up @@ -5399,7 +5402,7 @@ SUBROUTINE CLLS_solve_main( dims, n, o, m, weight, Ao_val, Ao_row, &

! record the initial slope along the search arc

slope = - ( merit - mu * nbnds )
slope = - ( merit - mu * rnbnds )

! define an interval [alhpa_l,alpha_u] containing the required stepsize

Expand Down Expand Up @@ -5493,11 +5496,11 @@ SUBROUTINE CLLS_solve_main( dims, n, o, m, weight, Ao_val, Ao_row, &
! record the initial slope along the search arc

IF ( arc == 'ZP' ) THEN
slope = - two * ( merit - mu * nbnds ) + tau * res_primal_dual
slope = - two * ( merit - mu * rnbnds ) + tau * res_primal_dual
ELSE IF ( puiseux ) THEN
slope = - two * ( merit - mu * nbnds )
slope = - two * ( merit - mu * rnbnds )
ELSE
slope = - ( merit - mu * nbnds )
slope = - ( merit - mu * rnbnds )
END IF
IF ( printw ) WRITE( out, "( A, ' value and slope = ', 1P, 2D12.4)") &
prefix, merit, slope
Expand Down Expand Up @@ -5754,7 +5757,7 @@ SUBROUTINE CLLS_solve_main( dims, n, o, m, weight, Ao_val, Ao_row, &
Y_u( dims%c_u_start : dims%c_u_end ) )

IF ( nbnds > 0 ) THEN
slknes = slknes / nbnds
slknes = slknes / rnbnds
ELSE
slknes = zero
END IF
Expand Down Expand Up @@ -6071,18 +6074,18 @@ SUBROUTINE CLLS_solve_main( dims, n, o, m, weight, Ao_val, Ao_row, &
MAXVAL( - Y_u( dims%c_u_start : dims%c_u_end ) ) )

IF ( nbnds_x > 0 ) THEN
slknes_x = slknes_x / nbnds_x
slknes_x = slknes_x / rnbnds_x
ELSE
slknes_x = zero
END IF

IF ( nbnds_c > 0 ) THEN
slknes_c = slknes_c / nbnds_c
slknes_c = slknes_c / rnbnds_c
ELSE
slknes_c = zero
END IF
IF ( nbnds > 0 ) THEN
slknes = slknes / nbnds
slknes = slknes / rnbnds
inform%complementary_slackness = slknes
ELSE
slknes = zero
Expand Down
47 changes: 26 additions & 21 deletions src/cqp/cqp.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
! THIS VERSION: GALAHAD 4.3 - 2024-01-17 AT 16:10 GMT.
! THIS VERSION: GALAHAD 4.3 - 2024-01-27 AT 16:10 GMT.

#include "galahad_modules.h"

Expand Down Expand Up @@ -3358,7 +3358,7 @@ SUBROUTINE CQP_solve_main( dims, n, m, A_val, A_col, A_ptr, &
REAL ( KIND = rp_ ) :: one_plus_2_sigma_mu, two_sigma_mu2, two_sigma_mu
REAL ( KIND = rp_ ) :: opt_alpha_guarantee, opt_merit_guarantee
REAL ( KIND = rp_ ) :: stop_p, stop_d, stop_c, two_mu

REAL ( KIND = rp_ ) :: rnbnds, rnbnds_x, rnbnds_c
LOGICAL :: set_printt, set_printi, set_printw, set_printd, set_printe
LOGICAL :: printt, printi, printe, printd, printw, set_printp, printp
LOGICAL :: maxpiv, stat_required, guarantee, unbounded, lbfgs
Expand Down Expand Up @@ -4125,6 +4125,9 @@ SUBROUTINE CQP_solve_main( dims, n, m, A_val, A_col, A_ptr, &
! find the max-norm of the residual

nbnds = nbnds_x + nbnds_c
rnbnds_x = REAL( nbnds_x, KIND = rp_ )
rnbnds_c = REAL( nbnds_c, KIND = rp_ )
rnbnds = REAL( nbnds, KIND = rp_ )
IF ( printi .AND. use_scale_c .AND. m > 0 .AND. &
dims%c_l_start <= dims%c_u_end ) &
WRITE( out, "( A, ' largest/smallest scale factor', 2ES11.4 )" ) &
Expand Down Expand Up @@ -4200,13 +4203,13 @@ SUBROUTINE CQP_solve_main( dims, n, m, A_val, A_col, A_ptr, &
! record the slackness and the deviation from the central path

IF ( nbnds_x > 0 ) THEN
slknes_x = slknes_x / nbnds_x
slknes_x = slknes_x / rnbnds_x
ELSE
slknes_x = zero
END IF

IF ( nbnds_c > 0 ) THEN
slknes_c = slknes_c / nbnds_c
slknes_c = slknes_c / rnbnds_c
ELSE
slknes_c = zero
END IF
Expand All @@ -4217,7 +4220,7 @@ SUBROUTINE CQP_solve_main( dims, n, m, A_val, A_col, A_ptr, &
ELSE
gamma_f = one
END IF
slknes = slknes / nbnds
slknes = slknes / rnbnds
gamma_c = control%gamma_c * slkmin / slknes
ELSE
gamma_f = zero ; slknes = zero ; gamma_c = zero
Expand Down Expand Up @@ -4622,10 +4625,10 @@ SUBROUTINE CQP_solve_main( dims, n, m, A_val, A_col, A_ptr, &
IF ( inform%feasible .AND. Hessian_kind == 0 .AND. &
gradient_kind == 0 ) THEN
IF ( inform%potential < control%potential_unbounded * &
( ( dims%x_l_end - dims%x_free ) + &
( n - dims%x_u_start + 1 ) + &
( dims%c_l_end - dims%c_l_start + 1 ) + &
( dims%c_u_end - dims%c_u_start + 1 ) ) ) THEN
REAL( ( dims%x_l_end - dims%x_free ) + &
( n - dims%x_u_start + 1 ) + &
( dims%c_l_end - dims%c_l_start + 1 ) + &
( dims%c_u_end - dims%c_u_start + 1 ), KIND = rp_ ) ) THEN
inform%status = GALAHAD_error_no_center ; GO TO 600
END IF

Expand Down Expand Up @@ -6420,7 +6423,7 @@ SUBROUTINE CQP_solve_main( dims, n, m, A_val, A_col, A_ptr, &

! record the initial slope along the search arc

slope = - ( merit - mu * nbnds )
slope = - ( merit - mu * rnbnds )

! define an interval [alhpa_l,alpha_u] containing the required stepsize

Expand Down Expand Up @@ -6515,11 +6518,11 @@ SUBROUTINE CQP_solve_main( dims, n, m, A_val, A_col, A_ptr, &
! record the initial slope along the search arc

IF ( arc == 'ZP' ) THEN
slope = - two * ( merit - mu * nbnds ) + tau * res_primal_dual
slope = - two * ( merit - mu * rnbnds ) + tau * res_primal_dual
ELSE IF ( puiseux ) THEN
slope = - two * ( merit - mu * nbnds )
slope = - two * ( merit - mu * rnbnds )
ELSE
slope = - ( merit - mu * nbnds )
slope = - ( merit - mu * rnbnds )
END IF
IF ( printw ) WRITE( out, "( A, ' value and slope = ', 1P, 2D12.4)") &
prefix, merit, slope
Expand Down Expand Up @@ -6778,7 +6781,7 @@ SUBROUTINE CQP_solve_main( dims, n, m, A_val, A_col, A_ptr, &
Y_u( dims%c_u_start : dims%c_u_end ) )

IF ( nbnds > 0 ) THEN
slknes = slknes / nbnds
slknes = slknes / rnbnds
ELSE
slknes = zero
END IF
Expand Down Expand Up @@ -7165,18 +7168,18 @@ SUBROUTINE CQP_solve_main( dims, n, m, A_val, A_col, A_ptr, &
MAXVAL( - Y_u( dims%c_u_start : dims%c_u_end ) ) )

IF ( nbnds_x > 0 ) THEN
slknes_x = slknes_x / nbnds_x
slknes_x = slknes_x / rnbnds_x
ELSE
slknes_x = zero
END IF

IF ( nbnds_c > 0 ) THEN
slknes_c = slknes_c / nbnds_c
slknes_c = slknes_c / rnbnds_c
ELSE
slknes_c = zero
END IF
IF ( nbnds > 0 ) THEN
slknes = slknes / nbnds
slknes = slknes / rnbnds
inform%complementary_slackness = slknes
ELSE
slknes = zero
Expand Down Expand Up @@ -8907,7 +8910,7 @@ SUBROUTINE CQP_compute_stepsize( dims, n, m, nbnds, order, puiseux, &
! ... and both (x-x_l)_i(z_l)_i - (gamma_c / nbds) * comp >= 0 and
! (x-x_u)_i(z_u)_i - (gamma_c / nbds) * comp >= 0

scomp = comp * gamma_c / nbnds
scomp = comp * gamma_c / REAL( nbnds, KIND = rp_ )

DO i = dims%x_free + 1, dims%x_u_start - 1
IF ( ( X( i ) - X_l( i ) ) * Z_l( i ) < scomp ) THEN
Expand Down Expand Up @@ -9144,7 +9147,7 @@ SUBROUTINE CQP_compute_lmaxstep( dims, n, m, nbnds, X, X_l, X_u, DX, &

! Local variables

REAL ( KIND = rp_ ) :: compc, compl, compq, coef0, coef1, coef2
REAL ( KIND = rp_ ) :: compc, compl, compq, coef0, coef1, coef2, rnbnds
REAL ( KIND = rp_ ) :: coef0_f, coef1_f, coef2_f, root1, root2, tol
REAL ( KIND = rp_ ) :: alpha_max_b, alpha_max_f, alpha, infeas_gamma_f

Expand All @@ -9155,6 +9158,7 @@ SUBROUTINE CQP_compute_lmaxstep( dims, n, m, nbnds, X, X_l, X_u, DX, &
RETURN
END IF
tol = epsmch ** 0.75
rnbnds = REAL( nbnds, KIND = rp_ )

! ================================================
! part to compute alpha_max_b
Expand Down Expand Up @@ -9191,8 +9195,9 @@ SUBROUTINE CQP_compute_lmaxstep( dims, n, m, nbnds, X, X_l, X_u, DX, &

! Scale these coefficients

compc = - gamma_c * coef0_f / nbnds ; compl = - gamma_c * coef1_f / nbnds
compq = - gamma_c * coef2_f / nbnds
compc = - gamma_c * coef0_f / rnbnds
compl = - gamma_c * coef1_f / rnbnds
compq = - gamma_c * coef2_f / rnbnds

! Compute the coefficients for the quadratic expression
! for the individual complementarity
Expand Down
7 changes: 0 additions & 7 deletions src/dum/hsl_ma48d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ subroutine ma48_analyse_double(matrix,factors,control,ainfo,finfo, &
integer(ip_), intent(in), optional :: perm(matrix%m+matrix%n) ! Init perm
integer(ip_), intent(in), optional :: lastcol(matrix%n) ! last cols

integer(ip_), allocatable :: iwork(:)
integer(ip_) :: i,job,k,la,lkeep,m,n,ne,stat,icntl(20),info(20)
real(dp_):: rinfo(10),cntl(10)

IF ( control%lp >= 0 ) WRITE( control%lp, &
"( ' We regret that the solution options that you have ', /, &
& ' chosen are not all freely available with GALAHAD.', /, &
Expand Down Expand Up @@ -202,9 +198,6 @@ subroutine ma48_solve_double(matrix,factors,rhs,x,control,sinfo,trans, &
integer(ip_), optional, intent(in) :: trans
real(dp_), optional :: resid(2)
real(dp_), optional :: error
integer icntl(20),info(20),job,m,n,stat
real(dp_) cntl(10),err(3)
logical(lp_) trans48

IF ( control%lp >= 0 ) WRITE( control%lp, &
"( ' We regret that the solution options that you have ', /, &
Expand Down
7 changes: 0 additions & 7 deletions src/dum/hsl_ma48s.f90
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ subroutine ma48_analyse_single(matrix,factors,control,ainfo,finfo, &
integer(ip_), intent(in), optional :: perm(matrix%m+matrix%n) ! Init perm
integer(ip_), intent(in), optional :: lastcol(matrix%n) ! last cols

integer(ip_), allocatable :: iwork(:)
integer(ip_) :: i,job,k,la,lkeep,m,n,ne,stat,icntl(20),info(20)
real(sp_):: rinfo(10),cntl(10)

IF ( control%lp >= 0 ) WRITE( control%lp, &
"( ' We regret that the solution options that you have ', /, &
& ' chosen are not all freely available with GALAHAD.', /, &
Expand Down Expand Up @@ -202,9 +198,6 @@ subroutine ma48_solve_single(matrix,factors,rhs,x,control,sinfo,trans, &
integer(ip_), optional, intent(in) :: trans
real(sp_), optional :: resid(2)
real(sp_), optional :: error
integer icntl(20),info(20),job,m,n,stat
real(sp_) cntl(10),err(3)
logical(lp_) trans48

IF ( control%lp >= 0 ) WRITE( control%lp, &
"( ' We regret that the solution options that you have ', /, &
Expand Down
2 changes: 0 additions & 2 deletions src/dum/hsl_ma57d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ module hsl_ma57_double
subroutine ma57_initialize(factors,control)
type(ma57_factors), intent(out), optional :: factors
type(ma57_control), intent(out), optional :: control
integer icntl(20),stat
real(dp_) cntl(5)

! Dummy subroutine available with GALAHAD

Expand Down
2 changes: 0 additions & 2 deletions src/dum/hsl_ma57s.f90
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ module hsl_ma57_single
subroutine ma57_initialize(factors,control)
type(ma57_factors), intent(out), optional :: factors
type(ma57_control), intent(out), optional :: control
integer icntl(20),stat
real(sp_) cntl(5)

! Dummy subroutine available with GALAHAD

Expand Down
Loading

0 comments on commit a3ca003

Please sign in to comment.