Skip to content

Commit

Permalink
C interface for genz module
Browse files Browse the repository at this point in the history
C interface for implicit fermi module
C interface for the reset of sp2 module
Corresponding tests
Bug fixes
  • Loading branch information
ares201005 committed Sep 22, 2023
1 parent 6c3b0f6 commit 31f6caa
Show file tree
Hide file tree
Showing 7 changed files with 1,309 additions and 110 deletions.
13 changes: 11 additions & 2 deletions scripts/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def get_public(fortran_code):


def transform_fortran_file(filename):

subroutine_re = re.compile(r'subroutine\s+([a-zA-Z0-9_]+)\s*\(([\s\S]*)\)', re.DOTALL)

# use to find the argument names of each subroutine
argument_re = re.compile(r'(real\(8\)|real\(dp\)|real\(PREC\)|integer|logical|type\(bml_matrix_t\)|character\(\d+\)|character\(len=\*\))(,.+?)?\s+::\s+([a-zA-Z0-9_,\s\(\):]+)')

Expand Down Expand Up @@ -65,6 +68,7 @@ def transform_fortran_file(filename):
"type(bml_matrix_t)": "bml_matrix_t*",
"integer": "int",
"character(len=*)":"char*",
"character(100)":"char*",
"character(10)":"char*",
"character(20)":"char*",
"character(50)":"char*",
Expand Down Expand Up @@ -92,6 +96,11 @@ def transform_fortran_file(filename):
line = line.replace("\n","").strip()
line = line + content[k+1].strip()
line = line.replace("&", "")
if "&" in content[k+1]:
line = line.replace("\n","").strip()
line = line + content[k+2].strip()
line = line.replace("&", "")

match = subroutine_re.match(line.strip())
if match:
subroutine_name = match.group(1)
Expand All @@ -103,8 +112,8 @@ def transform_fortran_file(filename):


ispublic = subroutine_name in public_subroutines
print(f"\ndebug-zy: a subroutine {subroutine_name} is found!", ispublic)
print(f"debug-zy: its arguments are: {argument_names}")
print(f"\nA subroutine {subroutine_name} is found!", ispublic)
print(f"Its arguments are: {argument_names}")
# skip the subroutine if it's not public
if not ispublic: continue
is_inside_subroutine = True
Expand Down
Loading

0 comments on commit 31f6caa

Please sign in to comment.