Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions fortitude/test.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
module physics_utils
contains
Comment on lines +1 to +2
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n fortitude/test.f90

Repository: coderabbitai/coderabbit-pr-review

Length of output: 1799


Harden module declarations with implicit none and explicit visibility.

Line 1–2 define module physics_utils without implicit none and without a default access policy. This reduces compile-time safety and exports everything by default.

Suggested patch
 module physics_utils
+    implicit none
+    private
+    public :: compute_energy, square
 contains
🧰 Tools
🪛 Fortitude (0.8.0)

[error] 1-2: module missing 'implicit none'

(C001)


[error] 1-2: module 'physics_utils' missing default accessibility statement

(C131)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@fortitude/test.f90` around lines 1 - 2, The module declaration for
physics_utils lacks an "implicit none" and explicit visibility controls; update
the module header (module physics_utils) to include "implicit none" in the
module scope and set an explicit default visibility (e.g., "private") and then
mark the intended API symbols with "public :: <routine_names>" or individual
"public" attributes; place these declarations before "contains" so that symbols
inside physics_utils are not exported implicitly and local variables require
explicit typing.


subroutine compute_energy(mass, velocity, energy)
real*8 :: mass, velocity, energy
energy = 0.5 * mass * velocity * velocity
end subroutine compute_energy

function square(x) result(y)
real :: x, y
y = x * x
end function square
Comment on lines +4 to +12
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -name "test.f90" -o -name "*.f90" | head -20

Repository: coderabbitai/coderabbit-pr-review

Length of output: 98


🏁 Script executed:

if [ -f "fortitude/test.f90" ]; then
  echo "=== File found: fortitude/test.f90 ===" 
  wc -l fortitude/test.f90
  echo ""
  echo "=== Lines 1-20 of fortitude/test.f90 ==="
  head -20 fortitude/test.f90
fi

Repository: coderabbitai/coderabbit-pr-review

Length of output: 610


🏁 Script executed:

rg "compute_energy|square" fortitude/test.f90

Repository: coderabbitai/coderabbit-pr-review

Length of output: 255


🏁 Script executed:

grep -n "compute_energy\|square" fortitude/test.f90

Repository: coderabbitai/coderabbit-pr-review

Length of output: 267


🏁 Script executed:

sed -n '45,60p' fortitude/test.f90

Repository: coderabbitai/coderabbit-pr-review

Length of output: 393


🏁 Script executed:

sed -n '30,55p' fortitude/test.f90

Repository: coderabbitai/coderabbit-pr-review

Length of output: 530


🏁 Script executed:

cat -n fortitude/test.f90 | sed -n '1,15p'

Repository: coderabbitai/coderabbit-pr-review

Length of output: 516


Use portable kinds and explicit intent in module procedures.

Line 5 uses non-standard real*8, and arguments in both procedures lack intent declarations. Use iso_fortran_env with real(real64) for portability and add explicit intent(in) / intent(out) to enable compiler checking and improve interface clarity.

Suggested patch
 module physics_utils
+    use, intrinsic :: iso_fortran_env, only: real64
     implicit none
     private
     public :: compute_energy, square
 contains

     subroutine compute_energy(mass, velocity, energy)
-        real*8 :: mass, velocity, energy
-        energy = 0.5 * mass * velocity * velocity
+        real(real64), intent(in)  :: mass, velocity
+        real(real64), intent(out) :: energy
+        energy = 0.5_real64 * mass * velocity * velocity
     end subroutine compute_energy

     function square(x) result(y)
-        real :: x, y
+        real, intent(in) :: x
+        real :: y
         y = x * x
     end function square
🧰 Tools
🪛 Fortitude (0.8.0)

[error] 5-5: 'real*8' uses non-standard syntax

(PORT021)


[error] 5-5: real kind set with number literal '8'

(PORT011)


[error] 5-5: subroutine argument 'mass' missing 'intent' attribute

(C061)


[error] 5-5: subroutine argument 'velocity' missing 'intent' attribute

(C061)


[error] 5-5: subroutine argument 'energy' missing 'intent' attribute

(C061)


[error] 10-10: function argument 'x' missing 'intent' attribute

(C061)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@fortitude/test.f90` around lines 4 - 12, Replace non-portable real*8 with a
standardized kind using iso_fortran_env (use real(real64)) and add explicit
intent attributes for procedure arguments: in subroutine compute_energy(mass,
velocity, energy) declare mass, velocity as real(real64), intent(in) and energy
as real(real64), intent(out); in function square(x) declare x as real(real64),
intent(in) and the result y as real(real64) (or specify intent(out) for an
internal variable if used). Also add use iso_fortran_env at the top of the
module or file so real64 is available.


end module physics_utils


subroutine loose_procedure(n, result)
integer :: n, result
integer :: i
result = 0
do i = 1, n
result = result + i
end do
end subroutine loose_procedure


function external_double(x)
real :: x, external_double
external_double = x * 2.0
end function external_double
Comment on lines +17 to +30
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

git ls-files | grep -i "test.f90"

Repository: coderabbitai/coderabbit-pr-review

Length of output: 96


🏁 Script executed:

cat -n fortitude/test.f90 | sed -n '15,32p'

Repository: coderabbitai/coderabbit-pr-review

Length of output: 508


Add implicit none and intent to external procedures.

Lines 17–30 external procedures currently rely on implicit typing rules and omit argument direction. Please make both interfaces explicit by adding implicit none and intent declarations to each argument.

Suggested patch
 subroutine loose_procedure(n, result)
-    integer :: n, result
+    implicit none
+    integer, intent(in) :: n
+    integer, intent(out) :: result
     integer :: i
     result = 0
     do i = 1, n
         result = result + i
     end do
 end subroutine loose_procedure

 function external_double(x)
-    real :: x, external_double
+    implicit none
+    real, intent(in) :: x
+    real :: external_double
     external_double = x * 2.0
 end function external_double
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
subroutine loose_procedure(n, result)
integer :: n, result
integer :: i
result = 0
do i = 1, n
result = result + i
end do
end subroutine loose_procedure
function external_double(x)
real :: x, external_double
external_double = x * 2.0
end function external_double
subroutine loose_procedure(n, result)
implicit none
integer, intent(in) :: n
integer, intent(out) :: result
integer :: i
result = 0
do i = 1, n
result = result + i
end do
end subroutine loose_procedure
function external_double(x)
implicit none
real, intent(in) :: x
real :: external_double
external_double = x * 2.0
end function external_double
🧰 Tools
🪛 Fortitude (0.8.0)

[error] 17-18: subroutine missing 'implicit none'

(C001)


[error] 17-18: subroutine not contained within (sub)module or program

(C092)


[error] 18-18: subroutine argument 'n' missing 'intent' attribute

(C061)


[error] 18-18: subroutine argument 'result' missing 'intent' attribute

(C061)


[error] 27-28: function missing 'implicit none'

(C001)


[error] 27-28: function not contained within (sub)module or program

(C092)


[error] 28-28: function argument 'x' missing 'intent' attribute

(C061)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@fortitude/test.f90` around lines 17 - 30, The external procedures
loose_procedure and external_double currently rely on implicit typing and lack
argument intent; add an explicit "implicit none" at the start of each routine
and add intent attributes for their arguments (e.g., intent(in) for inputs like
n and x, intent(out) or intent(inout) for result as appropriate) while keeping
the existing type declarations (integer :: n, result; real :: x,
external_double) so the interfaces are explicit and safe.



program main
use physics_utils
Comment on lines +33 to +34
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -name "test.f90" -type f | head -20

Repository: coderabbitai/coderabbit-pr-review

Length of output: 98


🏁 Script executed:

find . -name "physics_utils*" -type f | head -20

Repository: coderabbitai/coderabbit-pr-review

Length of output: 59


🏁 Script executed:

cat -n ./fortitude/test.f90 | head -50

Repository: coderabbitai/coderabbit-pr-review

Length of output: 1365


🏁 Script executed:

rg "module physics_utils" -A 20

Repository: coderabbitai/coderabbit-pr-review

Length of output: 1396


🏁 Script executed:

cat -n ./fortitude/test.f90 | sed -n '33,80p'

Repository: coderabbitai/coderabbit-pr-review

Length of output: 937


🏁 Script executed:

cat -n ./fortitude/test.f90 | sed -n '33,66p' | grep -i "square"

Repository: coderabbitai/coderabbit-pr-review

Length of output: 145


🏁 Script executed:

cat -n ./fortitude/test.f90 | sed -n '33,66p' | grep -i "call.*square\|square.*("

Repository: coderabbitai/coderabbit-pr-review

Length of output: 145


🏁 Script executed:

rg "square" ./fortitude/test.f90 -A 2 -B 2

Repository: coderabbitai/coderabbit-pr-review

Length of output: 234


Tighten program main scope controls.

Add implicit none to program main and constrain module imports with an only list. Only compute_energy is used from physics_utils; square is not called in the program.

Suggested patch
 program main
     use physics_utils, only: compute_energy
+    implicit none
🧰 Tools
🪛 Fortitude (0.8.0)

[error] 33-34: program missing 'implicit none'

(C001)


[error] 34-34: 'use' statement missing 'only' clause

(C121)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@fortitude/test.f90` around lines 33 - 34, Add explicit scoping to the
program: insert "implicit none" at the start of program main and tighten the
module import to "use physics_utils, only: compute_energy" so that only the used
symbol (compute_energy) is imported and unused symbol square is not brought into
scope; update the program main header accordingly.


real :: m, v, e
integer :: total, count
real :: pi
real, dimension(10) :: arr
integer :: i
real :: statfunc, z

common /shared_block/ pi, total

statfunc(z) = z * z + 1.0

pi = 3.14159
m = 1.5
v = 10.0d0
count = 100

call compute_energy(m, v, e)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pass DOUBLE PRECISION args to compute_energy

compute_energy declares all dummy arguments as real*8, but this call passes m, v, and e declared as default real in main. Because physics_utils is used, the compiler has an explicit interface and will typically reject this with a kind/type mismatch on standard builds (default REAL(4)), so the new file is not reliably compilable unless special compiler flags are used.

Useful? React with 👍 / 👎.

print *, "Energy:", e
Comment on lines +36 to +53
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verifies kind mismatch indicators in fortitude/test.f90 using static inspection.
python - <<'PY'
from pathlib import Path
src = Path("fortitude/test.f90").read_text()

has_dummy_real8 = "real*8 :: mass, velocity, energy" in src
has_actual_default_real = "real :: m, v, e" in src
has_call = "call compute_energy(m, v, e)" in src

if has_dummy_real8 and has_actual_default_real and has_call:
    print("Mismatch confirmed: compute_energy expects real*8, but main passes default real.")
else:
    print("Pattern not fully matched; re-check declarations and call site.")
PY

Repository: coderabbitai/coderabbit-pr-review

Length of output: 158


Fix real-kind mismatch in compute_energy call path.

Line 36 declares m, v, e as default real, but the call on line 52 passes them to compute_energy whose dummy arguments are real*8 (line 5). With an explicit module interface, this type/kind mismatch blocks compilation.

Use the real64 parameter from iso_fortran_env to ensure consistency:

Suggested patch
 program main
     use physics_utils
+    use, intrinsic :: iso_fortran_env, only: real64

-    real :: m, v, e
+    real(real64) :: m, v, e
@@
-    m = 1.5
-    v = 10.0d0
+    m = 1.5_real64
+    v = 10.0_real64
@@
     call compute_energy(m, v, e)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
real :: m, v, e
integer :: total, count
real :: pi
real, dimension(10) :: arr
integer :: i
real :: statfunc, z
common /shared_block/ pi, total
statfunc(z) = z * z + 1.0
pi = 3.14159
m = 1.5
v = 10.0d0
count = 100
call compute_energy(m, v, e)
print *, "Energy:", e
program main
use physics_utils
use, intrinsic :: iso_fortran_env, only: real64
real(real64) :: m, v, e
integer :: total, count
real :: pi
real, dimension(10) :: arr
integer :: i
real :: statfunc, z
common /shared_block/ pi, total
statfunc(z) = z * z + 1.0
pi = 3.14159
m = 1.5_real64
v = 10.0_real64
count = 100
call compute_energy(m, v, e)
print *, "Energy:", e
🧰 Tools
🪛 Fortitude (0.8.0)

[error] 43-43: common blocks are obsolescent, prefer modules or derived types

(OB011)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@fortitude/test.f90` around lines 36 - 53, The variables m, v, and e are
declared as default real but are passed to compute_energy whose dummy args are
real*8, causing a kind mismatch; fix by importing real64 from iso_fortran_env
(use iso_fortran_env, only: real64) and change the declarations of m, v, e to
real(real64) so their kind matches compute_energy's real*8 interface (or
alternatively change compute_energy's dummy argument types to real(real64));
ensure the module/file contains the use iso_fortran_env and that all related
interfaces (compute_energy) and calls consistently use real(real64).

print *, "Square via statement function:", statfunc(4.0)

do 10 i = 1, 10
arr(i) = real(i) * 1.5
if (arr(i) .gt. 10.0) goto 20
10 continue

20 continue

call loose_procedure(10, total)
print *, "Total:", total

end program main