Skip to content
Snippets Groups Projects

Draft: Fortran Support

2 files
+ 14
10
Compare changes
  • Side-by-side
  • Inline

Files

+ 4
10
@@ -6,21 +6,12 @@ import re
from typing_extensions import override
from Infrastructure.Instruction import Instruction
from Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_MARKER_COMMENT_END, ERROR_MARKER_COMMENT_BEGIN_FORT, ERROR_MARKER_COMMENT_END_FORT
from Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_MARKER_COMMENT_END, ERROR_MARKER_COMMENT_BEGIN_FORT, ERROR_MARKER_COMMENT_END_FORT, arg_c_to_fort
import Infrastructure.Variables as infvars
call_template_fort = "call @FUNC@(@ARGS@)"
call_template_c = "@FUNC@(@ARGS@);"
arg_c_to_fort = {
"MPI_INT": "MPI_INTEGER",
"MPI_DOUBLE": "MPI_DOUBLE_PRECISION",
"sizeof(int)": "int_size",
"sizeof(signed int)": "int_size",
"sizeof(double)": "double_size",
"true": ".TRUE.",
"false": ".FALSE.",
}
def get_arg_str(args: typing.OrderedDict[str, str], bigint: typing.List[str] = []):
s = ""
@@ -30,6 +21,9 @@ def get_arg_str(args: typing.OrderedDict[str, str], bigint: typing.List[str] = [
# NULL() and MPI_REQUEST_NULL (as a literal, not variable) are both caught by the compiler
# Tests are invalid, and would not compile
if v == "NULL" or v == "MPI_REQUEST_NULL": v = "! FORTRAN_INCOMPATIBLE"
# Using a C datatype with no (implemented) fortran equivalent, also invalid
from Infrastructure.TemplateFactory import predefined_types
if v in predefined_types and v not in arg_c_to_fort: v = "! FORTRAN_INCOMPATIBLE"
for c_arg in arg_c_to_fort.keys():
if c_arg in str(v):
v = v.replace(c_arg, arg_c_to_fort[c_arg])
Loading