@*
DimensionRepresentation.tmpl

Created by Graham Dennis on 2008-08-01.

Copyright (c) 2008-2012, Graham Dennis

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*@
@extends xpdeint.Geometry._DimensionRepresentation

@def defines
  @#
  @super
  @if $silent
    @stop
  @end if
  @#
#define ${globalLattice} ((int)${runtimeLattice})
  @#
@end def

@def globals
  @#
  @super
  @#
  @if $silent
    @stop
  @end if
  @#
  @# Note: Here we just *define* the variables for which we're going to
  @# allocate space later (in allocate() below). This is needed in case the
  @# lattice size is specified at runtime - if we allocate space here, it
  @# will use the default argument lattice size, rather than the one set
  @# in the argument processing code in the main() function.
  @#
  @# Make sure we don't create a variable for the propagtion direction dimension
  @if $runtimeLattice
${type}* ${arrayName} = NULL;
  @end if
  @#
  @if $hasLocalOffset
ptrdiff_t $localLattice = 0;
ptrdiff_t $localOffset = 0;
  @end if
  @#
@end def

@def allocate(self)
  @if $silent
    @stop
  @end if
  @# We allocate an extra point just in case
  @# Also make sure we don't create a variable for the propagtion direction dimension
  @if $runtimeLattice
${arrayName} = (${type}*) xmds_malloc(sizeof(${type}) * (${globalLattice}+1));
  @end if
@end def

