Skip to content

Commit

Permalink
satisfy pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
sbryngelson committed Jan 6, 2024
1 parent 98ba829 commit b6468bb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pretty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Count
- name: Format diff
run: ./mfc.sh format diff
2 changes: 1 addition & 1 deletion src/common/include/inline_conversions.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
c = (1d0/(rho*(adv(1)/blkmod1 + adv(2)/blkmod2)))
elseif (model_eqns == 3) then
c = 0d0
!$acc loop seq
!$acc loop seq
do q = 1, num_fluids
c = c + adv(q)*(1d0/gammas(q) + 1d0)* &
(pres + pi_infs(q)/(gammas(q) + 1d0))
Expand Down
2 changes: 1 addition & 1 deletion src/common/include/macros.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#:def DEALLOCATE(*args)
@:LOG({'@:DEALLOCATE(${re.sub(' +', ' ', ', '.join(args))}$)'})
deallocate (${', '.join(args)}$)
!$acc exit data delete(${', '.join(args)}$)
!$acc exit data delete(${', '.join(args)}$)
#:enddef DEALLOCATE

#define t_vec3 real(kind(0d0)), dimension(1:3)
Expand Down
5 changes: 4 additions & 1 deletion toolchain/bootstrap/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ if [ "$1" == "diff" ]; then
fi

# Indent acc directives
for filename in src/*/*.f*; do
srcfiles=( src/*/*.f* )
includefiles=( src/*/include/*.f* )
files=( "${srcfiles[@]}" "${includefiles[@]}" )
for filename in ${files[@]}; do
python3 toolchain/indenter.py "$filename"
done

Expand Down
9 changes: 6 additions & 3 deletions toolchain/indenter.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
def main():
num_args = len(sys.argv)
if num_args != 2:
AssertionError('Invalid number of arguments, found ', num_args)
raise Exception('Invalid number of arguments, found ', num_args)

infile = str(sys.argv[1])
outfile = infile+".new"
adjust_indentation(infile, outfile)
os.replace(outfile,infile)

# pylint: disable=too-many-branches
def adjust_indentation(input_file, output_file):
startingchar='!$acc'
startingloop1='!$acc parallel loop'
Expand All @@ -22,8 +23,10 @@ def adjust_indentation(input_file, output_file):
lines = file_in.readlines()

# this makes sure !$acc lines that have line continuations get indented at proper level
for kk in range(10):
# pylint: disable=too-many-nested-blocks
for _ in range(10):
# loop through file
# pylint: disable=consider-using-enumerate
for i in range(len(lines)):
if lines[i].lstrip().startswith(startingchar) and i + 1 < len(lines):
j = i + 1
Expand All @@ -50,7 +53,7 @@ def adjust_indentation(input_file, output_file):
while k >= 0:
# if line above is not empty
if lines[k].strip() != '':
# if line 2 above ends with line continuation, indent at that level
# if line 2 above ends with line continuation, indent at that level
if lines[k-1].strip().endswith('&'):
indent = len(lines[k-1]) - len(lines[k-1].lstrip())
# else indent at level of line above
Expand Down

0 comments on commit b6468bb

Please sign in to comment.