Compiling MODFLOW on linux

215 views
Skip to first unread message

Ida Lunde Hygum

unread,
Aug 29, 2022, 11:46:03 AM8/29/22
to MODFLOW Users Group
Hi!
I have tried to compile Modflow 6 (mf6.3.0) on Linux (Ubuntu 20.04.4 LTS). I know this is a question that has come up several times and I have looked at the answers (for example this: https://groups.google.com/g/modflow/c/Wg_t5usfIV0/m/1uq8sm0eEAAJ and this: https://groups.google.com/g/modflow/c/3qr0cn6GaMU) but still I am not able to get Modflow 6 to run. I am also a Linux beginner, so it is very likely I can have missed something.  

So fare I have tried following this guide:
https://www.simonwenkel.com/notes/geo/software/modflow/compiling-MODFLOW-on-linux.html . Here I download Modflow 6 and unzip it the as done in the guide but with the latest Modlfow release:

$ mkdir MODFLOW
$ cd MODFLOW
$ 7z x mf6.3.0.zip

This worked until I run the next command:
$ cd make
$ make

Which just returned this error message:
mkdir -p .
mkdir -p mod_temp
make: *** No rule to make target 'obj_temp/ilut.o', needed by 'mf6'.  Stop.

This does not create the obj_temp folder as what is explained in the guide, so I am not able to run "$ ./mf6".

After this I tried some other ways to compile Modflow 6, one of them was pymake, both through the command line (as described in this guide: https://sbhgeo.wordpress.com/2017/07/20/modflow-2000-installation-instructions-for-linux/ but with mf6 instead of mf2000) and by using the python script given at https://github.com/modflowpy/pymake:

import pymake
pm = pymake.Pymake()
pm.srcdir = '../src' #I changed the path here to where i downloaded Modflow 6 to
pm.target = 'mf6'
pm.include_subdirs = True
pm.build()

When running the pymake script I did change the src path so that it points to the right directory. The command did go through without any error messages and created the obj_temp directory with a range of files with the extension "*file*.o", which I read are windows executable files. This looks something like this:

...
 -rw-rw-r--  1 userid 16328 aug 29 14:41 ArrayHandlers.o
-rw-rw-r--  1 userid  39232 aug 29 14:41 ArrayReaders.o
-rw-rw-r--  1 userid  35272 aug 29 14:41 ats.o
-rw-rw-r--  1 userid   3416 aug 29 14:41 BaseExchange.o
-rw-rw-r--  1 userid   4976 aug 29 14:41 BaseGeometry.o
-rw-rw-r--  1 userid   8768 aug 29 14:41 BaseModel.o
-rw-rw-r--  1 userid   2520 aug 29 14:41 BaseSolution.o
....

I changed the access permission of the mf6.o file to (0775/-rwxrwxr-x) and then tried to run it from the directory:

$ ./mf6.o

But then I get this error message:
bash: ./mf6.o: cannot execute binary file: Exec format error

I also tried running flopy in python but it doesn't work (which makes sense since I believe i still haven't managed to compile the program for ubuntu).

Can anybody help with this? Or can give me some advice on how to proceed? It seems easy when following the guides but so fare I haven't been able to make it work.

Any help is greatly appreciated, thanks



Ida Lunde Hygum

unread,
Sep 27, 2022, 12:10:27 PM9/27/22
to MODFLOW Users Group
Hi!
So I finally managed to find somebody who could help me with this. Modflow is now running, though still with some error codes, but it works!
If anybody runs in to the same problem here is what worked for me, which was quite simple:

I edited the file "mf6.3.0/make/makefile".

On the lines that starts with SOURCEDIRX= (approx lines 7-28), I replaced every backslash with a slash. Once I did that I could compile Modflow.

Hope it is of some help!

jonghyun....@gmail.com

unread,
Oct 7, 2022, 12:07:58 AM10/7/22
to MODFLOW Users Group
I haven't test on Ubuntu 20.04.4 LTS but the python script below works on 18.04 LTS. You don't need to download the source code from the website. 
pymake.build_apps method will download and compile the source code automatically (pymake will modify the code based on your operating system as far as I understand). 

```
import pymake
pymake.build_apps('mf6')
```

Here is a Colab example tested on Ubuntu 18.04.6 LTS (through Colab)
  

Best,
Harry 

Jonghyun Harry Lee, Ph.D.
Associate Professor
Department of Civil and Environmental Engineering 
Water Resources Research Center 
University of Hawai‘i at Mānoa



Reply all
Reply to author
Forward
0 new messages