Pass unallocated arrays to Fortran as NULL pointers

Create issue
Issue #581 closed
Erik Schnetter created an issue

The deleted comment is wrong. We should always pass unallocated arrays to Fortran to catch allocation errors.


Comments (5)

  1. Roland Haas
    • removed comment

    while I think I can definitely construct a situation where a compiler is perfectly correct in trying to access the NULL pointer, namely something like:

    CCTK_REAL gxx(cctk_lsh(1), cctk_lsh(2), cctk_lsh(3)) CCTK_REAL betax(cctk_lsh(1), cctk_lsh(2), cctk_lsh(3)) ... gxxL = gxx(i,j,k) if( then bx = betax(i,j,k) else bx = 0.0 endif

    I think that unless we actually know of a compiler that gives segfaults in this case I would think that the benefit of having unallocated grid functions detected in Fortran outweights the undocumented behaviour we exploit here (plus we are already using undocumented/compiler-specific features when calling Fortran code from C).

    I compiles for me and seems to not crash the testsuites (gcc 4.6). Please apply.

  2. Erik Schnetter reporter
    • changed status to resolved
    • removed comment

    I did not change my mind -- I only did not want to apply this shortly before the release.


  3. Log in to comment