Skip to content

Commit 281e9b9

Browse files
authored
Update README with installation instructions (#66)
- add option to enable API rather than relying on a check
1 parent fa4bcbd commit 281e9b9

File tree

5 files changed

+174
-24
lines changed

5 files changed

+174
-24
lines changed

README.md

Lines changed: 153 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Modernized Minpack
77

88
### Description
99

10-
Minpack includes software for solving nonlinear equations and
10+
*Minpack* includes software for solving nonlinear equations and
1111
nonlinear least squares problems. Five algorithmic paths each include
1212
a core subroutine and an easy-to-use driver. The algorithms proceed
1313
either from an analytic specification of the Jacobian matrix or
@@ -16,15 +16,151 @@ systems of equations with a banded Jacobian matrix, for least squares
1616
problems with a large amount of data, and for checking the consistency
1717
of the Jacobian matrix with the functions.
1818

19-
This version is a modernization of the original Fortran 77 code. This is a work in progress. Modifications include:
19+
This version is a modernization of the original Fortran 77 code.
20+
Modifications include:
21+
2022
* Conversion from fixed (`.f`) to free-form (`.f90`) source.
2123
* Modified the tests so they can be automatically run in the [CI](https://github.com/fortran-lang/minpack/actions)
24+
* Implementation of C API for all procedures
25+
* Python bindings to the *minpack* C API
2226

2327
Further updates are planned...
2428

25-
### Decision trees
2629

27-
#### Decision tree for systems of nonlinear equations
30+
### Installation
31+
32+
To build this project from the source code in this repository you need to have
33+
a Fortran compiler supporting Fortran 2008 and one of the supported build systems:
34+
35+
- [fpm](https://fpm.fortran-lang.org) version 0.3.0 or newer
36+
- [meson](https://mesonbuild.com) version 0.55 or newer, with
37+
a build-system backend, *i.e.* [ninja](https://ninja-build.org) version 1.7 or newer
38+
39+
The project is hosted on GitHub and can be obtained by cloning it with
40+
41+
```
42+
git clone https://github.com/fortran-lang/minpack
43+
cd minpack
44+
```
45+
46+
47+
#### Building with fpm
48+
49+
Invoke fpm in the project root with
50+
51+
```
52+
fpm build
53+
```
54+
55+
To run the testsuite use
56+
57+
```
58+
fpm test
59+
```
60+
61+
You can access the *minpack* program programs using the run subcommand
62+
63+
```
64+
fpm run --example --list
65+
```
66+
67+
To use *minpack* in your project include it as dependency in your package manifest
68+
69+
```toml
70+
[dependencies]
71+
minpack.git = "https://github.com/fortran-lang/minpack"
72+
```
73+
74+
75+
#### Building with meson
76+
77+
Optional dependencies are
78+
79+
80+
Setup a build with
81+
82+
```
83+
meson setup _build
84+
```
85+
86+
The following build options can be adjusted:
87+
88+
- the Fortran compiler can be selected by setting the ``FC`` environment variable.
89+
- the installation location can be set with the ``--prefix=/path/to/install`` option
90+
- with the ``-Dpython=true`` option the Python bindings can be built
91+
92+
- Python 3.6 or newer is required with the CFFI package installed
93+
- the actual Python version can be selected using ``-Dpython_version=/path/to/python``
94+
95+
To compile and run the projects testsuite use
96+
97+
```
98+
meson test -C _build --print-errorlogs
99+
```
100+
101+
If the testsuite passes you can install with
102+
103+
```
104+
meson install -C _build
105+
```
106+
107+
This might require administrator access depending on the chosen install prefix.
108+
*Minpack* should now be available on your system, you can check by using the *pkg-config* tool
109+
110+
```
111+
pkg-config --modversion minpack
112+
```
113+
114+
To include *minpack* in your project add the following wrap file to your *subprojects* directory:
115+
116+
```ini
117+
[wrap-git]
118+
directory = minpack
119+
url = https://github.com/fortran-lang/minpack
120+
revision = head
121+
```
122+
123+
You can retrieve the dependency from the wrap fallback with
124+
125+
```meson
126+
minpack_dep = dependency('minpack', fallback: ['minpack', 'minpack_dep'])
127+
```
128+
129+
and add it as dependency to your targets.
130+
131+
132+
#### Supported compilers
133+
134+
The following compilers are known to work with *minpack*.
135+
136+
| Compiler | Version | Platform | Architecture | Minpack version |
137+
| --- | --- | --- | --- | --- |
138+
| GCC | 10.2 | Ubuntu 20.04 | x86\_64 | latest |
139+
| GCC | 10.2 | MacOS 11 | x86\_64 | latest |
140+
| GCC/MinGW | 10.3 | Windows Server 2022 | x86\_64 | latest |
141+
| Intel | 2021.5.0 | Manjaro Linux | x86\_64 | [fa4bcbd] |
142+
| Intel LLVM | 2022.0.0 | Manjaro Linux | x86\_64 | [fa4bcbd] |
143+
| NAG | 7.1 | RHEL | x86\_64 | [fa4bcbd] |
144+
145+
[fa4bcbd]: https://github.com/fortran-lang/minpack/tree/fa4bcbdc7a926a3607e8ff5397ca356a74c50d5a
146+
147+
The combinations annotated with *latest* are tested continuously for this project, for all other results the last commit or tag where this behavior was verified is linked.
148+
A list of tested compilers which are currently not working or only partially working and the respective issue are listed below.
149+
150+
| Compiler | Version | Platform | Architecture | Status |
151+
| --- | --- | --- | --- | --- |
152+
| GCC | 11.1 | MacOS 12 | Arm64 | C-API not supported |
153+
| Nvidia HPC SDK | 22.3 | Manjaro Linux | x86\_64 | Unit tests are failing |
154+
155+
Please share your experience with successful and failing builds for compiler/platform/architecture combinations not covered above.
156+
157+
158+
### Usage
159+
160+
*Minpack* provides a series of solves for systems of nonlinear equations and nonlinear least squares problems.
161+
To select the approriate solver for your problem checkout the diagrams below.
162+
163+
*Decision tree for systems of nonlinear equations*
28164

29165
```mermaid
30166
flowchart TB
@@ -37,7 +173,7 @@ flowchart TB
37173
middle2--No-->b4[<a href='https://fortran-lang.github.io/minpack/proc/hybrd1.html'>hybrd1</a>]
38174
```
39175

40-
#### Decision tree for nonlinear least squares problems
176+
*Decision tree for nonlinear least squares problems*
41177

42178
```mermaid
43179
flowchart TB
@@ -54,14 +190,23 @@ flowchart TB
54190
m2--No-->mr2[<a href='https://fortran-lang.github.io/minpack/proc/lmdif1.html'>lmdif1</a/>]
55191
```
56192

193+
In Fortran projects the above procedures can be made available by including the ``minpack_module``.
194+
Examples can be found in the [example](./example) directory.
195+
196+
To use *minpack* in non-Fortran projects which are compatible with C checkout the [``minpack.h``](./include/minpack.h) header for the available symbols and callback function signatures.
197+
Python bindings are available and documented in the [``python``](./python) subdirectory of this project.
198+
199+
57200
### Documentation
58201

59202
* The API documentation for the latest default branch can be found [here](https://fortran-lang.github.io/minpack/). This is generated by processing the source files with [FORD](https://github.com/Fortran-FOSS-Programmers/ford).
60203

204+
61205
### License
62206

63207
The Minpack source code and related files and documentation are distributed under a permissive free software [license](https://github.com/fortran-lang/minpack/blob/HEAD/LICENSE.txt) (BSD-style).
64208

209+
65210
### History
66211

67212
Minpack has been developed in 1980 by Jorge J. Moré, Burton S. Garbow, Kenneth
@@ -79,6 +224,7 @@ version to use as the community maintained fortran-lang version and decided to
79224
use the latter repository, which became the fortran-lang version. We have
80225
been porting improvements from the former repository over to the new fortran-lang repository.
81226

227+
82228
### Contributors
83229

84230
Many people have contributed to Minpack over the years:
@@ -91,10 +237,12 @@ Many people have contributed to Minpack over the years:
91237
* Jacob Williams
92238
* Sebastian Ehlert
93239

240+
94241
### See also
95242

96243
* [nlesolver-fortran](https://github.com/jacobwilliams/nlesolver-fortran)
97244

245+
98246
### References
99247
* Original sourcecode from: [Netlib](https://www.netlib.org/minpack/)
100248
* J. J. Moré, B. S. Garbow, and K. E. Hillstrom, [User Guide for MINPACK-1](http://cds.cern.ch/record/126569/files/CM-P00068642.pdf), Argonne National Laboratory Report ANL-80-74, Argonne, Ill., 1980.

examples/example_lmder1.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ subroutine fcn(m, n, x, fvec, fjac, ldfjac, iflag)
5656

5757
integer, intent(in) :: m
5858
integer, intent(in) :: n
59+
integer, intent(in) :: ldfjac
5960
real(wp), intent(in) :: x(n)
6061
real(wp), intent(inout) :: fvec(m)
6162
real(wp), intent(inout) :: fjac(ldfjac, n)
62-
integer, intent(in) :: ldfjac
6363
integer, intent(inout) :: iflag
6464

6565
integer :: i

meson.build

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,22 @@ project(
88
'buildtype=debugoptimized',
99
],
1010
)
11-
fc_nested_functions = meson.get_compiler('fortran').run(
12-
'call a(); contains; subroutine a(); print "(a)", "Nested functions supported"; end; end',
13-
).returncode() == 0
14-
if fc_nested_functions
15-
has_cc = add_languages('c', required: get_option('python'), native: false)
16-
else
17-
has_cc = false
18-
if get_option('python')
19-
error('Cannot compile Python API, Fortran compiler does not support nested functions')
20-
else
21-
warning('Fortran compiler does not support nested functions, C API is disabled')
22-
endif
11+
if get_option('api')
12+
has_cc = add_languages('c', native: false)
13+
elif get_option('python')
14+
error('Cannot compile Python API, Fortran compiler does not support nested functions')
15+
endif
16+
17+
srcs = files(
18+
'src/minpack.f90',
19+
)
20+
if get_option('api')
21+
srcs += files('src/minpack_capi.f90')
2322
endif
2423

2524
minpack_lib = library(
2625
meson.project_name(),
27-
sources: files(
28-
'src/minpack.f90',
29-
fc_nested_functions ? 'src/minpack_capi.f90' :,
30-
),
26+
sources: srcs,
3127
install: true,
3228
)
3329

@@ -50,7 +46,7 @@ install_data(
5046
install_dir: get_option('datadir')/'licenses'/meson.project_name()
5147
)
5248

53-
if fc_nested_functions
49+
if get_option('api')
5450
install_headers(
5551
minpack_header,
5652
)

meson_options.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
option(
2+
'api',
3+
type: 'boolean',
4+
value: true,
5+
description: 'Export bindings for the C API',
6+
)
17
option(
28
'python',
39
type: 'boolean',

test/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ foreach t : tests
1919
)
2020
endforeach
2121

22-
if has_cc
22+
if get_option('api')
2323
test(
2424
'c-api',
2525
executable(

0 commit comments

Comments
 (0)