stfc / PSyclone

Domain-specific compiler and code transformation system for Finite Difference/Volume/Element Earth-system models in Fortran
BSD 3-Clause "New" or "Revised" License
102 stars 28 forks source link

PSyclone line length limit error message prints wrong filename #2665

Open astroDimitrios opened 1 month ago

astroDimitrios commented 1 month ago

I came across this yesterday and not sure if it's a me thing! I have an algorithm, cape_cin_mixed_layer_alg_mod.X90, in LFRic that I tried to add another kernel to. When I then tried to build lfric_atm using the build system I get the following:

16:48:45 Preprocessing aviation/algorithms/cape_cin_mixed_layer_alg_mod.X90
16:48:45 Preprocessing aviation/algorithms/aviation_diags_alg_mod.X90
16:48:45 PSyclone - global optimisation /tmp/persistent/vn1.0_cape_cin/applications/lfric_atm/working/build_lfric_atm/aviation/algorithms/cape_cin_mixed_layer_alg_mod.x90
16:48:45 PSyclone - global optimisation /tmp/persistent/vn1.0_cape_cin/applications/lfric_atm/working/build_lfric_atm/aviation/algorithms/aviation_diags_alg_mod.x90
Warning: Algorithm Error: Algorithm file contains no invoke() calls: refusing to generate empty PSy code
Parse Error: the file does not conform to the specified 132 line length limit

Which is because the kernel contains a line with 134 characters. I was under the impression that we ignored any line limit in the build system and am not sure if this is an fparser or PSyclone Parse Error. Is there a way of printing with the error message the actual file it is complaining about? (In this case the kernel when only the algorithms are mentioned in the output)

Link to the rev of my branch where this is occuring.

sergisiso commented 1 month ago

Is it possible to run the lfric build system in a verbose mode to see the exact psyclone command?

It seems you are hitting: https://psyclone.readthedocs.io/en/latest/psyclone_command.html#fortran-line-length You can remove the "-l" flag if you know you have a compiler that accepts longer lines, or do "-l output" if you want to break them but don't care about the input files.

astroDimitrios commented 1 month ago

This is the more verbose output - this shows the -l all flag which is the LFRic default:

printf "%s \\033[1mPSyclone - global optimisation\\033[0m %s\n" `date +%H:%M:%S` /tmp/persistent/vn1.0_cape_cin/applications/lfric_atm/working/build_lfric_atm/aviation/algorithms/cape_cin_mixed_layer_alg_mod.x90
15:53:10 PSyclone - global optimisation /tmp/persistent/vn1.0_cape_cin/applications/lfric_atm/working/build_lfric_atm/aviation/algorithms/cape_cin_mixed_layer_alg_mod.x90
PYTHONPATH=/tmp/persistent/vn1.0_cape_cin/applications/lfric_atm/working/lfric_core/infrastructure/build/psyclone:$PYTHONPATH psyclone -api dynamo0.3 \
           -l all -d /tmp/persistent/vn1.0_cape_cin/applications/lfric_atm/working/build_lfric_atm \
           --config /tmp/persistent/vn1.0_cape_cin/applications/lfric_atm/working/lfric_core/etc/psyclone.cfg \
           -s optimisation/minimum/global.py \
           -oalg  /tmp/persistent/vn1.0_cape_cin/applications/lfric_atm/working/build_lfric_atm/aviation/algorithms/cape_cin_mixed_layer_alg_mod.f90 \
           -opsy /tmp/persistent/vn1.0_cape_cin/applications/lfric_atm/working/build_lfric_atm/aviation/algorithms/cape_cin_mixed_layer_alg_mod_psy.f90 /tmp/persistent/vn1.0_cape_cin/applications/lfric_atm/working/build_lfric_atm/aviation/algorithms/cape_cin_mixed_layer_alg_mod.x90
Parse Error: the file does not conform to the specified 132 line length limit
make[2]: *** [/tmp/persistent/vn1.0_cape_cin/applications/lfric_atm/working/build_lfric_atm/aviation/algorithms/cape_cin_mixed_layer_alg_mod.f90] Error 1

I can fix this easily now I know it's the kernel that's the problem but even in verbose mode the kernel isn't mentioned in the error message.

sergisiso commented 1 month ago

Ah, I see what you mean, you are right the kernel file name should be named in the error message.