Skip to content

Commit 3c5d2d3

Browse files
authored
Update Dockerfile to build ModEM with CMake and change CMake output directory (#43)
This Commit updates the Dockerfile so that it builds each of the ModEM forward formulations using CMake. This will help to test both the configure build chain and the new ModEM build chain. In the Dockerfile, it runs the cmake build in `/home/modem/modem-build`. This commit also updates the CMake ModEM build so that the exectuables no longer are generated in the `$CMAKE_BINARY_DIR/f90/` directory and are instead just in the top level `$CMAKE_BINARY_DIR` directory.
1 parent 5cd6d48 commit 3c5d2d3

4 files changed

Lines changed: 28 additions & 9 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ set(SUPPORTED_FORWARD_FORMULATIONS "MF;SP;SP2")
2525
set(SUPPORTED_MODEM_DIMS "2D;3D")
2626
set(SUPPORTED_GPU_OPTS "off;OFF;CUDA;HIP")
2727

28+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
29+
2830
if (USE_C_TIMERS)
2931
enable_language(C)
3032
endif()

Dockerfile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ RUN apt-get -y install valgrind
99
RUN apt-get -y install libblas-dev
1010
RUN apt-get -y install liblapack-dev
1111
RUN apt-get -y install make
12+
RUN apt-get -y install cmake
1213
RUN apt-get -y install wget
1314
RUN apt-get -y install python3
1415
RUN apt-get -y install python3-pip
1516
RUN apt-get -y install pipx
1617
RUN apt-get -y install vim
1718
RUN apt-get -y install git
1819
RUN apt-get -y install openmpi-bin openmpi-common libopenmpi-dev
20+
21+
# Create a ModEM user and give them sudo access
22+
# so it's easier for people to install things
23+
RUN apt-get -y install sudo
1924
RUN useradd -m -r -g users -s /bin/bash modem
25+
RUN adduser modem sudo
26+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
2027

2128
ENV LD_LIBRARY_PATH=/usr/local/lib/
2229
# For Python Installs
@@ -29,9 +36,16 @@ RUN chgrp -R users /home/modem/ModEM
2936
USER modem
3037
WORKDIR /home/modem/ModEM/f90
3138

32-
# Make SP2 MPI
39+
# Make MF, SP and SP2 using Configure
3340
RUN ./CONFIG/configure -m mpi -l MF -g release Makefile gfortran && make && mv Mod3DMT Mod3DMT_MF && make clean
3441
RUN ./CONFIG/configure -m mpi -l SP -g release Makefile gfortran && make && mv Mod3DMT Mod3DMT_SP && make clean
3542
RUN ./CONFIG/configure -m mpi -l SP2 -g release Makefile gfortran && make && mv Mod3DMT Mod3DMT_SP2 && make clean
3643

37-
WORKDIR /home/modem/
44+
# Make MF, SP and SP2 Using CMake
45+
RUN mkdir -p /home/modem/modem-build
46+
WORKDIR /home/modem/modem-build
47+
RUN cmake ~/ModEM -DCMAKE_Fortran_COMPILER=mpifort -DCMAKE_C_COMPILER=mpicc -DFORWARD_FORMULATION=MF && make
48+
RUN cmake ~/ModEM -DCMAKE_Fortran_COMPILER=mpifort -DCMAKE_C_COMPILER=mpicc -DFORWARD_FORMULATION=SP && make
49+
RUN cmake ~/ModEM -DCMAKE_Fortran_COMPILER=mpifort -DCMAKE_C_COMPILER=mpicc -DFORWARD_FORMULATION=SP2 && make
50+
51+
WORKDIR /home/modem/

docs/source/building_with_cmake.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,17 @@ written successfully, you'll be able to call ``make`` and build ModEM:
164164
[100%] Linking Fortran executable Mod3DMT
165165
[100%] Built target Mod3DMT
166166
167-
The ``Mod3DMT`` will then be placed in the f90 file inside your build directory,
168-
which you will be able to run as normal.
167+
The ModEM executables will be placed in the root of your build directory. They
168+
are appended with the name of the forward formulation use: ``Mod3DMT_MF,
169+
Mod3DMT_SP, Mod3DMT_SP2``. By default, the CMake build will build
170+
``Mod3DMT_SP2``.
169171

170172

171173
Options - Different configurations
172174
----------------------------------
173175

174-
You can build different ModEM configurations by specifying different options when calling
175-
``cmake``:
176+
You can build different ModEM configurations by specifying different options
177+
when calling ``cmake``:
176178

177179
Again, once can use the following to display all the available options:
178180

@@ -205,7 +207,8 @@ You can specify them on the command line by doing the following during the ``cma
205207
206208
.. warning::
207209

208-
The ModEM CMake build can only build the 3D version of ModEM and cannot build the 2D version.
210+
The ModEM CMake build can only build the 3D version of ModEM and cannot
211+
build the 2D version at this time.
209212

210213
.. _findlapack_n_blas:
211214

docs/source/getting_started.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ Normally, when running a docker container, the data created inside the container
353353
will be deleted when the container terminates. To prevent this, we can use a
354354
mount.
355355

356-
Mounting will allow your local ModEM code direcotry to be mounted into the
356+
Mounting will allow your local ModEM code directory to be mounted into the
357357
docker container. That way any change you make in one will be reflected on the
358358
other.
359359

@@ -426,7 +426,7 @@ Specifying mounts points
426426
https://docs.docker.com/engine/storage/bind-mounts/.
427427

428428
You may want to add additional mounts in your docker container. For example, you
429-
might want to include the ModEM-Examples direcotry:
429+
might want to include the ModEM-Examples directory:
430430

431431
.. code-block:: bash
432432

0 commit comments

Comments
 (0)