[ET Trac] #2571: runtime failure due to useing character*8 in DECLARE_CCTK_ARGUMENTS_CHECKED macro

Roland Haas trac-noreply at einsteintoolkit.org
Wed Oct 20 20:39:00 CDT 2021


#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:

```fortran
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](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` is never a character at all \(it’s either a double precision real or NULL\) and we only use the `characTer` construct to avoid assignment and also unused actual argument warnings.

--
Ticket URL: https://bitbucket.org/einsteintoolkit/tickets/issues/2571/runtime-failure-due-to-useing-character-8
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.einsteintoolkit.org/pipermail/trac/attachments/20211021/d7e86168/attachment.html 


More information about the Trac mailing list