Skip to content

Commit 200c9cf

Browse files
committed
Add fortitude linter
1 parent 93dbc89 commit 200c9cf

82 files changed

Lines changed: 3445 additions & 3351 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,19 @@ jobs:
231231
uses: codecov/codecov-action@v4
232232
with:
233233
token: ${{ secrets.CODECOV_TOKEN }}
234+
235+
lint:
236+
runs-on: ubuntu-latest
237+
steps:
238+
- name: Checkout code
239+
uses: actions/checkout@v4
240+
241+
- uses: actions/setup-python@v5
242+
with:
243+
python-version: '3.x'
244+
245+
- name: Install pre-commit
246+
run: pip install pre-commit
247+
248+
- name: Run pre-commit checks
249+
run: pre-commit run -a

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/PlasmaFAIR/fortitude-pre-commit
5+
rev: v0.9.0
6+
hooks:
7+
- id: fortitude
8+
args: ["--fix", "--preview"]

app/main.f90

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ program main
4848
call get_arguments(input, input_format, output, output_format, normalize, &
4949
& template, template_format, read_dot_files, error)
5050
if (allocated(error)) then
51-
write(error_unit, '(a)') error%message
51+
write(error_unit, "(a)") error%message
5252
error stop
5353
end if
5454

@@ -63,7 +63,7 @@ program main
6363
call read_structure(mol_template, template, error, template_format)
6464
end if
6565
if (allocated(error)) then
66-
write(error_unit, '(a)') error%message
66+
write(error_unit, "(a)") error%message
6767
error stop
6868
end if
6969
end if
@@ -91,13 +91,13 @@ program main
9191
end if
9292
end if
9393
if (allocated(error)) then
94-
write(error_unit, '(a)') error%message
94+
write(error_unit, "(a)") error%message
9595
error stop
9696
end if
9797

9898
if (allocated(mol_template)) then
9999
if (mol%nat /= mol_template%nat) then
100-
write(error_unit, '(*(a, 1x))') &
100+
write(error_unit, "(*(a, 1x))") &
101101
"Number of atoms missmatch in", template, "and", input
102102
error stop
103103
end if
@@ -122,7 +122,7 @@ program main
122122
call write_structure(mol, output, error, output_format)
123123
end if
124124
if (allocated(error)) then
125-
write(error_unit, '(a)') error%message
125+
write(error_unit, "(a)") error%message
126126
error stop
127127
end if
128128

@@ -133,16 +133,16 @@ program main
133133
subroutine help(unit)
134134
integer, intent(in) :: unit
135135

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

139-
write(unit, '(a)') &
139+
write(unit, "(a)") &
140140
"", &
141141
"Read structure from input file and writes it to output file.", &
142142
"The format is determined by the file extension or the format hint", &
143143
""
144144

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

156-
write(unit, '(a)')
156+
write(unit, "(a)")
157157

158158
end subroutine help
159159

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

165165
call get_mctc_version(string=version_string)
166-
write(unit, '(a, *(1x, a))') &
166+
write(unit, "(a, *(1x, a))") &
167167
& prog_name, "version", version_string
168168

169169
end subroutine version
@@ -294,9 +294,9 @@ function join(a1, a2) result(path)
294294
character :: filesep
295295

296296
if (is_windows()) then
297-
filesep = '\'
297+
filesep = "\"
298298
else
299-
filesep = '/'
299+
filesep = "/"
300300
end if
301301

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

324324
lnum = 0
325325

326-
open(file=filename, newunit=io, status='old', iostat=stat)
326+
open(file=filename, newunit=io, status="old", iostat=stat)
327327
if (stat /= 0) then
328328
call fatal_error(error, "Error: Could not open file '"//filename//"'")
329329
return
330330
end if
331331

332332
call next_line(io, line, pos, lnum, stat)
333-
if (stat == 0) &
334-
call read_next_token(line, pos, token, val, stat)
333+
if (stat == 0) then
334+
call read_next_token(line, pos, token, val, stat)
335+
end if
335336
if (stat /= 0) then
336337
call io_error(error, "Cannot read value from file", line, token, &
337338
filename, lnum, "expected integer value")

fpm.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,16 @@ md_extensions = ["markdown.extensions.toc", "markdown.extensions.smarty"]
3939
[extra.ford.extra_mods]
4040
iso_fortran_env = "https://gcc.gnu.org/onlinedocs/gfortran/ISO_005fFORTRAN_005fENV.html"
4141
jonquil = "https://toml-f.github.io/jonquil/module/jonquil.html"
42+
43+
[extra.fortitude.check]
44+
ignore = [
45+
"C002", # interface without implicit none
46+
"C003", # implicit none(external)
47+
"C011", # no default in select case
48+
"C061", # missing intent attribute
49+
"C072", # assumed size character intent
50+
"C121", # use without explicit only
51+
"C122", # intrinsic missing for internal modules
52+
"C181", # iostat not checked
53+
]
54+
line-length = 132

src/mctc/cutoff.f90

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,15 @@ elemental function shift_back_abc(in) result(out)
186186
real(wp) :: out
187187
real(wp),parameter :: p_pbc_eps = 1.0e-14_wp
188188
out = in
189-
if(in < (0.0_wp - p_pbc_eps)) &
190-
out = in + real(ceiling(-in),wp)
191-
if(in > (1.0_wp + p_pbc_eps)) &
192-
out = in - real(floor ( in),wp)
193-
if (abs(in - 1.0_wp) < p_pbc_eps) &
194-
out = in - 1.0_wp
189+
if(in < (0.0_wp - p_pbc_eps)) then
190+
out = in + real(ceiling(-in),wp)
191+
end if
192+
if(in > (1.0_wp + p_pbc_eps)) then
193+
out = in - real(floor ( in),wp)
194+
end if
195+
if (abs(in - 1.0_wp) < p_pbc_eps) then
196+
out = in - 1.0_wp
197+
end if
195198
end function shift_back_abc
196199

197200

0 commit comments

Comments
 (0)