Skip to content

Commit 24a4403

Browse files
authored
Add in a single Configuration file which can generate most ModEM Makefiles (#25)
This merge adds in a single configuration file, Configure, which has the ability to generate make files for all solvers, compilers and ModEM build options. There is already a lot of description in the Configure file itself, so no need to re-hash it here, but the goal of this single configure file is to make our lives easier as developers. Rather than making changes to all 30 something configuration files, we now only need to manage one. This Configure file only supports GFortran and Intel Fortran compilers, but could easily be added to support more. Currently, this configuration file does not have the capability to generate HIP/Cuda compatible makefiles. Perhaps that enough is a reason to use a different build system, currently, we are quite limited with building anything that is not a Fortran module. Regardless, this should be easier to maintain, and easier for users to understand. This script does make some assumptions, by default it will use MPI, rather than serial, and will build SP2, if the solver method is not specified. In the future we might want to make more assumptions, or could test to see if the user has specific compilers avaliable, i.e. check for gfortran, ifort, mpifort, but I don't think we have the number of new-users to justify that. We can always make that change if we get feedback that ModEM is hard to configure.
1 parent 2a5e7f2 commit 24a4403

4 files changed

Lines changed: 531 additions & 51 deletions

File tree

README.md

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,35 +83,59 @@ variables of the Makefile.
8383

8484
## Creating Makefiles from Configuration files
8585

86-
The current build system for ModEM uses the `fmkmf.pl` pearl script and the
87-
configuration scripts that are in `f90/CONFIG`. Although ModEM uses Make and
88-
Makefiles, makefiles are meant to be created by these configuration scripts.
86+
The current build system for ModEM uses the `fmkmf.pl` Perl Script and the
87+
configuration scripts that are in `f90/CONFIG`: `f90/CONFIG/Configure`.
88+
Although ModEM uses Make and Makefiles, makefiles are meant to be created by
89+
these configuration scripts.
8990

90-
To create Makefiles, run the configuration scripts that match your system,
91-
desired compiler and desired ModEM version. These configuration scripts
92-
call the `fmkmf.pl` script:
91+
The current build system for ModEM uses the `fmkmf.pl` Perl script and the
92+
configure script, `f90/CONFIG/configure`. Although ModEM uses Make and
93+
Makefiles, makefiles are meant to be generated by `f90/CONFIG/configure` and
94+
not by hand.
95+
96+
To create a new Makefile, run the configuration script and pass in your desired
97+
arguments This configuration scripts call the `fmkmf.pl` script:
9398

9499
``` bash
95100
$ cd f90/
96-
$ ./CONFIG/Configure.3D_MT.MAC.GFortran makefile.gnu.mpi MPI
101+
$ ./CONFIG/configure Makefile gfortran
97102
```
98103

99-
All configuration scripts take the same arguments:
104+
The `configure` scripts has the following usage:
100105

101106
```bash
102-
$ /CONFIG/Configfile <desired-makefile-name> <type>
107+
$ Usage: ./CONFIG/configure [-h] [-u] [-g release|debug] [-m mpi|serial] [-l solver] [-f] makefile-name compiler
108+
-h Display full help message
109+
-u Display this usage message
110+
-g <release | debug> Specify whether to build with debug symbols or not
111+
release - Default - Create Makefile with full optimizations (i.e. -O3)
112+
debug - Create Makefile with debug symbols (i.e. -g) and no optimizations
113+
-m <mpi* | serial> Specify MPI or serial
114+
mpi - Default - Builds with MPI
115+
serial - Builds Serially
116+
-l <MF | SP | SP2> Specify solver
117+
MF - Builds with MF
118+
SP - Builds with SP
119+
SP2 - Default - Builds with SP2
120+
-f Build with the Fine-Grained Parallel Version (-DFG on SP2)
121+
Only available with SP2
122+
-s Build spherical version of ModEM
103123
```
104124

105-
Where `type` is either: `MPI, release, debug`:
125+
### Examples using Configure
126+
127+
A few examples using configure:
106128

107-
* `MPI` - Generates a makefile that will compile an MPI version of ModEM
108-
* `release` - Generates a makefile that will compile a serial version of ModEM
109-
* `debug` - Generates a makefile that will compile a serial version of ModEM
110-
with `-O0` (no optimizations) and debug symbols (`-g`, bounds checking ,etc)
129+
```bash
130+
$ ./CONFIG/configure Makefile gfortran
131+
Generates a Makefile with GFortran options using MPI
111132

112-
Of course, any generated makefile can be altered as you see fit. For instance,
113-
it is often helpful to add the `-g` to compile with debug symbols when working
114-
with an MPI makefile.
133+
$ ./CONFIG/configure -g debug Makefile gfortran
134+
Generates an MPI Makefile with GFortran debugging options
135+
136+
$ ./CONFIG/configure -m serial -l MF Makefile gfortran
137+
Generates a serial Makefile with GFortran with the MF solver
138+
```
115139

116140
## Compiling
117141

docs/source/getting_started.rst

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,8 @@ Configure Scripts
5050
There are a number of configure scripts inside ``./f90/CONFIG`` in the form of
5151
``Configure.***``, ``Configure.SP.***``, ``Configure.3D_MT.**``, etc. These
5252
configure files are considered deprecated, and the ``configure`` script inside
53-
``f90`` should be used instead; however, the deprecated configure scripts are
54-
left for backwards compatibility.
55-
56-
The ``configure`` script inside ``f90`` can be used to generate ModEM makefiles
57-
for various configurations and compilers. This ``configure`` should be used
58-
to generate makefiles for ModEM.
53+
``f90/CONFIG`` should be used instead; however, the deprecated configure
54+
scripts are left for backwards compatibility.
5955

6056
Creating Makefiles from configure
6157
----------------------------------
@@ -78,8 +74,8 @@ Currently, ModEM has three different forwards 'flavors':
7874
.. code-block:: bash
7975
8076
$ cd f90/
81-
$ # By default ./configure creates a SP2 Makefile with MPI
82-
$ ./configure Makefile gfortran
77+
$ # By default ./CONFIG/configure creates a SP2 Makefile with MPI
78+
$ ./CONFIG/configure Makefile gfortran
8379
8480
The Configure scripts has the following usage::
8581

@@ -115,24 +111,24 @@ A few examples using Configure
115111

116112
.. code-block:: bash
117113
118-
$ ./configure Makefile gfortran
114+
$ ./CONFIG/configure Makefile gfortran
119115
$ # Generates a Makefile with GFortran options using MPI
120116
121-
$ ./configure -d debug Makefile ifort
117+
$ ./CONFIG/configure -d debug Makefile ifort
122118
$ # Generates an MPI Makefile with ifort debugging options
123119
124-
$ ./configure -m serial -l MF Makefile gfortran
120+
$ ./CONFIG/configure -m serial -l MF Makefile gfortran
125121
$ # Generates a serial Makefile with GFortran with the MF solver
126122
127-
$ FC=ftn LDFLAGS=-L/home/username/install/lib ./configure Makefile gfortran
123+
$ FC=ftn LDFLAGS=-L/home/username/install/lib ./CONFIG/configure Makefile gfortran
128124
$ # Generates an SP2, MPI capabile makefile, adding LDFLAGS to the link step and
129125
$ # specifies the compiler to be `ftn`.
130126
131-
$ FFLAGS='-mSSE2' ./configure Makefile ifort
127+
$ FFLAGS='-mSSE2' ./CONFIG/configure Makefile ifort
132128
$ # Create a SP2, MPI capabile makefile, with ifort/intel compiler options and add
133129
$ # the '-mSSE2' to all compiling steps.
134130
135-
$ LDFLAGS="-L/path/to/install/lib/" ./configure Makefile gfortran
131+
$ LDFLAGS="-L/path/to/install/lib/" ./CONFIG/configure Makefile gfortran
136132
$ # Generates a Makefile with GFortran options using MPI and passes
137133
$ # the location of /path/to/install/lib to the linker step
138134
@@ -145,9 +141,9 @@ by setting the ``FC`` environment variable:
145141

146142
.. code-block:: bash
147143
148-
$ FC=ftn ./configure Makefile gfortran
144+
$ FC=ftn ./CONFIG/configure Makefile gfortran
149145
$ # Or for intel:
150-
$ FC=ftn ./configure Makefile ifort
146+
$ FC=ftn ./CONFIG/configure Makefile ifort
151147
152148
153149
Ensure BLAS and LAPACK are linked
@@ -159,7 +155,7 @@ the linker where to find them. You can specify this when you run configure:
159155

160156
.. code-block:: bash
161157
162-
$ LDFLAGS="-L/path/to/install/lib/" ./configure Makefile gfortran
158+
$ LDFLAGS="-L/path/to/install/lib/" ./CONFIG/configure Makefile gfortran
163159
164160
If you have already created your makefile, you can also add the ``-L``
165161
specification to the ``LIBS_PATH`` of the Macro-Def section of your Makefile:
@@ -377,9 +373,9 @@ Now, we can move into ``~/ModEM-main`` to configure, build and run ModEM:
377373
$ cd ~/ModEM-main
378374
$ cd f90/
379375
$ # Compile with MPI, SP2 solver:
380-
$ ./configure Makefile gfortran
376+
$ ./CONFIG/configure Makefile gfortran
381377
$ # or compile serial, SP2 solver
382-
$ ./configure -m serial Makefile gfortran
378+
$ ./CONFIG/configure -m serial Makefile gfortran
383379
$ make
384380
$ # Run ModEM serially or with MPI:
385381
$ mpiexec -n 2 ./Mod3DMT ...

0 commit comments

Comments
 (0)