diff --git a/fab b/fab index f8b6e27..c585ff7 160000 --- a/fab +++ b/fab @@ -1 +1 @@ -Subproject commit f8b6e2781a2c29b7287b5b6c79488d921846adbc +Subproject commit c585ff734a83b97cd945ff96468bcf56eb3ce46c diff --git a/infrastructure/build/fab/default/setup_cray.py b/infrastructure/build/fab/default/setup_cray.py deleted file mode 100644 index 937caa6..0000000 --- a/infrastructure/build/fab/default/setup_cray.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 - -'''This file contains a function that sets the default flags for all -GNU based compilers in the ToolRepository. - -This function gets called from the default site-specific config file -''' - -from fab.build_config import BuildConfig -from fab.tools import Category, Tool, ToolRepository - - -def setup_gnu(build_config: BuildConfig): - '''Defines the default flags for all Cray compilers. - - :para build_config: the build config from which required parameters - can be taken. - ''' - - tr = ToolRepository() - gfortran = tr.get_tool(Category.FORTRAN_COMPILER, "gfortran") - flags = ['-ffree-line-length-none', '-g', - '-Werror=character-truncation', '-Werror=unused-value', - '-Werror=tabs', '-fdefault-real-8', '-fdefault-double-8', - '-Ditworks' - ] - gfortran.add_flags(flags) - - # ATM a linker is not using a compiler wrapper, and so - # linker-mpif90-gfortran does not inherit from linker-gfortran. - # For now set the flags in both linkers: - - # ATM we don't use a shell when starting a tool, and as such - # we can't directly use "$()". So query these values using - # a shell tool: - shell = tr.get_default(Category.SHELL) - # We must remove the trailing new line, and create a list: - nc_flibs = shell.run(additional_parameters=["nf-config --flibs"], - capture_output=True).strip().split() - - for linker_name in ["linker-gfortran", "linker-mpif90-gfortran"]: - linker = tr.get_tool(Category.LINKER, linker_name) - - linker.add_lib_flags("netcdf", nc_flibs, silent_replace=True) - linker.add_lib_flags("yaxt", ["-lyaxt", "-lyaxt_c"]) - linker.add_lib_flags("xios", ["-lxios"]) - linker.add_lib_flags("hdf5", ["-lhdf5"]) - - # Always link with C++ libs - linker.add_post_lib_flags(["-lstdc++"]) diff --git a/infrastructure/build/fab/default/setup_gnu.py b/infrastructure/build/fab/default/setup_gnu.py index 0753a33..c42aed3 100644 --- a/infrastructure/build/fab/default/setup_gnu.py +++ b/infrastructure/build/fab/default/setup_gnu.py @@ -7,19 +7,7 @@ ''' from fab.build_config import BuildConfig -from fab.tools import Category, Tool, ToolRepository - - -class Shell(Tool): - '''A simple wrapper that runs a shell script. - :name: the path to the script to run. - ''' - def __init__(self, name: str): - super().__init__(name=name, exec_name=name, - category=Category.MISC) - - def check_available(self): - return True +from fab.tools import Category, ToolRepository def setup_gnu(build_config: BuildConfig): @@ -38,24 +26,22 @@ def setup_gnu(build_config: BuildConfig): ] gfortran.add_flags(flags) - # ATM a linker is not using a compiler wrapper, and so - # linker-mpif90-gfortran does not inherit from linker-gfortran. - # For now set the flags in both linkers: - bash = Shell("bash") + # ATM we don't use a shell when running a tool, and as such + # we can't directly use "$()" as parameter. So query these values using + # Fab's shell tool (doesn't really matter which shell we get, so just + # ask for the default): + shell = tr.get_default(Category.SHELL) # We must remove the trailing new line, and create a list: - nc_flibs = bash.run(additional_parameters=["-c", "nf-config --flibs"], - capture_output=True).strip().split() - - for linker_name in ["linker-gfortran", "linker-mpif90-gfortran"]: - linker = tr.get_tool(Category.LINKER, linker_name) - # ATM we don't use a shell when starting a tool, and as such - # we can't directly use "$()". So query these values using - # a dummy shell tool: - - linker.add_lib_flags("netcdf", nc_flibs, silent_replace=True) - linker.add_lib_flags("yaxt", ["-lyaxt", "-lyaxt_c"]) - linker.add_lib_flags("xios", ["-lxios"]) - linker.add_lib_flags("hdf5", ["-lhdf5"]) - - # Always link with C++ libs - linker.add_post_lib_flags(["-lstdc++"]) + nc_flibs = shell.run(additional_parameters=["-c", "nf-config --flibs"], + capture_output=True).strip().split() + + # This will implicitly affect all gfortran based linkers, e.g. + # linker-mpif90-gfortran will use these flags as well. + linker = tr.get_tool(Category.LINKER, "linker-gfortran") + linker.add_lib_flags("netcdf", nc_flibs) + linker.add_lib_flags("yaxt", ["-lyaxt", "-lyaxt_c"]) + linker.add_lib_flags("xios", ["-lxios"]) + linker.add_lib_flags("hdf5", ["-lhdf5"]) + + # Always link with C++ libs + linker.add_post_lib_flags(["-lstdc++"]) diff --git a/infrastructure/build/fab/default/setup_intel_classic.py b/infrastructure/build/fab/default/setup_intel_classic.py index b95f551..26e8901 100644 --- a/infrastructure/build/fab/default/setup_intel_classic.py +++ b/infrastructure/build/fab/default/setup_intel_classic.py @@ -7,19 +7,7 @@ ''' from fab.build_config import BuildConfig -from fab.tools import Category, Tool, ToolRepository - - -class Shell(Tool): - '''A simple wrapper that runs a shell script. - :name: the path to the script to run. - ''' - def __init__(self, name: str): - super().__init__(name=name, exec_name=name, - category=Category.MISC) - - def check_available(self): - return True +from fab.tools import Category, ToolRepository def setup_intel_classic(build_config: BuildConfig): @@ -81,20 +69,22 @@ def setup_intel_classic(build_config: BuildConfig): ifort.add_flags(compiler_flag_group) - # ATM a linker is not using a compiler wrapper, and so - # linker-mpif90-gfortran does not inherit from linker-gfortran. - # For now set the flags in both linkers: - bash = Shell("bash") + # ATM we don't use a shell when running a tool, and as such + # we can't directly use "$()" as parameter. So query these values using + # Fab's shell tool (doesn't really matter which shell we get, so just + # ask for the default): + shell = tr.get_default(Category.SHELL) # We must remove the trailing new line, and create a list: - nc_flibs = bash.run(additional_parameters=["-c", "nf-config --flibs"], - capture_output=True).strip().split() - - for linker_name in ["linker-ifort", "linker-mpif90-ifort"]: - linker = tr.get_tool(Category.LINKER, linker_name) - linker.add_lib_flags("netcdf", nc_flibs, silent_replace=True) - linker.add_lib_flags("yaxt", ["-lyaxt", "-lyaxt_c"]) - linker.add_lib_flags("xios", ["-lxios"]) - linker.add_lib_flags("hdf5", ["-lhdf5"]) - - # Always link with C++ libs - linker.add_post_lib_flags(["-lstdc++"]) + nc_flibs = shell.run(additional_parameters=["-c", "nf-config --flibs"], + capture_output=True).strip().split() + + # This will implicitly affect all ifort based linkers, e.g. + # linker-mpif90-ifort will use these flags as well. + linker = tr.get_tool(Category.LINKER, "linker-ifort") + linker.add_lib_flags("netcdf", nc_flibs) + linker.add_lib_flags("yaxt", ["-lyaxt", "-lyaxt_c"]) + linker.add_lib_flags("xios", ["-lxios"]) + linker.add_lib_flags("hdf5", ["-lhdf5"]) + + # Always link with C++ libs + linker.add_post_lib_flags(["-lstdc++"]) diff --git a/infrastructure/build/fab/default/setup_intel_llvm.py b/infrastructure/build/fab/default/setup_intel_llvm.py deleted file mode 100644 index b95f551..0000000 --- a/infrastructure/build/fab/default/setup_intel_llvm.py +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env python3 - -'''This file contains a function that sets the default flags for all -Intel classic based compilers in the ToolRepository (ifort, icc). - -This function gets called from the default site-specific config file -''' - -from fab.build_config import BuildConfig -from fab.tools import Category, Tool, ToolRepository - - -class Shell(Tool): - '''A simple wrapper that runs a shell script. - :name: the path to the script to run. - ''' - def __init__(self, name: str): - super().__init__(name=name, exec_name=name, - category=Category.MISC) - - def check_available(self): - return True - - -def setup_intel_classic(build_config: BuildConfig): - '''Defines the default flags for all Intel classic compilers. - - :para build_config: the build config from which required parameters - can be taken. - ''' - - tr = ToolRepository() - ifort = tr.get_tool(Category.FORTRAN_COMPILER, "ifort") - - if not ifort.is_available: - # Since some flags depends on version, the code below requires - # that the intel compiler actually works. - return - - # The flag groups are mainly from infrastructure/build/fortran - # /ifort.mk - no_optimisation_flags = ['-O0'] - safe_optimisation_flags = ['-O2', '-fp-model=strict'] - risky_optimisation_flags = ['-O3', '-xhost'] - # With -warn errors we get externals that are too long. While this - # is a (usually safe) warning, the long externals then causes the - # build to abort. So for now we cannot use `-warn errors` - warnings_flags = ['-warn', 'all', '-gen-interfaces', 'nosource'] - unit_warnings_flags = ['-warn', 'all', '-gen-interfaces', 'nosource'] - init_flags = ['-ftrapuv'] - - # ifort.mk: bad interaction between array shape checking and - # the matmul" intrinsic in at least some iterations of v19. - if (19, 0, 0) <= ifort.get_version() < (19, 1, 0): - runtime_flags = ['-check', 'all,noshape', '-fpe0'] - else: - runtime_flags = ['-check', 'all', '-fpe0'] - - # ifort.mk: option for checking code meets Fortran standard - # - currently 2008 - fortran_standard_flags = ['-stand', 'f08'] - - # ifort.mk has some app and file-specific options for older - # intel compilers. They have not been included here - compiler_flag_group = [] - - # TODO: we need to move the compile mode into the BuildConfig - mode = "full_debug" - if mode == 'full-debug': - compiler_flag_group += (warnings_flags + - init_flags + runtime_flags + - no_optimisation_flags + - fortran_standard_flags) - elif mode == 'production': - compiler_flag_group += (warnings_flags + - risky_optimisation_flags) - else: # 'fast-debug' - compiler_flag_group += (warnings_flags + - safe_optimisation_flags + - fortran_standard_flags) - - ifort.add_flags(compiler_flag_group) - - # ATM a linker is not using a compiler wrapper, and so - # linker-mpif90-gfortran does not inherit from linker-gfortran. - # For now set the flags in both linkers: - bash = Shell("bash") - # We must remove the trailing new line, and create a list: - nc_flibs = bash.run(additional_parameters=["-c", "nf-config --flibs"], - capture_output=True).strip().split() - - for linker_name in ["linker-ifort", "linker-mpif90-ifort"]: - linker = tr.get_tool(Category.LINKER, linker_name) - linker.add_lib_flags("netcdf", nc_flibs, silent_replace=True) - linker.add_lib_flags("yaxt", ["-lyaxt", "-lyaxt_c"]) - linker.add_lib_flags("xios", ["-lxios"]) - linker.add_lib_flags("hdf5", ["-lhdf5"]) - - # Always link with C++ libs - linker.add_post_lib_flags(["-lstdc++"]) diff --git a/infrastructure/build/fab/default/setup_nvidia.py b/infrastructure/build/fab/default/setup_nvidia.py deleted file mode 100644 index ed5fa07..0000000 --- a/infrastructure/build/fab/default/setup_nvidia.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python3 - -'''This file contains a function that sets the default flags for all -GNU based compilers in the ToolRepository. - -This function gets called from the default site-specific config file -''' - -from fab.build_config import BuildConfig -from fab.tools import Category, Tool, ToolRepository - - -class Shell(Tool): - '''A simple wrapper that runs a shell script. - :name: the path to the script to run. - ''' - def __init__(self, name: str): - super().__init__(name=name, exec_name=name, - category=Category.MISC) - - def check_available(self): - return True - - -def setup_gnu(build_config: BuildConfig): - '''Defines the default flags for all GNU compilers. - - :para build_config: the build config from which required parameters - can be taken. - ''' - - tr = ToolRepository() - nvfortran = tr.get_tool(Category.FORTRAN_COMPILER, "nvfortran") - flags = [] - nvfortran.add_flags(flags) - - # ATM a linker is not using a compiler wrapper, and so - # linker-mpif90-nvfortran does not inherit from linker-nvfortran. - # For now set the flags in both linkers: - bash = Shell("bash") - # We must remove the trailing new line, and create a list: - nc_flibs = bash.run(additional_parameters=["-c", "nf-config --flibs"], - capture_output=True).strip().split() - - for linker_name in ["linker-nvfortran", "linker-mpif90-nvfortran"]: - linker = tr.get_tool(Category.LINKER, linker_name) - # ATM we don't use a shell when starting a tool, and as such - # we can't directly use "$()". So query these values using - # a dummy shell tool: - - linker.add_lib_flags("netcdf", nc_flibs, silent_replace=True) - linker.add_lib_flags("yaxt", ["-lyaxt", "-lyaxt_c"]) - linker.add_lib_flags("xios", ["-lxios"]) - linker.add_lib_flags("hdf5", ["-lhdf5"]) - - # Always link with C++ libs - linker.add_post_lib_flags(["-lstdc++"]) diff --git a/infrastructure/build/fab/joerg_default/config.py b/infrastructure/build/fab/joerg_default/config.py index 119d770..b3674bb 100644 --- a/infrastructure/build/fab/joerg_default/config.py +++ b/infrastructure/build/fab/joerg_default/config.py @@ -1,6 +1,6 @@ #! /usr/bin/env python3 -from fab.tools import Category, ToolRepository +from fab.tools import ToolRepository from default.config import Config as DefaultConfig @@ -15,26 +15,3 @@ def __init__(self): super().__init__() tr = ToolRepository() tr.set_default_compiler_suite("gnu") - - def setup_gnu(self, build_config): - '''Define default compiler flags for GNU. - ''' - - super().setup_gnu(build_config) - gfortran = ToolRepository().get_tool(Category.FORTRAN_COMPILER, - "gfortran") - gfortran.add_flags( - [ - # The lib directory contains mpi.mod - '-I', ('/home/joerg/work/spack/var/spack/environments/' - 'lfric-v0/.spack-env/view/lib'), - # mod_wait.mod - '-I', ('/home/joerg/work/spack/var/spack/environments/' - 'lfric-v0/.spack-env/view/include'), - '-DITSUPERWORKS' - ]) - for linker_name in ["linker-gfortran", "linker-mpif90-gfortran"]: - gfortran = ToolRepository().get_tool(Category.LINKER, linker_name) - gfortran.add_post_lib_flags( - ['-L', ('/home/joerg/work/spack/var/spack/' - 'environments/lfric-v0/.spack-env/view/lib')]) diff --git a/infrastructure/build/fab/nci_gadi/config.py b/infrastructure/build/fab/nci_gadi/config.py index 347ab12..5d04cfb 100644 --- a/infrastructure/build/fab/nci_gadi/config.py +++ b/infrastructure/build/fab/nci_gadi/config.py @@ -14,18 +14,6 @@ from default.config import Config as DefaultConfig -class Shell(Tool): - '''A simple wrapper that runs a shell script. - :name: the path to the script to run. - ''' - def __init__(self, name: str): - super().__init__(name=name, exec_name=name, - category=Category.MISC) - - def check_available(self): - return True - - class Tauf90(CompilerWrapper): '''Class for the Tau profiling Fortran compiler wrapper. It will be using the name "tau-COMPILER_NAME", but will call tau_f90.sh. @@ -84,15 +72,16 @@ def __init__(self): compiler = tr.get_tool(Category.C_COMPILER, cc) tr.add_tool(Taucc(compiler)) - # ATM a linker is not using a compiler wrapper, and so - # linker-mpif90-gfortran does not inherit from linker-gfortran. - # For now set the flags in both linkers: - bash = Shell("bash") + # ATM we don't use a shell when running a tool, and as such + # we can't directly use "$()" as parameter. So query these values using + # Fab's shell tool (doesn't really matter which shell we get, so just + # ask for the default): + shell = tr.get_default(Category.SHELL) # We must remove the trailing new line, and create a list: - nc_flibs = bash.run(additional_parameters=["-c", "nf-config --flibs"], - capture_output=True).strip().split() + nc_flibs = shell.run(additional_parameters=["-c", "nf-config --flibs"], + capture_output=True).strip().split() linker = tr.get_tool(Category.LINKER, "linker-tau-ifort") - linker.add_lib_flags("netcdf", nc_flibs, silent_replace=True) + linker.add_lib_flags("netcdf", nc_flibs) linker.add_lib_flags("yaxt", ["-lyaxt", "-lyaxt_c"]) linker.add_lib_flags("xios", ["-lxios"]) linker.add_lib_flags("hdf5", ["-lhdf5"])