diff --git a/bin/bout-add-mod-path b/bin/bout-add-mod-path index 9faf1be3de..ee7ea66d25 100755 --- a/bin/bout-add-mod-path +++ b/bin/bout-add-mod-path @@ -104,8 +104,7 @@ def create_mod(modulepath, name, top, build): else: prereq = "" with open(filename, "w") as f: - f.write( - f"""#%Module 1.0 + f.write(f"""#%Module 1.0 # # BOUT++ module for use with 'environment-modules' package # Created by bout-add-mod-path v0.9 @@ -119,17 +118,14 @@ setenv BOUT_TOP {top} prepend-path PATH {top}/bin prepend-path PYTHONPATH {top}/tools/pylib prepend-path IDL_PATH +{top}/tools/idllib:'' -""" - ) +""") if build != top: - f.write( - f"""#%Module 1.0 + f.write(f"""#%Module 1.0 setenv BOUT_BUILD {build} prepend-path PATH {build}/bin prepend-path LD_LIBRARY_PATH {build}/lib prepend-path PYTHONPATH {build}/tools/pylib -""" - ) +""") print(f"created `{filename}`") diff --git a/bin/bout-pylib-cmd-to-bin b/bin/bout-pylib-cmd-to-bin index 8f88a5dbf4..8d6dbed7ae 100755 --- a/bin/bout-pylib-cmd-to-bin +++ b/bin/bout-pylib-cmd-to-bin @@ -126,8 +126,7 @@ def createwrapper(mod, func_name, func, name): out += end f.write(out) - fprint( - """#!/usr/bin/env python3 + fprint("""#!/usr/bin/env python3 # PYTHON_ARGCOMPLETE_OK import argparse @@ -136,8 +135,7 @@ try: except ImportError: argcomplete=None -""" - ) +""") doc = True para = False ret = False @@ -183,19 +181,16 @@ except ImportError: arg_help[curarg].append(esc(blas)) # Print functions that are needed if "str_to_slice" in arg_type.values(): - fprint( - """ + fprint(""" def str_to_slice(sstr): args=[] for s in sstr.split(','): args.append(int(s)) print(args) return slice(*args) -""" - ) +""") if "str_to_bool" in arg_type.values(): - fprint( - """ + fprint(""" def str_to_bool(sstr): low=sstr.lower() # no or false @@ -206,8 +201,7 @@ def str_to_bool(sstr): return True else: raise ArgumentTypeError("Cannot parse %s to bool type"%sstr) -""" - ) +""") # Create the parser fprint("parser = argparse.ArgumentParser(%s)" % (esc(docs))) spec = inspect.signature(func) @@ -247,24 +241,19 @@ def str_to_bool(sstr): pre = "\n " fprint(")") - fprint( - """ + fprint(""" if argcomplete: argcomplete.autocomplete(parser) -# late import for faster auto-complete""" - ) +# late import for faster auto-complete""") fprint("from %s import %s" % (mod, func_name)) - fprint( - """ + fprint(""" args = parser.parse_args() # Call the function %s, using command line arguments %s(**args.__dict__) -""" - % (func_name, func_name) - ) +""" % (func_name, func_name)) # alternative, but I think 0o755 is easier to read # import stat # os.chmod(filename,stat.S_IRWXU|stat.S_IRGRP|stat.S_IXGRP|stat.S_IROTH|stat.S_IXOTH) diff --git a/bin/bout-v5-factory-upgrader.py b/bin/bout-v5-factory-upgrader.py index 29fc07db30..ee24572a94 100755 --- a/bin/bout-v5-factory-upgrader.py +++ b/bin/bout-v5-factory-upgrader.py @@ -5,7 +5,6 @@ import difflib import re - # Dictionary of factory methods that may need updating factories = { "Interpolation": { @@ -62,9 +61,7 @@ def find_factory_calls(factory, source): \s*=\s* {factory_name}:: .*{create_method}.* - """.format( - **factory - ), + """.format(**factory), source, re.VERBOSE, ) @@ -75,9 +72,7 @@ def find_type_pointers(factory, source): r""" \b{type_name}\s*\*\s* # Type name and pointer ([\w_]+)\s*; # Variable name - """.format( - **factory - ), + """.format(**factory), source, re.VERBOSE, ) @@ -107,9 +102,7 @@ def fix_declarations(factory, variables, source): (.*?)(class\s*)? # optional "class" keyword \b({type_name})\s*\*\s* # Type-pointer ({variable_name})\s*; # Variable - """.format( - type_name=factory["type_name"], variable_name=variable - ), + """.format(type_name=factory["type_name"], variable_name=variable), r"\1std::unique_ptr<\3> \4{nullptr};", source, flags=re.VERBOSE, @@ -123,9 +116,7 @@ def fix_declarations(factory, variables, source): ({variable_name})\s* # Variable =\s* # Assignment from factory ({factory_name}::.*{create_method}.*); - """.format( - variable_name=variable, **factory - ), + """.format(variable_name=variable, **factory), r"\1auto \4 = \5;", source, flags=re.VERBOSE, @@ -139,9 +130,7 @@ def fix_declarations(factory, variables, source): ({variable_name})\s* # Variable =\s* # Assignment (0|nullptr|NULL); - """.format( - variable_name=variable, **factory - ), + """.format(variable_name=variable, **factory), r"\1std::unique_ptr<\2> \3{nullptr};", source, flags=re.VERBOSE, diff --git a/bin/bout-v5-format-upgrader.py b/bin/bout-v5-format-upgrader.py index 7c7d13ac7f..a534ca240a 100755 --- a/bin/bout-v5-format-upgrader.py +++ b/bin/bout-v5-format-upgrader.py @@ -5,7 +5,6 @@ import difflib import re - format_replacements = { "c": "c", "d": "d", diff --git a/bin/bout-v5-header-upgrader.py b/bin/bout-v5-header-upgrader.py index 49a8fbcbe4..77794ab920 100755 --- a/bin/bout-v5-header-upgrader.py +++ b/bin/bout-v5-header-upgrader.py @@ -9,7 +9,6 @@ from typing import List from subprocess import run - header_shim_sentinel = "// BOUT++ header shim" header_warning = f"""\ @@ -122,8 +121,7 @@ def create_patch(filename, original, modified): if __name__ == "__main__": parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, - description=textwrap.dedent( - """\ + description=textwrap.dedent("""\ Fix deprecated header locations for BOUT++ v4 -> v5 All BOUT++ headers are now under ``include/bout`` and @@ -142,8 +140,7 @@ def create_patch(filename, original, modified): If you have staged changes, this tool will not work, so to avoid committing undesired or unrelated changes. - """ - ), + """), ) parser.add_argument( diff --git a/bin/bout-v5-input-file-upgrader.py b/bin/bout-v5-input-file-upgrader.py index e2940ff58a..ea979005d5 100755 --- a/bin/bout-v5-input-file-upgrader.py +++ b/bin/bout-v5-input-file-upgrader.py @@ -271,8 +271,7 @@ def possibly_apply_patch(patch, options_file, quiet=False, force=False): if __name__ == "__main__": parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, - description=textwrap.dedent( - """\ + description=textwrap.dedent("""\ Fix input files for BOUT++ v5+ Please note that this will only fix input options in sections with @@ -300,8 +299,7 @@ def possibly_apply_patch(patch, options_file, quiet=False, force=False): Files that change in this way will have the "canonicalisation" patch presented first. If you choose not to apply this patch, the "upgrade - fixer" patch will still include it.""" - ), + fixer" patch will still include it."""), ) parser.add_argument("files", action="store", nargs="+", help="Input files") diff --git a/bin/bout-v5-macro-upgrader.py b/bin/bout-v5-macro-upgrader.py index 11b4926255..d644fed9e8 100755 --- a/bin/bout-v5-macro-upgrader.py +++ b/bin/bout-v5-macro-upgrader.py @@ -342,8 +342,7 @@ def create_patch(filename, original, modified): if __name__ == "__main__": parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, - description=textwrap.dedent( - """\ + description=textwrap.dedent("""\ Fix macro defines for BOUT++ v4 -> v5 Please note that this is only slightly better than dumb text replacement. It @@ -359,8 +358,7 @@ def create_patch(filename, original, modified): still replace them in strings or comments. Please check the diff output carefully! - """ - ), + """), ) parser.add_argument("files", action="store", nargs="+", help="Input files") diff --git a/bin/bout-v5-physics-model-upgrader.py b/bin/bout-v5-physics-model-upgrader.py index 26fb8ef6e0..260d1d59ee 100755 --- a/bin/bout-v5-physics-model-upgrader.py +++ b/bin/bout-v5-physics-model-upgrader.py @@ -8,7 +8,6 @@ import textwrap import warnings - PHYSICS_MODEL_INCLUDE = '#include "bout/physicsmodel.hxx"' PHYSICS_MODEL_SKELETON = """ @@ -213,13 +212,11 @@ def fix_bout_constrain(source, error_on_warning): "\n ".join(["{}:{}".format(i, source_lines[i]) for i in line_range]) ) - message = textwrap.dedent( - """\ + message = textwrap.dedent("""\ Some uses of `bout_constrain` remain, but we could not automatically convert them to use `Solver::constraint`. Please fix them before continuing: - """ - ) + """) message += " " + "\n ".join(lines_context) if error_on_warning: @@ -389,8 +386,7 @@ def create_patch(filename, original, modified): if __name__ == "__main__": parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, - description=textwrap.dedent( - """\ + description=textwrap.dedent("""\ Upgrade legacy physics models to use the PhysicsModel class This will do the bare minimum required to compile, and @@ -403,8 +399,7 @@ def create_patch(filename, original, modified): By default, this will use the file name stripped of file extensions as the name of the new class. Use '--name=' to give a different name. - """ - ), + """), ) parser.add_argument("files", action="store", nargs="+", help="Files to fix") diff --git a/bin/bout-v5-xzinterpolation-upgrader.py b/bin/bout-v5-xzinterpolation-upgrader.py index 37c79e0de8..e70c3c54ae 100755 --- a/bin/bout-v5-xzinterpolation-upgrader.py +++ b/bin/bout-v5-xzinterpolation-upgrader.py @@ -54,9 +54,7 @@ def fix_header_includes(old_header, new_header, source): (<|") ({header}) # Header name (>|") - """.format( - header=old_header - ), + """.format(header=old_header), r"\1\2{header}\4".format(header=new_header), source, flags=re.VERBOSE, @@ -67,9 +65,7 @@ def fix_interpolations(old_interpolation, new_interpolation, source): return re.sub( r""" \b{}\b - """.format( - old_interpolation - ), + """.format(old_interpolation), r"{}".format(new_interpolation), source, flags=re.VERBOSE, @@ -120,9 +116,7 @@ def fix_factories(old_factory, new_factory, source): return re.sub( r""" \b{}\b - """.format( - old_factory - ), + """.format(old_factory), r"{}".format(new_factory), source, flags=re.VERBOSE, diff --git a/bin/update_version_number_in_files.py b/bin/update_version_number_in_files.py index ec9a31bc32..3e9758a8c1 100755 --- a/bin/update_version_number_in_files.py +++ b/bin/update_version_number_in_files.py @@ -158,8 +158,7 @@ def create_patch(filename, original, modified): if __name__ == "__main__": parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, - description=textwrap.dedent( - """\ + description=textwrap.dedent("""\ Update the software version number to the specified version, to be given in the form major.minor.patch, e.g. 5.10.3 @@ -172,8 +171,7 @@ def create_patch(filename, original, modified): the 'minor' version number of the provided version will be incremented by 1, e.g. 5.10.3 -> 5.11.3 - """ - ), + """), ) parser.add_argument( diff --git a/src/field/gen_fieldops.py b/src/field/gen_fieldops.py index 29631ff7aa..3e07d6fec4 100755 --- a/src/field/gen_fieldops.py +++ b/src/field/gen_fieldops.py @@ -11,7 +11,6 @@ """ - from __future__ import print_function from builtins import object diff --git a/tests/MMS/GBS/runtest-slab2d b/tests/MMS/GBS/runtest-slab2d index 97c7e11459..221c34e815 100755 --- a/tests/MMS/GBS/runtest-slab2d +++ b/tests/MMS/GBS/runtest-slab2d @@ -11,7 +11,6 @@ from boutdata.collect import collect from numpy import sqrt, max, abs, mean, array, log, concatenate - build_and_log("MMS test") diff --git a/tests/MMS/GBS/runtest-slab3d b/tests/MMS/GBS/runtest-slab3d index f193583e47..45acd53af7 100755 --- a/tests/MMS/GBS/runtest-slab3d +++ b/tests/MMS/GBS/runtest-slab3d @@ -14,7 +14,6 @@ from numpy import sqrt, max, abs, mean, array, log, concatenate import pickle - build_and_log("MMS test") # List of NX values to use diff --git a/tests/MMS/advection/runtest b/tests/MMS/advection/runtest index 1290a4c247..9a0a691287 100755 --- a/tests/MMS/advection/runtest +++ b/tests/MMS/advection/runtest @@ -20,7 +20,6 @@ import pickle import time - if __name__ == "__main__": build_and_log("MMS advection") diff --git a/tests/MMS/diffusion/runtest b/tests/MMS/diffusion/runtest index a25b3519a6..ef6b335f70 100755 --- a/tests/MMS/diffusion/runtest +++ b/tests/MMS/diffusion/runtest @@ -15,7 +15,6 @@ from boutdata.collect import collect from numpy import sqrt, max, abs, mean, array, log - build_and_log("MMS diffusion test") # List of NX values to use diff --git a/tests/MMS/diffusion2/Z/plot_error.py b/tests/MMS/diffusion2/Z/plot_error.py index 5c4e1164c1..4b4b666758 100644 --- a/tests/MMS/diffusion2/Z/plot_error.py +++ b/tests/MMS/diffusion2/Z/plot_error.py @@ -4,6 +4,7 @@ @author: yolen """ + import boutdata import matplotlib.pyplot as plt diff --git a/tests/MMS/diffusion2/runtest b/tests/MMS/diffusion2/runtest index 546be3b2c1..d1b8072fc8 100755 --- a/tests/MMS/diffusion2/runtest +++ b/tests/MMS/diffusion2/runtest @@ -20,7 +20,6 @@ from numpy import sqrt, max, abs, mean, array, log from os.path import join - build_and_log("MMS diffusion test") # List of input directories diff --git a/tests/MMS/fieldalign/runtest.broken b/tests/MMS/fieldalign/runtest.broken index e09fbeccd5..bfb2023c1d 100755 --- a/tests/MMS/fieldalign/runtest.broken +++ b/tests/MMS/fieldalign/runtest.broken @@ -18,7 +18,6 @@ from os.path import join import time - build_and_log("MMS test") # nxlist = [256, 128, 64, 32, 16, 8] # do in reverse order to save disk space diff --git a/tests/MMS/hw/runtest b/tests/MMS/hw/runtest index b6abadc3b9..62740fcbbd 100755 --- a/tests/MMS/hw/runtest +++ b/tests/MMS/hw/runtest @@ -15,7 +15,6 @@ from boutdata.collect import collect from numpy import sqrt, max, abs, mean, array, log, concatenate - build_and_log("MMS test") # List of NX values to use diff --git a/tests/MMS/laplace/runtest b/tests/MMS/laplace/runtest index 98eb62da87..80c8bf08af 100755 --- a/tests/MMS/laplace/runtest +++ b/tests/MMS/laplace/runtest @@ -14,7 +14,6 @@ from boutdata.collect import collect from numpy import sqrt, max, abs, mean, array, log, concatenate - build_and_log("MMS test") # List of NX values to use diff --git a/tests/MMS/spatial/diffusion/runtest b/tests/MMS/spatial/diffusion/runtest index 000cf8f09b..8d4e759d59 100755 --- a/tests/MMS/spatial/diffusion/runtest +++ b/tests/MMS/spatial/diffusion/runtest @@ -22,7 +22,6 @@ from os.path import join import matplotlib.pyplot as plt - build_and_log("MMS diffusion test") # List of input directories diff --git a/tests/MMS/wave-1d-y/runtest b/tests/MMS/wave-1d-y/runtest index 9a4de5a3bb..332d6864b0 100755 --- a/tests/MMS/wave-1d-y/runtest +++ b/tests/MMS/wave-1d-y/runtest @@ -20,7 +20,6 @@ from sys import stdout from numpy import sqrt, max, abs, mean, array, log, concatenate, pi - build_and_log("Making MMS wave test") # List of NX values to use diff --git a/tests/MMS/wave-1d/runtest b/tests/MMS/wave-1d/runtest index f13fb7bd11..1adb7c7d6d 100755 --- a/tests/MMS/wave-1d/runtest +++ b/tests/MMS/wave-1d/runtest @@ -15,7 +15,6 @@ from boutdata.collect import collect from numpy import sqrt, max, abs, mean, array, log, concatenate - build_and_log("Making MMS wave test") # List of NX values to use diff --git a/tests/integrated/test-cyclic/runtest b/tests/integrated/test-cyclic/runtest index 5e31da6239..c68f9b033e 100755 --- a/tests/integrated/test-cyclic/runtest +++ b/tests/integrated/test-cyclic/runtest @@ -17,7 +17,6 @@ from boututils.run_wrapper import build_and_log, shell, launch from boutdata.collect import collect from sys import stdout, exit - build_and_log("Cyclic Reduction test") flags = ["", "nsys=2", "nsys=5 periodic", "nsys=7 n=10"] diff --git a/tests/integrated/test-griddata/runtest b/tests/integrated/test-griddata/runtest index 1c57bf5be7..6aef955023 100755 --- a/tests/integrated/test-griddata/runtest +++ b/tests/integrated/test-griddata/runtest @@ -13,7 +13,6 @@ from boutdata.collect import collect import numpy as np from sys import stdout, exit - build_and_log("griddata test") for nproc in [1]: diff --git a/tests/integrated/test-gyro/runtest b/tests/integrated/test-gyro/runtest index 52ab0de4ab..7a0209fa57 100755 --- a/tests/integrated/test-gyro/runtest +++ b/tests/integrated/test-gyro/runtest @@ -25,7 +25,6 @@ from boutdata.collect import collect import numpy as np from sys import stdout, exit - build_and_log("Gyro-average inversion test") # Read benchmark values diff --git a/tests/integrated/test-invpar/runtest b/tests/integrated/test-invpar/runtest index de7f028528..53f6015fe9 100755 --- a/tests/integrated/test-invpar/runtest +++ b/tests/integrated/test-invpar/runtest @@ -12,7 +12,6 @@ from boututils.run_wrapper import build_and_log, shell, launch from boutdata.collect import collect from sys import stdout, exit - build_and_log("parallel inversion test") flags_src = [ diff --git a/tests/integrated/test-laplace/runtest b/tests/integrated/test-laplace/runtest index e54e46d0d8..d1e9c3d1c9 100755 --- a/tests/integrated/test-laplace/runtest +++ b/tests/integrated/test-laplace/runtest @@ -41,7 +41,6 @@ from boutdata.collect import collect import numpy as np from sys import stdout, exit - build_and_log("Laplacian inversion test") # Read benchmark values diff --git a/tests/integrated/test-multigrid_laplace/runtest b/tests/integrated/test-multigrid_laplace/runtest index 4a7455f80b..f325185c46 100755 --- a/tests/integrated/test-multigrid_laplace/runtest +++ b/tests/integrated/test-multigrid_laplace/runtest @@ -22,7 +22,6 @@ from boututils.run_wrapper import build_and_log, shell, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("multigrid Laplacian inversion test") print("Running multigrid Laplacian inversion test") diff --git a/tests/integrated/test-multigrid_laplace/runtest_multiple_grids b/tests/integrated/test-multigrid_laplace/runtest_multiple_grids index 6817120b13..739d15f7d4 100755 --- a/tests/integrated/test-multigrid_laplace/runtest_multiple_grids +++ b/tests/integrated/test-multigrid_laplace/runtest_multiple_grids @@ -18,7 +18,6 @@ from boututils.run_wrapper import shell, build_and_log, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("Multigrid Laplacian inversion test") print("Running multigrid Laplacian inversion test") diff --git a/tests/integrated/test-multigrid_laplace/runtest_unsheared b/tests/integrated/test-multigrid_laplace/runtest_unsheared index cda68f2167..d0dca3a808 100755 --- a/tests/integrated/test-multigrid_laplace/runtest_unsheared +++ b/tests/integrated/test-multigrid_laplace/runtest_unsheared @@ -18,7 +18,6 @@ from boututils.run_wrapper import shell, build_and_log, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("Making multigrid Laplacian inversion test") print("Running multigrid Laplacian inversion test") diff --git a/tests/integrated/test-naulin-laplace/runtest b/tests/integrated/test-naulin-laplace/runtest index f972eab6cc..145257c23b 100755 --- a/tests/integrated/test-naulin-laplace/runtest +++ b/tests/integrated/test-naulin-laplace/runtest @@ -22,7 +22,6 @@ from boututils.run_wrapper import build_and_log, shell, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("LaplaceNaulin inversion test") print("Running LaplaceNaulin inversion test") diff --git a/tests/integrated/test-naulin-laplace/runtest_multiple_grids b/tests/integrated/test-naulin-laplace/runtest_multiple_grids index c0281c3a4e..f56a80677e 100755 --- a/tests/integrated/test-naulin-laplace/runtest_multiple_grids +++ b/tests/integrated/test-naulin-laplace/runtest_multiple_grids @@ -18,7 +18,6 @@ from boututils.run_wrapper import shell, build_and_log, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("Making LaplaceNaulin inversion test") print("Running LaplaceNaulin inversion test") diff --git a/tests/integrated/test-naulin-laplace/runtest_unsheared b/tests/integrated/test-naulin-laplace/runtest_unsheared index 8f47f33026..a845a9d92f 100755 --- a/tests/integrated/test-naulin-laplace/runtest_unsheared +++ b/tests/integrated/test-naulin-laplace/runtest_unsheared @@ -18,7 +18,6 @@ from boututils.run_wrapper import shell, build_and_log, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("LaplaceNaulin inversion test") print("Running LaplaceNaulin inversion test") diff --git a/tests/integrated/test-petsc_laplace/runtest b/tests/integrated/test-petsc_laplace/runtest index ac248c4ce7..83e1006338 100755 --- a/tests/integrated/test-petsc_laplace/runtest +++ b/tests/integrated/test-petsc_laplace/runtest @@ -30,7 +30,6 @@ from boutdata.collect import collect # import numpy as np from sys import stdout, exit - build_and_log("PETSc Laplacian inversion test") print("Running PETSc Laplacian inversion test") diff --git a/tests/integrated/test-petsc_laplace_MAST-grid/runtest b/tests/integrated/test-petsc_laplace_MAST-grid/runtest index 5a4cbf875a..3be39949c3 100755 --- a/tests/integrated/test-petsc_laplace_MAST-grid/runtest +++ b/tests/integrated/test-petsc_laplace_MAST-grid/runtest @@ -28,7 +28,6 @@ from boututils.run_wrapper import build_and_log, shell, launch_safe from boutdata.collect import collect from sys import stdout, exit - build_and_log( "PETSc Laplacian inversion test with non-identity metric (taken from grid for MAST SOL)" ) diff --git a/tests/integrated/test-region-iterator/runtest b/tests/integrated/test-region-iterator/runtest index e5825285de..2277ef15e9 100755 --- a/tests/integrated/test-region-iterator/runtest +++ b/tests/integrated/test-region-iterator/runtest @@ -17,7 +17,6 @@ from boututils.run_wrapper import build_and_log, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("Region Iterator test") flags = [""] diff --git a/tests/integrated/test-restarting/runtest b/tests/integrated/test-restarting/runtest index 262aa818b6..daf19ebac6 100755 --- a/tests/integrated/test-restarting/runtest +++ b/tests/integrated/test-restarting/runtest @@ -5,7 +5,6 @@ from boutdata.collect import collect import numpy as np from sys import stdout, exit - build_and_log("restart test") # Run once for 10 timesteps diff --git a/tests/integrated/test-smooth/runtest b/tests/integrated/test-smooth/runtest index bd7296341a..91ae793164 100755 --- a/tests/integrated/test-smooth/runtest +++ b/tests/integrated/test-smooth/runtest @@ -16,7 +16,6 @@ from boutdata.collect import collect import numpy as np from sys import stdout, exit - build_and_log("smoothing operator test") # Read benchmark values diff --git a/tests/integrated/test-squash/runtest b/tests/integrated/test-squash/runtest index 2f35e00589..8bf358ee8e 100755 --- a/tests/integrated/test-squash/runtest +++ b/tests/integrated/test-squash/runtest @@ -9,7 +9,6 @@ import argparse import re import os.path - # requires: all_tests # requires: netcdf # cores: 4 diff --git a/tests/integrated/test-yupdown/runtest b/tests/integrated/test-yupdown/runtest index 34fcd36496..13d7365b53 100755 --- a/tests/integrated/test-yupdown/runtest +++ b/tests/integrated/test-yupdown/runtest @@ -6,7 +6,6 @@ from sys import exit from numpy import max, abs - build_and_log("parallel slices test") failed = False diff --git a/tools/README.md b/tools/README.md index da8ff6c037..3cb109ad99 100644 --- a/tools/README.md +++ b/tools/README.md @@ -2,19 +2,5 @@ pylib -- Library of Python tools. This is the mainly used interface for post-processing. -idllib --- -Library of IDL tools - -matlablib --- -Library of Matlab tools. - -eigensolver --- -Eigenvalue solver for ITG test case - -pdb2idl --- -Library for reading PDB files into IDL - +Other tools where removed with v5.3.0, as they where unmaintained. +You can find them in older versions, e.g. in [5.2.0](https://github.com/boutproject/BOUT-dev/releases/tag/v5.2.0) diff --git a/tools/archiving/README b/tools/archiving/README deleted file mode 100644 index 3ccdb594b3..0000000000 --- a/tools/archiving/README +++ /dev/null @@ -1,8 +0,0 @@ -Tools or scripts to help manage & archive BOUT++ data output - -mdsplus Tools to manage BOUT++ runs using MDSplus - -pdb2cdf Convert PDB files to netCDF - -sdctools Simulation Data Compression library - diff --git a/tools/archiving/dumpsample/Makefile b/tools/archiving/dumpsample/Makefile deleted file mode 100644 index a9f3bebd90..0000000000 --- a/tools/archiving/dumpsample/Makefile +++ /dev/null @@ -1,29 +0,0 @@ - -CC = c++ -LD = c++ - -CFLAGS = -Wall -g - -PDB_PATH=/hwdisks/home/bd512/local/ - -INCLUDE = -I$(PDB_PATH)/include -LIBS = -lm -L$(PDB_PATH)/lib -lpdb -lpml -lscore - -TARGET = pdbsample -OBJ = pdbsample.o - -.PHONY:all -all: $(TARGET) - -$(TARGET): $(OBJ) Makefile - $(LD) -o $(TARGET) $(OBJ) $(LIBS) - -$(OBJ): %.o: %.cpp Makefile - $(CC) $(CFLAGS) -c $< -o $@ $(INCLUDE) - -.PHONY:clean -clean: - rm -f $(OBJ) $(TARGET) - -.PHONY:force -force: clean all diff --git a/tools/archiving/dumpsample/README b/tools/archiving/dumpsample/README deleted file mode 100644 index 70b4b64da5..0000000000 --- a/tools/archiving/dumpsample/README +++ /dev/null @@ -1,7 +0,0 @@ - -Codes: - -pdbsample Samples a single PDB file -ncsample Sample a netCDF file - -dumpsample Perl script to sample BOUT++ outputs diff --git a/tools/archiving/dumpsample/dumpsample b/tools/archiving/dumpsample/dumpsample deleted file mode 100755 index 942fd9731e..0000000000 --- a/tools/archiving/dumpsample/dumpsample +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/perl -# -# Reduce the time-resolution of BOUT++ output. -# - -use File::Basename; - -# Check command-line arguments -$numArgs = $#ARGV + 1; - -if( $numArgs != 3 ) { - print "Useage: \n"; - exit; -} - -$inputdir = $ARGV[0]; -$outputdir = $ARGV[1]; -$ts = $ARGV[2]; - -if ($inputdir eq $outputdir) { - # Input and output directories are the same - print "Input and output directories must be different\n"; - exit; -} - -# Check 3rd argument is an integer -if($ARGV[2] =~ /^\d+$/) { - print "Reducing time resolution by a factor of $ARGV[2]\n"; -}else { - print "3rd argument must be an integer\n"; - exit; -} - -@infiles = <$inputdir/BOUT.dmp.*>; - -foreach $file (@infiles) { - $f = $outputdir . "/" . basename($file); - - if($file =~ m/.pdb$/) { - # PDB file - print "PDB file: $file -> $f\n"; - system("pdbsample $file $f $ts") == 0 - or die "Could not execute pdbsample\n"; - }elsif( $file =~ m/(.nc|.cdl|.cdf|.ncdf)$/ ) { - # NetCDF file - print "NetCDF file\n"; - }else { - print $file . " has unknown file format\n"; - } - -} diff --git a/tools/archiving/dumpsample/pdbsample.cxx b/tools/archiving/dumpsample/pdbsample.cxx deleted file mode 100644 index 90ea69adb2..0000000000 --- a/tools/archiving/dumpsample/pdbsample.cxx +++ /dev/null @@ -1,232 +0,0 @@ -/******************************************************* - * PDB Sample - * - * - * Ben Dudson, University of York, July 2009 - *******************************************************/ - -#include -#include - -// The PDB library (C) -#include "pdb.h" - -int main(int argc, char** argv) { - if (argc < 4) { - fprintf(stderr, "Useage: %s \n", argv[0]); - return 1; - } - - int tstride; - if (sscanf(argv[3], "%d", &tstride) != 1) { - fprintf(stderr, "\tERROR: t stride must be an integer\n"); - return 1; - } - - // Open input file - PDBfile* in; - if ((in = PD_open(argv[1], "r")) == NULL) { - fprintf(stderr, "\tERROR: Could not open input file '%s'\n", argv[1]); - return 1; - } - - // Open output file - PDBfile* out; - if ((out = PD_open(argv[2], "w")) == NULL) { - fprintf(stderr, "\tERROR: Could not open output file '%s'\n", argv[2]); - return 1; - } - - // Get list of variables - - int nvars; - char** var_names = PD_ls(in, NULL, NULL, &nvars); - if ((var_names == (char**)NULL) || (nvars < 1)) { - fprintf(stderr, "\tERROR: No variables\n"); - return 1; - } - - // Go through the variables - char* varname; - for (int var = 0; var < nvars; var++) { - varname = var_names[var]; - - syment* ep; // PDB query types - dimdes* dims; - - // Query size of the variable - if ((ep = PD_query_entry(in, varname, NULL)) == (syment*)NULL) { - fprintf(stderr, "\tError querying variable %s\n", varname); - return 1; - } - dims = PD_entry_dimensions(ep); - int nd = 0; // Count number of dimensions - int varsize = 1; // Number of elements - long inds[12]; - while (dims != (dimdes*)NULL) { - long min, max; - min = dims->index_min; - max = dims->index_max; - - if (nd > 3) { - fprintf(stderr, "\tERROR: Can't handle variable '%s': more than 4D\n", varname); - return 2; - } - - inds[3 * nd] = min; - inds[3 * nd + 1] = max; - inds[3 * nd + 2] = 1L; - - varsize *= max - min + 1; - - nd++; - dims = dims->next; - } - - // Get variable type - char* typ; - typ = PD_entry_type(ep); - - if ((strcmp(varname, "t_array") == 0) && (nd == 1)) { - float* fdata = new float[varsize]; - - // Read the data from the PDB file - - inds[2] = tstride; - int nread; - if ((nread = PD_read_as_alt(in, varname, "float", fdata, inds)) == 0) { - fprintf(stderr, "\tWARNING: Could not read t_array. Ignoring\n"); - delete[] fdata; - continue; - } - - inds[0] = 0L; - inds[1] = nread - 1; - inds[2] = 1L; - - if (PD_write_alt(out, varname, "float", fdata, 1, inds) == FALSE) { - fprintf(stderr, "\tWARNING: Could not write '%s'. Ignoring\n", varname); - } - - delete[] fdata; - - } else if (nd == 4) { - // Reducing time resolution - - if (strcasecmp(typ, "integer") == 0) { - int* idata = new int[varsize]; - - // Read the data from the PDB file - inds[2] = tstride; - int nread; - if ((nread = PD_read_as_alt(in, varname, "integer", idata, inds)) == 0) { - fprintf(stderr, "\tWARNING: Could not read '%s'. Ignoring\n", varname); - delete[] idata; - continue; - } - - if (nread % (varsize / (inds[1] - inds[0] + 1)) != 0) { - fprintf(stderr, "ERROR: Accounting error: (%ld, %ld), %d, %d\n", inds[0], - inds[1], varsize, nread); - delete[] idata; - continue; - } - - nread = nread / (varsize / (inds[1] - inds[0] + 1)); - - inds[0] = 0L; - inds[1] = nread - 1; - inds[2] = 1L; - - if (PD_write_alt(out, varname, "integer", idata, 4, inds) == FALSE) { - fprintf(stderr, "\tWARNING: Could not write '%s'. Ignoring\n", varname); - } - - delete[] idata; - - } else if ((strcasecmp(typ, "float") == 0) || (strcasecmp(typ, "double") == 0)) { - // Convert doubles to floats - - float* fdata = new float[varsize]; - - // Read the data from the PDB file - inds[2] = tstride; - int nread; - if ((nread = PD_read_as_alt(in, varname, "float", fdata, inds)) == 0) { - fprintf(stderr, "\tWARNING: Could not read '%s'. Ignoring\n", varname); - delete[] fdata; - continue; - } - - if (nread % (varsize / (inds[1] - inds[0] + 1)) != 0) { - fprintf(stderr, "ERROR: Accounting error: (%ld, %ld), %d, %d\n", inds[0], - inds[1], varsize, nread); - delete[] fdata; - continue; - } - - nread = nread / (varsize / (inds[1] - inds[0] + 1)); - - inds[0] = 0L; - inds[1] = nread - 1; - inds[2] = 1L; - - if (PD_write_alt(out, varname, "float", fdata, 4, inds) == FALSE) { - fprintf(stderr, "\tWARNING: Could not write '%s'. Ignoring\n", varname); - } - - delete[] fdata; - - } else { - fprintf(stderr, "\tWARNING: '%s' has unrecognised type '%s'. Ignoring\n", varname, - typ); - } - } else { - // Just copy the data across - - if (strcasecmp(typ, "integer") == 0) { - - int* idata = new int[varsize]; - - // Read the data from the PDB file - if (PD_read_as(in, varname, "integer", idata) == 0) { - fprintf(stderr, "\t\tWARNING: Could not read variable. Ignoring\n"); - delete[] idata; - continue; - } - - if (PD_write_alt(out, varname, "integer", idata, nd, inds) == FALSE) { - fprintf(stderr, "\tWARNING: Could not write variable '%s'\n", varname); - } - - delete[] idata; - - } else if ((strcasecmp(typ, "float") == 0) || (strcasecmp(typ, "double") == 0)) { - // Convert doubles to floats - - float* fdata = new float[varsize]; - - // Read the data from the PDB file - if (PD_read_as(in, varname, "float", fdata) == 0) { - fprintf(stderr, "\tWARNING: Could not read variable '%s'. Ignoring\n", varname); - delete[] fdata; - continue; - } - - if (PD_write_alt(out, varname, "float", fdata, nd, inds) == FALSE) { - fprintf(stderr, "\tWARNING: Could not write variable '%s'\n", varname); - } - - delete[] fdata; - } else { - fprintf(stderr, "WARNING: '%s' has unrecognised type '%s'. Ignoring\n", varname, - typ); - } - } - } - - PD_close(in); - PD_close(out); - - return 0; -} diff --git a/tools/archiving/mdsplus/data/bout_mds_model.characteristics b/tools/archiving/mdsplus/data/bout_mds_model.characteristics deleted file mode 100644 index b3a5920b84..0000000000 Binary files a/tools/archiving/mdsplus/data/bout_mds_model.characteristics and /dev/null differ diff --git a/tools/archiving/mdsplus/data/bout_mds_model.datafile b/tools/archiving/mdsplus/data/bout_mds_model.datafile deleted file mode 100644 index ef462ba99f..0000000000 Binary files a/tools/archiving/mdsplus/data/bout_mds_model.datafile and /dev/null differ diff --git a/tools/archiving/mdsplus/data/bout_mds_model.tree b/tools/archiving/mdsplus/data/bout_mds_model.tree deleted file mode 100644 index f4171bb4c8..0000000000 Binary files a/tools/archiving/mdsplus/data/bout_mds_model.tree and /dev/null differ diff --git a/tools/archiving/mdsplus/idl/mds2inp.pro b/tools/archiving/mdsplus/idl/mds2inp.pro deleted file mode 100644 index 8f6fdc4575..0000000000 --- a/tools/archiving/mdsplus/idl/mds2inp.pro +++ /dev/null @@ -1,177 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; Reads settings from an MDSplus shot, outputting a BOUT.inp file -; Currently just prints the settings to stdout -; -; KEYWORDS -; -; server Name (and optionally the port) of MDS server -; Default 'localhost' -; tree MDS tree. Default 'bout_mds' -; shot Shot number. By default reads the latest -; -; Run server: mdsip -p 8000 -m -h $MDS_ROOT/etc/mdsip.hosts -; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -PRO print_settings, path, nremove, prefix, fd - - setting_nid=MDSVALUE('GETNCI("'+path+'","NID_NUMBER")',status=status) - IF NOT (status AND 1) THEN RETURN - - n = N_ELEMENTS(setting_nid) - ;PRINT, "Number of settings:", n - - nvars = 0 ; keep track of the number of variables - FOR i=0, n-1 DO BEGIN - str = mdsvalue('GETNCI($,"MINPATH")',setting_nid[i]) - ;PRINT, str - - ; look for members - pos = STRPOS(str, ':') - - IF pos NE -1 THEN BEGIN - ; this string is a leaf - - len = STRLEN(str) - - name = STRMID(str, pos+1, len - pos-1) - path = STRMID(str, nremove, pos - nremove) - - ; replace '.' with '/' - STRREPLACE, path, '.', '/' - - ;PRINT, "-> '" + path + "' - '"+name+"'" - - IF nvars EQ 0 THEN BEGIN - paths = [path] - names = [name] - nids = [setting_nid[i]] - ENDIF ELSE BEGIN - paths = [paths, path] - names = [names, name] - nids = [nids, setting_nid[i]] - ENDELSE - nvars = nvars + 1 - - ENDIF - - ENDFOR - - ; get the settings without section - - IF STRLEN(prefix) GT 0 THEN PRINTF, fd, '['+prefix+']' - - w = WHERE(paths EQ '', count) - IF count GT 0 THEN BEGIN - FOR i=0, count-1 DO BEGIN - ; get the value - p = MDSVALUE('GETNCI($, "PATH")', nids[i]) - - v = MDSVALUE(p, status=status, /quiet) - - IF status AND 1 THEN BEGIN - ; success - PRINTF, fd, names[i]+" = " + STRING(v) - ENDIF ELSE BEGIN - ; failed - no data - - PRINTF, fd, '# '+names[i]+ ' = ' - ENDELSE - ENDFOR - - w = WHERE(paths NE '', count) - IF count GT 0 THEN BEGIN - paths = paths[w] - names = names[w] - nids = nids[w] - ENDIF - nvars = count - ENDIF - - WHILE nvars GT 0 DO BEGIN - IF STRLEN(prefix) GT 0 THEN PRINTF, fd, '['+prefix+'/'+paths[0]+']' ELSE PRINTF, fd, '['+paths[0]+']' - - w = WHERE(paths EQ paths[0], count) - - FOR i=0, count-1 DO BEGIN - ; get the value - p = MDSVALUE('GETNCI($, "PATH")', nids[w[i]]) - v = MDSVALUE(p, status=status, /quiet) - - IF status AND 1 THEN BEGIN - ; success - PRINTF, fd, names[i]+" = " + STRING(v) - ENDIF ELSE BEGIN - ; failed - no data - - PRINTF, fd, '# '+names[i]+ ' = ' - ENDELSE - ENDFOR - - w = WHERE(paths NE paths[0], count) - IF count GT 0 THEN BEGIN - paths = paths[w] - names = names[w] - nids = nids[w] - ENDIF - nvars = count - ENDWHILE -END - -PRO mds2inp, server=server, tree=tree, shot=shot - - IF NOT KEYWORD_SET(server) THEN server = "localhost" - IF NOT KEYWORD_SET(tree) THEN tree = "bout_mds" - - mdsconnect, server, status = status - - IF NOT (status AND 1) THEN BEGIN - PRINT, "Could not connect" - RETURN - ENDIF - - IF NOT KEYWORD_SET(shot) THEN BEGIN - ; get the latest shot - shot = MDSVALUE('current_shot("'+tree+'")') - PRINT, "Latest shot = ", shot - ENDIF - - mdsopen, tree, shot, status=status - IF NOT (status AND 1) THEN BEGIN - PRINT, "Could not open tree" - mdsdisconnect - RETURN - ENDIF - - ; get the description and model - - desc = MDSVALUE(':DESC', status=status) - IF NOT (status AND 1) THEN desc = 'No description' - model = MDSVALUE(':MODEL', status=status) - IF NOT (status AND 1) THEN model = 'NO MODEL' - - ; NOTE: This method could be replaced with calls for CHILDREN_NIDS - ; but that doesn't seem to work (says no data for node) - - fd = -1 - - PRINTF, fd, "# BOUT++ input file. Generated from MDSplus data" - PRINTF, fd, "# Date: " + SYSTIME() - PRINTF, fd, "# Shot: " + STRTRIM(STRING(shot),2) - PRINTF, fd, "# Description: " + desc - PRINTF, fd, "# Model: " + model - PRINTF, fd, "" - - settings_path = "\\TOP.SETTINGS***" - print_settings, settings_path, 10, '', fd - - print_settings, "\\TOP."+model+".SETTINGS***", 10+STRLEN(model), model, fd - - - mdsclose - mdsdisconnect - -END - - diff --git a/tools/archiving/mdsplus/manual/Makefile b/tools/archiving/mdsplus/manual/Makefile deleted file mode 100644 index df1e184ecc..0000000000 --- a/tools/archiving/mdsplus/manual/Makefile +++ /dev/null @@ -1,8 +0,0 @@ - -TARGET = bout_mdsplus - -$(TARGET).pdf: $(TARGET).tex - latexmk -pdf $(TARGET).tex -interaction=batchmode - -clean: - latexmk -C diff --git a/tools/archiving/mdsplus/manual/bout_mdsplus.tex b/tools/archiving/mdsplus/manual/bout_mdsplus.tex deleted file mode 100644 index 17852e30f2..0000000000 --- a/tools/archiving/mdsplus/manual/bout_mdsplus.tex +++ /dev/null @@ -1,50 +0,0 @@ -% Manual describing the MDSplus interface to BOUT++ - -\documentclass[12pt]{article} -\usepackage[nofoot]{geometry} -\usepackage{graphicx} -\usepackage{fancyhdr} - -%% Modify margins -\addtolength{\oddsidemargin}{-.25in} -\addtolength{\evensidemargin}{-.25in} -\addtolength{\textwidth}{0.5in} -\addtolength{\textheight}{0.25in} -%% SET HEADERS AND FOOTERS - -\pagestyle{fancy} -\fancyfoot{} -\renewcommand{\sectionmark}[1]{ % Lower case Section marker style - \markright{\thesection.\ #1}} -\fancyhead[LE,RO]{\bfseries\thepage} % Page number (boldface) in left on even - % pages and right on odd pages -\renewcommand{\headrulewidth}{0.3pt} - -\newcommand{\code}[1]{\texttt{#1}} -\newcommand{\file}[1]{\texttt{\bf #1}} - -%% commands for boxes with important notes -\newlength{\notewidth} -\addtolength{\notewidth}{\textwidth} -\addtolength{\notewidth}{-3.\parindent} -\newcommand{\note}[1]{ -\fbox{ -\begin{minipage}{\notewidth} -{\bf NOTE}: #1 -\end{minipage} -}} - -\begin{document} - -\title{MDSplus interface for BOUT++} -\author{B.Dudson, University of York} - -\maketitle - -\tableofcontents - -\section{Introduction} - - - -\end{document} diff --git a/tools/archiving/pdb2cdf/Makefile b/tools/archiving/pdb2cdf/Makefile deleted file mode 100644 index d08edc127c..0000000000 --- a/tools/archiving/pdb2cdf/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -BOUT_TOP = ../../.. -include $(BOUT_TOP)/make.config - -TARGET = pdb2cdf -OBJ = pdb2cdf.o - -.PHONY:all -all: $(TARGET) - -$(TARGET): $(OBJ) Makefile - $(LD) -o $(TARGET) $(OBJ) $(EXTRA_LIBS) - -$(OBJ): %.o: %.cxx Makefile - $(CC) $(CFLAGS) -c $< -o $@ $(EXTRA_INCS) diff --git a/tools/archiving/pdb2cdf/README b/tools/archiving/pdb2cdf/README deleted file mode 100644 index a8ce636d6a..0000000000 --- a/tools/archiving/pdb2cdf/README +++ /dev/null @@ -1,25 +0,0 @@ -PDB2CDF -======= - -Convert Portable Data Binary (PDB) files to netCDF format - -PDB: https://wci.llnl.gov/codes/pact/ -netCDF: http://www.unidata.ucar.edu/software/netcdf/ - -Handles up to 4-D integers, floats and doubles. Tries to assign the correct -dimensions to the variables using the following procedure: - -1. Find the variable with the largest number of dimensions -2. Labels the dimensions of this variable 'X', 'Y', 'Z', 'T' - (always in that order), and records the index ranges -3. For each variable, match index ranges to get the dimension, - using the first one which matches. Dimensions are assumed - to always be in the same order: XZ, YT, XY etc. but NOT ZX, TZ etc. -4. Variables which cannot be matched to dimensions will currently - cause the code to fall over. Should be improved later. - -The ordering of dimensions was chosen for BOUT++ files, but -apart from this, the code is not specific to BOUT++. - -B.Dudson, April 2009 -University of York diff --git a/tools/archiving/pdb2cdf/pdb2cdf.cxx b/tools/archiving/pdb2cdf/pdb2cdf.cxx deleted file mode 100644 index ac8bc85de6..0000000000 --- a/tools/archiving/pdb2cdf/pdb2cdf.cxx +++ /dev/null @@ -1,382 +0,0 @@ -/******************************************************* - * PDB2CDF - * - * Convert PDB files to netCDF - *******************************************************/ - -#include -#include - -// The PDB library (C) -#include "pdb.h" - -// netCDF C++ library -#include - -// Dimension -struct TDim { - char* label; // Label for the dimension - int size; - int min, max; // Minimum, maximum index - NcDim* nDim; // netCDF dimension -}; - -// List of dimensions. Handles up to 3 -static TDim dimlist3d[] = {{"x", 0}, {"y", 0}, {"z", 0}}; - -// Special case for 4D -static TDim dimlist4d[] = {{"t", 0}, {"x", 0}, {"y", 0}, {"z", 0}}; - -int main(int argc, char** argv) { - TDim* dimlist; - - if (argc < 2) { - fprintf(stderr, "Useage: %s file1 file2 ...\n", argv[0]); - return 1; - } - - for (int i = 1; i < argc; i++) { // Go through each PDB file - char* inname = argv[i]; - PDBfile* in; - - // Open input file - - if ((in = PD_open(inname, "r")) == NULL) { - fprintf(stderr, "ERROR: Could not open input file '%s'\n", inname); - return 1; - } - - // Get list of variables - - int nvars; - char** var_names = PD_ls(in, NULL, NULL, &nvars); - if ((var_names == (char**)NULL) || (nvars < 1)) { - fprintf(stderr, "ERROR: No variables\n"); - return 1; - } - - // Create a filename for the output - char* outname; - int len = strlen(inname); - if (len < 5) { - // Not long enough - just append .cdl - outname = new char[len + 5]; - snprintf(outname, len + 5, "%s%s", inname, ".cdl"); - } else { - // Replace '.pdb' by '.cdl' - outname = new char[len + 1]; - strncpy(outname, inname, len + 1); - strncpy(outname + len - 3, "cdl", 3); - } - - // Open output file, overwriting if it exists - NcFile dataFile(outname, NcFile::Replace); - - if (!dataFile.is_valid()) { - fprintf(stderr, "ERROR: Could not open output file '%s'\n", outname); - return 1; - } - - printf("Converting %s -> %s\n", inname, outname); - - // Find the variable with the largest number of dimensions - printf("\tAnalysing dimensions..."); - int maxdims = -1; // maximum number of variables - int maxdimvar = 0; // variable with the most dimensions - - syment* ep; // PDB query types - dimdes* dims; - - char* varname; - for (int var = 0; var < nvars; var++) { - varname = var_names[var]; - // Query size of the variable - - if ((ep = PD_query_entry(in, varname, NULL)) == (syment*)NULL) { - fprintf(stderr, "Error querying variable %s\n", varname); - return 1; - } - dims = PD_entry_dimensions(ep); - int nd = 0; /* Count number of dimensions */ - while (dims != (dimdes*)NULL) { - nd++; - dims = dims->next; - } - if (nd > maxdims) { - maxdims = nd; - maxdimvar = var; - } - } - - printf("%d dimensions\n", maxdims); - - if (maxdims < 4) { - dimlist = dimlist3d; - } else { - dimlist = dimlist4d; - } - - if (maxdims > 4) { - fprintf(stderr, "ERROR: Can only handle up to 4D variables\n"); - return 1; - } - - // Get the size of each dimension - varname = var_names[maxdimvar]; - if ((ep = PD_query_entry(in, varname, NULL)) == (syment*)NULL) { - fprintf(stderr, "Error querying variable %s\n", varname); - return 1; - } - dims = PD_entry_dimensions(ep); - - for (int d = 0; d < maxdims; d++) { - dimlist[d].min = dims->index_min; - dimlist[d].max = dims->index_max; - dimlist[d].size = dims->index_max - dims->index_min + 1; - - // Create a netCDF dimension - dimlist[d].nDim = dataFile.add_dim(dimlist[d].label, dimlist[d].size); - - printf("\t\t%s: %d -> %d (%d)\n", dimlist[d].label, dimlist[d].min, dimlist[d].max, - dimlist[d].size); - - dims = dims->next; - } - - // Go through each variable - for (int var = 0; var < nvars; var++) { - varname = var_names[var]; - if ((ep = PD_query_entry(in, varname, NULL)) == (syment*)NULL) { - fprintf(stderr, "Error querying variable %s\n", varname); - return 1; - } - - printf("\t%s", varname); - - // Get dimensions - int nd = 0; // Number of dimensions - int vardim[4]; // Indices in the dimlist array - int lastdim = -1; // Always assume indices have the same order - int varsize = 1; // Number of elements - - bool gotdims = true; - - dims = PD_entry_dimensions(ep); - while (dims != (dimdes*)NULL) { - int min, max; - min = dims->index_min; - max = dims->index_max; - - varsize *= max - min + 1; - - vardim[nd] = -1; - // Find which dimension this corresponds to - for (int d = lastdim + 1; d < maxdims; d++) { - if ((dimlist[d].min == min) && (dimlist[d].max == max)) { - if (lastdim == -1) { - printf("[%s", dimlist[d].label); - } else { - printf(",%s", dimlist[d].label); - } - vardim[nd] = d; - lastdim = d; - break; - } - } - if (vardim[nd] == -1) { - // Not an existing dimension. Should create a new dimension - fprintf(stderr, "ERROR: %s has an unrecognised %d dimension [%d -> %d]\n", - varname, nd + 1, min, max); - gotdims = false; - break; - } - - nd++; - dims = dims->next; - } - - if (!gotdims) { - continue; // Skip this variable - } - - if (lastdim != -1) { - printf("] (%d elements) ", varsize); - } - - // Now know number of dimensions nd, and a list of dimension indices vardim - - // Get variable type - char* typ; - typ = PD_entry_type(ep); - - printf(" Type: %s ", typ); - fflush(stdout); - - if (strcasecmp(typ, "integer") == 0) { - - int* idata = new int[varsize]; - - // Read the data from the PDB file - if (PD_read_as(in, varname, "integer", idata) == FALSE) { - fprintf(stderr, "\t\tWARNING: Could not read variable. Ignoring\n"); - continue; - } - switch (nd) { - case 0: { - // Add a 0-D variable to the netCDF file - NcVar* ncdata = dataFile.add_var(varname, ncInt); - - // Write data - ncdata->put(idata); - break; - } - case 1: { - NcVar* ncdata = dataFile.add_var(varname, ncInt, dimlist[vardim[0]].nDim); - ncdata->put(idata, varsize); - break; - } - case 2: { - NcVar* ncdata = dataFile.add_var(varname, ncInt, dimlist[vardim[0]].nDim, - dimlist[vardim[1]].nDim); - ncdata->put(idata, dimlist[vardim[0]].size, dimlist[vardim[1]].size); - break; - } - case 3: { - NcVar* ncdata = - dataFile.add_var(varname, ncInt, dimlist[vardim[0]].nDim, - dimlist[vardim[1]].nDim, dimlist[vardim[2]].nDim); - ncdata->put(idata, dimlist[vardim[0]].size, dimlist[vardim[1]].size, - dimlist[vardim[2]].size); - break; - } - case 4: { - NcVar* ncdata = dataFile.add_var( - varname, ncInt, dimlist[vardim[0]].nDim, dimlist[vardim[1]].nDim, - dimlist[vardim[2]].nDim, dimlist[vardim[3]].nDim); - ncdata->put(idata, dimlist[vardim[0]].size, dimlist[vardim[1]].size, - dimlist[vardim[2]].size, dimlist[vardim[3]].size); - break; - } - default: { - fprintf(stderr, "\t\tWARNING: Cannot yet handle %d-D integers. Ignoring\n", nd); - } - } - delete[] idata; - - ////////////////////////////////////////////////////////////////// - - } else if (strcasecmp(typ, "float") == 0) { - - float* fdata = new float[varsize]; - - // Read the data from the PDB file - if (PD_read_as(in, varname, "float", fdata) == FALSE) { - fprintf(stderr, "\t\tWARNING: Could not read variable. Ignoring\n"); - continue; - } - switch (nd) { - case 0: { - NcVar* ncdata = dataFile.add_var(varname, ncFloat); - - // Write data - ncdata->put(fdata); - break; - } - case 1: { - NcVar* ncdata = dataFile.add_var(varname, ncFloat, dimlist[vardim[0]].nDim); - ncdata->put(fdata, varsize); - break; - } - case 2: { - NcVar* ncdata = dataFile.add_var(varname, ncFloat, dimlist[vardim[0]].nDim, - dimlist[vardim[1]].nDim); - ncdata->put(fdata, dimlist[vardim[0]].size, dimlist[vardim[1]].size); - break; - } - case 3: { - NcVar* ncdata = - dataFile.add_var(varname, ncFloat, dimlist[vardim[0]].nDim, - dimlist[vardim[1]].nDim, dimlist[vardim[2]].nDim); - ncdata->put(fdata, dimlist[vardim[0]].size, dimlist[vardim[1]].size, - dimlist[vardim[2]].size); - break; - } - case 4: { - NcVar* ncdata = dataFile.add_var( - varname, ncFloat, dimlist[vardim[0]].nDim, dimlist[vardim[1]].nDim, - dimlist[vardim[2]].nDim, dimlist[vardim[3]].nDim); - ncdata->put(fdata, dimlist[vardim[0]].size, dimlist[vardim[1]].size, - dimlist[vardim[2]].size, dimlist[vardim[3]].size); - break; - } - default: { - fprintf(stderr, "\t\tWARNING: Cannot yet handle %d-D floats. Ignoring\n", nd); - } - } - delete[] fdata; - - ////////////////////////////////////////////////////////////////// - - } else if (strcasecmp(typ, "double") == 0) { - - double* ddata = new double[varsize]; - - // Read the data from the PDB file - if (PD_read_as(in, varname, "double", ddata) == FALSE) { - fprintf(stderr, "\t\tWARNING: Could not read variable. Ignoring\n"); - continue; - } - switch (nd) { - case 0: { - NcVar* ncdata = dataFile.add_var(varname, ncDouble); - - // Write data - ncdata->put(ddata); - break; - } - case 1: { - NcVar* ncdata = dataFile.add_var(varname, ncDouble, dimlist[vardim[0]].nDim); - ncdata->put(ddata, varsize); - break; - } - case 2: { - NcVar* ncdata = dataFile.add_var(varname, ncDouble, dimlist[vardim[0]].nDim, - dimlist[vardim[1]].nDim); - ncdata->put(ddata, dimlist[vardim[0]].size, dimlist[vardim[1]].size); - break; - } - case 3: { - NcVar* ncdata = - dataFile.add_var(varname, ncDouble, dimlist[vardim[0]].nDim, - dimlist[vardim[1]].nDim, dimlist[vardim[2]].nDim); - ncdata->put(ddata, dimlist[vardim[0]].size, dimlist[vardim[1]].size, - dimlist[vardim[2]].size); - break; - } - case 4: { - NcVar* ncdata = dataFile.add_var( - varname, ncDouble, dimlist[vardim[0]].nDim, dimlist[vardim[1]].nDim, - dimlist[vardim[2]].nDim, dimlist[vardim[3]].nDim); - ncdata->put(ddata, dimlist[vardim[0]].size, dimlist[vardim[1]].size, - dimlist[vardim[2]].size, dimlist[vardim[3]].size); - break; - } - default: { - fprintf(stderr, "\t\tWARNING: Cannot yet handle %d-D doubles. Ignoring\n", nd); - } - } - delete[] ddata; - } else { - fprintf(stderr, "\tWARNING: '%s' has unrecognised type '%s'. Ignoring\n", varname, - typ); - } - printf("\n"); - } - - delete[] outname; - - dataFile.close(); // Close the output file. Probably optional. - } - - return 0; -} diff --git a/tools/archiving/sdctools/LICENSE b/tools/archiving/sdctools/LICENSE deleted file mode 100644 index a44189fdca..0000000000 --- a/tools/archiving/sdctools/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -Copyright (c) 2007 B.Dudson, University of York - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/archiving/sdctools/Makefile b/tools/archiving/sdctools/Makefile deleted file mode 100644 index d501067023..0000000000 --- a/tools/archiving/sdctools/Makefile +++ /dev/null @@ -1,35 +0,0 @@ - -SDC = ./sdclib/ -PACT = /hwdisks/home/bd512/local/ -IDL_DIR = /hwdisks/sfw/idl/idl6.3/idl/ - -CC = gcc -LD = gcc - -CFLAGS = -Wall -O - -INCLUDES = -I$(SDC) -I$(PACT)/include -LIBS = $(SDC)/sdclib.o -L$(PACT)/lib -lpdb -lpml -lscore -lm - - -.PHONY: all - -all: compress sdc2idl.so - -compress: compress.o - $(LD) -o compress compress.o $(LIBS) - -compress.o: compress.c - $(CC) $(CFLAGS) -c compress.c $(INCLUDES) - - -sdc2idl.so: sdc2idl.o - $(LD) -o sdc2idl.so sdc2idl.o $(SDC)/sdclib.so -shared -lm - -sdc2idl.o: sdc2idl.c - $(CC) -c $(CFLAGS) -fPIC -c sdc2idl.c -I$(SDC) -I$(IDL_DIR)/external - - -.PHONY: clean -clean: - rm *.o compress sdc2idl.so diff --git a/tools/archiving/sdctools/README b/tools/archiving/sdctools/README deleted file mode 100644 index af4c37dbb2..0000000000 --- a/tools/archiving/sdctools/README +++ /dev/null @@ -1,207 +0,0 @@ - - -Scientific Data Compression Library (SDCLib) Version 1.0 -Ben Dudson, University of York, August 2007 - -Introduction -============ - -This is a simple compression library, intended for the relatively -smoothly varying output from simulations such as BOUT++. -Uses polynomial interpolation in time to reduce number of stored -time-points - If the input is a polynomial in time, then the minimum -number of points needed will be stored, for example to store a -quadratic 3 points will be stored. -Compression is lossy - some accuracy is sacrificed in order to -reduce the size of the data, although the level of accuracy can -be specified and changed mid-way through the data. -This accuracy is guaranteed - the reconstruction is guaranteed -to be within the absolute and relative error bounds specified. - -NOTES: -1. This library is currently under development and probably still has some bugs. - Please don't use it to store anything you cannot replace. - -2. Currently doesn't take account of different integer/float sizes - (e.g. 32 vs 64-bit machines) apart from checking that variables - are the correct size for the archive. - If you attempt to read using 64-bit code an archive created by 32-bit code, - an error will be thrown. - -3. Archives cannot be altered once created. Appending data to files may happen - eventually, but modifying files is just too much of a pain. - -Any comments/suggestions/flames to Ben Dudson, bd512@york.ac.uk - - -Operation -========= - -Because this is a compressed format, searching for a given time-point would be difficult -unless the entire dataset were periodically output in one block. -As with a video file, these are called i-frames, and a table of their locations is stored -at the end of the file (like AVI). - -In between these i-frames, different parts of the domain will (probably) change at -different rates, and so the domain is split into several regions - when creating an -archive the number of regions must be specified. - -Creating an SDC archive ------------------------ - -SDC stores data in blocks. The idea is that a file format would be customised for a -given application, with it's own header describing the data. -After this would come the SDC header and then the data. - -First you must open a file - -FILE *fp -fp = fopen("somefile.sdc", "wb"); - -Write whatever header you want to this file, then call - -SDCfile* sdc_newfile(FILE *fp, int N, int order, int reset, int nregions); - -which returns NULL if an error occurs. -N is the number of data points in each time-slice -order is the maximum order of the interpolation (1 - linear, 2 - quadratic etc) -reset is the number of time-points between i-frames where all data is output (like a video, for faster searching) -nregions is the number of regions to split the data into. This doesn't have to be a divisor of N. - -This will write the SDC header to the file, allocate memory and prepare to write data. - -To specify the accuracy to be used, call - -void sdc_set_tol(SDCfile *f, float abstol, float reltol, float eta); - -which sets the absolute tolerance abstol, the relative tolerance reltol, -and a small quantity used in the relative tolerance eta. -The criterion for writing a block of data is to make sure the error e never satisfies: - -( |e| > reltol ) or ( |e| / (|data| + eta) > reltol ) - -Hence values below eta are ignored for the relative tolerance calculation. -These tolerances can be changed whilst writing the file to adapt the accuracy if needed. -Currently the default values for these are abstol = 1.0e-3, reltol = 1.0e-2, -and eta = 1.0e-10 which seem to give pretty decent results. - -To write a time-slice of the data, call - -int sdc_write(SDCfile *f, float *data); - -where data is a pointer to an array of N elements. This will return non-zero -if an error occurs. When all the data has been written, YOU MUST call: - -int sdc_close(SDCfile *f); - -which will write a final i-frame and generally tidy up. If you fail to do this, -terrible things will happen, and your data may be corrupted too. -After this, you can do what you want to the file, then close it - -fclose(fp); - -Reading an archive ------------------- - -First open the file, read whatever headers you wrote and then call - -SDCfile* sdc_open(FILE *fp); - -which will read the SDC data header. To read a time-slice, call - -int sdc_read(SDCfile *f, int t, float *data); - -where t is the time-index (counted from zero at the start of the file), -and data is a pointer to a block of memory. This function will return -non-zero if an error occurs. Reading is most efficient in order from -first to last time-point; reading in reverse order is the least efficient. - -Thats it! When finished reading, you can call - -int sdc_close(SDCfile *f); - -to free memory etc. As with the writing, you have to close the file itself separately. - -Tricks / Examples -================= - -Interleaved data ----------------- - -Several SDC data sets can be interleaved in a single file, for example with two sets - -FILE *fp -fp = fopen("somefile.sdc", "wb"); - -/* Create headers */ -SDCfile *f1, *f2; -f1 = sdc_newfile(fp, N1, order1, reset1, nregions1); -f2 = sdc_newfile(fp, N2, order2, reset2, nregions2); - -Can now write data to f1 or f2 in any order and then close both of them. -To read the data, you must read headers in the same order: - -f1 = sdc_open(fp); -f2 = sdc_open(fp); - -but data can then be read in any order from f1 or f2. - -Compress utility ----------------- - -The imaginatively named "compress" code takes a set of PDB files, selects a single variable -and concatenates all the data into a single output SDC file called "output.sdc". -The data can be any floating-point variable of 1,2,3 or 4 dimensions. The final index of the variable -is assumed to be time. The variable in each file needs to be the same size in each spatial dimension, but -not necessarily the same number of time-points. - -For example, to take all the collected BOUT data, and compress the density to an output file, - -compress ni_xyzt data*.pdb - -You will then be asked for the following parameters (decent values for full 4D 50x64x64x