Skip to content

Commit

Permalink
Merge pull request #1 from gold2718/fix_parsing_nested_subroutines_co…
Browse files Browse the repository at this point in the history
…ntains

Do not require label on end subroutine statement
  • Loading branch information
climbfuji authored Jan 4, 2022
2 parents ef7a984 + 5c4d312 commit aacab9d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion scripts/fortran_tools/parse_fortran_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ def parse_scheme_metadata(statements, pobj, spec_name, table_name, run_env):
seen_contains = seen_contains or is_contains_statement(statement, insub)
if seen_contains:
inpreamble = False
# End if
if asmatch is not None:
# We have run off the end of something, hope that is okay
# Put this statement back for the caller to deal with
Expand Down Expand Up @@ -680,7 +681,7 @@ def parse_scheme_metadata(statements, pobj, spec_name, table_name, run_env):
# End if
elif inpreamble or seen_contains:
# Process a preamble statement (use or argument declaration)
if esmatch is not None and scheme_name == esmatch.group(1):
if esmatch is not None:
inpreamble = False
seen_contains = False
insub = False
Expand Down
18 changes: 16 additions & 2 deletions test/capgen_test/temp_calc_adjust.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ SUBROUTINE temp_calc_adjust_run(nbox, timestep, temp_level, temp_calc, &
integer, intent(out) :: errflg
!----------------------------------------------------------------

integer :: col_index
integer :: col_index
real(kind_phys) :: bar = 1.0_kind_phys

errmsg = ''
errflg = 0

call temp_calc_adjust_nested_subroutine(temp_calc)
if (check_foo()) then
call foo(bar)
end if

CONTAINS

Expand All @@ -46,7 +50,17 @@ ELEMENTAL SUBROUTINE temp_calc_adjust_nested_subroutine(temp)

END SUBROUTINE temp_calc_adjust_nested_subroutine

END SUBROUTINE temp_calc_adjust_run
SUBROUTINE foo(bar)
REAL(kind_phys), intent(inout) :: bar
bar = bar + 1.0_kind_phys

END SUBROUTINE

logical function check_foo()
check_foo = .true.
end function check_foo

END SUBROUTINE

!> \section arg_table_temp_calc_adjust_init Argument Table
!! \htmlinclude arg_table_temp_calc_adjust_init.html
Expand Down

0 comments on commit aacab9d

Please sign in to comment.