-
Notifications
You must be signed in to change notification settings - Fork 5
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
Bug: FTG inserts code inside an #ifdef .. #endif if it is placed at the end of the declarative region #12
Comments
Thanks for reporting. This issue should be present with all FTG and Serialbox2 versions, since I have never made any attempt to take care of preprocessor directives for the code generation and left it to the user to shift the generated lines if needed. |
Yes, it happens in all the FTG versions I've tried. But it is no big deal, now that I know to look for it -- it was only annoying in that the first time it took a while to discover. That said, it would probably be quite easy to avoid with a Boolean to notice if one is in an #ifdef at the declaration/executable boundary of the subroutine FTG is applied to. |
I have just closed #11 which is duplicate to this one. |
The whole thing is bit tricky. Currently, FTG puts the capture-input code directly after the last variable declaration, like this: SUBROUTINE example(arg)
INTEGER, INTENT(in) :: arg
#ifdef __SWITCH__
LOGIGAL :: whatever
#endif
CALL do_something() becomes SUBROUTINE example(arg)
INTEGER, INTENT(in) :: arg
#ifdef __SWITCH__
LOGIGAL :: whatever
! ================= BEGIN FORTRAN TEST GENERATOR (FTG) =======================
ftg_example_round = ftg_example_round + 1
CALL ftg_example_capture_input(arg)
! ================= END FORTRAN TEST GENERATOR (FTG) =========================
#endif
CALL do_something() I could change it to not put it after the last declaration, but before the first statement, which in most cases should be the same. But then, we have a similar issue: SUBROUTINE example(arg)
INTEGER, INTENT(in) :: arg
#ifdef __SWITCH__
CALL do_sometimes()
#endif became: SUBROUTINE example(arg)
INTEGER, INTENT(in) :: arg
#ifdef __SWITCH__
! ================= BEGIN FORTRAN TEST GENERATOR (FTG) =======================
ftg_example_round = ftg_example_round + 1
CALL ftg_example_capture_input(arg)
! ================= END FORTRAN TEST GENERATOR (FTG) =========================
CALL do_sometimes()
#endif Another solution would be to search specifically for SUBROUTINE example(arg)
INTEGER, INTENT(in) :: arg
#ifdef __SWITCH__
LOGIGAL :: whatever
CALL do_sometimes()
#endif In general, there is no common solution for the preprocessor problem which can also occur at every other location where code is inserted and I would still say that FTG generally ignores it, so one has to fix problems either manually or let FTG work with the already preprocessed code. But for this specific case, where one or more |
Fixed in v1.5.0. |
FTG 2.3.0 and 2.3.1 both insert the ftg initialization incorrectly in the following code:
Original code:
FTG generated:
This means that the input was not being captured, despite all my head-scratching...
The text was updated successfully, but these errors were encountered: