Skip to content

Commit

Permalink
Perform various infrastructure related trivial updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vanderhe committed Apr 26, 2024
1 parent c8c5f71 commit 6912813
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 154 deletions.
18 changes: 9 additions & 9 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,36 @@ 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
work with modifications, whether created in whole or in part
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
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindCustomBlas.cmake
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindCustomLapack.cmake
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion cmake/SkProgsUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion common/include/LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
97 changes: 84 additions & 13 deletions common/include/common.fypp
Original file line number Diff line number Diff line change
@@ -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. !
#!-------------------------------------------------------------------------------------------------!
Expand All @@ -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
Expand All @@ -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



#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand All @@ -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
61 changes: 54 additions & 7 deletions common/include/error.fypp
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
#!-------------------------------------------------------------------------------------------------!
#! 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
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


#! Macro to return an error flag if return variable available or throw
#! 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}$
Expand All @@ -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

Expand All @@ -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
3 changes: 1 addition & 2 deletions doc/devel/code_structure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 !
Expand Down Expand Up @@ -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

6 changes: 3 additions & 3 deletions doc/devel/general_notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <r>
expectation values.
2 changes: 1 addition & 1 deletion doc/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sys/generic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
9 changes: 7 additions & 2 deletions sys/intel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
26 changes: 0 additions & 26 deletions tools/utils/srccheck/pylint/pylintrc-2.ini

This file was deleted.

Loading

0 comments on commit 6912813

Please sign in to comment.