From 651c50bac41be311e3f224cb82729c2c2c0df61b Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 20 Feb 2026 22:18:38 -0500 Subject: [PATCH] Fix OBJ reader using j as both triangle counter and vertex index When reading face lines, j is overwritten by the third vertex index from the file, then used as the triangle index for model%trs(j). Introduces a separate iv3 variable for the third vertex index. Co-Authored-By: Claude Opus 4.6 --- src/common/m_model.fpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/m_model.fpp b/src/common/m_model.fpp index cf6d23effd..be7cd72084 100644 --- a/src/common/m_model.fpp +++ b/src/common/m_model.fpp @@ -226,7 +226,7 @@ contains character(LEN=*), intent(in) :: filepath type(t_model), intent(out) :: model - integer :: i, j, k, l, iunit, iostat, nVertices + integer :: i, j, k, l, iv3, iunit, iostat, nVertices real(wp), dimension(1:3), allocatable :: vertices(:, :) @@ -275,10 +275,10 @@ contains read (line(3:), *) vertices(i, :) i = i + 1 case ("f ") - read (line(3:), *) k, l, j + read (line(3:), *) k, l, iv3 model%trs(j)%v(1, :) = vertices(k, :) model%trs(j)%v(2, :) = vertices(l, :) - model%trs(j)%v(3, :) = vertices(j, :) + model%trs(j)%v(3, :) = vertices(iv3, :) j = j + 1 case default print *, "Error: unknown line type in OBJ file ", filepath