Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,19 @@ jobs:
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit checks
run: pre-commit run -a
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/PlasmaFAIR/fortitude-pre-commit
rev: v0.9.0
hooks:
- id: fortitude
args: ["--fix", "--preview"]
31 changes: 16 additions & 15 deletions app/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ program main
call get_arguments(input, input_format, output, output_format, normalize, &
& template, template_format, read_dot_files, error)
if (allocated(error)) then
write(error_unit, '(a)') error%message
write(error_unit, "(a)") error%message
error stop
end if

Expand All @@ -63,7 +63,7 @@ program main
call read_structure(mol_template, template, error, template_format)
end if
if (allocated(error)) then
write(error_unit, '(a)') error%message
write(error_unit, "(a)") error%message
error stop
end if
end if
Expand Down Expand Up @@ -91,13 +91,13 @@ program main
end if
end if
if (allocated(error)) then
write(error_unit, '(a)') error%message
write(error_unit, "(a)") error%message
error stop
end if

if (allocated(mol_template)) then
if (mol%nat /= mol_template%nat) then
write(error_unit, '(*(a, 1x))') &
write(error_unit, "(*(a, 1x))") &
"Number of atoms missmatch in", template, "and", input
error stop
end if
Expand All @@ -122,7 +122,7 @@ program main
call write_structure(mol, output, error, output_format)
end if
if (allocated(error)) then
write(error_unit, '(a)') error%message
write(error_unit, "(a)") error%message
error stop
end if

Expand All @@ -133,16 +133,16 @@ program main
subroutine help(unit)
integer, intent(in) :: unit

write(unit, '(a, *(1x, a))') &
write(unit, "(a, *(1x, a))") &
"Usage: "//prog_name//" [options] <input> <output>"

write(unit, '(a)') &
write(unit, "(a)") &
"", &
"Read structure from input file and writes it to output file.", &
"The format is determined by the file extension or the format hint", &
""

write(unit, '(2x, a, t25, a)') &
write(unit, "(2x, a, t25, a)") &
"-i, --input <format>", "Hint for the format of the input file", &
"-o, --output <format>", "Hint for the format of the output file", &
"--normalize", "Normalize all element symbols to capitalized format", &
Expand All @@ -153,7 +153,7 @@ subroutine help(unit)
"--version", "Print program version and exit", &
"--help", "Show this help message"

write(unit, '(a)')
write(unit, "(a)")

end subroutine help

Expand All @@ -163,7 +163,7 @@ subroutine version(unit)
character(len=:), allocatable :: version_string

call get_mctc_version(string=version_string)
write(unit, '(a, *(1x, a))') &
write(unit, "(a, *(1x, a))") &
& prog_name, "version", version_string

end subroutine version
Expand Down Expand Up @@ -294,9 +294,9 @@ function join(a1, a2) result(path)
character :: filesep

if (is_windows()) then
filesep = '\'
filesep = "\"
else
filesep = '/'
filesep = "/"
end if

path = a1 // filesep // a2
Expand All @@ -323,15 +323,16 @@ subroutine read_file(filename, val, error)

lnum = 0

open(file=filename, newunit=io, status='old', iostat=stat)
open(file=filename, newunit=io, status="old", iostat=stat)
if (stat /= 0) then
call fatal_error(error, "Error: Could not open file '"//filename//"'")
return
end if

call next_line(io, line, pos, lnum, stat)
if (stat == 0) &
call read_next_token(line, pos, token, val, stat)
if (stat == 0) then
call read_next_token(line, pos, token, val, stat)
end if
if (stat /= 0) then
call io_error(error, "Cannot read value from file", line, token, &
filename, lnum, "expected integer value")
Expand Down
13 changes: 13 additions & 0 deletions fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,16 @@ md_extensions = ["markdown.extensions.toc", "markdown.extensions.smarty"]
[extra.ford.extra_mods]
iso_fortran_env = "https://gcc.gnu.org/onlinedocs/gfortran/ISO_005fFORTRAN_005fENV.html"
jonquil = "https://toml-f.github.io/jonquil/module/jonquil.html"

[extra.fortitude.check]
ignore = [
"C002", # interface without implicit none
"C003", # implicit none(external)
"C011", # no default in select case
"C061", # missing intent attribute
"C072", # assumed size character intent
"C121", # use without explicit only
"C122", # intrinsic missing for internal modules
"C181", # iostat not checked
]
line-length = 132
15 changes: 9 additions & 6 deletions src/mctc/cutoff.f90
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,15 @@ elemental function shift_back_abc(in) result(out)
real(wp) :: out
real(wp),parameter :: p_pbc_eps = 1.0e-14_wp
out = in
if(in < (0.0_wp - p_pbc_eps)) &
out = in + real(ceiling(-in),wp)
if(in > (1.0_wp + p_pbc_eps)) &
out = in - real(floor ( in),wp)
if (abs(in - 1.0_wp) < p_pbc_eps) &
out = in - 1.0_wp
if(in < (0.0_wp - p_pbc_eps)) then
out = in + real(ceiling(-in),wp)
end if
if(in > (1.0_wp + p_pbc_eps)) then
out = in - real(floor ( in),wp)
end if
if (abs(in - 1.0_wp) < p_pbc_eps) then
out = in - 1.0_wp
end if
end function shift_back_abc


Expand Down
Loading
Loading