From 69128132b97e1dd8afcd80360599f8e70a9f6c23 Mon Sep 17 00:00:00 2001 From: Tammo van der Heide Date: Fri, 26 Apr 2024 16:06:44 +0200 Subject: [PATCH] Perform various infrastructure related trivial updates --- CONTRIBUTING.rst | 18 ++-- cmake/Modules/FindCustomBlas.cmake | 2 +- cmake/Modules/FindCustomLapack.cmake | 2 +- cmake/SkProgsUtils.cmake | 2 +- common/include/LICENSE | 2 +- common/include/common.fypp | 97 +++++++++++++++++++--- common/include/error.fypp | 61 ++++++++++++-- doc/devel/code_structure.txt | 3 +- doc/devel/general_notes.txt | 6 +- doc/input.txt | 2 +- sys/generic.cmake | 2 +- sys/intel.cmake | 9 +- tools/utils/srccheck/pylint/pylintrc-2.ini | 26 ------ tools/utils/srccheck/pylint/pylintrc-3.ini | 30 ------- utils/srccheck/pylint/pylintrc-2.ini | 26 ------ utils/srccheck/pylint/pylintrc-3.ini | 30 ------- 16 files changed, 164 insertions(+), 154 deletions(-) delete mode 100644 tools/utils/srccheck/pylint/pylintrc-2.ini delete mode 100644 tools/utils/srccheck/pylint/pylintrc-3.ini delete mode 100644 utils/srccheck/pylint/pylintrc-2.ini delete mode 100644 utils/srccheck/pylint/pylintrc-3.ini diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 93f75b4e..9e445389 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -35,24 +35,24 @@ When you contribute to the project, your contribution must align with the Developer Certificate of Origin Version 1.1 - + Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 1 Letterman Drive Suite D4700 San Francisco, CA, 94129 - + Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - - + + Developer's Certificate of Origin 1.1 - + By making a contribution to this project, I certify that: - + (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or - + (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that @@ -60,11 +60,11 @@ When you contribute to the project, your contribution must align with the by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or - + (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. - + (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is diff --git a/cmake/Modules/FindCustomBlas.cmake b/cmake/Modules/FindCustomBlas.cmake index 6ec8e9c2..bc195426 100644 --- a/cmake/Modules/FindCustomBlas.cmake +++ b/cmake/Modules/FindCustomBlas.cmake @@ -1,6 +1,6 @@ # Distributed under the OSI-approved BSD 2-Clause License. # -# Copyright (C) 2021 DFTB+ developers group +# Copyright (C) 2024 DFTB+ developers group # #[=======================================================================[.rst: diff --git a/cmake/Modules/FindCustomLapack.cmake b/cmake/Modules/FindCustomLapack.cmake index 7486c0a6..365d683f 100644 --- a/cmake/Modules/FindCustomLapack.cmake +++ b/cmake/Modules/FindCustomLapack.cmake @@ -1,6 +1,6 @@ # Distributed under the OSI-approved BSD 2-Clause License. # -# Copyright (C) 2021 DFTB+ developers group +# Copyright (C) 2024 DFTB+ developers group # #[=======================================================================[.rst: diff --git a/cmake/SkProgsUtils.cmake b/cmake/SkProgsUtils.cmake index dd57ebbc..d5f85909 100644 --- a/cmake/SkProgsUtils.cmake +++ b/cmake/SkProgsUtils.cmake @@ -137,7 +137,7 @@ function(skprogs_guess_toolchain toolchain) if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU") set(_toolchain "gnu") - elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel") + elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel|IntelLLVM") set(_toolchain "intel") elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "NAG") set(_toolchain "nag") diff --git a/common/include/LICENSE b/common/include/LICENSE index 39a18bb4..10fb1e3e 100644 --- a/common/include/LICENSE +++ b/common/include/LICENSE @@ -1,5 +1,5 @@ DFTB+: general package for performing fast atomistic simulations -Copyright (C) 2006 - 2021 DFTB+ developers group +Copyright (C) 2006 - 2024 DFTB+ developers group This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free diff --git a/common/include/common.fypp b/common/include/common.fypp index 917f43d9..38fa456a 100644 --- a/common/include/common.fypp +++ b/common/include/common.fypp @@ -1,6 +1,6 @@ #!-------------------------------------------------------------------------------------------------! #! DFTB+: general package for performing fast atomistic simulations ! -#! Copyright (C) 2006 - 2020 DFTB+ developers group ! +#! Copyright (C) 2006 - 2024 DFTB+ developers group ! #! ! #! See the LICENSE file for terms of usage and distribution. ! #!-------------------------------------------------------------------------------------------------! @@ -12,22 +12,48 @@ #! Default values for all preprocessor variables #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -#:if not defined('DEBUG') - #:set DEBUG = 0 -#:endif - +#:set DEBUG = getvar('DEBUG', 0) #:set WITH_ASSERT = defined('WITH_ASSERT') or DEBUG > 0 #:set WITH_MPI = defined('WITH_MPI') +#:set WITH_OMP = defined('WITH_OMP') +#:set WITH_GPU = defined('WITH_GPU') +#:set WITH_MAGMA = defined('WITH_MAGMA') +#:set WITH_ELSI = defined('WITH_ELSI') +#:set WITH_PEXSI = defined('WITH_PEXSI') and WITH_ELSI +#:set WITH_SCALAPACK = defined('WITH_SCALAPACK') +#:set WITH_MBD = defined('WITH_MBD') +#:set WITH_SOCKETS = defined('WITH_SOCKETS') +#:set WITH_ARPACK = defined('WITH_ARPACK') +#:set WITH_PLUMED = defined('WITH_PLUMED') +#:set WITH_TRANSPORT = defined('WITH_TRANSPORT') +#:set WITH_POISSON = defined('WITH_POISSON') +#:set WITH_SDFTD3 = defined('WITH_SDFTD3') +#:set WITH_TBLITE = defined('WITH_TBLITE') +#:set WITH_CHIMES = defined('WITH_CHIMES') +#:set WITH_UNIT_TESTS = defined('WITH_UNIT_TESTS') +#:set EXP_TRAP = defined('EXP_TRAP') +#:set INTERNAL_ERFC = defined('INTERNAL_ERFC') +#:set EMULATE_F08_MATH = defined('EMULATE_F08_MATH') +#:set INSTANCE_SAFE_BUILD = defined('INSTANCE_SAFE_BUILD') + #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #! ASSERT and DEBUG related macros #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #! Check a condition if WITH_ASSERT is True and call assertError if condition is False. -#:def ASSERT(cond) +#! If an optional text string is included, print this in addition as an error +#:def ASSERT(cond, msg=None) #:if WITH_ASSERT if (.not. (${cond}$)) then - call assertError("${_FILE_}$", ${_LINE_}$) + block + use dftbp_common_assert, only : assertError + #:if msg + call assertError("${_FILE_}$", ${_LINE_}$, ${msg}$) + #:else + call assertError("${_FILE_}$", ${_LINE_}$) + #:endif + end block end if #:endif #:enddef ASSERT @@ -40,7 +66,32 @@ #:endif #:enddef DEBUG_CODE -#:endif + +#! Adds a code block depending on the availability of an optional build component. +#! +#! Wraps code accessing routines or methods of an optional build component. The progamming +#! logic outside of the wrapped code must ensure, that the wrapped block is never reached if the +#! optional component is not available. (In debug mode the wrapped code will be replaced with an +#! error-call if the component is not available.) +#! +#! Args: +#! name (str): Name of the external component +#! available (bool): Whether the external component is available +#! code (str): Code to wrap +#! +#:def REQUIRES_COMPONENT(name, available, code) + #:if available + $:code + #:else + #:if DEBUG > 0 + block + use dftbp_io_message, only : error + call error("Internal error: trying to execute code of the non-existent component '${name}$'") + end block + #:endif + #:endif +#:enddef REQUIRES_COMPONENT + #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -58,11 +109,31 @@ #:enddef -#! Macro for automated deallocations -#:def SAFE_DEALLOC(*args) - #:for arg in args - if (allocated(${arg}$)) deallocate(${arg}$) - #:endfor +#! Creates a class instance by allocating, initializing and move_allocing a specific type +#! +#! Args: +#! cls (str): Name of the LHS variable (must be a class) +#! dyntype (str): Dynamic type of the actual instance to be initialized +#! init (str): Initialization routine to call (with allocated instance as first arg) +#! initargs (str): Further arguments to pass to the init routine. +#:def CREATE_CLASS(cls, dyntype, init, *initargs) +block + type(${dyntype}$), allocatable :: inst + allocate(inst) + call ${init}$(inst, ${", ".join(initargs)}$) + call move_alloc(inst, ${cls}$) +end block #:enddef + +#! Simple macro printing out the position of a line +#:def PRINT_POSITION() +block + use iso_fortran_env, only : output_unit + write(output_unit, "(a)") "Reached line ${_LINE_}$ in ${_FILE_}$" + flush(output_unit) +end block +#:enddef + +#:endif #:endmute diff --git a/common/include/error.fypp b/common/include/error.fypp index b63680a8..e83610f9 100644 --- a/common/include/error.fypp +++ b/common/include/error.fypp @@ -1,12 +1,17 @@ #!-------------------------------------------------------------------------------------------------! #! DFTB+: general package for performing fast atomistic simulations ! -#! Copyright (C) 2006 - 2020 DFTB+ developers group ! +#! Copyright (C) 2006 - 2024 DFTB+ developers group ! #! ! #! See the LICENSE file for terms of usage and distribution. ! #!-------------------------------------------------------------------------------------------------! +#! +#:mute +#:if not defined("_ERROR_FYPP_") +#:set _ERROR_FYPP_ + #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -#! Error string handling wrappers for returns from routinese +#! Error string handling wrappers for returns from routines #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -14,11 +19,11 @@ #! an error and shut down otherwise #:def ERROR_HANDLING(errVar, errNumber, msg) block - use dftbp_accuracy, only : lc - use dftbp_message + use dftbp_common_accuracy, only : lc + use dftbp_io_message !> Error handling string character(lc) :: stringTmp - + write(stringTmp,"(A)")${msg}$ if (present(${errVar}$)) then ${errVar}$ = ${errNumber}$ @@ -35,8 +40,8 @@ #! an error and shut down otherwise #:def FORMATTED_ERROR_HANDLING(errVar, errNumber, formating, *variables) block - use dftbp_accuracy, only : lc - use dftbp_message + use dftbp_common_accuracy, only : lc + use dftbp_io_message !> Error handling string character(lc) :: stringTmp @@ -60,3 +65,45 @@ end if end if #:enddef + + +#! Signals error status. +#:def SET_ERROR(status, code, message) + call ${status}$%setError(${code}$, ${message}$, "${_FILE_}$", ${_LINE_}$) +#:enddef SET_ERROR + + +#! Signals error status with error message formatting +#:def SET_FORMATTED_ERROR(status, code, format, *messageVars) + block + character(1024) :: message + write(message, ${ format }$) ${ ",".join(messageVars) }$ + $:SET_ERROR(status, code, 'trim(message)') + end block +#:enddef SET_FORMATTED_ERROR + + +#! Signals error status and returns from current scope +#:def RAISE_ERROR(status, code, message) + $:SET_ERROR(status, code, message) + return +#:enddef RAISE_ERROR + + +#! Signals error status with error message formatting and returns from current scope +#:def RAISE_FORMATTED_ERROR(status, code, format, *messageVars) + $:SET_FORMATTED_ERROR(status, code, format, *messageVars) + return +#:enddef + + +#! Returns immediately from current scope if status signals an error. +#:def PROPAGATE_ERROR(status) + if (${status}$%hasError()) then + return + end if +#:enddef PROPAGATE_ERROR + + +#:endif +#:endmute diff --git a/doc/devel/code_structure.txt b/doc/devel/code_structure.txt index e65dea68..5232dd7f 100644 --- a/doc/devel/code_structure.txt +++ b/doc/devel/code_structure.txt @@ -4,7 +4,7 @@ OVERVIEW main.f90: main program globals.f90: Variables of the main program, except the mixer all - other subroutines/functions use intent(in)/intent(out) to protect + other subroutines/functions use intent(in)/intent(out) to protect these variables, so in some sence this is not global The variables are also allocated here. IMPORTANT: This also gives a short comment what the variable is ! @@ -49,4 +49,3 @@ utilities.f90: misc stuff (factorial etc.) zora_routines.f90: ZORA routines, contains even the routines for the naive implementation, see NAIVE_ZORA for their use - diff --git a/doc/devel/general_notes.txt b/doc/devel/general_notes.txt index bddb7bfc..7d4d12dc 100644 --- a/doc/devel/general_notes.txt +++ b/doc/devel/general_notes.txt @@ -41,7 +41,7 @@ alpha with a known issue: Although I am confident I got the prefactor right I cannot reproduce literature results. Not sure why. For the ZORA stuff see vlenthe.pdf in references. Here, I basically use -the implementation for ADF Band (Chapter 6.2) which explicitely assumes a +the implementation for ADF Band (Chapter 6.2) which explicitely assumes a sphericallysymmetric potential with one more step (which has to be checked): Impementing 6.13-6.15 directly leads to an matrix element containg the second derivative of the basis function. IMHO one can @@ -60,7 +60,7 @@ ZORA as currently implemented. The confining potential matrix elements are also evaluated analytically. The confinig potential does not enter in the ZORA kinetic energy -operator, since the kinetic energy would then vanish for r->infty which is -clearly wrong. Having the confining potential only in the SCF potential but +operator, since the kinetic energy would then vanish for r->infty which is +clearly wrong. Having the confining potential only in the SCF potential but not in the ZORA kinetic energy seems to work reasonanbly judging from the expectation values. diff --git a/doc/input.txt b/doc/input.txt index f18dbbbe..f4b64d51 100644 --- a/doc/input.txt +++ b/doc/input.txt @@ -13,7 +13,7 @@ Line 2: xc_functional integer :: xc_functional, 0=HF, 1=X-Alpha, 2=PW-LDA, 3=PBE - NOTE: HF only correct for 1S states, X-Aalpha is untested alpha=0.7 + NOTE: HF only correct for 1S states, X-Alpha is untested alpha=0.7 Line 3: r_0 power diff --git a/sys/generic.cmake b/sys/generic.cmake index c6fde8ce..3102fac0 100644 --- a/sys/generic.cmake +++ b/sys/generic.cmake @@ -28,7 +28,7 @@ set(Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" set(Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" CACHE STRING "Fortran compiler flags for Release build") -set(Fortran_FLAGS_RELWITHDEBINFO "${Fortran_FLAGS_RELWITHDEBINFO}" +set(Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO}" CACHE STRING "Fortran compiler flags for Release build") set(Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" diff --git a/sys/intel.cmake b/sys/intel.cmake index 98c32ddc..e4c1fa02 100644 --- a/sys/intel.cmake +++ b/sys/intel.cmake @@ -18,8 +18,13 @@ # # Fortran compiler settings # -set(Fortran_FLAGS_RELEASE "-O2 -ip" - CACHE STRING "Fortran compiler flags for Release build") +if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "IntelLLVM") + set(Fortran_FLAGS_RELEASE "-O2" + CACHE STRING "Fortran compiler flags for Release build") +else() + set(Fortran_FLAGS_RELEASE "-O2 -ip" + CACHE STRING "Fortran compiler flags for Release build") +endif() set(Fortran_FLAGS_RELWITHDEBINFO "-g ${Fortran_FLAGS_RELEASE}" CACHE STRING "Fortran compiler flags for Release build") diff --git a/tools/utils/srccheck/pylint/pylintrc-2.ini b/tools/utils/srccheck/pylint/pylintrc-2.ini deleted file mode 100644 index 4c909ac7..00000000 --- a/tools/utils/srccheck/pylint/pylintrc-2.ini +++ /dev/null @@ -1,26 +0,0 @@ -[TYPECHECK] - -ignored-modules = numpy, numpy.linalg -ignored-classes = numpy, numpy.linalg - -[BASIC] - -variable-rgx = [a-z_][a-z0-9_]{1,30}$ -good-names = _ - -[FORMAT] - -max-line-length = 80 - -[DESIGN] - -min-public-methods = 0 -max-locals = 20 -max-attributes = 20 -max-args = 10 -max-returns = 10 -max-statements = 100 -max-branches = 20 - -[MESSAGES CONTROL] -disable = old-style-class,star-args diff --git a/tools/utils/srccheck/pylint/pylintrc-3.ini b/tools/utils/srccheck/pylint/pylintrc-3.ini deleted file mode 100644 index 5d85cf14..00000000 --- a/tools/utils/srccheck/pylint/pylintrc-3.ini +++ /dev/null @@ -1,30 +0,0 @@ -[TYPECHECK] - -ignored-modules = numpy, numpy.linalg -ignored-classes = numpy, numpy.linalg - -[BASIC] - -variable-rgx = [a-z_][a-z0-9_]{1,30}$ -good-names = _ - -[FORMAT] - -max-line-length = 80 - -[DESIGN] - -min-public-methods = 0 -max-locals = 20 -max-attributes = 20 -max-args = 10 -max-returns = 10 -max-statements = 100 -max-branches = 20 - -[MESSAGES CONTROL] -disable = star-args - -[IMPORTS] -# remove optparse from deprecated modules -deprecated-modules = diff --git a/utils/srccheck/pylint/pylintrc-2.ini b/utils/srccheck/pylint/pylintrc-2.ini deleted file mode 100644 index 4c909ac7..00000000 --- a/utils/srccheck/pylint/pylintrc-2.ini +++ /dev/null @@ -1,26 +0,0 @@ -[TYPECHECK] - -ignored-modules = numpy, numpy.linalg -ignored-classes = numpy, numpy.linalg - -[BASIC] - -variable-rgx = [a-z_][a-z0-9_]{1,30}$ -good-names = _ - -[FORMAT] - -max-line-length = 80 - -[DESIGN] - -min-public-methods = 0 -max-locals = 20 -max-attributes = 20 -max-args = 10 -max-returns = 10 -max-statements = 100 -max-branches = 20 - -[MESSAGES CONTROL] -disable = old-style-class,star-args diff --git a/utils/srccheck/pylint/pylintrc-3.ini b/utils/srccheck/pylint/pylintrc-3.ini deleted file mode 100644 index 5d85cf14..00000000 --- a/utils/srccheck/pylint/pylintrc-3.ini +++ /dev/null @@ -1,30 +0,0 @@ -[TYPECHECK] - -ignored-modules = numpy, numpy.linalg -ignored-classes = numpy, numpy.linalg - -[BASIC] - -variable-rgx = [a-z_][a-z0-9_]{1,30}$ -good-names = _ - -[FORMAT] - -max-line-length = 80 - -[DESIGN] - -min-public-methods = 0 -max-locals = 20 -max-attributes = 20 -max-args = 10 -max-returns = 10 -max-statements = 100 -max-branches = 20 - -[MESSAGES CONTROL] -disable = star-args - -[IMPORTS] -# remove optparse from deprecated modules -deprecated-modules =