@@ -646,6 +646,7 @@ def parse_fortran_function(file_path: Path, suppress_warnings=False):
646646 complex_vars = set()
647647 integer_vars = set()
648648 char_vars = set()
649+ logical_vars = set()
649650 array_vars = set()
650651
651652 # Find the argument declaration section
@@ -656,23 +657,23 @@ def parse_fortran_function(file_path: Path, suppress_warnings=False):
656657 line_stripped = line.strip()
657658
658659 # Look for argument section markers (both in comments and actual code)
659- if 'Scalar Arguments' in line_stripped or 'Array Arguments' in line_stripped:
660+ looking_for_var_decl = line_stripped.upper()
661+ if 'SCALAR ARGUMENTS' in looking_for_var_decl or 'ARRAY ARGUMENTS' in looking_for_var_decl:
660662 in_args_section = True
661663 continue
662664 elif line_stripped.startswith('*') and ('..' in line_stripped or '=' in line_stripped):
663665 in_args_section = False
664666 continue
665667
666668 # Also look for the actual declaration lines (not in comments)
667- if line_stripped and not line_stripped.startswith('*') and not line_stripped.startswith('C '):
669+ if line_stripped and not line_stripped.startswith('*') and not line_stripped.startswith('C ') and in_args_section :
668670 # Look for ARRAY variables
669- is_array = ('(' in line_stripped) and (')' in line_stripped)
671+ is_array = ('(' in line_stripped) and (')' in line_stripped) # Probably better: re.search(r'(\s*\*\s*)', line_stripped) != None
670672
671673 # Parse variable declarations
672- looking_for_var_decl = line_stripped[0:16].upper() # 16 is the length of DOUBLE PRECISION
673674 if looking_for_var_decl.startswith('REAL') or looking_for_var_decl.startswith('DOUBLE PRECISION') or looking_for_var_decl.startswith('FLOAT'):
674675 # Extract variable names from REAL, DOUBLE PRECISION, or FLOAT declaration
675- real_decl = re.search(r'(?:REAL|DOUBLE PRECISION|FLOAT)(?:\(\w+\))?\s+(.+)', line_stripped, re.IGNORECASE)
676+ real_decl = re.search(r'(?:REAL|DOUBLE PRECISION|FLOAT)\*?\d* (?:\(\w+\))?\s+(.+)', line_stripped, re.IGNORECASE)
676677 if real_decl:
677678 vars_str = real_decl.group(1)
678679 # Before anything, remove F90 style '::' declaration
@@ -723,7 +724,7 @@ def parse_fortran_function(file_path: Path, suppress_warnings=False):
723724
724725 elif looking_for_var_decl.startswith('COMPLEX'):
725726 # Extract variable names from COMPLEX declaration
726- complex_decl = re.search(r'COMPLEX\*?\d*\s+(.+)', line_stripped, re.IGNORECASE)
727+ complex_decl = re.search(r'COMPLEX\*?\d*(?:\(\w+\))? \s+(.+)', line_stripped, re.IGNORECASE)
727728 if complex_decl:
728729 vars_str = complex_decl.group(1)
729730 # Before anything, remove F90 style '::' declaration
@@ -739,6 +740,25 @@ def parse_fortran_function(file_path: Path, suppress_warnings=False):
739740 complex_vars.add(var) # Add complex variables to complex_vars
740741 if is_array:
741742 array_vars.add(var)
743+
744+ elif looking_for_var_decl.startswith('LOGICAL'):
745+ if not keep_going:
746+ # Extract variable names from COMPLEX declaration
747+ bool_decl = re.search(r'LOGICAL\*?\d*(?:\(\w+\))?\s+(.+)', line_stripped, re.IGNORECASE)
748+ if bool_decl:
749+ vars_str = bool_decl.group(1)
750+ # First remove array dimensions, then split by comma
751+ vars_str_clean = re.sub(r'\([^)]*\)', '', vars_str)
752+ if vars_str_clean:
753+ # Split by comma and clean up
754+ for var in vars_str_clean.split(','):
755+ var = var.strip()
756+ # Remove any remaining modifiers
757+ var = re.sub(r'\*.*$', '', var)
758+ if var and re.match(r'^[A-Za-z][A-Za-z0-9_]*$', var):
759+ logical_vars.add(var) # Add complex variables to complex_vars
760+ if is_array:
761+ array_vars.add(var)
742762
743763 # For FUNCTIONs with explicit return types, add function name to appropriate variable set
744764 if func_type == 'FUNCTION':
@@ -871,6 +891,7 @@ def parse_fortran_function(file_path: Path, suppress_warnings=False):
871891 'complex_vars': complex_vars,
872892 'integer_vars': integer_vars,
873893 'char_vars': char_vars,
894+ 'bool_vars': logical_vars,
874895 'array_vars': array_vars
875896 }
876897
@@ -8410,6 +8431,8 @@ def parse_tap_trace4inout(fname):
84108431 current_type = "metavar integer"
84118432 elif p.upper() in param_types['char_vars'] or p.lower() in param_types['char_vars']:
84128433 current_type = "character()"
8434+ elif p.upper() in param_types['bool_vars'] or p.lower() in param_types['bool_vars']:
8435+ current_type = "boolean()"
84138436 if p.upper() in param_types['array_vars'] or p.lower() in param_types['array_vars']:
84148437 current_type = "arrayType(" + current_type + ", dimColons())"
84158438 types.append(current_type)
0 commit comments