GithubHelp home page GithubHelp logo

pymake's Introduction

pymake

Python package for building MODFLOW-based programs from source files.

Version 1.2.10.dev0

PyPI Version Anaconda Version
pymake continuous integration codecov Codacy Badge Documentation Status

This is a python package for compiling MODFLOW-based and other Fortran, C, and C++ programs. The package determines the build order using a directed acyclic graph and then compiles the source files using GNU compilers (gcc, g++, gfortran), Clang compilers (clang, clang++), or the Intel compilers (ifort, icl, icc, mpiifort).

pymake can be run from the command line or it can be called from within python. By default, pymake sets the optimization level, Fortran flags, C/C++ flags, and linker flags that are consistent with those used to compile MODFLOW-based programs released by the USGS.

Note that if gfortran is used to compile MODFLOW-based codes, the openspec.f and FILESPEC.inc (MT3DMS) files will automatically be changed to the following so that binary files are created properly using standard Fortran:

c -- created by pymake.py
CHARACTER*20 ACCESS,FORM,ACTION(2)
DATA ACCESS/'STREAM'/
DATA FORM/'UNFORMATTED'/
DATA (ACTION(I),I=1,2)/'READ','READWRITE'/
c -- end of include file

Command Line Usage

When pymake is installed, a mfpymake (or mfpymake.exe for Windows) program is installed.mfpymake can be used to compile MODFLOW 6 from source files located on your computer directly from the command line using the Intel Fortran compiler ifort from the root directory containing the src subdirectory by specifying:

mfpymake src/ mf6 -mc --subdirs -fc ifort

To see help for running from command line, use the following statement.

mfpymake -h

The help message identifies required positional arguments and optional arguments that can be provided to override default values.

usage: mfpymake [-h] [-fc {ifort,mpiifort,gfortran,none}]
                [-cc {gcc,clang,clang++,icc,icl,mpiicc,g++,cl,none}]
                [-ar {ia32,ia32_intel64,intel64}] [-mc] [-dbl] [-dbg] [-e]
                [-dr] [-sd] [-ff FFLAGS] [-cf CFLAGS] [-sl {-lc,-lm}] [-mf]
                [-md] [-cs COMMONSRC] [-ef EXTRAFILES] [-exf EXCLUDEFILES]
                [-so] [-ad APPDIR] [-v] [--keep] [--zip ZIP] [--inplace]
                [--networkx] [--meson] [--mesondir]
                srcdir target

This is the pymake program for compiling fortran, c, and c++ source
files, such as the source files that come with MODFLOW. The program
works by building a directed acyclic graph of the module dependencies
and then compiling the source files in the proper order.

positional arguments:
  srcdir                Path source directory.
  target                Name of target to create. (can include path)

optional arguments:
  -h, --help            show this help message and exit
  -fc {ifort,mpiifort,gfortran,none}
                        Fortran compiler to use. (default is gfortran)
  -cc {gcc,clang,clang++,icc,icl,mpiicc,g++,cl,none}
                        C/C++ compiler to use. (default is gcc)
  -ar {ia32,ia32_intel64,intel64}, --arch {ia32,ia32_intel64,intel64}
                        Architecture to use for Intel and Microsoft compilers
                        on Windows. (default is intel64)
  -mc, --makeclean      Clean temporary object, module, and source files when
                        done. (default is False)
  -dbl, --double        Force double precision. (default is False)
  -dbg, --debug         Create debug version. (default is False)
  -e, --expedite        Only compile out of date source files. Clean must not
                        have been used on previous build. (default is False)
  -dr, --dryrun         Do not actually compile. Files will be deleted, if
                        --makeclean is used. Does not work yet for ifort.
                        (default is False)
  -sd, --subdirs        Include source files in srcdir subdirectories.
                        (default is None)
  -ff FFLAGS, --fflags FFLAGS
                        Additional Fortran compiler flags. Fortran compiler
                        flags should be enclosed in quotes and start with a
                        blank space or separated from the name (-ff or
                        --fflags) with a equal sign (-ff='-O3'). (default is
                        None)
  -cf CFLAGS, --cflags CFLAGS
                        Additional C/C++ compiler flags. C/C++ compiler flags
                        should be enclosed in quotes and start with a blank
                        space or separated from the name (-cf or --cflags)
                        with a equal sign (-cf='-O3'). (default is None)
  -sl {-lc,-lm}, --syslibs {-lc,-lm}
                        Linker system libraries. Linker libraries should be
                        enclosed in quotes and start with a blank space or
                        separated from the name (-sl or --syslibs) with a
                        equal sign (-sl='-libgcc'). (default is None)
  -mf, --makefile       Create a GNU make makefile. (default is False)
  -md, --makefiledir    GNU make makefile directory. (default is '.')
  -cs COMMONSRC, --commonsrc COMMONSRC
                        Additional directory with common source files.
                        (default is None)
  -ef EXTRAFILES, --extrafiles EXTRAFILES
                        List of extra source files to include in the
                        compilation. extrafiles can be either a list of files
                        or the name of a text file that contains a list of
                        files. (default is None)
  -exf EXCLUDEFILES, --excludefiles EXCLUDEFILES
                        List of extra source files to exclude from the
                        compilation. excludefiles can be either a list of
                        files or the name of a text file that contains a list
                        of files. (default is None)
  -so, --sharedobject   Create shared object or dll on Windows. (default is
                        False)
  -ad APPDIR, --appdir APPDIR
                        Target path that overides path defined target path
                        (default is None)
  -v, --verbose         Verbose output to terminal. (default is False)
  --keep                Keep existing executable. (default is False)
  --zip ZIP             Zip built executable. (default is False)
  --inplace             Source files in srcdir are used directly. (default is
                        False)
  --networkx            Use networkx package to build Directed Acyclic Graph
                        use to determine the order source files are compiled
                        in. (default is False)
  --meson               Use meson to build executable. (default is False)
  --mesondir            meson directory. (default is '.')

Note that the source directory should not contain any bad 
or duplicate source files as all source files in the source 
directory, the common source file directory (srcdir2), and 
the extra files (extrafiles) will be built and linked. 
Files can be excluded by using the excludefiles command 
line switch.

Examples:

Compile MODFLOW 6 from the root directory containing the 
source files in subdirectories in the src/ subdirectory:

$ mfpymake src/ mf6 --subdirs

Compile MODFLOW 6 in the bin subdirectory using the Intel 
Fortran compiler from the root directory containing the source 
files in subdirectories in the the src/ subdirectory:

$ mfpymake src/ mf6 --subdirs -fc ifort --appdir bin

Note that command line arguments for Fortran flags, C/C++ flags, and syslib libraries should be enclosed in quotes and start with a space prior to the first value (-ff ' -O3') or use an equal sign separating the command line argument and the values (-ff='-O3'). The command line argument to use an -O3 optimization level when compiling MODFLOW 6 with the ifort compiler would be:

mfpymake src/ mf6 -mc --subdirs -fc ifort -ff='-O3'

From Python

Script to compile MODFLOW 6

When using the pymake object (Pymake()) only the positional arguments (srcdir, target) need to be specified in the script.

import pymake

pm = pymake.Pymake()
pm.srcdir = '../src'
pm.target = 'mf6'
pm.include_subdirs = True
pm.build()

It is suggested that optional variables required for successful compiling and linking be manually specified in the script to mininimize the potential for unsuccessful builds. For MODFLOW 6, subdirectories in the src subdirectory need to be included and 'pm.include_subdirs = True' has been specified in the script. Custom optimization levels and compiler flags could be specified to get consistent builds.

Non-default values for the optional arguments can specified as command line arguments. For example, MODFLOW 6 could be compiled using Intel compilers instead of the default GNU compilers with the script listed above by specifying:

python mymf6script.py -fc ifort -cc icc

Automatic Download and Build

When pymake is installed, a make-program (or make-program.exe for Windows) program is installed. make-program can be used to build MODFLOW 6, MODFLOW-2005, MODFLOW-NWT, MODFLOW-USG, MODFLOW-LGR, MODFLOW-2000, MODPATH 6, MODPATH 7, GSFLOW, VS2DT, MT3DMS, MT3D-USGS, SEAWAT, GSFLOW, PRMS, and SUTRA. Utility programs CRT, Triangle, and GRIDGEN can also be built. make-program downloads the distribution file (requires an internet connection), unzips the file, sets the pymake settings required to build the program, and compiles the program from the source files. Optional pymake command line arguments can be used to customize the build (-fc, -cc, --fflags, etc.). For example, MODFLOW 6 could be built using intel compilers and an O3 optimization level by specifying:

make-program mf6 -fc=ifort --fflags='-O3'

See pymake Read the Docs for more information.

Installation

To install pymake using pip type:

pip install mfpymake

To install pymake using conda type:

conda install -c conda-forge mfpymake

To install the latest pymake release directly from the git repository type:

pip install https://github.com/modflowpy/pymake/zipball/master

To update your version of pymake with the latest development version from the git repository type:

pip install https://github.com/modflowpy/pymake/zipball/develop --upgrade

pymake's People

Contributors

codacy-badger avatar dependabot[bot] avatar emorway-usgs avatar frankwillmore avatar gyanz avatar hofer-julian avatar jdhughes avatar jdhughes-usgs avatar jlarsen-usgs avatar langevin-usgs avatar mwtoews avatar onnoebbens avatar rabbl avatar timcera avatar wpbonelli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pymake's Issues

directory\ncollect2: error: ld returned 1 exit status

Looking for help with the following error with compiling mf2k_gwt, compiling on Ubuntu 16.04

image

here is the script:

from __future__ import print_function
import os
import shutil
import pymake
from pymake.download import download_and_unzip


def make_mf2k_gwt():

    # get current directory
    dstpth = os.path.join('temp')
    if os.path.exists(dstpth):
        shutil.rmtree(dstpth)
    os.makedirs(dstpth)
    os.chdir(dstpth)

    # Download the MODFLOW-2000 GWT distribution
    url = "https://water.usgs.gov/nrp/gwsoftware/mf2k_gwt/UNIX/mf2k_gwt.src.tar.gz"

    download_and_unzip(url)

    # Set directory name and source directory
    dirname = 'mf2k_gwt'
    srcdir = os.path.join(dirname, 'src')

    # Replace filespec with standard fortran
    l = '''
          CHARACTER*20 ACCESS,FORM,ACTION(2)
          DATA ACCESS/'STREAM'/
          DATA FORM/'UNFORMATTED'/
          DATA (ACTION(I),I=1,2)/'READ','READWRITE'/
    '''
    fn = os.path.join(srcdir, 'openspec.inc')
    f = open(fn, 'w')
    f.write(l)
    f.close()

    fn = os.path.join(srcdir, 'MF2KGMG.h')
    nfn = os.path.join(srcdir, 'mf2kgmg.h')
    os.rename(fn,nfn)

    fn = os.path.join(srcdir, 'CCFD.h')
    nfn = os.path.join(srcdir, 'ccfd.h')
    os.rename(fn,nfn)

    fn = os.path.join(srcdir, 'SOLVERS.h')
    nfn = os.path.join(srcdir, 'solvers.h')
    os.rename(fn,nfn)

    target = 'mf2k_gwt'
    pymake.main(srcdir, target, 'gfortran', 'gcc', makeclean=True,
                expedite=False, dryrun=False, double=True, debug=False)

if __name__ == "__main__":
    make_mf2k_gwt()

pymake-created makefile for building shared lib

Hey guys - Im not sure if Im doing this right, but im trying to get makefile from pymake that I can use to build the shared lib on linux. I added pm.makefile=True in mf6/autotest/build_exes.py.build_mf6_so() and I get a makefile and a makedefault, but they dont make it thru the build (haha - make) - all the objects get compiled, but the linker dies:

/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'

pymake itself has no trouble building. Im sure this is user error - any idea what Im doing wrong?

No gsflow make capabilites?

Hello, as of last year I could make gflow using the make_gsflow.py script, which seems to have left the repository now. I tried using the make-program utility and get the following:

make-program gsflow -fc=gfortran --fflags='-O3'
Traceback (most recent call last):
File "/Users/payton.gardner/soft/FlopyTothDemo/.conda/bin/make-program", line 10, in
sys.exit(main())
^^^^^^
File "/Users/payton.gardner/soft/FlopyTothDemo/.conda/lib/python3.11/site-packages/pymake/cmds/build.py", line 140, in main
build_apps(**args)
File "/Users/payton.gardner/soft/FlopyTothDemo/.conda/lib/python3.11/site-packages/pymake/pymake_build_apps.py", line 146, in build_apps
code_dict[target] = usgs_program_data.get_target(target)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/payton.gardner/soft/FlopyTothDemo/.conda/lib/python3.11/site-packages/pymake/utils/usgsprograms.py", line 198, in get_target
return usgs_program_data()._target_data(key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/payton.gardner/soft/FlopyTothDemo/.conda/lib/python3.11/site-packages/pymake/utils/usgsprograms.py", line 144, in _target_data
raise KeyError(msg)
KeyError: '"gsflow" key does not exist. Available keys: "mf6", "zbud6", "libmf6", "mp7", "mt3dms", "mt3dusgs", "vs2dt", "triangle", "gridgen", "crt", "sutra", "mf2000", "mf2005", "mfusg", "zonbudusg", "swtv4", "mp6", "mflgr", "zonbud3", "mfnwt1.1.4", "mfnwt", "mfusg_gsi"'

Looks, like gsflow is no longer a make target? Is there any reason? If not, can we get the make_gflow.py script back?

Thanks,
Payton

compile error mt3dms mac

I am using a MacBook pro intel architecture and tried to compile mt3dms. I am using gcc10.3. Unfortunatelly, I am getting the following error:

File "/Users/markuszechner/opt/anaconda3/lib/python3.7/site-packages/pymake/pymake.py", line 799, in build
raise FileNotFoundError("could not build {}".format(self.target))
FileNotFoundError: could not build mt3dms

The strange thing is that I can compile mp6, mp7, or mf2005 without any problems - it seems that only mt3dms is causing that issue.

When I used my old MacBook pro (also intel), I was able to install it without any issues - at that time, I used gcc 9.2.0. I tried to go back to 9.2 but homebrew only had 9.3 available. I tried 9.3 but that did not work. I don't know if this is important but I used homebrew to install the gcc versions (brew install gcc). There was one strange thing I realized when installing gcc: Ater I installed version 10 I was able to get the gfortran version (gfortran --version) but when reinstalling 9.3 that command did not work anymore - not sure if that is important.

Thanks a lot for your help!

Stay Safe!

Markus

using pymake without setup.py

Is there some trick to using pymake without having to first run setup.py install? I've got it plumbed up in site-package pth file, but when I import pymake, I get an "ImportError python attempted relative import with no known parent package" coming from the from .dag line in __init__.py.

Help: AssertionError: Target does not exist.

When I run make_mf2005.py I get the following error and the target file 'mf2005dbl' is never created.

Traceback (most recent call last):
File "make_mf2005.py", line 42, in
make_mf2005()
File "make_mf2005.py", line 35, in make_mf2005
assert os.path.isfile(target), 'Target does not exist.'
AssertionError: Target does not exist.

Can you think of any reason(s) why there is no mf2005dbl file? MF2005.1_12.u gets downloaded and placed in a folder 'temp' but I can't think of what is wrong to cause the file never to be written to the path (sorry, newbie)

Could you please offer me the swtv4?

My personal computer is Windows, and I hope to gain an executable file to run my Seawat model on HPC which is based on Linux system.

When I run the example file (make_swtv4.py) on my personal computer, there comes an error, and I don't know how to deal with it. So can someone offer me the swtv4 file that can be run on the Linux system?
Thanks for your help!

module directory

Both Intel Fortran (ifort) and Portland Group Fortran (pgfortran) use -module dir to describe the directory where module files files should be placed when created and where they should be searched for.

This is in contrast to GNU Fortran, which uses the -Jdir directive to describe the same feature, and is currently hard-coded to pymake.py

I can think of two ways to address this difference: one in the Makefile using variables, and the other by modifying pymake.py to produce different output depending on the options. (On a related note, I've also been thinking that a PyMake class should be created in pymake.py to provide OOP conveniences in creating objects for (e.g.) GNU and Intel compilers on POSIX or Win32 platforms, or create target rules only if certain source files are found.)

Pymake fails to install if numpy isn't being installed manually first

I get the following error message (I wonder why autotest pops up here at all):

Collecting mfpymake
  Using cached mfpymake-1.2.4.tar.gz (75 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [55 lines of output]
      Traceback (most recent call last):
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\site-packages\setuptools\config.py", line 419, in _parse_attr
          return getattr(StaticModule(module_name), attr_name)
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\site-packages\setuptools\config.py", line 26, in __init__
          spec = importlib.util.find_spec(name)
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\importlib\util.py", line 94, in find_spec
          parent = __import__(parent_name, fromlist=['__path__'])
        File "C:\Users\hofer_jn\AppData\Local\Temp\pip-install-ivzcy3zu\mfpymake_a60fcc056ca94562ba05233ab202b5e5\pymake\__init__.py", line 9, in <module>
          from .autotest.autotest import (
        File "C:\Users\hofer_jn\AppData\Local\Temp\pip-install-ivzcy3zu\mfpymake_a60fcc056ca94562ba05233ab202b5e5\pymake\autotest\autotest.py", line 54, in <module>
          import numpy as np
      ModuleNotFoundError: No module named 'numpy'
     
      During handling of the above exception, another exception occurred:
     
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\hofer_jn\AppData\Local\Temp\pip-install-ivzcy3zu\mfpymake_a60fcc056ca94562ba05233ab202b5e5\setup.py", line 3, in <module>
          setup()
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\site-packages\setuptools\__init__.py", line 155, in setup
          return distutils.core.setup(**attrs)
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\site-packages\setuptools\_distutils\core.py", line 122, in setup
          dist.parse_config_files()
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\site-packages\setuptools\dist.py", line 818, in parse_config_files
          parse_configuration(
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\site-packages\setuptools\config.py", line 158, in parse_configuration
          meta.parse()
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\site-packages\setuptools\config.py", line 498, in parse
          section_parser_method(section_options)
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\site-packages\setuptools\config.py", line 469, in parse_section
          self[name] = value
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\site-packages\setuptools\config.py", line 222, in __setitem__
          value = parser(value)
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\site-packages\setuptools\config.py", line 599, in _parse_version
          version = self._parse_attr(value, self.package_dir)
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\site-packages\setuptools\config.py", line 422, in _parse_attr
          module = importlib.import_module(module_name)
        File "C:\Users\hofer_jn\Anaconda3\envs\xmipy\lib\importlib\__init__.py", line 126, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
        File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
        File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
        File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
        File "<frozen importlib._bootstrap_external>", line 883, in exec_module
        File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
        File "C:\Users\hofer_jn\AppData\Local\Temp\pip-install-ivzcy3zu\mfpymake_a60fcc056ca94562ba05233ab202b5e5\pymake\__init__.py", line 9, in <module>
          from .autotest.autotest import (
        File "C:\Users\hofer_jn\AppData\Local\Temp\pip-install-ivzcy3zu\mfpymake_a60fcc056ca94562ba05233ab202b5e5\pymake\autotest\autotest.py", line 54, in <module>
          import numpy as np
      ModuleNotFoundError: No module named 'numpy'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

compile flag -ffpe-summary isn't available in all gfortran

It appears that after a certain version, -ffpe-summary compiler flag isn't available in gfortran.

mfusg appears to build with gfortran 4.6.3 on ubuntu precise x86_64 with the removal of this flag. I'm not sure what the implications are though.

Trying to use pymake for MODPATH 7: AttributeError: module 'pymake.pymake' has no attribute 'parser'.

When I try to use the makebin.bat file included with Modpath-7 to run run makebin.py I get the error:

args = pymake.pymake.parser()
AttributeError: module 'pymake.pymake' has no attribute 'parser'

When I run pip list it shows that pymake 1.2.1 is installed (it previously wasn't and the output from makebin.py instructed me to do so). Any suggestions for what I might be doing wrong? I was hoping to recompile with this commit included so that I can use MP7 on a grid that didn't meet the unnecessarily strict criteria.

ImportError: cannot import name 'is_exe'

I just tried to install pymake, but unfortunately it didn't work.

I think the line in pymake.py
from flopy import is_exe ...
should be
from flopy.mbase import is_exe ...

Compile seawat4 on Ubuntu 14.04

Hello,

I am trying to use pymake to compile seawat v4 (Ubuntu 14.04.2). Unfortunately I have run into some errors. One I have not been able to resolve yet:

gfortran -O2 -c ./src_temp/parallel/para-mpi.f -o ./obj_temp/para-mpi.o -Iobj_temp -Jmod_temp
./src_temp/parallel/para-mpi.f:15: Error: Can't open included file 'mpif.h'
Traceback (most recent call last):
File "", line 1, in
File "pymake.py", line 342, in main
expedite, dryrun)
File "pymake.py", line 232, in compile_with_gnu
subprocess.check_call(cmdlist)
File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['gfortran', '-O2', '-c', './src_temp/parallel/para-mpi.f', '-o', './obj_temp/para-mpi.o', '-Iobj_temp', '-Jmod_temp']' returned non-zero exit status 1

Any ideas?

Much appreciated.

Regards,
Arjen

autotest functionality

The autotest functionality in pymake will be moved to a separate repository over the next month and will be deprecated in pymake and eventually removed.

The new autotest repository mftestpy will be established the week of 7/27/2020 and no new features will be added once the mftestpy repo is being used in the MODFLOW 6 CI workflow.

Conflict with PyPi pymake?

I am possibly confused. Does is this pymake specific to building modflow and modflow packages, or is it a version of the standard PyPi pymake? I am getting an error that is, in one form or another, most likely version related:

AttributeError: module 'pymake' has no attribute 'build_apps'

So I guess my question is, what is the relationship between modflowpy/pymake and PyPI/pymake (ie, pip install py-make )

Thanks!

python 2.7 with ifort on Linux

In python 2.X, sys.platform returns "linux2" for Linux machines (tested on ubuntu 14.04 LTS).

Current version of pymake.f in line 986:

if platform.lower() == 'darwin' or platform.lower() == 'linux'

returns False for ifort option when using python 2.X on Linux

Hope this helps for your project.

Thanks,
Harry

pymake stalling on windows

@mwtoews, I think some of the recent changes you made for capturing the compile messages is causing a problem on windows. Our builds are stalling with SEAWAT and MF2000, for example. I can run compile.bat just fine from a windows terminal, but python seems to get hung up. We've verified that it happens on a couple of different windows machines. I'm guessing the issue is somewhere in here:

        proc = Popen([batchfile, ], stdout=PIPE, stderr=PIPE)
        while True:
            line = proc.stdout.readline()
            c = line.decode('utf-8')
            if c != '':
                c = c.rstrip('\r\n')
                print('{}'.format(c))
            else:
                break

Could you take a look?

On windows mf2000 exe writes unformatted binary files

The default is not "binary" or STREAM ACCESS. To make mf2000 consistent with the other executables in this repo, the openspec file should be changed so that FORM = 'UNFORMATTED' should be replaced with FORM = 'BINARY' to be consistent with mfnwt and mf2005.

Compile MF-NWT on the mac

I successfully compiled mfnwt on the mac using pymake. I only encountered one issue halting the compilation process:

./src_temp/gwf2swr7_NWT.f:14361.22:

    dt = SECNDS(T1)                                               
                          1

Error: 'x' argument of 'secnds' intrinsic at (1) must be of kind 4

I fixed this by changing the following code in gwf2swr7_NWT.f:

DOUBLEPRECISION, INTENT(INOUT) :: T1
DOUBLEPRECISION, INTENT(INOUT) :: T2
DOUBLEPRECISION, INTENT(INOUT) :: Ts

to

REAL(4), INTENT(INOUT) :: T1
REAL(4), INTENT(INOUT) :: T2
REAL(4), INTENT(INOUT) :: Ts

This issue appears to be exclusive of gfortran. Compiling other MODFLOW packages may generate other errors. To debug the .f files and achieve compilation, check warnings and errors appearing on the terminal window—they do not appear in the ipython notebook. This would be a nice addition to pymake.

Thanks Chris!

Compile mt3d

On Ubuntu cannot find file 'filespec.inc'

change with:

fn = os.path.join(srcdir, 'FILESPEC.INC')

and compiled perfectly

Change filespec.inc in MT3D/SEAWAT BTN file to be lower case

When doing a download and build of SEAWAT or MT3D on linux, would be good to enforce a lowercase naming convention for filespec.inc. This will require programmatically changing the BTN source file to use a lowercase "include filespec.inc" and undoing the upper case filespec.inc change that Joe just made to pymake.

pip install

A clean pymake install no longer downloads the required package subdirectories (.plot/ and .utils/). Probably due to setup.py changes in #98. This is causing flopy ci to fail.

malloc error running mf6.2 on mac

Hi,

I have a problem with mf6.2 on my mac:

I compiled it with pymake_mf6.py, using gfortran 5.2.0

When trying to run a program with the new mf6 I get the message:

mf6(21895,0x7fff77256300) malloc: *** error for object 0x7faeb1e01458: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

Program received signal SIGABRT: Process abort signal.

Backtrace for this error:
#0 0x103b10092
#1 0x103b0f3b0
#2 0x7fff8ba19f19

Can you please help me.

Thanks
Barbara Fleck ([email protected]

urllib.error.ContentTooShortError

It takes several tries for the modflow2000 example, make_mf2000.py, script to download the associated tar.gz file. Link seems fine if downloading in a web-browser though. Took me about 6 tries before I got a successful download. Not sure where the issue is. Pic is of full error code. Thanks
image

pymake installation on mac

The pymake installation on python 2.7 on Mac OS X brings the following error:

$ pip install https://github.com/modflowpy/pymake/zipball/master
Collecting https://github.com/modflowpy/pymake/zipball/master
  Downloading https://github.com/modflowpy/pymake/zipball/master
    Complete output from command python setup.py egg_info:
    pymake graphing capabilities not available.
    running egg_info
    error: Invalid distribution name or version syntax: -main--1.1.0

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /var/folders/l0/k1r1vbqx1hbglfgs2w7z38c40000gn/T/pip-R9so8g-build/

With pip3 it's workign well.

$ pip3 install https://github.com/modflowpy/pymake/zipball/master
Collecting https://github.com/modflowpy/pymake/zipball/master
  Downloading https://github.com/modflowpy/pymake/zipball/master
Installing collected packages: -main-
  Running setup.py install for -main- ... done
Successfully installed -main--1.1.0

compile modflow 2005 on a mac-errors?

Hi. I've compiled MODFLOW 2005 using pymake succesfully, but when I run modflow (using the example model files) I get the following message:

/MF2005.1_11u/test-run/mf2005dbl ; exit;

                              MODFLOW-2005     
U.S. GEOLOGICAL SURVEY MODULAR FINITE-DIFFERENCE GROUND-WATER FLOW MODEL
                         Version 1.11.00 8/8/2013                        

Enter the name of the NAME FILE:
mf2005.1_11u/test-run/bcf2ss
Using NAME file: mf2005.1_11u/test-run/bcf2ss.nam
Run start date and time (yyyy/mm/dd hh:mm:ss): 2015/09/22 22:36:36

*** ERROR OPENING FILE "bcf2ss.ba6" ON UNIT 8
SPECIFIED FILE STATUS: OLD
SPECIFIED FILE FORMAT: FORMATTED
SPECIFIED FILE ACCESS: SEQUENTIAL
SPECIFIED FILE ACTION: READ
-- STOP EXECUTION (SGWF2BAS7OPEN)
logout

[Process completed]

Does anyone have any suggestions for what causes this error message? The compile process ran with 6 warnings, similar to:

./src_temp/mf2kgmg.c:164:29: warning: cast to 'MF2KGMG_operator ' (aka 'struct
MF2KGMG_operator *') from smaller integer type 'int'
[-Wint-to-pointer-cast]
MF2KGMG_operator
GMG_ptr=(MF2KGMG_operator_)_GMGID;

I've also tried compiling using the makefile supplied with the source code, but I end up with the same error message from the compiled MODFLOW executable. I'm using a macbook pro running OSX10.10.

Many thanks.

Pymake() class improvements

A Pymake() class was recently introduced. The class makes it possible to download and build multiple MODFLOW-based programs with the same class. The class is implemented and used in the autotests and by the build_apps method that is used in the examples included in the repository.

Although the Pymake() is being used and tested, feedback on the implementation is welcomed. Pull Requests to improve the class would also be welcomed.

Compile MF-NWT on debian jessie

I'm trying to compile modflow-nwt on debian jessie, but I can't get it work.
I have tried with pymake, but thats not possible (like written in the documentation).

A makefile is not available with the source, so is there a known workaround?

mf2005 not compiling on MacOS Monterey

The new MacOS Monterey broke well running old USGS programs now leaving incomplete output files upon normal termination. This proved to be due to not flushing the file buffers upon ending the program. This is also the case when recompiled with the newest gfortran for MacOS Monterey, hence the problem would lay in the dynamic system libraries that come with the OS. This is solved by adding CALL FLUSH() just before the last END statement in the main program.
Next to this, Apple also broke compiling with Pymake. This is due to 1) the stdio.h and stdlib.h no longer on normal /usr/local/bin or so. It is solved by adding an INCLUDEDIR directive pointing to the right folder. Second, Apple removed the standard libraries like libc.a, libc.so from the file system. They are not win the "dynamic link cache". This turns out to be solved by adding --sysroot compiler directive.

I add the adapted makefiles for both mf2005 and seawat that show the correct arguments. Notice that seawat has more issues, due to the new fortran compiler being more seviere than previous ones, which are also described in the makefile.
makefile_mac_monterey_swt.txt
makefile_mf2005_MacMontery.txt
Compling_issue_analysis.txt

Linux/mingw64 (cross-compiler) fortran

Please find attached a hacked version of the pymake.py file to use the mingw64 toolchain for compiling a windows x64.exe version of MODFLOW using Linux. Here is the general reference for how the mingw64 gfortran differs from standard gfortran (it also has options for the 32-bit versions):

https://sourceforge.net/p/mingw-w64/wiki2/UsingLinuxBinaries/#using-the-cross-compilers-to-generate-windows-32-bit-and-64-bit-binary-executables

Basically, in addition to the prefix for both the gfortran and gcc, in the linker phase needs the -static option, as well as replace the -lc option with either -m64 or -m32.

Don't currently have a clean patch for you.

pymake_w64.py.txt

make swtv4 errors

I had to rename some .h files to get code compiled, so after creating FILESPEC.inc I added the following lines:

Replace #include "solvers.h" with #include "SOLVERS.h"

fn = os.path.join(srcdir, 'SOLVERS.h')
nfn = os.path.join(srcdir, 'solvers.h')
os.rename(fn,nfn)

fn = os.path.join(srcdir, 'MF2KGMG.h')
nfn = os.path.join(srcdir, 'mf2kgmg.h')
os.rename(fn,nfn)

fn = os.path.join(srcdir, 'CCFD.h')
nfn = os.path.join(srcdir, 'ccfd.h')
os.rename(fn,nfn)

gfortran linker - should probably default to "static" option for non-win32

The following code in pymake.py (starting at line 373):

    # syslibs
    syslibs = []
    if sys.platform != 'win32':
        syslibs.append('-lc')

Should probably default to:

    syslibs = []
    if sys.platform != 'win32':
        syslibs.append('-static')
        syslibs.append('-lc')

The difference is that without the -static option, the resulting executable does not bundle the "c library", rather it links to where it is installed on the system.

Without the static it means, that in order to run the executable, you have to install the gfortran development files. Which is fine, but adds a step that requires internet access if you are running a live USB version of Linux.

The difference in executable size between the linked (~2.5MB) and static (~5MB) is IMHO not worth it as a default.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.