Add optional support for CarpetEvolutionMask to GRHydro

Issue #1003 closed
Roland Haas created an issue

the attached patch adds access to CarpetEvolutionMask's evolution mask to GRHydro. CarpetEvolutionMaks tracks which points on each level contribute to the final answer, roughly speaking anything that would show up in a call to the interpolators.

The functional change to GRHydro is trivial (just a parameter, a GF access and a cycle in the routine that checks for C2P failures). However getting the equivalent of CCTK_VarDataPtr to work in Fortran turned out to be ugly. Better solutions are very welcome. Desired features are:

  • easy to use
  • not error prone
  • allows to run GRHydro without CarpetEvolutionMask (this means inheriting won't work)
  • low memory footprint

Keyword: GRHydro

Comments (5)

  1. Erik Schnetter
    • removed comment

    Most Fortran compilers (and Cactus expects this, and Simfactory sets the respective compiler options) support "Cray pointers". These are pointer-sized integers that can be used in very much the same way as pointers in C.

    The syntax is slightly unintuitive if one comes from C; instead of an operator that allows dereferencing a pointer, there is a second variable declared for this operation, similar in spirit to Fortran's "equivalence" statement.

    The syntax goes approximately like this:

    CCTK_REAL var(ni,nj,nk) pointer (pvar, var) pvar = ... call flesh function to set pointer var(i,j,k) = ... The "pointer" statement declares a pointer, and the pointer type is taken from the second variable. In C, this would be something like

    typeof(var) *pvar; In addition, the "pointer" statement means that the variable "var" has no memory allocated; instead, accessing var implicitly dereferences the pointer "pvar". In C, "var" becomes "*pvar".

    Technically, pvar is declared as an integer variable with sufficient size to hold a pointer, probably an integer*8 on most systems. As such, pvar can e.g. also be output, passed to subroutines, etc. However, this is rarely necessary -- for almost all purposes, "var" can be used like a regular variable; the only difference is that its memory isn't allocated by the compiler, but by setting "pvar".

    There is also an intrinsic function "loc" to obtain the address of a variable, similar to C's "&" operator.

  2. Log in to comment