# IT4Innovations
# LK 2023

name = 'Amber'
local_amber_ver = 22
local_ambertools_ver = 23
# Patch levels from https://ambermd.org/AmberPatches.php and https://ambermd.org/ATPatches.php
patchlevels = (3, 0)  # (AmberTools, Amber)
version = '%s.%s' % (local_amber_ver, patchlevels[1])
versionsuffix = '-AmberTools-%s.%s' % (local_ambertools_ver, patchlevels[0])

homepage = 'https://ambermd.org/amber.html'
description = """Amber (originally Assisted Model Building with Energy Refinement) is software for performing
 molecular dynamics and structure prediction."""

toolchain = {'name': 'foss', 'version': '2021b'}
toolchainopts = {'usempi': True, 'openmp': True}

sources = [
    '%%(name)s%s.tar.bz2' % local_amber_ver,
    {'filename': 'AmberTools%s.tar.bz2' % local_ambertools_ver, 'alt_location': 'AmberTools'},
]
patches = [
    {'name': 'AmberTools-20_cmake-locate-netcdf.patch', 'alt_location': 'AmberTools'},
    {'name': 'AmberTools-20_fix_missing_MPI_LIBRARY_error.patch', 'alt_location': 'AmberTools'},
    {'name': 'AmberTools-20_fix_xblas_missing_make_dependency.patch', 'alt_location': 'AmberTools'},
    {'name': 'AmberTools-21_CMake-FlexiBLAS.patch', 'alt_location': 'AmberTools'},
 #   {'name': 'AmberTools-21_fix_DGESVD_workspace_query.patch', 'alt_location': 'AmberTools'},
    {'name': 'AmberTools-21_fix_incorrect_dvout_call.patch', 'alt_location': 'AmberTools'},
 #   {'name': 'AmberTools-21_fix_incorrect_mexit_calls.patch', 'alt_location': 'AmberTools'},
    {'name': 'AmberTools-21_fix_more_blas_argument_problems.patch', 'alt_location': 'AmberTools'},
 #   {'name': 'AmberTools-21_fix_multiple_definition.patch', 'alt_location': 'AmberTools'},
    {'name': 'AmberTools-21_fix_potential_use_before_init.patch', 'alt_location': 'AmberTools'},
    {'name': 'AmberTools-21_fix_rism_argument_mismatch.patch', 'alt_location': 'AmberTools'},
    {'name': 'AmberTools-21_fix_xray_fftpack_arg_mismatch.patch', 'alt_location': 'AmberTools'},
    {'name': 'AmberTools-22_fix_test_missing_cuda_dir.patch', 'alt_location': 'AmberTools'},
    #{'name': 'AmberTools-22_fix_missing_error_check_on_test_run.patch', 'alt_location': 'AmberTools'},
    'Amber-22_reduce_precision_of_kmmd_test.patch',
    'Amber-22_remove_undeclared_redundant_variable.patch',
]
checksums = [
    '3c887ccbad690fc76ff0b120a3448eae023c08e76582aac07900d4a9708ebd16',  # Amber22.tar.bz2
    'debb52e6ef2e1b4eaa917a8b4d4934bd2388659c660501a81ea044903bf9ee9d',  # AmberTools23.tar.bz2
    '473e07c53b6f641d96d333974a6af2e03413fecef79f879d3fdecf7fecaab4d0',  # AmberTools-20_cmake-locate-netcdf.patch
    # AmberTools-20_fix_missing_MPI_LIBRARY_error.patch
    '0b89a0624167bc23876bcdefcb1055f591e38e3bd559a71d5749e342bd311acc',
    # AmberTools-20_fix_xblas_missing_make_dependency.patch
    'ff25e91fdc72347a778c3837b581e174d6a8c71efa5b46e11391b18bca84fd65',
    '9543812c24c4b7842f64f1f8abaf2c92b5c4c0fadcdbd9811e76b81a778f0d36',  # AmberTools-21_CMake-FlexiBLAS.patch
    # AmberTools-21_fix_DGESVD_workspace_query.patch
    #'560c73e9d8bd159c609098c63a0256cdee78f49e524d06ea94d16d3146f69bcd',
    '1054d4007f5c79126a41582e1e80514267cf406416ed6c471574cd708b16319b',  # AmberTools-21_fix_incorrect_dvout_call.patch
    #'d1de8c596119dcedbb809515816f0c98762306c469e9caf2c0b878d9b0a1095f',  # AmberTools-21_fix_incorrect_mexit_calls.patch
    # AmberTools-21_fix_more_blas_argument_problems.patch
    'c6279b57752239184b942d37f760749494ae0eff95236f3368c76ac0d2726a7c',
    #'ce30eeaba9feea53aa115e4b0dcc5be943b8a55abe322480c807ca7ea963d83b',  # AmberTools-21_fix_multiple_definition.patch
    # AmberTools-21_fix_potential_use_before_init.patch
    '377e645b5bd2c91ebb4d0b6fbca0407a94289e5ddc5b1e7ed0cb0b0724ad2139',
    # AmberTools-21_fix_rism_argument_mismatch.patch
    '14255e5739cec39303df570f06820c7532f7395e1b73b1e4104377984e2c9fc1',
    # AmberTools-21_fix_xray_fftpack_arg_mismatch.patch
    '99c954e693659efc2a1d121f91510f56408006f0751d91595f45a34b03364e2f',
    'fb1ab74314d7816169bb9f3f527b78085654aae2825c52cebf50a5760401b737',  # AmberTools-22_fix_test_missing_cuda_dir.patch
    # AmberTools-22_fix_missing_error_check_on_test_run.patch
    #'a86eee60bd65c16a849469e303cb99dfc207cbadd2ae9e70b9ff580ced785475',
    'b5855866c63c2ee860a5e6ad6f618ac4dab7072f5caae95769d4b2457d616a8e',  # Amber-22_reduce_precision_of_kmmd_test.patch
    # Amber-22_remove_undeclared_redundant_variable.patch
    'b94900c2178dd6dbf2824b17074980a3e5e6e71b38c0b2b30e1f147e4e1ac8cb',
]

builddependencies = [
    ('CMake', '3.21.1'),
    ('Bison', '3.7.6'),
    ('flex', '2.6.4'),
    ('make', '4.3'),
]

dependencies = [
    ('zlib', '1.2.11'),
    ('bzip2', '1.0.8'),
    ('Python', '3.9.6'),
    ('SciPy-bundle', '2021.10'),  # mpi4py required for MMPBSA
    ('Perl', '5.34.0'),
    ('Boost', '1.77.0'),
    ('libreadline', '8.1'),
    ('matplotlib', '3.4.3'),
    ('netCDF', '4.8.1'),
    ('netCDF-Fortran', '4.5.3'),
    ('PnetCDF', '1.12.3'),
    ('Tkinter', '3.9.6'),
    ('X11', '20210802'),
]

# All tests are expected to pass or be skipped
runtest = True

static = False

moduleclass = 'chem'
