Closed phmarti closed 6 years ago
That's not Cheetah's fault but FTG's. I guess, I forgot that preprocessor directives must not be indented when I implemented the pretty printing. Unfortunately, I'm not at home/office until wednesday and don't have my laptop with me. If it's urgent, you can quickly fix it yourself, just change line 156 in generator.py from
lines.append((' ' * indent) + line)
to
if not line.startswith('#'):
line = (' ' * indent) + line
lines.append(line)
Thanks. It's not really urgent as I have a simple workaround, but now I'm struggling with new blank lines appearing. That wouldn't really be a problem, except it breaks my other patches.
@phmarti, can you give a little bit more details about that? Examples of template and generate code...
@chovyy Woups, I have been doing too many different things simulatenously. The modified template is here: https://github.com/C2SM-RCM/eniac-scripts/blob/timings/standalones/common/ftg/icon_standalone_eniac/capture.aftersubroutine.tmpl
I added the ftg_acc_copyout routine and a similar ftg_acc_copyin in the replay template.
The output looks like this:
CALL ftg_allocate_and_read_allocatable("qs", qs, ftg_rperturb)
#if defined(FTG_ACC_COPYIN) && !defined(FTG_ACC_NOCOPYIN_qs)
!$ACC ENTER DATA COPYIN( qs )
#endif
CALL ftg_allocate_and_read_allocatable("qg", qg, ftg_rperturb)
#if defined(FTG_ACC_COPYIN) && !defined(FTG_ACC_NOCOPYIN_qg)
!$ACC ENTER DATA COPYIN( qg )
#endif
CALL ftg_allocate_and_read_allocatable("qnc", qnc, ftg_rperturb)
#if defined(FTG_ACC_COPYIN) && !defined(FTG_ACC_NOCOPYIN_qnc)
!$ACC ENTER DATA COPYIN( qnc )
#endif
CALL ftg_read("qi0", qi0)
CALL ftg_read("qc0", qc0)
Without my addition it was simply:
CALL ftg_allocate_and_read_allocatable("qs", qs, ftg_rperturb)
CALL ftg_allocate_and_read_allocatable("qg", qg, ftg_rperturb)
CALL ftg_allocate_and_read_allocatable("qnc", qnc, ftg_rperturb)
CALL ftg_read("qi0", qi0)
CALL ftg_read("qc0", qc0)
I couldn't figure out where the extra blank line after #endif
comes from.
That has something to do with how Cheetah handles those #def
s. It always adds a blank line at the end. If you don't want that, use #slurp
as explained here.
Example:
line1
$l2
line3
#def l2()
line2
#end def
produces
line1
line2
line3
while
line1
$l2
line3
#def l2()
line2#slurp
#end def
ends up in
line1
line2
line3
Thanks! I read that page but somehow I missed the last paragraph!
Is now fixed in v1.5.1 and v1.6.2-beta.
I'm trying to add a couple of preprocessor directives into the cheetah templates for ICON. They are simple #ifdef conditions and I managed to introduce them and properly escape the special characters. But Cheetah seems to force indentation when it generates the code. Do you know how to stop it from doing this?