Skip to content

Commit 1d87192

Browse files
authored
Finalizes some source code lint checks and automates them (#780)
1 parent 67b130b commit 1d87192

File tree

15 files changed

+38
-45
lines changed

15 files changed

+38
-45
lines changed

.fortitude.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[check]
2+
# Ignored Rules and justification:
3+
ignore = ["E001","S001","S101","M011","F001","S041","T001","S101","S102","T002","T011","T042","M001"]
4+
file-extensions = ["f90","fpp","fypp"]
5+
output-format = "pylint"

.github/workflows/lint-source.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ jobs:
2525
steps:
2626
- uses: actions/checkout@v4
2727

28-
- name: Install Fortitude
29-
run: pip install fortitude-lint ansi2txt
28+
- name: Initialize MFC
29+
run: ./mfc.sh init
3030

31-
- name: Lint the source code
32-
run: fortitude check --file-extensions=f90,fpp,fypp --ignore=E001,S001,S101,M011,F001,S041,T001,S101,S102,T002,T011 ./src/** || true
33-
34-
- name: Ensure kind is specified
35-
run: fortitude check --file-extensions=f90,fpp,fypp --select=P001 ./src/**
36-
37-
- name: Ensure subroutines are named
38-
run: fortitude check --file-extensions=f90,fpp,fypp --select=S061 ./src/**
31+
- name: Lint the full source
32+
run: |
33+
source build/venv/bin/activate
34+
find ./src -type f -not -name '*nvtx*' -exec fortitude check {} \;
35+
find ./src -type f -not -name '*nvtx*' -exec fortitude check {} \; | wc -l | xargs -I{} sh -c '[ {} -gt 0 ] && exit 1 || exit 0'
3936
4037
- name: No double precision intrinsics
4138
run: |

src/common/m_helper.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ contains
244244
subroutine s_int_to_str(i, res)
245245

246246
integer, intent(in) :: i
247-
character(len=*), intent(out) :: res
247+
character(len=*), intent(inout) :: res
248248

249249
write (res, '(I0)') i
250250
res = trim(res)

src/common/m_variables_conversion.fpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ contains
10811081
real(wp) :: dyn_pres
10821082
real(wp) :: nbub, R3, vftmp, R3tmp
10831083
real(wp), dimension(nb) :: Rtmp
1084-
real(wp) :: G = 0._wp
1084+
real(wp) :: G
10851085
real(wp), dimension(2) :: Re_K
10861086

10871087
integer :: i, j, k, l, q !< Generic loop iterators
@@ -1090,6 +1090,8 @@ contains
10901090
real(wp), dimension(num_species) :: Ys
10911091
real(wp) :: e_mix, mix_mol_weight, T
10921092

1093+
G = 0._wp
1094+
10931095
#ifndef MFC_SIMULATION
10941096
! Converting the primitive variables to the conservative variables
10951097
do l = 0, p

src/post_process/m_data_output.fpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module m_data_output
5050
real(wp), allocatable, dimension(:, :, :), public :: q_sf
5151
real(wp), allocatable, dimension(:, :, :) :: q_root_sf
5252
real(wp), allocatable, dimension(:, :, :) :: cyl_q_sf
53+
5354
! Single precision storage for flow variables
5455
real(sp), allocatable, dimension(:, :, :), public :: q_sf_s
5556
real(sp), allocatable, dimension(:, :, :) :: q_root_sf_s
@@ -219,10 +220,6 @@ contains
219220
220221
file_loc = trim(proc_rank_dir)//'/.'
221222
222-
!INQUIRE( DIRECTORY = TRIM(file_loc), & ! Intel compiler
223-
!EXIST = dir_check )
224-
! INQUIRE( FILE = TRIM(file_loc), & ! NAG/PGI/GCC compiler
225-
! EXIST = dir_check )
226223
call my_inquire(file_loc, dir_check)
227224
if (dir_check .neqv. .true.) then
228225
call s_create_directory(trim(proc_rank_dir))
@@ -235,10 +232,6 @@ contains
235232
236233
file_loc = trim(rootdir)//'/.'
237234
238-
!INQUIRE( DIRECTORY = TRIM(file_loc), & ! Intel compiler
239-
! EXIST = dir_check )
240-
! INQUIRE( FILE = TRIM(file_loc), & ! NAG/PGI/GCC compiler
241-
! EXIST = dir_check )
242235
call my_inquire(file_loc, dir_check)
243236
if (dir_check .neqv. .true.) then
244237
call s_create_directory(trim(rootdir))
@@ -259,10 +252,6 @@ contains
259252
260253
file_loc = trim(proc_rank_dir)//'/.'
261254
262-
!INQUIRE( DIRECTORY = TRIM(file_loc), & ! Intel compiler
263-
! EXIST = dir_check )
264-
! INQUIRE( FILE = TRIM(file_loc), & ! NAG/PGI/GCC compiler
265-
! EXIST = dir_check )
266255
call my_inquire(file_loc, dir_check)
267256
268257
if (dir_check .neqv. .true.) then
@@ -276,10 +265,6 @@ contains
276265
277266
file_loc = trim(rootdir)//'/.'
278267
279-
!INQUIRE( DIRECTORY = TRIM(file_loc), & ! Intel compiler
280-
! EXIST = dir_check )
281-
! INQUIRE( FILE = TRIM(file_loc), & ! NAG/PGI/GCC compiler
282-
! EXIST = dir_check )
283268
call my_inquire(file_loc, dir_check)
284269
285270
if (dir_check .neqv. .true.) then

src/pre_process/m_data_output.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ contains
831831
! Generic string used to store the address of a particular file
832832
character(LEN=len_trim(case_dir) + 2*name_len) :: file_loc
833833
character(len=15) :: temp
834-
character(LEN=1), dimension(3) :: coord = (/'x', 'y', 'z'/)
834+
character(LEN=1), dimension(3), parameter :: coord = (/'x', 'y', 'z'/)
835835

836836
! Generic logical used to check the existence of directories
837837
logical :: dir_check

src/pre_process/m_patches.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ contains
14161416
integer :: i, j, k !< generic loop iterators
14171417
14181418
real(wp) :: epsilon, beta
1419-
complex(wp) :: cmplx_i = (0._wp, 1._wp)
1419+
complex(wp), parameter :: cmplx_i = (0._wp, 1._wp)
14201420
complex(wp) :: H
14211421
14221422
! Transferring the patch's centroid and radius information

src/pre_process/m_perturbation.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,8 @@ contains
497497
real(wp) :: ang, norm
498498
real(wp) :: tr, ti, cr, ci !< temporary memory
499499
real(wp) :: xratio
500-
integer idx
501-
integer i, j, k
500+
integer :: idx
501+
integer :: i, j, k
502502

503503
xratio = mixlayer_vel_coef
504504

src/simulation/m_bubbles_EL.fpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ contains
401401
!! @param save_count File identifier
402402
subroutine s_restart_bubbles(bub_id, save_count)
403403

404-
integer :: bub_id, save_count
404+
integer, intent(inout) :: bub_id, save_count
405405

406406
character(LEN=path_len + 2*name_len) :: file_loc
407407

@@ -1460,7 +1460,7 @@ contains
14601460
function particle_in_domain(pos_part)
14611461

14621462
logical :: particle_in_domain
1463-
real(wp), dimension(3) :: pos_part
1463+
real(wp), dimension(3), intent(in) :: pos_part
14641464

14651465
! 2D
14661466
if (p == 0 .and. cyl_coord .neqv. .true.) then
@@ -1513,7 +1513,7 @@ contains
15131513
function particle_in_domain_physical(pos_part)
15141514

15151515
logical :: particle_in_domain_physical
1516-
real(wp), dimension(3) :: pos_part
1516+
real(wp), dimension(3), intent(in) :: pos_part
15171517

15181518
particle_in_domain_physical = ((pos_part(1) < x_cb(m)) .and. (pos_part(1) >= x_cb(-1)) .and. &
15191519
(pos_part(2) < y_cb(n)) .and. (pos_part(2) >= y_cb(-1)))
@@ -1589,7 +1589,7 @@ contains
15891589
!! @param q_time Current time
15901590
subroutine s_write_lag_particles(qtime)
15911591

1592-
real(wp) :: qtime
1592+
real(wp), intent(in) :: qtime
15931593
integer :: k
15941594

15951595
character(LEN=path_len + 2*name_len) :: file_loc
@@ -1631,7 +1631,8 @@ contains
16311631
!! @param q_time Current time
16321632
subroutine s_write_void_evol(qtime)
16331633

1634-
real(wp) :: qtime, volcell, voltot
1634+
real(wp), intent(in) :: qtime
1635+
real(wp) :: volcell, voltot
16351636
real(wp) :: lag_void_max, lag_void_avg, lag_vol
16361637
real(wp) :: void_max_glb, void_avg_glb, vol_glb
16371638

@@ -1704,11 +1705,12 @@ contains
17041705
subroutine s_write_restart_lag_bubbles(t_step)
17051706

17061707
! Generic string used to store the address of a particular file
1708+
integer, intent(in) :: t_step
1709+
17071710
character(LEN=path_len + 2*name_len) :: file_loc
17081711
logical :: file_exist
1709-
1710-
integer :: i, k, t_step
17111712
integer :: bub_id, tot_part, tot_part_wrtn, npart_wrtn
1713+
integer :: i, k
17121714

17131715
#ifdef MFC_MPI
17141716
! For Parallel I/O

src/simulation/m_data_output.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ contains
110110
!! time-step.
111111
subroutine s_open_run_time_information_file
112112

113-
character(LEN=name_len) :: file_name = 'run_time.inf' !<
113+
character(LEN=name_len), parameter :: file_name = 'run_time.inf' !<
114114
!! Name of the run-time information file
115115

116116
character(LEN=path_len + name_len) :: file_path !<

0 commit comments

Comments
 (0)