Skip to content

Commit 39522f0

Browse files
committed
parse end program for FPM_UNIT_PROGRAM
1 parent da6d1bf commit 39522f0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/fpm_source_parsing.f90

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,10 @@ function parse_f_source(f_filename,error) result(f_source)
333333
end if
334334

335335
! Detect if contains a program
336-
! (no modules allowed after program def)
337-
if (index(file_lines_lower(i)%s,'program ') == 1) then
336+
! - no modules allowed after program def
337+
! - program header may be missing (only "end program" statement present)
338+
if (index(file_lines_lower(i)%s,'program ')==1 .or. &
339+
parse_sequence(file_lines_lower(i)%s,'end','program')) then
338340

339341
temp_string = split_n(file_lines_lower(i)%s,n=2,delims=' ',stat=stat)
340342
if (stat == 0) then
@@ -351,6 +353,7 @@ function parse_f_source(f_filename,error) result(f_source)
351353
f_source%unit_type = FPM_UNIT_PROGRAM
352354

353355
cycle
356+
354357

355358
end if
356359

0 commit comments

Comments
 (0)