-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
216 changed files
with
18,269 additions
and
2,337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright 2019-2023 ETH Zurich and the DaCe authors. All rights reserved. | ||
""" Simple Fortran SDFG command-line compiler. """ | ||
|
||
import dace | ||
import os | ||
import sys | ||
import argparse | ||
import shutil | ||
from dace.frontend.fortran import fortran_parser | ||
|
||
def main(): | ||
# Command line options parser | ||
parser = argparse.ArgumentParser(description='Fortran to SDFG command-line transpiler.') | ||
|
||
# Required argument for Fortran file path | ||
parser.add_argument('filepath', help='<PATH TO FORTRAN FILE>', type=str) | ||
|
||
# Optional argument for output location | ||
parser.add_argument('-o', | ||
'--out', | ||
type=str, | ||
help='If provided, saves library as the given file or in the specified path, ' | ||
'together with a header file.') | ||
|
||
parser.add_argument('-O', | ||
'--optimize', | ||
dest='optimize', | ||
action='store_true', | ||
help="If set, invokes the command-line optimization" | ||
" interface", | ||
default=False) | ||
|
||
args = parser.parse_args() | ||
|
||
filepath = args.filepath | ||
if not os.path.isfile(filepath): | ||
print('Fortran file', filepath, 'not found') | ||
exit(1) | ||
|
||
outpath = args.out | ||
|
||
# Load SDFG | ||
sdfg = fortran_parser.create_sdfg_from_fortran_file(filepath) | ||
|
||
if args.optimize: | ||
sdfg.optimize() | ||
|
||
# Compile SDFG | ||
sdfg.compile(outpath) | ||
|
||
# Copying header file to optional path | ||
if outpath is not None: | ||
source = os.path.join(sdfg.build_folder, 'include', sdfg.name + '.h') | ||
if os.path.isdir(outpath): | ||
outpath = os.path.join(outpath, sdfg.name + '.h') | ||
else: | ||
outpath = os.path.join(os.path.dirname(outpath), sdfg.name + '.h') | ||
shutil.copyfile(source, outpath) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.