diff --git a/autotest/test_cli_cmds.py b/autotest/test_cli_cmds.py index b82aaf4..661bd72 100644 --- a/autotest/test_cli_cmds.py +++ b/autotest/test_cli_cmds.py @@ -53,6 +53,21 @@ def test_make_program(function_tmpdir, target: str) -> None: run_cli_cmd(cmd) +@flaky(max_runs=RERUNS) +@pytest.mark.dependency(name="make_program") +@pytest.mark.base +def test_make_program_double(function_tmpdir) -> None: + cmd = [ + "make-program", + "mf2005", + "--double", + "--verbose", + "--appdir", + str(function_tmpdir), + ] + run_cli_cmd(cmd) + + @pytest.mark.dependency(name="make_program_all") @pytest.mark.schedule def test_make_program_all(module_tmpdir) -> None: diff --git a/docs/build_apps.md b/docs/build_apps.md index 12b15b9..62b89df 100644 --- a/docs/build_apps.md +++ b/docs/build_apps.md @@ -7,33 +7,31 @@ and options can be determined by executing: ```console $ make-program --help -usage: make-program [-h] [--release_precision] - [-fc {ifort,mpiifort,gfortran,none}] - [-cc {gcc,clang,clang++,icc,icl,mpiicc,g++,cl,none}] [-dr] - [-ff FFLAGS] [-cf CFLAGS] [-ad APPDIR] [-v] [--keep] - [--zip ZIP] [--meson] +usage: make-program [-h] [-fc {ifort,mpiifort,gfortran,none}] + [-cc {gcc,clang,clang++,icc,icl,mpiicc,g++,cl,none}] + [-dbl] [-dr] [-ff FFLAGS] [-cf CFLAGS] [-ad APPDIR] [-v] + [--keep] [--zip ZIP] [--meson] targets Download and build USGS MODFLOW and related programs. positional arguments: - targets Program(s) to build. Options: crt, gridgen, libmf6, - mf2000, mf2005, mf6, mflgr, mfnwt, mfusg, mfusg_gsi, - mp6, mp7, mt3dms, mt3dusgs, sutra, swtv4, triangle, - vs2dt, zbud6, zonbud3, zonbudusg, :. Specifying the - target to be ':' will build all of the programs. + targets Program(s) to build. Options: crt, gridgen, gsflow, + libmf6, mf2000, mf2005, mf6, mflgr, mfnwt, mfusg, + mfusg_gsi, mp6, mp7, mt3dms, mt3dusgs, sutra, swtv4, + triangle, vs2dt, zbud6, zonbud3, zonbudusg, :. + Specifying the target to be ':' will build all of the + programs. Multiple targets can be specified by + separating individual targets by a comma (i.e., + mf6,zbud6). -optional arguments: +options: -h, --help show this help message and exit - --release_precision If release_precision is False, then the release - precision version will be compiled along with a double - precision version of the program for programs where - the standard_switch and double_switch in - usgsprograms.txt is True. default is True. -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) + -dbl, --double Force double precision. (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) @@ -64,6 +62,9 @@ Examples: Download and compile triangle in the ./temp subdirectory: $ make-program triangle --appdir temp + Download and compile double precision versions of mf2005 and mfusg + $ make-program mf2005,mfusg --double + Download and compile all programs in the ./temp subdirectory: $ make-program : --appdir temp diff --git a/pymake/cmds/build.py b/pymake/cmds/build.py index 7d2a723..297674d 100755 --- a/pymake/cmds/build.py +++ b/pymake/cmds/build.py @@ -17,27 +17,33 @@ "targets", "appdir", "verbose", - "release_precision", "fc", "cc", "fflags", "cflags", + "double", "verbose", "zip", "keep", "dryrun", "meson", ) + +# command arguments (sys.argv) to pop from ARGS COM_ARG_KEYS = ( "fc", "cc", "fflags", "cflags", + "double", "zip", "keep", "dryrun", ) +# ARGS to keep and pass to build_apps() +KEEP_ARG_KEYS = ("double",) + def main() -> None: """Command line interface @@ -60,6 +66,9 @@ def main() -> None: Download and compile triangle in the ./temp subdirectory: $ {prog} triangle --appdir temp + Download and compile double precision versions of mf2005 and mfusg + $ {prog} mf2005,mfusg --double + Download and compile all programs in the ./temp subdirectory: $ {prog} : --appdir temp """ @@ -75,16 +84,8 @@ def main() -> None: "Program(s) to build. Options:\n " + ", ".join(all_targets) + ". Specifying the target to be ':' will " - + "build all of the programs." - ) - - release_precision_help = ( - "If release_precision is False, then the " - + "release precision version will be compiled " - + "along with a double precision version of " - + "the program for programs where the standard_" - + "switch and double_switch in " - + "usgsprograms.txt is True. default is True." + + "build all of the programs. Multiple targets can be specified " + + "by separating individual targets by a comma (i.e., mf6,zbud6)." ) # command line arguments specific to make-program @@ -96,13 +97,6 @@ def main() -> None: "choices": None, "action": None, }, - "release_precision": { - "tag": ("--release_precision",), - "help": release_precision_help, - "default": False, - "choices": None, - "action": "store_true", - }, } # add standard command line arguments to parser dictionary for make-program @@ -138,7 +132,8 @@ def main() -> None: # delete arguments that are used by Pymake() class in build_apps for key in arg_key_pop: - del args[key] + if key not in KEEP_ARG_KEYS: + del args[key] # remove args from command line arguments for key in com_arg_pop: diff --git a/pymake/pymake_build_apps.py b/pymake/pymake_build_apps.py index a76e526..95e48ee 100644 --- a/pymake/pymake_build_apps.py +++ b/pymake/pymake_build_apps.py @@ -41,7 +41,7 @@ def build_apps( download_dir=None, appdir=None, verbose=None, - release_precision=True, + double=False, meson=False, mesondir=".", clean=True, @@ -52,19 +52,15 @@ def build_apps( ---------- targets : str or list of str targets to build. If targets is None, all current targets will - be build. Default is None + be built. Default is None pymake_object : Pymake() Pymake object created outside of build_apps download_dir : str download directory path appdir : str target path - release_precision : bool - boolean indicating if only the release precision version should be - build. If release_precision is False, then the release precision - version will be compiled along with a double precision version of - the program for programs where the standard_switch and double_switch - in usgsprograms.txt is True. default is True. + double : bool + force double precision. (default is False) meson : bool boolean indicating that the executable should be built using the meson build system. (default is False) @@ -92,7 +88,7 @@ def build_apps( targets = usgs_program_data.get_keys(current=True) else: if isinstance(targets, str): - targets = [targets] + targets = targets.split(",") code_dict = {} @@ -221,16 +217,19 @@ def build_apps( ) # determine if single, double, or both should be built - precision = usgs_program_data.get_precision(target) + prog_precision = usgs_program_data.get_precision(target) # just build the first precision in precision list if - # standard_precision is True - if release_precision: - precision = precision[0:1] + # reset prog_precision if double + if double: + prog_precision = ["double"] - for double in precision: + for precision_str in prog_precision: # set double flag - pmobj.double = double + if precision_str == "double": + pmobj.double = True + else: + pmobj.double = False # determine if the target should be built build_target = pmobj.set_build_target_bool( diff --git a/pymake/utils/usgsprograms.py b/pymake/utils/usgsprograms.py index 23bfba6..792149c 100644 --- a/pymake/utils/usgsprograms.py +++ b/pymake/utils/usgsprograms.py @@ -248,9 +248,9 @@ def get_precision(key): target = usgs_program_data().get_target(key) precision = [] if target.standard_switch: - precision.append(False) + precision.append("default") if target.double_switch: - precision.append(True) + precision.append("double") return precision @staticmethod