Skip to content

TypeError crash in ccpp_fortran_to_metadata.py instead of error message #725

@jimmielin

Description

@jimmielin

Description

ccpp_fortran_to_metadata.py crashes with TypeError: sequence item 0: expected str instance, ParseSyntaxError found when parsing a module with a variable declaration that triggers a
ParseSyntaxError:

Traceback (most recent call last):
  File "...ccpp_fortran_to_metadata.py", line 248, in <module>
    _main_func()
  File "...ccpp_fortran_to_metadata.py", line 241, in _main_func
    _ = parse_fortran_files(fort_files, run_env,
  File "...ccpp_fortran_to_metadata.py", line 185, in parse_fortran_files
    ftables, _ = parse_fortran_file(filename, run_env)
  File "...scripts/fortran_tools/parse_fortran_file.py", line 1063, in parse_fortran_file
    statements, ptables, additional_routines = parse_module(pobj, statements, run_env)
  File "...scripts/fortran_tools/parse_fortran_file.py", line 1036, in parse_module
    raise CCPPError('\n'.join(errors))
TypeError: sequence item 0: expected str instance, ParseSyntaxError found

Steps to Reproduce

On latest develop

  1. Create a Fortran file with a module-level DDT variable with integer dimensions that triggers the error
module fruit_basket
   implicit none
!> \section arg_table_fruit_basket  Argument Table
!! \htmlinclude arg_table_fruit_basket.html
   integer, parameter :: N_FRUITS = 10
   type :: banana_t
      real :: ripeness
   end type banana_t
   type(banana_t) :: bananas(0:N_FRUITS)
end module fruit_basket
  1. Run ccpp_fortran_to_metadata.py
  2. Script crashes with TypeError instead of reporting the parse error.

PR forthcoming. The expected fix will allow for the correct error

bananas: '0:N_FRUITS' is an invalid dimension name; integer dimension indices not supported, at ...module_with_ddt_var.F90:13

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugFor issues describing bugs, or PRs fixing bugs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions