Skip to content

Commit

Permalink
Merge pull request #40 from jacobwilliams/39-blas
Browse files Browse the repository at this point in the history
External BLAS library
  • Loading branch information
jacobwilliams authored Jan 7, 2024
2 parents 14f0027 + 9a41acf commit 467545c
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 7 deletions.
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@ Updates to the original code include:
* It includes updated versions of some of the third-party routines used in the original code (BLAS, LINPACK, and NNLS).
* Some new features were added to support printing error messages and reporting iterations to the user.
* The user can now specify the max and min `alpha` to use during the line search.
* The user can supply a routine to compute the gradients of the objective function and constriants, or allow the code to estimate them using finite differences (backward, forward, or central).
* The user can supply a routine to compute the gradients of the objective function and constraints, or allow the code to estimate them using finite differences (backward, forward, or central).
* The documentation strings in the code have been converted to [FORD](https://github.com/Fortran-FOSS-Programmers/ford) format, allowing for [nicely formatted documentation](https://jacobwilliams.github.io/slsqp/) to be auto-generated.
* A couple of bug fixes noted elsewhere have been applied.

### License

* The original sourcecode and the modifications are released under a [permissive BSD-style license](https://github.com/jacobwilliams/slsqp/blob/master/LICENSE).

### Building SLSQP

#### **Fortran Package Manager**
Expand Down Expand Up @@ -69,14 +65,28 @@ or, to use a specific version:
slsqp = { git="https://github.com/jacobwilliams/slsqp.git", tag = "1.3.0" }
```

### Development
## Dependencies

* Development continues on [GitHub](https://github.com/jacobwilliams/slsqp).
The library requires some [BLAS](https://netlib.org/blas/) routines, which are included. However, the user may also choose to link to an external BLAS library. This can be done by using the `HAS_BLAS` compiler directive. For example:

```
fpm build --compiler gfortran --flag "-DHAS_BLAS -lblas"
```

However, note that an external BLAS can only be used if the library is compiled with double precision (`real64`) reals.

### Documentation

The latest API documentation can be found [here](https://jacobwilliams.github.io/slsqp/). This was generated from the source code using [FORD](https://github.com/Fortran-FOSS-Programmers/ford).

### License

* The original sourcecode and the modifications are released under a [permissive BSD-style license](https://github.com/jacobwilliams/slsqp/blob/master/LICENSE).

### Development

* Development continues on [GitHub](https://github.com/jacobwilliams/slsqp).

### References

* [Original sourcecode at NETLIB](http://www.netlib.org/toms/733)
Expand Down
58 changes: 58 additions & 0 deletions src/slsqp_support.f90 → src/slsqp_support.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,62 @@ module slsqp_support

public :: daxpy,dcopy,ddot,dnrm2,dscal

#ifdef HAS_BLAS

! linking with an external BLAS library.
! Define the interfaces here. Note that this
! will only work if the `wp` is the same kind
! as used in the BLAS library.

interface
pure subroutine daxpy(n,da,dx,incx,dy,incy)
import :: wp
implicit none
integer,intent(in) :: n
real(wp),intent(in) :: da
real(wp),dimension(*),intent(in) :: dx
integer,intent(in) :: incx
real(wp),dimension(*),intent(inout) :: dy
integer,intent(in) :: incy
end subroutine daxpy
pure subroutine dcopy(n,dx,incx,dy,incy)
import :: wp
implicit none
integer,intent(in) :: n
real(wp),dimension(*),intent(in) :: dx
integer,intent(in) :: incx
real(wp),dimension(*),intent(out) :: dy
integer,intent(in) :: incy
end subroutine dcopy
pure real(wp) function ddot(n,dx,incx,dy,incy)
import :: wp
implicit none
integer,intent(in) :: n
real(wp),dimension(*),intent(in) :: dx
integer,intent(in) :: incx
real(wp),dimension(*),intent(in) :: dy
integer,intent(in) :: incy
end function ddot
pure function dnrm2(n,x,incx) result(norm)
import :: wp
implicit none
integer,intent(in) :: incx
integer,intent(in) :: n
real(wp),dimension(*),intent(in) :: x
real(wp) :: norm
end function dnrm2
pure subroutine dscal(n,da,dx,incx)
import :: wp
implicit none
integer,intent(in) :: n
real(wp),intent(in) :: da
real(wp),dimension(*),intent(inout) :: dx
integer,intent(in) :: incx
end subroutine dscal
end interface

#else

contains
!*******************************************************************************

Expand Down Expand Up @@ -333,6 +389,8 @@ pure subroutine dscal(n,da,dx,incx)
end subroutine dscal
!*******************************************************************************

#endif

!*******************************************************************************
end module slsqp_support
!*******************************************************************************

0 comments on commit 467545c

Please sign in to comment.