Skip to content

Commit d0f44d5

Browse files
committed
Bounds check fix
Fixed bounds check error that pops up. OR statement isn’t short-circuit evaluated.
1 parent 93fdfe9 commit d0f44d5

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/snopt_wrapper.f90

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,20 @@ subroutine f_sninit ( name, len, iPrint, iSumm, iw, leniw, rw, lenrw ) &
217217

218218
iPrt = iPrint
219219

220-
if ( len == 0 .or. name(1) == c_null_char ) then
220+
if ( len == 0 ) then
221221
iPrt = 0
222222
else
223-
pname = ''
224-
do j = 1, len
225-
if ( name(j) == c_null_char ) exit
226-
pname(j:j) = name(j)
227-
end do
228-
close ( iPrt )
229-
open ( iPrt, file=trim(pname), status='unknown', position='append' )
223+
if ( name(1) == c_null_char ) then
224+
iPrt = 0
225+
else
226+
pname = ''
227+
do j = 1, len
228+
if ( name(j) == c_null_char ) exit
229+
pname(j:j) = name(j)
230+
end do
231+
close ( iPrt )
232+
open ( iPrt, file=trim(pname), status='unknown', position='append' )
233+
end if
230234
end if
231235

232236
call snInit ( iPrt, iSumm, cw, lencw, iw, leniw, rw, lenrw )

0 commit comments

Comments
 (0)