Skip to content

Commit

Permalink
add style CI from Microphysics (#2769)
Browse files Browse the repository at this point in the history
this checks for tabs and trailing whitespace
zingale authored Mar 9, 2024

Unverified

This user has not yet uploaded their public signing key.
1 parent 4aedefc commit fbd880f
Showing 154 changed files with 1,061 additions and 965 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/get_release_txt.py
Original file line number Diff line number Diff line change
@@ -26,9 +26,9 @@
txt = txt[m.end():].strip()
else:
txt = ""
# we now need to substitute characters in the string so that
# the action can deal with line breaks

# we now need to substitute characters in the string so that
# the action can deal with line breaks
txt = txt.replace('%', '%25')
txt = txt.replace('\n', '%0A')
txt = txt.replace('\r', '%0D')
22 changes: 22 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Style

on: [push, pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-style
cancel-in-progress: true

jobs:
tabs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Tabs
run: .github/workflows/style/check_tabs.sh

trailing_whitespaces:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Trailing Whitespaces
run: .github/workflows/style/check_trailing_whitespaces.sh
36 changes: 36 additions & 0 deletions .github/workflows/style/check_tabs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -eu -o pipefail

find . -type d \( -name .git \
-o -path ./paper \
-o -name build -o -name install \
-o -name tmp_build_dir -o -name tmp_install_dir \
\) -prune -o \
-type f \( \( -name "*.H" -o -name "*.h" -o -name "*.hh" -o -name "*.hpp" \
-o -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" \
-o -name "*.f" -o -name "*.F" -o -name "*.f90" -o -name "*.F90" \
-o -name "*.py" \
-o -name "*.md" -o -name "*.rst" \
-o -name "*.sh" \
-o -name "*.tex" \
-o -name "*.txt" \
-o -name "*.yml" \) \
-a \( ! -name "*.tab.h" -a ! -name "*.tab.nolint.H" \
-a ! -name "*.lex.h" -a ! -name "*.lex.nolint.H" \) \
\) \
-exec grep -Iq . {} \; \
-exec sed -i 's/\t/\ \ \ \ /g' {} +

gitdiff=`git diff`

if [ -z "$gitdiff" ]
then
exit 0
else
echo -e "\nTabs are not allowed. Changes suggested by"
echo -e " ${0}\n"
git --no-pager diff
echo ""
exit 1
fi
38 changes: 38 additions & 0 deletions .github/workflows/style/check_trailing_whitespaces.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

set -eu -o pipefail

find . -type d \( -name .git \
-o -path ./paper \
-o -name build -o -name install \
-o -name tmp_build_dir -o -name tmp_install_dir \
-o -path ./util/gcem \
\) -prune -o \
-type f \( \( -name "*.H" -o -name "*.h" -o -name "*.hh" -o -name "*.hpp" \
-o -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" \
-o -name "*.f" -o -name "*.F" -o -name "*.f90" -o -name "*.F90" \
-o -name "*.py" \
-o -name "*.rst" \
-o -name "*.sh" \
-o -name "*.tex" \
-o -name "*.txt" \
-o -name "*.yml" \) \
-a \( ! -name "*.tab.h" -a ! -name "*.tab.nolint.H" \
-a ! -name "*.lex.h" -a ! -name "*.lex.nolint.H" \
-a ! -path "./networks/*/reaclib_rates.H" \) \
\) \
-exec grep -Iq . {} \; \
-exec sed -i 's/[[:blank:]]\+$//g' {} +

gitdiff=`git diff`

if [ -z "$gitdiff" ]
then
exit 0
else
echo -e "\nTrailing whitespaces at the end of a line are not allowed. Changes suggested by"
echo -e " ${0}\n"
git --no-pager diff
echo ""
exit 1
fi
10 changes: 5 additions & 5 deletions Diagnostics/DustCollapse/analytic.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
! Print out the analytic solution for the homologous dust collapse problem,
! from Colgate and White 1966, ApJ, 143, 626.
!
!
! This will yield r(t) as a function of t

module constants_module
@@ -18,7 +18,7 @@ module constants_module

! we try to do equal timesteps, but eventually, the radius of the
! sphere is changing so quickly that we need to adjust the size of
! the timestep. The code will take nstep timesteps, with the
! the timestep. The code will take nstep timesteps, with the
! initial timestep to be (t_f - t_i)/(nstep - 1). Once the radius
! begins to change significantly, we will begin halving the timestep
! as needed.
@@ -111,7 +111,7 @@ function f(r,t) result (func)
use constants_module

implicit none

double precision, intent(in) :: r, t
double precision :: func

@@ -130,7 +130,7 @@ function dfdr(r,t) result (dfuncdr)
use constants_module

implicit none

double precision, intent(in) :: r, t
double precision :: dfuncdr

@@ -145,4 +145,4 @@ function dfdr(r,t) result (dfuncdr)
end function dfdr



200 changes: 100 additions & 100 deletions Diagnostics/DustCollapse/analytic.txt
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
1.00000000000000002E-003 649909135.03119123
2.00000001505167783E-003 649636489.29833126
3.00000003010335563E-003 649181909.86863339
4.00000004515503344E-003 648545142.11149800
5.00000006020671125E-003 647725827.94719517
6.00000007525838906E-003 646723505.15455902
7.00000009031006686E-003 645537605.90191960
8.00000010536174554E-003 644167454.93684888
9.00000012041342334E-003 642612267.44508624
1.00000001354651012E-002 640871146.53866076
1.10000001505167790E-002 638943080.30864108
1.20000001655684568E-002 636826938.57690644
1.30000001806201346E-002 634521469.03385830
1.40000001956718124E-002 632025293.06391215
1.50000002107234902E-002 629336900.94825923
1.60000002257751697E-002 626454646.57255840
1.70000002408268493E-002 623376741.51493466
1.80000002558785288E-002 620101248.48522842
1.90000002709302084E-002 616626074.03659952
2.00000002859818879E-002 612948960.51813209
2.10000003010335674E-002 609067477.12493813
2.20000003160852470E-002 604979010.01064956
2.30000003311369265E-002 600680751.32512844
2.40000003461886061E-002 596169687.06278419
2.50000003612402856E-002 591442583.57983398
2.60000003762919651E-002 586495972.61729527
2.70000003913436447E-002 581326134.64072454
2.80000004063953242E-002 575929080.27714694
2.90000004214470038E-002 570300529.59325635
3.00000004364986833E-002 564435888.91553104
3.10000004515503629E-002 558330224.84078777
3.20000004666020424E-002 551978235.02284503
3.30000004816537185E-002 545374215.24478471
3.40000004967053945E-002 538512022.19347811
3.50000005117570706E-002 531385031.23928392
3.60000005268087467E-002 523986088.38359386
3.70000005418604228E-002 516307455.36294323
3.80000005569120988E-002 508340746.68114388
3.90000005719637749E-002 500076857.06765401
4.00000005870154510E-002 491505877.51411915
4.10000006020671270E-002 482616997.59909481
4.20000006171188031E-002 473398391.23751330
4.30000006321704792E-002 463837082.26100677
4.40000006472221553E-002 453918785.24165601
4.50000006622738313E-002 443627715.70000380
4.60000006773255074E-002 432946362.08711797
4.70000006923771835E-002 421855209.57271582
4.80000007074288595E-002 410332402.41148412
4.90000007224805356E-002 398353327.09658945
5.00000007375322117E-002 385890092.01365507
5.10000007525838878E-002 372910869.89102477
5.20000007676355638E-002 359379055.40856612
5.30000007826872399E-002 345252169.23859328
5.40000007977389160E-002 330480407.04867899
5.50000008127905921E-002 315004679.66142160
5.60000008278422681E-002 298753904.09996289
5.70000008428939442E-002 281641156.80718756
5.80000008579456203E-002 263558033.79028088
5.90000008729972963E-002 244366057.62596649
6.00000008880489724E-002 223882951.33293855
6.10000009031006485E-002 201859366.65185842
6.20000009181523246E-002 177936241.02956882
6.30000009332040006E-002 151557910.30957550
6.40000009482556836E-002 121765291.35095723
6.50000009633073667E-002 86559267.089058787
6.55000009708332082E-002 65426461.293441042
6.57500009745961289E-002 53302138.933172308
6.60000009783590497E-002 39426676.852969810
6.61250009802405031E-002 31420419.466817942
6.61875009811812298E-002 26990556.317915626
6.62500009821219565E-002 22141701.774704639
6.63125009830626833E-002 16660747.853145797
6.63437509835330536E-002 13545243.019599622
6.63750009840034239E-002 10005961.472616604
6.63906259842386021E-002 7977189.7376845730
6.63984384843561981E-002 6859353.5722278254
6.64062509844737942E-002 5640194.0016339840
6.64140634845913902E-002 4269001.8157937871
6.64179697346501813E-002 3494062.1127031618
6.64218759847089724E-002 2619905.3127237577
6.64238291097383748E-002 2123622.6108079469
6.64257822347677773E-002 1559918.6189464168
6.64267587972824786E-002 1236456.8137497872
6.64272470785398222E-002 1057927.6240404730
6.64277353597971659E-002 862738.15614189487
6.64282236410545096E-002 642083.82668608800
6.64284677816831814E-002 516374.94981919462
6.64287119223118533E-002 372785.75911960861
6.64288339926261961E-002 289635.30197500519
6.64288950277833606E-002 243297.18415601959
6.64289560629405251E-002 192010.14249639038
6.64289865805191143E-002 163648.20723028996
6.64290170980977035E-002 132563.58387729200
6.64290476156762927E-002 97253.723591483620
6.64290628744655803E-002 76985.780308764486
6.64290705038602242E-002 65794.226798446252
6.64290781332548680E-002 53550.730279557472
6.64290857626495118E-002 39692.287404006805
6.64290895773468337E-002 31781.040806673544
6.64290933920441556E-002 22714.975861705043
1.00000000000000002E-003 649909135.03119123
2.00000001505167783E-003 649636489.29833126
3.00000003010335563E-003 649181909.86863339
4.00000004515503344E-003 648545142.11149800
5.00000006020671125E-003 647725827.94719517
6.00000007525838906E-003 646723505.15455902
7.00000009031006686E-003 645537605.90191960
8.00000010536174554E-003 644167454.93684888
9.00000012041342334E-003 642612267.44508624
1.00000001354651012E-002 640871146.53866076
1.10000001505167790E-002 638943080.30864108
1.20000001655684568E-002 636826938.57690644
1.30000001806201346E-002 634521469.03385830
1.40000001956718124E-002 632025293.06391215
1.50000002107234902E-002 629336900.94825923
1.60000002257751697E-002 626454646.57255840
1.70000002408268493E-002 623376741.51493466
1.80000002558785288E-002 620101248.48522842
1.90000002709302084E-002 616626074.03659952
2.00000002859818879E-002 612948960.51813209
2.10000003010335674E-002 609067477.12493813
2.20000003160852470E-002 604979010.01064956
2.30000003311369265E-002 600680751.32512844
2.40000003461886061E-002 596169687.06278419
2.50000003612402856E-002 591442583.57983398
2.60000003762919651E-002 586495972.61729527
2.70000003913436447E-002 581326134.64072454
2.80000004063953242E-002 575929080.27714694
2.90000004214470038E-002 570300529.59325635
3.00000004364986833E-002 564435888.91553104
3.10000004515503629E-002 558330224.84078777
3.20000004666020424E-002 551978235.02284503
3.30000004816537185E-002 545374215.24478471
3.40000004967053945E-002 538512022.19347811
3.50000005117570706E-002 531385031.23928392
3.60000005268087467E-002 523986088.38359386
3.70000005418604228E-002 516307455.36294323
3.80000005569120988E-002 508340746.68114388
3.90000005719637749E-002 500076857.06765401
4.00000005870154510E-002 491505877.51411915
4.10000006020671270E-002 482616997.59909481
4.20000006171188031E-002 473398391.23751330
4.30000006321704792E-002 463837082.26100677
4.40000006472221553E-002 453918785.24165601
4.50000006622738313E-002 443627715.70000380
4.60000006773255074E-002 432946362.08711797
4.70000006923771835E-002 421855209.57271582
4.80000007074288595E-002 410332402.41148412
4.90000007224805356E-002 398353327.09658945
5.00000007375322117E-002 385890092.01365507
5.10000007525838878E-002 372910869.89102477
5.20000007676355638E-002 359379055.40856612
5.30000007826872399E-002 345252169.23859328
5.40000007977389160E-002 330480407.04867899
5.50000008127905921E-002 315004679.66142160
5.60000008278422681E-002 298753904.09996289
5.70000008428939442E-002 281641156.80718756
5.80000008579456203E-002 263558033.79028088
5.90000008729972963E-002 244366057.62596649
6.00000008880489724E-002 223882951.33293855
6.10000009031006485E-002 201859366.65185842
6.20000009181523246E-002 177936241.02956882
6.30000009332040006E-002 151557910.30957550
6.40000009482556836E-002 121765291.35095723
6.50000009633073667E-002 86559267.089058787
6.55000009708332082E-002 65426461.293441042
6.57500009745961289E-002 53302138.933172308
6.60000009783590497E-002 39426676.852969810
6.61250009802405031E-002 31420419.466817942
6.61875009811812298E-002 26990556.317915626
6.62500009821219565E-002 22141701.774704639
6.63125009830626833E-002 16660747.853145797
6.63437509835330536E-002 13545243.019599622
6.63750009840034239E-002 10005961.472616604
6.63906259842386021E-002 7977189.7376845730
6.63984384843561981E-002 6859353.5722278254
6.64062509844737942E-002 5640194.0016339840
6.64140634845913902E-002 4269001.8157937871
6.64179697346501813E-002 3494062.1127031618
6.64218759847089724E-002 2619905.3127237577
6.64238291097383748E-002 2123622.6108079469
6.64257822347677773E-002 1559918.6189464168
6.64267587972824786E-002 1236456.8137497872
6.64272470785398222E-002 1057927.6240404730
6.64277353597971659E-002 862738.15614189487
6.64282236410545096E-002 642083.82668608800
6.64284677816831814E-002 516374.94981919462
6.64287119223118533E-002 372785.75911960861
6.64288339926261961E-002 289635.30197500519
6.64288950277833606E-002 243297.18415601959
6.64289560629405251E-002 192010.14249639038
6.64289865805191143E-002 163648.20723028996
6.64290170980977035E-002 132563.58387729200
6.64290476156762927E-002 97253.723591483620
6.64290628744655803E-002 76985.780308764486
6.64290705038602242E-002 65794.226798446252
6.64290781332548680E-002 53550.730279557472
6.64290857626495118E-002 39692.287404006805
6.64290895773468337E-002 31781.040806673544
6.64290933920441556E-002 22714.975861705043
2 changes: 1 addition & 1 deletion Diagnostics/Sedov/main.cpp
Original file line number Diff line number Diff line change
@@ -304,7 +304,7 @@ int main(int argc, char* argv[])
e_bin[index] += (fab(i,j,k,rhoe_comp) / fab(i,j,k,dens_comp)) * vol;

volcount[index] += vol;

}
}
}
4 changes: 2 additions & 2 deletions Docs/preprocess_files.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ def strip_directives(filename, filepath, outpath):
"""
Read in file, remove all preprocessor directives and output.
This is also going to switch square brackets initializing arrays to
This is also going to switch square brackets initializing arrays to
parentheses and remove the new-line characters
"""

@@ -43,7 +43,7 @@ def strip_directives(filename, filepath, outpath):
continue

# loop over files in subdirectories and run strip_directives on all
# C++ header files
# C++ header files
for f in sorted(os.listdir(os.path.join(rootdir, subdir))):
if (f[-2:] == ".H"):
strip_directives(f, os.path.join(rootdir, subdir), outdir)
2 changes: 1 addition & 1 deletion Docs/source/ConvertCheckpoint.rst
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ Now let’s suppose that you want to grow the domain by a factor of 8
and cover that new larger domain with a level that is a factor of 2
coarser than the existing level 0 grids.

#. First, set ``DIM =`` in the GNUmakefile, and type ``make`` in the
#. First, set ``DIM =`` in the GNUmakefile, and type ``make`` in the
``Util/ConvertCheckpoint/`` directory. This will
make an executable from the ``Embiggen.cpp`` code.

2 changes: 1 addition & 1 deletion Docs/source/EOS.rst
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ Equation of State

Castro is written in a modular fashion so that the EOS
can be supplied by the user. No equations of state
are distributed with Castro, instead they are part
are distributed with Castro, instead they are part
of the separate `Microphysics repository <https://github.com/amrex-astro/Microphysics>`_.

Most equations of state are written to take :math:`(\rho, T, X_k)` as
Loading

0 comments on commit fbd880f

Please sign in to comment.