Skip to content

Commit 0750f7a

Browse files
authored
Fixes from Fortitude linter (#190)
* Add fortitude.toml * Linter fixes (adding intent attributes mostly) * Ignore S102 * More rule ignores for now * Apply autofixable fixes * Fix most of linter errors * Enable missing-intent rule
1 parent a781b39 commit 0750f7a

35 files changed

+144
-118
lines changed

fortitude.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[check]
2+
ignore = [
3+
"S001", # line-too-long
4+
"S051", # deprecated-relational-operator (fix available)
5+
"S101", # trailing-whitespace
6+
"S102", # incorrect-space-before-comment, we should enable this, autofix enable
7+
"M011", # use-all (should use "only:")
8+
"M001", # procedure-not-in-module (need a per-file ignore for init.F90)
9+
"T042", # assumed-size-character-intent TODO: We should fix all instances!
10+
]
11+
line-length = 132
12+
show-fixes = true

src/analysis.F90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ subroutine analysis(x, y, z, vx, vy, vz, fxc, fyc, fzc, eclas)
2828
use mod_analyze_geometry
2929
use mod_io
3030
use mod_system, only: am
31-
implicit none
3231
real(DP), intent(in) :: x(:, :), y(:, :), z(:, :)
3332
real(DP), intent(in) :: fxc(:, :), fyc(:, :), fzc(:, :)
3433
real(DP), intent(in) :: vx(:, :), vy(:, :), vz(:, :)
@@ -102,7 +101,6 @@ subroutine trajout(x, y, z, time_step)
102101
use mod_general, only: nwalk, natom, sim_time
103102
use mod_mpi, only: get_mpi_rank
104103
use mod_system, only: names
105-
implicit none
106104
real(DP), intent(in) :: x(:, :), y(:, :), z(:, :)
107105
integer, intent(in) :: time_step
108106
integer :: iat, iw

src/cmdline.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module mod_cmdline
22
use mod_interfaces, only: print_compile_info
3+
implicit none
34
private
45
public :: get_cmdline
56

67
contains
78

89
subroutine print_help()
9-
implicit none
1010
integer, dimension(8) :: time_data
1111

1212
call date_and_time(values=time_data)

src/ekin.F90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ subroutine temperature(px, py, pz, amt, eclas)
1515
use mod_nhc, only: inose, get_nhcham
1616
use mod_gle, only: get_langham
1717
use mod_shake, only: nshake
18-
implicit none
1918
integer :: iw, iat
2019
real(DP), intent(in) :: px(:, :), py(:, :), pz(:, :)
2120
real(DP), intent(in) :: amt(:, :)
@@ -68,7 +67,6 @@ end subroutine temperature
6867
real(DP) function ekin_v(vx, vy, vz)
6968
use mod_general, only: nwalk, natom
7069
use mod_system, only: am
71-
implicit none
7270
real(DP), intent(in) :: vx(:, :), vy(:, :), vz(:, :)
7371
real(DP) :: temp1, ekin_mom
7472
integer :: iw, iat

src/en_restraint.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ subroutine energy_restraint(x, y, z, px, py, pz, eclas)
109109

110110
!Iterative procedure
111111
convercrit = 100
112-
do while (convercrit > 0.00001)
112+
do while (convercrit > 0.00001D0)
113113
! deltaE(t+dt) prediction - improves the accuracy
114114
deltaEnext = 0
115115
do iat = 1, natom
@@ -166,7 +166,7 @@ subroutine energy_restraint(x, y, z, px, py, pz, eclas)
166166
eclas = eclas ! + quadratic_restraint_energy
167167

168168
!Output to en_restraint.dat
169-
write (UERMD, '(I8,F16.8,E20.10,E20.10,F16.8)') it, excE * AUTOEV, deltaE, 0.0, 0.0
169+
write (UERMD, '(I8,F16.8,E20.10,E20.10,F16.8)') it, excE * AUTOEV, deltaE, 0.0D0, 0.0D0
170170

171171
end if
172172

src/error.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module mod_error
2828

2929
abstract interface
3030
subroutine error(filename, line_number, message)
31+
implicit none
3132
character(len=*), intent(in) :: filename
3233
integer, intent(in) :: line_number
3334
character(len=*), intent(in) :: message

src/fftw_interface.F90

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ subroutine fftw_normalmodes_init(nwalk)
3838

3939
deallocate (x_tmp)
4040
deallocate (cx_tmp)
41-
end subroutine
41+
end subroutine fftw_normalmodes_init
4242

4343
! Simple wrapper functions around the FFTW interface.
4444
subroutine dft_normalmode2cart(nm, cart)
@@ -72,16 +72,16 @@ subroutine fftw_normalmodes_init(nwalk)
7272
end subroutine fftw_normalmodes_init
7373

7474
subroutine dft_normalmode2cart(nm, cart)
75-
complex(C_DOUBLE_COMPLEX), dimension(:) :: nm
76-
real(C_DOUBLE), dimension(:) :: cart
75+
complex(C_DOUBLE_COMPLEX), dimension(:), intent(inout) :: nm
76+
real(C_DOUBLE), dimension(:), intent(inout) :: cart
7777
cart = 0.0D0
7878
nm = (0.0D0, 0.0D0)
7979
call not_compiled_with('FFTW library')
8080
end subroutine dft_normalmode2cart
8181

8282
subroutine dft_cart2normalmode(cart, nm)
83-
complex(C_DOUBLE_COMPLEX), dimension(:) :: nm
84-
real(C_DOUBLE), dimension(:) :: cart
83+
complex(C_DOUBLE_COMPLEX), dimension(:), intent(inout) :: nm
84+
real(C_DOUBLE), dimension(:), intent(inout) :: cart
8585
cart = 0.0D0
8686
nm = (0.0D0, 0.0D0)
8787
call not_compiled_with('FFTW library')

src/force_abin.F90

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ real(DP) function read_energy(engrad_unit, abort) result(energy)
165165
!$OMP FLUSH(abort)
166166
return
167167
end if
168-
end function
168+
end function read_energy
169169

170170
subroutine read_forces(fx, fy, fz, num_atom, iw, engrad_unit, abort)
171171
use mod_files, only: stderr
@@ -209,7 +209,6 @@ subroutine force_abin(x, y, z, fx, fy, fz, eclas, chpot, walkmax)
209209
use mod_lz, only: nstate_lz, tocalc_lz, en_array_lz, istate_lz, write_lz_data
210210
use mod_qmmm, only: natqm
211211
use mod_utils, only: toupper, append_rank
212-
implicit none
213212
real(DP), intent(in) :: x(:, :), y(:, :), z(:, :)
214213
real(DP), intent(out) :: fx(:, :), fy(:, :), fz(:, :)
215214
real(DP), intent(out) :: eclas
@@ -325,7 +324,6 @@ subroutine oniom(x, y, z, fx, fy, fz, eclas, iw, abort)
325324
use mod_qmmm, only: natqm
326325
use mod_sh_integ, only: nstate
327326
use mod_sh, only: en_array, istate
328-
implicit none
329327
real(DP), intent(in) :: x(:, :), y(:, :), z(:, :)
330328
real(DP), intent(inout) :: fx(:, :), fy(:, :), fz(:, :)
331329
real(DP), intent(inout) :: eclas

src/force_bound.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ subroutine sbc_init(x, y, z)
6161
write (*, *) 'Calculating cluster radius from given densty.'
6262
rho = rho * fact !conversion from g/L to atomic units
6363
rb_sbc = mass_total / rho * 3 / 4 / PI
64-
rb_sbc = rb_sbc**(1 / 3.)
64+
rb_sbc = rb_sbc**(1 / 3.0D0)
6565
end if
6666

6767
if (rmax > rb_sbc) then
@@ -73,7 +73,7 @@ subroutine sbc_init(x, y, z)
7373

7474
write (*, *) 'rb_sbc[A]=', rb_sbc / ang
7575

76-
end subroutine
76+
end subroutine sbc_init
7777

7878
subroutine force_sbc(x, y, z, fx, fy, fz, walkmax)
7979
use mod_const, only: ANG
@@ -118,7 +118,7 @@ subroutine force_sbc(x, y, z, fx, fy, fz, walkmax)
118118
end if
119119

120120
return
121-
end subroutine
121+
end subroutine force_sbc
122122

123123
! TODO: This could be a general purpose routine,
124124
! move to utils

src/force_h2o.F90

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ subroutine force_h2o_cvrqd(x, y, z, fx, fy, fz, Eclas, natom, nbeads)
129129
! TODO: Given the small difference between the Schwenke potential,
130130
! we might not need to implement numerical forces here.
131131
! call numerical_forces(x, y, z, fx, fy, fz, Epot, natom, nbeads)
132+
! Just to squash compiler warnings
133+
if (.false.) then
134+
print*,natom
135+
fx = 0.0D0
136+
fy = 0.0D0
137+
fz = 0.0D0
138+
end if
132139

133140
end subroutine force_h2o_cvrqd
134141

@@ -159,7 +166,7 @@ subroutine numerical_forces(x, y, z, fx, fy, fz, Epot, natom, nbeads)
159166
real(DP) :: Epot_delta(1)
160167

161168
real(DP) :: Eclas_orig
162-
real(DP) :: delta = 5.0E-5_DP
169+
real(DP), parameter :: DELTA = 5.0E-5_DP
163170
integer :: i, j, k
164171

165172
! Calculate forces numerically using central differences
@@ -180,11 +187,11 @@ subroutine numerical_forces(x, y, z, fx, fy, fz, Epot, natom, nbeads)
180187
! Move the atom forwards
181188
select case (k)
182189
case (1)
183-
x_new_forward(i, j) = x_new_forward(i, j) + delta
190+
x_new_forward(i, j) = x_new_forward(i, j) + DELTA
184191
case (2)
185-
y_new_forward(i, j) = y_new_forward(i, j) + delta
192+
y_new_forward(i, j) = y_new_forward(i, j) + DELTA
186193
case (3)
187-
z_new_forward(i, j) = z_new_forward(i, j) + delta
194+
z_new_forward(i, j) = z_new_forward(i, j) + DELTA
188195
end select
189196

190197
! Calculate the energy for the forward perturbed geometry
@@ -197,11 +204,11 @@ subroutine numerical_forces(x, y, z, fx, fy, fz, Epot, natom, nbeads)
197204
! Calculate the numerical force
198205
select case (k)
199206
case (1)
200-
fx(i, j) = -(Epot_delta(1) - Eclas_orig) / delta
207+
fx(i, j) = -(Epot_delta(1) - Eclas_orig) / DELTA
201208
case (2)
202-
fy(i, j) = -(Epot_delta(1) - Eclas_orig) / delta
209+
fy(i, j) = -(Epot_delta(1) - Eclas_orig) / DELTA
203210
case (3)
204-
fz(i, j) = -(Epot_delta(1) - Eclas_orig) / delta
211+
fz(i, j) = -(Epot_delta(1) - Eclas_orig) / DELTA
205212
end select
206213
end do
207214
end do

src/force_spline.F90

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ subroutine finalize_spline()
8787
if (allocated(second_derivatives)) then
8888
deallocate (second_derivatives)
8989
end if
90-
end subroutine
90+
end subroutine finalize_spline
9191

9292
subroutine read_grid(fname, x_grid, y_grid, grid_size)
9393
use mod_files, only: stdout
@@ -122,7 +122,7 @@ subroutine read_grid(fname, x_grid, y_grid, grid_size)
122122
end do
123123
close (u)
124124

125-
end subroutine
125+
end subroutine read_grid
126126

127127
subroutine validate_grid(x_grid, ngrid)
128128
real(DP), dimension(ngrid), intent(in) :: x_grid
@@ -141,7 +141,7 @@ subroutine validate_grid(x_grid, ngrid)
141141
return
142142
end if
143143
end do
144-
end subroutine
144+
end subroutine validate_grid
145145

146146
subroutine print_splined_potential(fname, x_grid, grid_size)
147147
character(len=*), intent(in) :: fname
@@ -158,6 +158,6 @@ subroutine print_splined_potential(fname, x_grid, grid_size)
158158
x = x + dx
159159
end do
160160
close (u)
161-
end subroutine
161+
end subroutine print_splined_potential
162162

163-
end module
163+
end module mod_splined_grid

src/force_tcpb.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module mod_force_tcpb
3333
character(len=1024) :: input_file = ''
3434
! This make TC reuse WF from previous step.
3535
integer :: globaltreatment = 0
36-
end type
36+
end type tcpb_params
3737
type(tcpb_params) :: tcpb
3838
character(len=5), allocatable :: qmattypes(:)
3939
save

src/forces.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ subroutine force_quantum(fx, fy, fz, x, y, z, amg, quantum_energy)
260260
fz(j, i) = (z(j, i) - z(j, kplus))
261261
fz(j, i) = fz(j, i) + (z(j, i) - z(j, kminus))
262262
fz(j, i) = -fz(j, i) * ak(j, i)
263-
equant = equant + 0.5 * ak(j, i) * (x(j, i) - x(j, kplus))**2
264-
equant = equant + 0.5 * ak(j, i) * (y(j, i) - y(j, kplus))**2
265-
equant = equant + 0.5 * ak(j, i) * (z(j, i) - z(j, kplus))**2
263+
equant = equant + 0.5D0 * ak(j, i) * (x(j, i) - x(j, kplus))**2
264+
equant = equant + 0.5D0 * ak(j, i) * (y(j, i) - y(j, kplus))**2
265+
equant = equant + 0.5D0 * ak(j, i) * (z(j, i) - z(j, kplus))**2
266266
end do
267267
end do
268268
end if

src/fortran_interfaces.F90

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@
66
module mod_interfaces
77
use, intrinsic :: iso_c_binding, only: C_INT, C_INT32_T
88
use mod_const, only: DP
9+
implicit none
910
public
1011
interface
1112

1213
subroutine print_compile_info()
14+
implicit none
1315
end subroutine print_compile_info
1416

1517
subroutine finish(error_code)
18+
implicit none
1619
integer, intent(in) :: error_code
1720
end subroutine finish
1821

1922
subroutine force_clas(fx, fy, fz, x, y, z, eclas, chpot)
2023
import :: DP
24+
implicit none
2125
real(DP), intent(inout) :: x(:, :), y(:, :), z(:, :)
2226
real(DP), intent(inout) :: fx(:, :), fy(:, :), fz(:, :)
2327
real(DP), intent(out) :: eclas
@@ -26,6 +30,7 @@ end subroutine force_clas
2630

2731
subroutine force_quantum(fx, fy, fz, x, y, z, amg, energy)
2832
import :: DP
33+
implicit none
2934
real(DP), intent(in) :: x(:, :), y(:, :), z(:, :)
3035
real(DP), intent(inout) :: fx(:, :), fy(:, :), fz(:, :)
3136
real(DP), intent(in) :: amg(:, :)
@@ -34,6 +39,7 @@ end subroutine force_quantum
3439

3540
subroutine force_wrapper(x, y, z, fx, fy, fz, eclas, chpot, walkmax)
3641
import :: DP
42+
implicit none
3743
real(DP), intent(in) :: x(:, :), y(:, :), z(:, :)
3844
real(DP), intent(inout) :: fx(:, :), fy(:, :), fz(:, :)
3945
real(DP), intent(out) :: eclas
@@ -42,13 +48,15 @@ subroutine force_wrapper(x, y, z, fx, fy, fz, eclas, chpot, walkmax)
4248
end subroutine force_wrapper
4349

4450
subroutine omp_set_num_threads(nthreads)
51+
implicit none
4552
integer, intent(in) :: nthreads
4653
end subroutine omp_set_num_threads
4754

4855
! TODO: This interface currently doesn't work, probably because
4956
! of how we pass the 2D arrays...
5057
!subroutine force_water(x, y, z, fx, fy, fz, eclas, natom, walkmax, watpot) !bind(C)
5158
! use, intrinsic :: iso_c_binding
59+
! implicit none
5260
! real(C_DOUBLE), intent(in) :: x(:, :), y(:, :), z(:, :)
5361
! real(C_DOUBLE), intent(inout) :: fx(:, :), fy(:, :), fz(:, :)
5462
! real(C_DOUBLE), intent(inout) :: eclas
@@ -59,21 +67,24 @@ end subroutine omp_set_num_threads
5967
! int usleep(useconds_t useconds)
6068
function usleep(useconds) bind(c, name='usleep')
6169
import :: C_INT, C_INT32_T
62-
integer(kind=C_INT32_T), value :: useconds
70+
implicit none
71+
integer(kind=C_INT32_T), intent(in), value :: useconds
6372
integer(kind=C_INT) :: usleep
6473
end function usleep
6574

6675
! Computes potential energy of a water molecule
6776
! using Schwenke potential, see h2o_schwenke.f
6877
subroutine h2o_pot_schwenke(rij, v, n)
6978
import :: DP
79+
implicit none
7080
integer, intent(in) :: n
7181
real(DP), intent(in) :: rij(n, 3)
7282
real(DP), intent(out) :: v(n)
7383
end subroutine h2o_pot_schwenke
7484

7585
subroutine h2o_pot_cvrqd(V, rOH1, rOH2, aHOH, mH, mO)
7686
import :: DP
87+
implicit none
7788
real(DP), intent(out) :: V
7889
real(DP), intent(in) :: rOH1, rOH2, aHOH, mH, mO
7990
end subroutine h2o_pot_cvrqd

0 commit comments

Comments
 (0)