#2571: runtime failure due to useing character*8 in DECLARE_CCTK_ARGUMENTS_CHECKED macro
Reporter:Roland Haas
Status:new
Milestone:
Version:development version
Type:bug
Priority:major
Component:Cactus

I just learned (via Skype) that Cactus' use of character*8 variables can cause runtime errors in Fortran:

At line 13 of file Cactus/arrangements/EinsteinBase/TmunuBase/src/SetStressEnergyState.F90
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'dtbetax_p' (0/8)

and digging down a bit and looking at the processed Fortran file (configs/sim/build/TmunuBase/SetStressEnergyState.f90) one finds:

characTer*8, intent(IN) :: dtbetax_p
integer, parameter :: cctki_use_dtbetax_p = kind(dtbetax_p)

and https://stackoverflow.com/questions/4780069/passing-a-string-as-an-argument-when-the-dummy-has-specified-length where the Fortran 2003 standard gets quoted with an explanation:

If a scalar dummy argument is of type default character, the length len of the dummy argument shall be less than or equal to the length of the actual argument. The dummy argument becomes associated with the leftmost len characters of the actual argument.

This all used gfortran 11.

Safest would be if we could declare as characTer*0 if that is allowed. Of course it’s still wrong in that the actual argument passed to dtbetax_p--
Ticket URL: https://bitbucket.org/einsteintoolkit/tickets/issues/2571/runtime-failure-due-to-useing-character-8