From 3cce5de334ea4513c71cb924a87127c66d24b3c9 Mon Sep 17 00:00:00 2001 From: juckerj <39263956+jonasjucker@users.noreply.github.com> Date: Tue, 13 Aug 2024 09:57:00 +0200 Subject: [PATCH] drop rttov (#986) --- repos/c2sm/packages/icon/package.py | 24 +-- .../kind_inconsistency/mod_brdf_atlas.patch | 10 - .../kind_inconsistency/rttov_types.patch | 14 -- repos/c2sm/packages/rttov/package.py | 200 ------------------ test/system_test.py | 10 +- 5 files changed, 2 insertions(+), 256 deletions(-) delete mode 100644 repos/c2sm/packages/rttov/kind_inconsistency/mod_brdf_atlas.patch delete mode 100644 repos/c2sm/packages/rttov/kind_inconsistency/rttov_types.patch delete mode 100644 repos/c2sm/packages/rttov/package.py diff --git a/repos/c2sm/packages/icon/package.py b/repos/c2sm/packages/icon/package.py index ef1aa84e67..2469c859ef 100755 --- a/repos/c2sm/packages/icon/package.py +++ b/repos/c2sm/packages/icon/package.py @@ -89,10 +89,6 @@ class Icon(AutotoolsPackage, CudaPackage): default=True, description='Enable usage of the RTE+RRTMGP toolbox ' 'for radiation calculations') - variant( - 'rttov', - default=False, - description='Enable usage of the radiative transfer model for TOVS') variant('dace', default=False, description='Enable the DACE modules for data assimilation') @@ -232,9 +228,6 @@ class Icon(AutotoolsPackage, CudaPackage): depends_on('libfyaml', when='+coupling') depends_on('libxml2', when='+art') - depends_on('rttov+hdf5', when='+rttov') - depends_on('rttov~openmp', when='~openmp+rttov') - for x in serialization_values: depends_on('serialbox+fortran', when='serialization={0}'.format(x)) # WORKAROUND: A build and link dependency should imply that the same compiler is used. This enforces it. @@ -322,7 +315,6 @@ def configure_args(self): 'nwp', 'ecrad', 'rte-rrtmgp', - 'rttov', 'dace', 'emvorado', 'art', @@ -507,9 +499,6 @@ def configure_args(self): if '+cdi-pio' in self.spec: libs += self.spec['yaxt:fortran'].libs - if '+rttov' in self.spec: - libs += self.spec['rttov'].libs - libs += self.spec['lapack:fortran'].libs libs += self.spec['blas:fortran'].libs libs += self.spec['netcdf-fortran'].libs @@ -517,7 +506,7 @@ def configure_args(self): if '+coupling' in self.spec or '~cdi-pio' in self.spec: libs += self.spec['netcdf-c'].libs - if '+emvorado' in self.spec or '+rttov' in self.spec: + if '+emvorado' in self.spec: libs += self.spec['hdf5:fortran,hl'].libs elif '+sct' in self.spec: libs += self.spec['hdf5'].libs @@ -683,17 +672,6 @@ def validate_extra_config_args(self, arg): f'with the existing variant {variant_from_arg}. Set this variant instead.' ) - @run_after('configure') - def adjust_rttov_macro(self): - if '+rttov' in self.spec: - rttov_major_version = self.spec['rttov'].version.up_to(1) - if rttov_major_version != ver(13): - filter_file('_RTTOV_VERSION=13', - '_RTTOV_VERSION={0}'.format(rttov_major_version), - 'icon.mk', - string=True, - backup=False) - def check(self): # By default "check" calls make with targets "check" and "test". # This testing is beyond the scope of BuildBot test at CSCS. diff --git a/repos/c2sm/packages/rttov/kind_inconsistency/mod_brdf_atlas.patch b/repos/c2sm/packages/rttov/kind_inconsistency/mod_brdf_atlas.patch deleted file mode 100644 index 2da82a381a..0000000000 --- a/repos/c2sm/packages/rttov/kind_inconsistency/mod_brdf_atlas.patch +++ /dev/null @@ -1,10 +0,0 @@ -# This patch is applicable starting version 12.1 ---- a/src/brdf_atlas/mod_brdf_atlas.F90 -+++ b/src/brdf_atlas/mod_brdf_atlas.F90 -@@ -83,3 +83,3 @@ MODULE mod_brdf_atlas -- INTEGER(KIND=jpim), PARAMETER :: brdfmodis_gridres = 100_jprb ! 0.1 deg -- INTEGER(KIND=jpim), PARAMETER :: brdfmodis_ygrid1 = 89950_jprb ! 89.95 deg -- INTEGER(KIND=jpim), PARAMETER :: brdfmodis_xgrid1 = -179950_jprb ! -179.95 deg -+ INTEGER(KIND=jpim), PARAMETER :: brdfmodis_gridres = 100_jpim ! 0.1 deg -+ INTEGER(KIND=jpim), PARAMETER :: brdfmodis_ygrid1 = 89950_jpim ! 89.95 deg -+ INTEGER(KIND=jpim), PARAMETER :: brdfmodis_xgrid1 = -179950_jpim ! -179.95 deg diff --git a/repos/c2sm/packages/rttov/kind_inconsistency/rttov_types.patch b/repos/c2sm/packages/rttov/kind_inconsistency/rttov_types.patch deleted file mode 100644 index d01a1dedb7..0000000000 --- a/repos/c2sm/packages/rttov/kind_inconsistency/rttov_types.patch +++ /dev/null @@ -1,14 +0,0 @@ -# This patch is applicable only for version 12.3 -# but a similar one is needed for version 12.2 ---- a/src/main/rttov_types.F90 -+++ b/src/main/rttov_types.F90 -@@ -1308,3 +1308,3 @@ MODULE rttov_types -- REAL(jpim), POINTER :: coef_pdt(:,:) => NULL() -- REAL(jpim), POINTER :: val_mean(:) => NULL() -- REAL(jpim), POINTER :: val_norm(:) => NULL() -+ REAL(jprb), POINTER :: coef_pdt(:,:) => NULL() -+ REAL(jprb), POINTER :: val_mean(:) => NULL() -+ REAL(jprb), POINTER :: val_norm(:) => NULL() -@@ -1314 +1314 @@ MODULE rttov_types -- REAL(jpim), POINTER :: pc(:,:) => NULL() -+ REAL(jprb), POINTER :: pc(:,:) => NULL() diff --git a/repos/c2sm/packages/rttov/package.py b/repos/c2sm/packages/rttov/package.py deleted file mode 100644 index 2fc2fcab62..0000000000 --- a/repos/c2sm/packages/rttov/package.py +++ /dev/null @@ -1,200 +0,0 @@ -import os -from collections import defaultdict - -from llnl.util import lang - - -class Rttov(Package): - """RTTOV (Radiative Transfer for TOVS) is a very fast radiative transfer - model for passive visible, infrared and microwave downward-viewing satellite - radiometers, spectrometers and interferometers.""" - - homepage = 'https://nwp-saf.eumetsat.int/site/software/rttov/' - git = 'git@github.com:C2SM/rttov.git' - - version('13.1', tag='v13.1', git=git) - - variant('hdf5', default=False, description='Enable HDF5 support') - variant('netcdf', default=False, description='Enable NetCDF support') - variant('openmp', default=False, description='Enable OpenMP support') - - depends_on('lapack') - # There is no direct dependency on BLAS API but we might not be able to link - # to 'lapack:fortran' libraries without linking to 'blas:fortran' ones when - # using an external customized installation of LAPACK. For example, in case - # of libraries that are shipped together with PGI/NVIDIA compilers, - # subroutine DGETRF, which is part of the LAPACK API, is implemented not in - # liblapack.so but in libblas.so. - depends_on('blas') - - depends_on('netcdf-fortran', when='+netcdf') - depends_on('hdf5+fortran+hl', when='+hdf5') - - depends_on('perl', type='build') - - # Fix kind inconsistency: - patch('kind_inconsistency/mod_brdf_atlas.patch', when='@12.1:') - patch('kind_inconsistency/rttov_types.patch', when='@12.3') - - def url_for_version(self, version): - return 'file://{0}/rttov{1}.tar.{2}'.format( - os.getcwd(), version.joined, - 'gz' if int(str(version.up_to(1))) <= 12 else 'xz') - - @when('%nag') - def patch(self): - # A number of source files assume that the kinds of integer and real - # variables are specified in bytes. However, the NAG compiler accepts - # such code only with an additional compiler flag -kind=byte. We do not - # simply add the flag because all user applications would have to be - # compiled with this flag too, which goes against one of the purposes of - # using the NAG compiler: make sure the code does not contradict the - # Fortran standards. The following logic could have been implemented as - # regular patch files, which would, however, be quite large. We would - # also have to introduce several versions of each patch file to support - # different versions of the package. - - patch_kind_files = [ - 'src/main/rttov_fastem5.F90', 'src/main/rttov_fastem5_ad.F90', - 'src/main/rttov_fastem5_k.F90', 'src/main/rttov_fastem5_tl.F90' - ] - - filter_file(r'(?i)(real\(\d+,)8(\))', - '\\1selected_real_kind(13, 300)\\2', - *patch_kind_files, - ignore_absent=True) - - @property - def libs(self): - basenames = [ - 'other', 'emis_atlas', 'brdf_atlas', 'parallel', 'coef_io' - ] - if '+hdf5' in self.spec: - basenames.append('hdf') - basenames.append('main') - return find_libraries([ - 'librttov{0}_{1}'.format(self.spec.version.up_to(1), n) - for n in basenames - ], - root=self.prefix.lib, - shared=False) - - def install(self, spec, prefix): - build_aux_dir = join_path(self.stage.source_path, 'build') - - arch_filename = 'spack' - # We provide the variables on the command line or via the environment - # instead of writing them to an arch file: - with open(join_path(build_aux_dir, 'arch', arch_filename), 'w'): - pass - - build_dirname = 'spack-build' - - makefile_args = [ - 'ARCH={0}'.format(arch_filename), - 'INSTALLDIR={0}'.format(build_dirname), 'AR=ar r' - ] - - makefile_vars = defaultdict(list) - - # Paths to the compilers are set by Spack automatically via the - # environment variables: CC, FC and F77. However the makefile of the - # package expects the Fortran 77 compiler to be set as FC77. Therefore, - # we provide the value on the command line: - makefile_vars['FC77'].append(self.compiler.f77) - - # The following is taken from files in the 'build/arch' directory: - if self.compiler.name == 'gcc' or self._compiler_is_mixed_gfortran(): - makefile_vars['FFLAGS_ARCH'].append('-O3 -ffree-line-length-none') - elif self.compiler.name == 'intel': - common_flags = '-O3 -fp-model source' - makefile_vars['FFLAGS_ARCH'].append(common_flags) - target_basenames = ['rttov_opdep_9_ad', 'rttov_opdep_9_k'] - if self.spec.satisfies('@13:'): - target_basenames.extend( - ['rttov_opdep_13_ad', 'rttov_opdep_13_k']) - for f in target_basenames: - makefile_vars['FFLAGS_ARCH_{0}'.format(f)].extend( - ['-unroll0', common_flags]) - if '+openmp' in self.spec: - for f in ['rttov_mfasis_ad', 'rttov_mfasis_k']: - makefile_vars['FFLAGS_ARCH_{0}'.format(f)].append( - '-O2 -fp-model source') - elif self.compiler.name == 'nag': - common_flags = '-maxcontin=500' - makefile_vars['FFLAGS_ARCH'].extend(['-O4', common_flags]) - makefile_vars['FFLAGS_ARCH_rttov_unix_env'].extend( - ['-DRTTOV_USE_F90_UNIX_ENV', '-O4', common_flags]) - if self.spec.satisfies('@13:'): - for f in ['rttov_fresnel_ad', 'rttov_fresnel_k']: - makefile_vars['FFLAGS_ARCH_{0}'.format(f)].extend( - ['-O0', common_flags]) - elif self.compiler.name in ['pgi', 'nvhpc']: - common_flags = '-Kieee -notraceback' - makefile_vars['FFLAGS_ARCH'].extend([ - '-O2', '-fast' if '+openmp' in self.spec else '-fastsse', - common_flags - ]) - makefile_vars['FFLAGS_ARCH_rttov_dom_setup_profile'].extend( - ['-O1', common_flags]) - else: - makefile_vars['FFLAGS_ARCH'].append('-O2') - - if '+openmp' in self.spec: - openmp_flag = self.compiler.openmp_flag - if self._compiler_is_mixed_gfortran(): - from spack.compilers.gcc import Gcc - openmp_flag = Gcc.openmp_flag - - for var, val in makefile_vars.items(): - if var.startswith('FFLAGS_ARCH'): - val.append(openmp_flag) - makefile_vars['LDFLAGS_ARCH'].append(openmp_flag) - - if '+netcdf' in self.spec: - makefile_vars['FFLAGS_EXTERN'].append('-D_RTTOV_NETCDF') - makefile_vars['LDFLAGS_EXTERN'].append( - self.spec['netcdf-fortran'].libs.link_flags) - - if '+hdf5' in self.spec: - makefile_vars['FFLAGS_EXTERN'].append('-D_RTTOV_HDF') - makefile_vars['LDFLAGS_EXTERN'].append( - self.spec['hdf5:fortran,hl'].libs.link_flags) - - lapack_libs = self.spec['lapack:fortran'].libs - lapack_libs += self.spec['blas:fortran'].libs - makefile_vars['LDFLAGS_EXTERN'].append(lapack_libs.link_flags) - - makefile_args.extend([ - '{0}={1}'.format(var, ' '.join(val)) - for var, val in makefile_vars.items() - ]) - - with working_dir(join_path(self.stage.source_path, 'src')): - makefile_pl = Executable(join_path(build_aux_dir, 'Makefile.PL')) - makefile_pl( - 'RTTOV_HDF={0}'.format('1' if '+hdf5' in self.spec else '0'), - 'RTTOV_F2PY=0', 'RTTOV_USER_LAPACK=1') - make(*makefile_args, parallel=False) - - build_dir = join_path(self.stage.source_path, build_dirname) - - install_tree(join_path(build_dir, 'bin'), prefix.bin) - install_tree(join_path(build_dir, 'lib'), prefix.lib) - - # Install the Fortran module and include files to the same directory: - install_tree(join_path(build_dir, 'include'), prefix.include) - install_tree(join_path(build_dir, 'mod'), prefix.include) - - @lang.memoized - def _compiler_is_mixed_gfortran(self): - if self.compiler.name == 'gcc' or not self.compiler.fc: - return False - - fc_name, _, _ = os.path.basename(self.compiler.fc).partition('-') - - if not fc_name: - return False - - from spack.compilers.gcc import Gcc - return fc_name in Gcc.fc_names diff --git a/test/system_test.py b/test/system_test.py index 424bc6d6d3..1242cfe34a 100644 --- a/test/system_test.py +++ b/test/system_test.py @@ -123,7 +123,6 @@ def test_install_2024_1_nvhpc(): @pytest.mark.icon def test_install_conditional_dependencies(): # +coupling triggers libfyaml, libxml2, netcdf-c - # +rttov triggers rttov # serialization=create triggers serialbox # +cdi-pio triggers libcdi-pio, yaxt (but unfortunately this is broken) # +emvorado triggers eccodes, hdf5, zlib @@ -132,7 +131,7 @@ def test_install_conditional_dependencies(): # gpu=openacc+cuda triggers cuda spack_install( - 'icon @2024.1-1 %nvhpc +coupling +rttov serialization=create +emvorado +mpi gpu=openacc+cuda cuda_arch=80' + 'icon @2024.1-1 %nvhpc +coupling serialization=create +emvorado +mpi gpu=openacc+cuda cuda_arch=80' ) @@ -258,13 +257,6 @@ def test_install_py_typing_extensions_default(devirt_env): spack_install('py-typing-extensions') -@pytest.mark.no_balfrin #Irrelevant -@pytest.mark.rttov -@pytest.mark.parametrize("compiler", ['gcc', 'nvhpc']) -def test_install_rttov(compiler): - spack_install(f'rttov @13.1 %{compiler}') - - @pytest.mark.scales_ppm def test_install_default(): spack_install('scales-ppm')