-
Notifications
You must be signed in to change notification settings - Fork 191
Fypp cleanup #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fypp cleanup #129
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -35,3 +35,6 @@ build/ | |
|
||
# Build directory for out-of-tree builds | ||
/build | ||
|
||
# Emacs backup files | ||
*~ | ||
This file contains hidden or 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 hidden or 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,42 @@ | ||
# Preprocesses a list of files with given preprocessor and preprocessor options | ||
# | ||
# Args: | ||
# preproc [in]: Preprocessor program | ||
# preprocopts [in]: Preprocessor options | ||
# srcext [in]: File extension of the source files | ||
# trgext [in]: File extension of the target files | ||
# srcfiles [in]: List of the source files | ||
# trgfiles [out]: Contains the list of the preprocessed files on exit | ||
# | ||
function(preprocess preproc preprocopts srcext trgext srcfiles trgfiles) | ||
|
||
set(_trgfiles) | ||
foreach(srcfile IN LISTS srcfiles) | ||
string(REGEX REPLACE "\\.${srcext}$" ".${trgext}" trgfile ${srcfile}) | ||
add_custom_command( | ||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${trgfile} | ||
COMMAND ${preproc} ${preprocopts} ${CMAKE_CURRENT_SOURCE_DIR}/${srcfile} ${CMAKE_CURRENT_BINARY_DIR}/${trgfile} | ||
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${srcfile}) | ||
list(APPEND _trgfiles ${CMAKE_CURRENT_BINARY_DIR}/${trgfile}) | ||
endforeach() | ||
set(${trgfiles} ${_trgfiles} PARENT_SCOPE) | ||
|
||
endfunction() | ||
|
||
|
||
|
||
# Preprocesses fortran files with fypp. | ||
# | ||
# It assumes that source files have the ".fypp" extension. Target files will be | ||
# created the extension ".f90". The FYPP variable must contain the path to the | ||
# fypp-preprocessor. | ||
# | ||
# Args: | ||
# fyppopts [in]: Options to pass to fypp. | ||
# fyppfiles [in]: Files to be processed by fypp | ||
# f90files [out]: List of created f90 files on exit | ||
# | ||
function (fypp_f90 fyppopts fyppfiles f90files) | ||
preprocess("${FYPP}" "${fyppopts}" "fypp" "f90" "${fyppfiles}" _f90files) | ||
set(${f90files} ${_f90files} PARENT_SCOPE) | ||
endfunction() |
This file contains hidden or 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 hidden or 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,49 @@ | ||
#:mute | ||
|
||
#! Real kinds to be considered during templating | ||
#:set REAL_KINDS = ["sp", "dp", "qp"] | ||
|
||
#! Real types to be considere during templating | ||
#:set REAL_TYPES = ["real({})".format(k) for k in REAL_KINDS] | ||
|
||
#! Collected (kind, type) tuples for real types | ||
#:set REAL_KINDS_TYPES = list(zip(REAL_KINDS, REAL_TYPES)) | ||
|
||
|
||
#! Integer kinds to be considered during templating | ||
#:set INT_KINDS = ["int8", "int16", "int32", "int64"] | ||
|
||
#! Integer types to be considere during templating | ||
#:set INT_TYPES = ["integer({})".format(k) for k in INT_KINDS] | ||
|
||
#! Collected (kind, type) tuples for integer types | ||
#:set INT_KINDS_TYPES = list(zip(INT_KINDS, INT_TYPES)) | ||
|
||
|
||
#! Whether Fortran 90 compatible code should be generated | ||
#:set VERSION90 = defined('VERSION90') | ||
|
||
|
||
#! Ranks to be generated when templates are created | ||
#:if not defined('MAXRANK') | ||
#:if VERSION90 | ||
#:set MAXRANK = 7 | ||
#:else | ||
#:set MAXRANK = 15 | ||
#:endif | ||
#:endif | ||
|
||
|
||
#! Generates an array rank suffix. | ||
#! | ||
#! Args: | ||
#! rank [in]: Integer with rank. | ||
#! | ||
#! Returns: | ||
#! Array rank suffix string (e.g. (:,:) if rank = 2) | ||
#! | ||
#:def ranksuffix(rank) | ||
#{if rank > 0}#(${":" + ",:" * (rank - 1)}$)#{endif}# | ||
#:enddef | ||
|
||
#:endmute |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍