#! /usr/bin/perl -w # This perl script generates the include file "cctk_Loop.h". # API: # There is a basic looping macro (LOOP) which takes the array size and # loop bounds as arguments. This macro can loop over all arrays, both # grid functions and grid arrays. A second version of this macro # (LOOP_NORMAL) also provides information about the normal to the # boundary and distance to the boundary to the loop kernel. # There are three specialised versions that take instead cctkGH and # the boundary sizes as arguments (LOOP_INTERIOR, LOOP_BOUNDARIES, and # LOOP_INTBOUNDARIES). These macros are intended for grid functions # only, and loop over the respective subsets of points, either only # interior points, or all physical boundaries, or the "interior" # physical boundaries (excluding edges and corners that are also # ghosts or symmetry points). # Note: Edges and corners can have several boundary types at once, # e.g. can be both a physical and a symmetry point. LOOP_BOUNDARY and # LOOP_INTBOUNDARY treats these different: LOOP_BOUNDARY loops over # all points that are physical boundaries (independent of whether they # also are symmetry or ghost boundaries), while LOOP_INTBOUNARY loops # over those points that are only physical boundaries (and excludes # any points that belongs to a symmetry or ghost boundary). # LOOP_BOUNDARY does not require applying a symmetry condition or # synchronisation afterwards (but does not allow taking tangential # derivatives); LOOP_INTBOUNDARY allows taking tangential derivatives # (but requires applying symmetry boundaries and synchronising # afterwards). # There are four specialised versions that take instead a cctkGH # (LOOP_ALL, LOOP_INT, LOOP_BND, and LOOP_INTBND). These macros are # intended for grid functions only and obtain the boundary sizes from # CoordBase via an aliased function. They loop over the respective # subsets of points, either all points, or all interior points, or all # physical boundaries, or the "interior" physical boundaries (see # above). # Each macro exists in two versions, a regular and a strided one # (STR). The strided macros are intended for vectorised code, and the # stride should be the vector size. # Each macro exists for variable numbers of dimensions, currently 1 # through 4. # Internals: # Since these macros call each other, it is important that the local # variables they declare do not conflict. Therefore, we denote four # "levels" of macros, corresponding to the description above: # level 0: LOOP_NORMAL # level 1: LOOP # level 2: LOOP_INTERIOR, LOOP_BOUNDARIES, LOOP_INTBOUNDARIES # level 3: LOOP_ALL, LOOP_INT, LOOP_BND, LOOP_INTBND # Each level may only call macros of a lower level. All local # variables carry a prefix "cctki[LEVEL]_" to ensure that there are no # naming conflicts. use strict; # Global variable: number of dimensions (1 to 4) our $dim; # Expand [DIM] to the (global) number of dimensions sub expand ($) { my ($str) = @_; my $dimm1 = $dim-1; my $dim2 = 2*$dim; $str =~ s{\[DIM\]}{$dim}g; $str =~ s{\[DIM-1\]}{$dimm1}g; $str =~ s{\[2\*DIM\]}{$dim2}g; if ($dim==1) { $str =~ s{\[DIM==1\?([^:]*):([^]]*)\]}{$1}g; } else { $str =~ s{\[DIM==1\?([^:]*):([^]]*)\]}{$2}g; } return $str; } # Add a newline sub nl ($) { my ($str) = @_; return "$str\n"; } # Add a backslash and newline sub bsnl ($) { my ($str) = @_; return "$str \\\n"; } # Repeat a string once for each dimension, expanding 'I' and 'C' to a # different number (0,1,2,3) and character (i,j,k,l) each time sub rpt ($) { my ($str) = @_; my @ret; for my $d (1..$dim) { my $int = $d-1; my $int1 = $int+1; my $int2 = 2*$int; my $int21 = 2*$int+1; my $int22 = 2*$int+2; my $char = ('i','j','k','l')[$d-1]; my $charm1 = ('ERROR','i','j','k')[$d-1]; my $tmp = $str; $tmp =~ s{\[I\]}{$int}g; $tmp =~ s{\[I\+1\]}{$int1}g; $tmp =~ s{\[2\*I\]}{$int2}g; $tmp =~ s{\[2\*I\+1\]}{$int21}g; $tmp =~ s{\[2\*I\+2\]}{$int22}g; $tmp =~ s{\[C\]}{$char}g; $tmp =~ s{\[C-1\]}{$charm1}g; if ($d==1) { $tmp =~ s{\[I==1\?([^:]*):([^]]*)\]}{$1}g; } else { $tmp =~ s{\[I==1\?([^:]*):([^]]*)\]}{$2}g; } push @ret, $tmp; } return @ret; } # Terminate a list (intersperse a string, and add the string at the # end as well) sub term ($@) { my ($str, @txt) = @_; return (join $str, @txt) . $str; } # Separate a list (intersperse a string, but not at the end) sub sep ($@) { my ($str, @txt) = @_; return (join $str, @txt); } # Repeat and separate with a comma sub crpt ($) { my ($str) = @_; return (sep ',', rpt $str); } # The first argument is a list reference to force a list context for # wherever this argument is evaluated sub bsnlsep ($;$$) { my ($txt, $str1, $str2) = @_; $str1 = '' if ! defined $str1; $str2 = $str1 if ! defined $str2; my @ret; for my $t (@$txt[0..$#$txt-1]) { push @ret, "$t$str1"; } if ($#$txt >= 0) { push @ret, "$$txt[$#$txt]$str2"; } return map {bsnl $_} @ret; } my @lines; # Header push @lines, ( (nl '#ifndef _CCTK_LOOP_H_'), (nl '#define _CCTK_LOOP_H_'), (nl ''), (nl '/* WARNING: This file is auto-generated. Do not edit. */'), (nl '/* Edit cctk_Loop.h.pl instead, and then re-generate this file via */'), (nl '/* perl cctk_Loop.h.pl */'), (nl '/* Documentation can also be found in "cctk_Loop.h.pl". */'), (nl ''), (nl '#ifdef CCODE'), (nl '# include '), (nl '# include '), (nl '# include '), (nl '# include '), (nl ''), (nl '# ifndef CCTK_DISABLE_OMP_COLLAPSE'), (nl '# define CCTK_PRAGMA_OMP_FOR_COLLAPSE_1 _Pragma("omp for collapse(1)")'), (nl '# define CCTK_PRAGMA_OMP_FOR_COLLAPSE_2 _Pragma("omp for collapse(2)")'), (nl '# define CCTK_PRAGMA_OMP_FOR_COLLAPSE_3 _Pragma("omp for collapse(3)")'), (nl '# define CCTK_PRAGMA_OMP_FOR_COLLAPSE_4 _Pragma("omp for collapse(4)")'), (nl '# else'), (nl '# define CCTK_PRAGMA_OMP_FOR_COLLAPSE_1 _Pragma("omp for")'), (nl '# define CCTK_PRAGMA_OMP_FOR_COLLAPSE_2 _Pragma("omp for")'), (nl '# define CCTK_PRAGMA_OMP_FOR_COLLAPSE_3 _Pragma("omp for")'), (nl '# define CCTK_PRAGMA_OMP_FOR_COLLAPSE_4 _Pragma("omp for")'), (nl '# endif'), (nl '#endif /* #ifdef CCODE */'), ); for $dim (1,2,3,4) { push @lines, map {expand $_} ( (nl ''), (nl ''), (nl ''), (nl '/* [DIM]D */'), (nl ''), (nl '#ifdef CCODE'), (nl ''), (nl '/* LOOP */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_NORMAL(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki0_[C]dir_').','), (bsnl ' '.(crpt 'cctki0_[C]min_').','), (bsnl ' '.(crpt 'cctki0_[C]max_').','), (bsnl ' '.(crpt 'cctki0_[C]ash_').')'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt '(cctki0_[C]dir_)').','), (bsnl ' '.(crpt '(cctki0_[C]min_)').','), (bsnl ' '.(crpt '(cctki0_[C]max_)').','), (bsnl ' '.(crpt '(cctki0_[C]ash_)').','), (bsnl ' cctki0_dummy_imin,cctki0_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_NORMAL(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_NORMAL(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_NORMAL(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki0_[C]dir_').','), (bsnl ' '.(crpt 'cctki0_[C]min_').','), (bsnl ' '.(crpt 'cctki0_[C]max_').','), (bsnl ' '.(crpt 'cctki0_[C]ash_').','), (bsnl ' imin,imax, cctki0_istr_)'), (bsnl ' do {'), (bsnl ' typedef int cctki0_loop[DIM]_normal_##name;'), (rpt (bsnl ' int const cctki0_[C]dir = (cctki0_[C]dir_);')), (rpt (bsnl ' int const cctki0_[C]min = (cctki0_[C]min_);')), (rpt (bsnl ' int const cctki0_[C]max = (cctki0_[C]max_);')), (rpt (bsnl ' int const cctki0_[C]ash CCTK_ATTRIBUTE_UNUSED = (cctki0_[C]ash_);')), (bsnl ' int const cctki0_istr = (cctki0_istr_);'), # Export loop bounds in the i direction (bsnl ' int const imin CCTK_ATTRIBUTE_UNUSED = cctki0_imin;'), (bsnl ' int const imax CCTK_ATTRIBUTE_UNUSED = cctki0_imax;'), (bsnl ' [DIM==1?:CCTK_PRAGMA_OMP_FOR_COLLAPSE_[DIM-1]]'), (reverse (rpt (bsnl ' [I==1?:for (int [C]=cctki0_[C]min; [C]cctk_dim != [DIM]) {'), (bsnl ' _Pragma("omp critical")'), (bsnl ' CCTK_WARN(CCTK_WARN_ABORT,'), (bsnl ' "The macro CCTK_LOOP[DIM]_INTERIOR can only be used in [DIM] dimensions");'), (bsnl ' }'), (bsnl ' CCTK_LOOP[DIM]STR(name##_interior,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt '(cctki2_[C]blo_)').','), (rpt (bsnl ' cctki2_cctkGH->cctk_lsh[[I]]-(cctki2_[C]bhi_),')), (rpt (bsnl ' cctki2_cctkGH->cctk_ash[[I]],')), (bsnl ' imin,imax, (cctki2_istr_)) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INTERIOR(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR(name##_interior);'), (bsnl ' typedef cctki2_loop[DIM]_interior_##name cctki2_ensure_proper_nesting CCTK_ATTRIBUTE_UNUSED;'), (bsnl ' } while(0)'), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_BOUNDARIES */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_BOUNDARIES(name, cctki2_cctkGH_,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo_').','), (bsnl ' '.(crpt 'cctki2_[C]bhi_').','), (bsnl ' '.(crpt 'cctki2_[C]bboxlo_').','), (bsnl ' '.(crpt 'cctki2_[C]bboxhi_').')'), (bsnl ' CCTK_LOOP[DIM]STR_BOUNDARIES(name, (cctki2_cctkGH_),'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt '(cctki2_[C]blo_)').','), (bsnl ' '.(crpt '(cctki2_[C]bhi_)').','), (bsnl ' '.(crpt '(cctki2_[C]bboxlo_)').','), (bsnl ' '.(crpt '(cctki2_[C]bboxhi_)').','), (bsnl ' cctki2_dummy_imin,cctki2_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_BOUNDARIES(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_BOUNDARIES(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_BOUNDARIES(name, cctki2_cctkGH_,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo_').','), (bsnl ' '.(crpt 'cctki2_[C]bhi_').','), (bsnl ' '.(crpt 'cctki2_[C]bboxlo_').','), (bsnl ' '.(crpt 'cctki2_[C]bboxhi_').','), (bsnl ' imin,imax, cctki2_istr_)'), (bsnl ' do {'), (bsnl ' typedef int cctki2_loop[DIM]_boundaries_##name;'), (bsnl ' cGH const *restrict const cctki2_cctkGH = (cctki2_cctkGH_);'), (bsnl ' if (cctki2_cctkGH->cctk_dim != [DIM]) {'), (bsnl ' _Pragma("omp critical")'), (bsnl ' CCTK_WARN(CCTK_WARN_ABORT,'), (bsnl ' "The macro CCTK_LOOP[DIM]_BOUNDARIES can only be used in [DIM] dimensions");'), (bsnl ' }'), (bsnl ' int const cctki2_blo[] = { '.(crpt '(cctki2_[C]blo_)').' };'), (bsnl ' int const cctki2_bhi[] = { '.(crpt '(cctki2_[C]bhi_)').' };'), (bsnl ' int const cctki2_bbox[] = { '.(crpt '(cctki2_[C]bboxlo_), (cctki2_[C]bboxhi_)').' };'), (bsnl ' int const cctki2_lsh[] = { '.(crpt 'cctki2_cctkGH->cctk_lsh[[I]]').' };'), (bsnl ' int const cctki2_istr CCTK_ATTRIBUTE_UNUSED = (cctki2_istr_);'), # Loop over all faces, edges, and corners (reverse (rpt (bsnl ' for (int cctki2_[C]dir=-1; cctki2_[C]dir<=+1; ++cctki2_[C]dir) {'))), (bsnl ' int cctki2_any_bbox ='), (bsnlsep [rpt ' (cctki2_[C]dir<0 ? cctki2_bbox[[2*I]] : 0) || (cctki2_[C]dir>0 ? cctki2_bbox[[2*I+1]] : 0)'], '||', ';'), (bsnl ' if (cctki2_any_bbox) {'), (bsnl ' int const cctki2_bmin[] = {'), (rpt (bsnl ' cctki2_[C]dir<0 ? 0 : cctki2_[C]dir==0 ? cctki2_blo[[I]] : cctki2_lsh[[I]] - cctki2_bhi[[I]],')), (bsnl ' };'), (bsnl ' int const cctki2_bmax[] = {'), (rpt (bsnl ' cctki2_[C]dir<0 ? cctki2_blo[[I]] : cctki2_[C]dir==0 ? cctki2_lsh[[I]] - cctki2_bhi[[I]] : cctki2_lsh[[I]],')), (bsnl ' };'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL(name##_boundaries,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki2_[C]dir').','), (bsnl ' '.(crpt 'cctki2_bmin[[I]]').','), (bsnl ' '.(crpt 'cctki2_bmax[[I]]').','), (rpt (bsnl ' cctki2_cctkGH->cctk_ash[[I]],')), (bsnl ' imin,imax, cctki2_istr) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_BOUNDARIES(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR_NORMAL(name##_boundaries);'), (bsnl ' } /* if bbox */'), (reverse (rpt (bsnl ' } /* for dir */'))), (bsnl ' typedef cctki2_loop[DIM]_boundaries_##name cctki2_ensure_proper_nesting CCTK_ATTRIBUTE_UNUSED;'), (bsnl ' } while (0)'), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_INTBOUNDARIES */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTBOUNDARIES(name, cctki2_cctkGH_,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo_').','), (bsnl ' '.(crpt 'cctki2_[C]bhi_').','), (bsnl ' '.(crpt 'cctki2_[C]bboxlo_').','), (bsnl ' '.(crpt 'cctki2_[C]bboxhi_').')'), (bsnl ' CCTK_LOOP[DIM]STR_INTBOUNDARIES(name, (cctki2_cctkGH_),'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt '(cctki2_[C]blo_)').','), (bsnl ' '.(crpt '(cctki2_[C]bhi_)').','), (bsnl ' '.(crpt '(cctki2_[C]bboxlo_)').','), (bsnl ' '.(crpt '(cctki2_[C]bboxhi_)').','), (bsnl ' cctki2_dummy_imin,cctki2_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INTBOUNDARIES(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTBOUNDARIES(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INTBOUNDARIES(name, cctki2_cctkGH_,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo_').','), (bsnl ' '.(crpt 'cctki2_[C]bhi_').','), (bsnl ' '.(crpt 'cctki2_[C]bboxlo_').','), (bsnl ' '.(crpt 'cctki2_[C]bboxhi_').','), (bsnl ' imin,imax, cctki2_istr_)'), (bsnl ' do {'), (bsnl ' typedef int cctki2_loop[DIM]_intboundaries_##name;'), (bsnl ' cGH const *restrict const cctki2_cctkGH = (cctki2_cctkGH_);'), (bsnl ' if (cctki2_cctkGH->cctk_dim != [DIM]) {'), (bsnl ' _Pragma("omp critical")'), (bsnl ' CCTK_WARN(CCTK_WARN_ABORT,'), (bsnl ' "The macro CCTK_LOOP[DIM]_INTBOUNDARIES can only be used in [DIM] dimensions");'), (bsnl ' }'), (bsnl ' int const cctki2_blo[] = { '.(crpt '(cctki2_[C]blo_)').' };'), (bsnl ' int const cctki2_bhi[] = { '.(crpt '(cctki2_[C]bhi_)').' };'), (bsnl ' int const cctki2_bbox[] = { '.(crpt '(cctki2_[C]bboxlo_), (cctki2_[C]bboxhi_)').' };'), (bsnl ' int const cctki2_lsh[] = { '.(crpt 'cctki2_cctkGH->cctk_lsh[[I]]').' };'), (bsnl ' int const cctki2_istr CCTK_ATTRIBUTE_UNUSED = (cctki2_istr_);'), # Loop over all faces, edges, and corners (reverse (rpt (bsnl ' for (int cctki2_[C]dir=-1; cctki2_[C]dir<=+1; ++cctki2_[C]dir) {'))), (bsnl ' int cctki2_any_bbox ='), (bsnlsep [rpt ' (cctki2_[C]dir<0 ? cctki2_bbox[[2*I]] : 0) || (cctki2_[C]dir>0 ? cctki2_bbox[[2*I+1]] : 0)'], '||', ';'), (bsnl ' int cctki2_all_bbox ='), (bsnlsep [rpt ' (cctki2_[C]dir<0 ? cctki2_bbox[[2*I]] : 1) && (cctki2_[C]dir>0 ? cctki2_bbox[[2*I+1]] : 1)'], '&&', ';'), (bsnl ' if (cctki2_all_bbox && cctki2_any_bbox) {'), (bsnl ' int const cctki2_bmin[] = {'), (rpt (bsnl ' cctki2_[C]dir<0 ? 0 : cctki2_[C]dir==0 ? cctki2_blo[[I]] : cctki2_lsh[[I]] - cctki2_bhi[[I]],')), (bsnl ' };'), (bsnl ' int const cctki2_bmax[] = {'), (rpt (bsnl ' cctki2_[C]dir<0 ? cctki2_blo[[I]] : cctki2_[C]dir==0 ? cctki2_lsh[[I]] - cctki2_bhi[[I]] : cctki2_lsh[[I]],')), (bsnl ' };'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL(name##_intboundaries,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki2_[C]dir').','), (bsnl ' '.(crpt 'cctki2_bmin[[I]]').','), (bsnl ' '.(crpt 'cctki2_bmax[[I]]').','), (rpt (bsnl ' cctki2_cctkGH->cctk_ash[[I]],')), (bsnl ' imin,imax, cctki2_istr) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INTBOUNDARIES(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR_NORMAL(name##_intboundaries);'), (bsnl ' } /* if bbox */'), (reverse (rpt (bsnl ' } /* for dir */'))), (bsnl ' typedef cctki2_loop[DIM]_intboundaries_##name cctki2_ensure_proper_nesting CCTK_ATTRIBUTE_UNUSED;'), (bsnl ' } while (0)'), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_ALL */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_ALL(name, cctki3_cctkGH_,'), (bsnl ' '.(crpt '[C]').')'), (bsnl ' CCTK_LOOP[DIM]STR_ALL(name, (cctki3_cctkGH_),'), (bsnl ' '.(crpt '[C]').','), (bsnl ' cctki3_dummy_imin,cctki3_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_ALL(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_ALL(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_ALL(name, cctki3_cctkGH_,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' imin,imax, cctki3_istr_)'), (bsnl ' do {'), (bsnl ' typedef int cctki3_loop[DIM]_all_##name;'), (bsnl ' cGH const *restrict const cctki3_cctkGH = (cctki3_cctkGH_);'), (bsnl ' if (cctki3_cctkGH->cctk_dim != [DIM]) {'), (bsnl ' _Pragma("omp critical")'), (bsnl ' CCTK_WARN(CCTK_WARN_ABORT,'), (bsnl ' "The macro CCTK_LOOP[DIM]_ALL can only be used in [DIM] dimensions");'), (bsnl ' }'), (bsnl ' CCTK_LOOP[DIM]STR(name##_all,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt '0').','), (rpt (bsnl ' cctki3_cctkGH->cctk_lsh[[I]],')), (rpt (bsnl ' cctki3_cctkGH->cctk_ash[[I]],')), (bsnl ' imin,imax, (cctki3_istr_)) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_ALL(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR(name##_all);'), (bsnl ' typedef cctki3_loop[DIM]_all_##name cctki3_ensure_proper_nesting CCTK_ATTRIBUTE_UNUSED;'), (bsnl ' } while (0)'), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_INT */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INT(name, cctki3_cctkGH_,'), (bsnl ' '.(crpt '[C]').')'), (bsnl ' CCTK_LOOP[DIM]STR_INT(name, (cctki3_cctkGH_),'), (bsnl ' '.(crpt '[C]').','), (bsnl ' cctki3_dummy_imin,cctki3_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INT(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INT(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INT(name, cctki3_cctkGH_,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' imin,imax, cctki3_istr_)'), (bsnl ' do {'), (bsnl ' typedef int cctki3_loop[DIM]_int_##name;'), (bsnl ' cGH const *restrict const cctki3_cctkGH = (cctki3_cctkGH_);'), (bsnl ' if (cctki3_cctkGH->cctk_dim != [DIM]) {'), (bsnl ' _Pragma("omp critical")'), (bsnl ' CCTK_WARN(CCTK_WARN_ABORT,'), (bsnl ' "The macro CCTK_LOOP[DIM]_INT can only be used in [DIM] dimensions");'), (bsnl ' }'), (bsnl ' CCTK_INT cctki3_bndsize [[2*DIM]];'), (bsnl ' CCTK_INT cctki3_is_ghostbnd[[2*DIM]];'), (bsnl ' CCTK_INT cctki3_is_symbnd [[2*DIM]];'), (bsnl ' CCTK_INT cctki3_is_physbnd [[2*DIM]];'), (bsnl ' _Pragma("omp single copyprivate(cctki3_bndsize)")'), (bsnl ' GetBoundarySizesAndTypes'), (bsnl ' (cctki3_cctkGH, [2*DIM], cctki3_bndsize, cctki3_is_ghostbnd, cctki3_is_symbnd, cctki3_is_physbnd);'), (bsnl ' CCTK_LOOP[DIM]STR_INTERIOR(name##_int,'), (bsnl ' cctki3_cctkGH,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'cctki3_bndsize[[2*I]]').','), (bsnl ' '.(crpt 'cctki3_bndsize[[2*I+1]]').','), (bsnl ' imin,imax, (cctki3_istr_)) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INT(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR_INTERIOR(name##_int);'), (bsnl ' typedef cctki3_loop[DIM]_int_##name cctki3_ensure_proper_nesting CCTK_ATTRIBUTE_UNUSED;'), (bsnl ' } while (0)'), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_BND */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_BND(name, cctki3_cctkGH_,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').')'), (bsnl ' CCTK_LOOP[DIM]STR_BND(name, (cctki3_cctkGH_),'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' cctki3_dummy_imin,cctki3_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_BND(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_BND(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_BND(name, cctki3_cctkGH_,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' imin,imax, cctki3_istr_)'), (bsnl ' do {'), (bsnl ' typedef int cctki3_loop[DIM]_bnd_##name;'), (bsnl ' cGH const *restrict const cctki3_cctkGH = (cctki3_cctkGH_);'), (bsnl ' if (cctki3_cctkGH->cctk_dim != [DIM]) {'), (bsnl ' _Pragma("omp critical")'), (bsnl ' CCTK_WARN(CCTK_WARN_ABORT,'), (bsnl ' "The macro CCTK_LOOP[DIM]_BND can only be used in [DIM] dimensions");'), (bsnl ' }'), (bsnl ' CCTK_INT cctki3_bndsize [[2*DIM]];'), (bsnl ' CCTK_INT cctki3_is_ghostbnd[[2*DIM]];'), (bsnl ' CCTK_INT cctki3_is_symbnd [[2*DIM]];'), (bsnl ' CCTK_INT cctki3_is_physbnd [[2*DIM]];'), (bsnl ' _Pragma("omp single copyprivate(cctki3_bndsize, cctki3_is_physbnd)")'), (bsnl ' GetBoundarySizesAndTypes'), (bsnl ' (cctki3_cctkGH, [2*DIM], cctki3_bndsize, cctki3_is_ghostbnd, cctki3_is_symbnd, cctki3_is_physbnd);'), (bsnl ' CCTK_LOOP[DIM]STR_BOUNDARIES(name##_bnd,'), (bsnl ' cctki3_cctkGH,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki3_bndsize[[2*I]]').','), (bsnl ' '.(crpt 'cctki3_bndsize[[2*I+1]]').','), (bsnl ' '.(crpt 'cctki3_is_physbnd[[2*I]]').','), (bsnl ' '.(crpt 'cctki3_is_physbnd[[2*I+1]]').','), (bsnl ' imin,imax, (cctki3_istr_)) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_BND(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR_BOUNDARIES(name##_bnd);'), (bsnl ' typedef cctki3_loop[DIM]_bnd_##name cctki3_ensure_proper_nesting CCTK_ATTRIBUTE_UNUSED;'), (bsnl ' } while (0)'), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_INTBND */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTBND(name, cctki3_cctkGH_,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').')'), (bsnl ' CCTK_LOOP[DIM]STR_INTBND(name, (cctki3_cctkGH_),'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' cctki3_dummy_imin,cctki3_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INTBND(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTBND(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INTBND(name, cctki3_cctkGH_,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' imin,imax, cctki3_istr_)'), (bsnl ' do {'), (bsnl ' typedef int cctki3_loop[DIM]_intbnd_##name;'), (bsnl ' cGH const *restrict const cctki3_cctkGH = (cctki3_cctkGH_);'), (bsnl ' if (cctki3_cctkGH->cctk_dim != [DIM]) {'), (bsnl ' _Pragma("omp critical")'), (bsnl ' CCTK_WARN(CCTK_WARN_ABORT,'), (bsnl ' "The macro CCTK_LOOP[DIM]_INTBND can only be used in [DIM] dimensions");'), (bsnl ' }'), (bsnl ' CCTK_INT cctki3_bndsize [[2*DIM]];'), (bsnl ' CCTK_INT cctki3_is_ghostbnd[[2*DIM]];'), (bsnl ' CCTK_INT cctki3_is_symbnd [[2*DIM]];'), (bsnl ' CCTK_INT cctki3_is_physbnd [[2*DIM]];'), (bsnl ' _Pragma("omp single copyprivate(cctki3_bndsize, cctki3_is_physbnd)")'), (bsnl ' GetBoundarySizesAndTypes'), (bsnl ' (cctki3_cctkGH, [2*DIM], cctki3_bndsize, cctki3_is_ghostbnd, cctki3_is_symbnd, cctki3_is_physbnd);'), (bsnl ' CCTK_LOOP[DIM]STR_INTBOUNDARIES(name##_intbnd,'), (bsnl ' cctki3_cctkGH,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki3_bndsize[[2*I]]').','), (bsnl ' '.(crpt 'cctki3_bndsize[[2*I+1]]').','), (bsnl ' '.(crpt 'cctki3_is_physbnd[[2*I]]').','), (bsnl ' '.(crpt 'cctki3_is_physbnd[[2*I+1]]').','), (bsnl ' imin,imax, (cctki3_istr_)) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INTBND(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR_INTBOUNDARIES(name##_intbnd);'), (bsnl ' typedef cctki3_loop[DIM]_intbnd_##name cctki3_ensure_proper_nesting CCTK_ATTRIBUTE_UNUSED;'), (bsnl ' } while (0)'), (nl ''), (nl '#endif /* #ifdef CCODE */'), (nl ''), (nl ''), (nl ''), (nl '#ifdef FCODE'), (nl ''), (nl '/* LOOP */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_NORMAL_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL_DECLARE(name)'), (bsnl ' && integer :: name/**/0_dummy_imin, name/**/0_dummy_imax'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_NORMAL_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL_OMP_PRIVATE(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_NORMAL(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki0_[C]dir').','), (bsnl ' '.(crpt 'cctki0_[C]min').','), (bsnl ' '.(crpt 'cctki0_[C]max').','), (bsnl ' '.(crpt 'cctki0_[C]ash').')'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki0_[C]dir').','), (bsnl ' '.(crpt 'cctki0_[C]min').','), (bsnl ' '.(crpt 'cctki0_[C]max').','), (bsnl ' '.(crpt 'cctki0_[C]ash').','), (bsnl ' name/**/0_dummy_imin,name/**/0_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_NORMAL(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_NORMAL(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_NORMAL_DECLARE(name)'), (bsnl ' && integer :: '.(crpt 'name/**/0_[C]dir')), (bsnl ' && integer :: '.(crpt 'name/**/0_[C]min')), (bsnl ' && integer :: '.(crpt 'name/**/0_[C]max')), (bsnl ' && integer :: '.(crpt 'name/**/0_[C]ash')), (bsnl ' && integer :: name/**/0_istr'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_NORMAL_OMP_PRIVATE(name)'), (bsnl ' && !$omp private ('.(crpt '[C]').')'), (bsnl ' && !$omp private ('.(crpt 'n[C]').')'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_NORMAL(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki0_[C]dir').','), (bsnl ' '.(crpt 'cctki0_[C]min').','), (bsnl ' '.(crpt 'cctki0_[C]max').','), (bsnl ' '.(crpt 'cctki0_[C]ash').','), (bsnl ' imin,imax, cctki0_istr)'), (rpt (bsnl ' && name/**/0_[C]dir = cctki0_[C]dir')), (rpt (bsnl ' && name/**/0_[C]min = cctki0_[C]min')), (rpt (bsnl ' && name/**/0_[C]max = cctki0_[C]max')), (rpt (bsnl ' && name/**/0_[C]ash = cctki0_[C]ash')), (bsnl ' && name/**/0_istr = cctki0_istr'), # Export loop bounds in the i direction (bsnl ' && imin = name/**/0_imin'), (bsnl ' && imax = name/**/0_imax'), (bsnl ' && !$omp do[DIM==1?: collapse([DIM-1])]'), (reverse (rpt (bsnl (' && do [C] = name/**/0_[C]min' . # Align i-loop to vector size '[I==1? - modulo(' . (sep '', rpt '[I==1?(imin:+name/**/0_[C-1]ash*([C]]') . (sep '', rpt ')') . ', name/**/0_istr):]' . ', name/**/0_[C]max' . '[I==1?, name/**/0_istr:]')))), (rpt (bsnl ' && n[C] = 0')), (rpt (bsnl ' && if (name/**/0_[C]dir < 0) n[C] = [C]')), (rpt (bsnl ' && if (name/**/0_[C]dir > 0) n[C] = name/**/0_[C]max+1-[C]')), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_NORMAL(name)'), (rpt (bsnl ' && end do')), (nl ''), (nl ''), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_DECLARE(name)'), (bsnl ' && integer :: name/**/1_dummy_imin, name/**/1_dummy_imax'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_OMP_PRIVATE(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM](name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'cctki0_[C]min').','), (bsnl ' '.(crpt 'cctki0_[C]max').','), (bsnl ' '.(crpt 'cctki0_[C]ash').')'), (bsnl ' CCTK_LOOP[DIM]STR(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'cctki0_[C]min').','), (bsnl ' '.(crpt 'cctki0_[C]max').','), (bsnl ' '.(crpt 'cctki0_[C]ash').','), (bsnl ' name/**/1_dummy_imin,name/**/1_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM](name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL_DECLARE(name)'), (bsnl ' && integer :: '.(crpt 'name/**/1_n[C]')), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL_OMP_PRIVATE(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'cctki1_[C]min').','), (bsnl ' '.(crpt 'cctki1_[C]max').','), (bsnl ' '.(crpt 'cctki1_[C]ash').','), (bsnl ' imin,imax, cctki1_istr)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'name/**/1_n[C]').','), (bsnl ' '.(crpt '0').','), (bsnl ' '.(crpt 'cctki1_[C]min').','), (bsnl ' '.(crpt 'cctki1_[C]max').','), (bsnl ' '.(crpt 'cctki1_[C]ash').','), (bsnl ' imin,imax, cctki1_istr)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_NORMAL(name)'), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_INTERIOR */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTERIOR_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTERIOR_DECLARE(name)'), (bsnl ' && integer :: name/**/2_dummy_imin, name/**/2_dummy_imax'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTERIOR_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTERIOR_OMP_PRIVATE(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTERIOR(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo').','), (bsnl ' '.(crpt 'cctki2_[C]bhi').')'), (bsnl ' CCTK_LOOP[DIM]STR_INTERIOR(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo').','), (bsnl ' '.(crpt 'cctki2_[C]bhi').','), (bsnl ' name/**/2_dummy_imin,name/**/2_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INTERIOR(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTERIOR(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INTERIOR_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_DECLARE(name/**/_interior)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INTERIOR_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_OMP_PRIVATE(name/**/_interior)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INTERIOR(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo').','), (bsnl ' '.(crpt 'cctki2_[C]bhi').','), (bsnl ' imin,imax, cctki2_istr)'), (bsnl ' CCTK_LOOP[DIM]STR(name/**/_interior,'), (bsnl ' '.(crpt '[C]').','), (rpt (bsnl ' (cctki2_[C]blo)+1,')), (rpt (bsnl ' cctk_lsh([I+1])-(cctki2_[C]bhi),')), (bsnl ' '.(crpt 'cctk_ash([I+1])').','), (bsnl ' imin,imax, cctki2_istr)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INTERIOR(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR(name/**/_interior)'), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_BOUNDARIES */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_BOUNDARIES_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_BOUNDARIES_DECLARE(name)'), (bsnl ' && integer :: name/**/2_dummy_imin, name/**/2_dummy_imax'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_BOUNDARIES_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_BOUNDARIES_OMP_PRIVATE(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_BOUNDARIES(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo').','), (bsnl ' '.(crpt 'cctki2_[C]bhi').','), (bsnl ' '.(crpt 'cctki2_[C]bboxlo').','), (bsnl ' '.(crpt 'cctki2_[C]bboxhi').')'), (bsnl ' CCTK_LOOP[DIM]STR_BOUNDARIES(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo').','), (bsnl ' '.(crpt 'cctki2_[C]bhi').','), (bsnl ' '.(crpt 'cctki2_[C]bboxlo').','), (bsnl ' '.(crpt 'cctki2_[C]bboxhi').','), (bsnl ' name/**/2_dummy_imin,name/**/2_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_BOUNDARIES(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_BOUNDARIES(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_BOUNDARIES_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL_DECLARE(name/**/_boundaries)'), (bsnl ' && integer :: name/**/2_blo([DIM]), name/**/2_bhi([DIM])'), (bsnl ' && integer :: name/**/2_bboxlo([DIM]), name/**/2_bboxhi([DIM])'), (bsnl ' && integer :: name/**/2_istr'), (rpt (bsnl ' && integer :: name/**/2_[C]dir')), (bsnl ' && logical :: name/**/2_any_bbox'), (bsnl ' && integer :: name/**/2_bmin([DIM]), name/**/2_bmax([DIM])'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_BOUNDARIES_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL_OMP_PRIVATE(name/**/_boundaries)'), (bsnl ' && !$omp private (name/**/2_bmin, name/**/2_bmax)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_BOUNDARIES(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo').','), (bsnl ' '.(crpt 'cctki2_[C]bhi').','), (bsnl ' '.(crpt 'cctki2_[C]bboxlo').','), (bsnl ' '.(crpt 'cctki2_[C]bboxhi').','), (bsnl ' imin,imax, cctki2_istr)'), (bsnl ' && name/**/2_blo = (/ '.(crpt 'cctki2_[C]blo').' /)'), (bsnl ' && name/**/2_bhi = (/ '.(crpt 'cctki2_[C]bhi').' /)'), (bsnl ' && name/**/2_bboxlo = (/ '.(crpt 'cctki2_[C]bboxlo').' /)'), (bsnl ' && name/**/2_bboxhi = (/ '.(crpt 'cctki2_[C]bboxhi').' /)'), (bsnl ' && name/**/2_istr = (cctki2_istr)'), # Loop over all faces, edges, and corners (reverse (rpt (bsnl ' && do name/**/2_[C]dir=-1, +1'))), (bsnl ' && name/**/2_any_bbox = .false.'), (rpt (bsnl ' && if (name/**/2_[C]dir<0) name/**/2_any_bbox = name/**/2_any_bbox .or. name/**/2_bboxlo([I+1]) /= 0')), (rpt (bsnl ' && if (name/**/2_[C]dir>0) name/**/2_any_bbox = name/**/2_any_bbox .or. name/**/2_bboxhi([I+1]) /= 0')), (bsnl ' && if (name/**/2_any_bbox) then'), (rpt (bsnl ' && name/**/2_bmin([I+1]) = name/**/2_blo([I+1])+1')), (rpt (bsnl ' && if (name/**/2_[C]dir<0) name/**/2_bmin([I+1]) = 1')), (rpt (bsnl ' && if (name/**/2_[C]dir>0) name/**/2_bmin([I+1]) = cctk_lsh([I+1]) - name/**/2_bhi([I+1])')), (rpt (bsnl ' && name/**/2_bmax([I+1]) = cctk_lsh([I+1]) - name/**/2_bhi([I+1])')), (rpt (bsnl ' && if (name/**/2_[C]dir<0) name/**/2_bmax([I+1]) = name/**/2_blo([I+1])')), (rpt (bsnl ' && if (name/**/2_[C]dir>0) name/**/2_bmax([I+1]) = cctk_lsh([I+1])')), (bsnl ' && CCTK_LOOP[DIM]STR_NORMAL(name/**/_boundaries,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'name/**/2_[C]dir').','), (bsnl ' '.(crpt 'name/**/2_bmin([I+1])').','), (bsnl ' '.(crpt 'name/**/2_bmax([I+1])').','), (rpt (bsnl ' cctk_ash([I+1]),')), (bsnl ' imin,imax, name/**/2_istr)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_BOUNDARIES(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_NORMAL(name/**/_boundaries)'), (bsnl ' && end if /* bbox */'), (rpt (bsnl ' && end do /* dir */')), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_INTBOUNDARIES */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTBOUNDARIES_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTBOUNDARIES_DECLARE(name)'), (bsnl ' && integer :: name/**/2_dummy_imin, name/**/2_dummy_imax'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTBOUNDARIES_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTBOUNDARIES_OMP_PRIVATE(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTBOUNDARIES(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo').','), (bsnl ' '.(crpt 'cctki2_[C]bhi').','), (bsnl ' '.(crpt 'cctki2_[C]bboxlo').','), (bsnl ' '.(crpt 'cctki2_[C]bboxhi').')'), (bsnl ' CCTK_LOOP[DIM]STR_INTBOUNDARIES(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo').','), (bsnl ' '.(crpt 'cctki2_[C]bhi').','), (bsnl ' '.(crpt 'cctki2_[C]bboxlo').','), (bsnl ' '.(crpt 'cctki2_[C]bboxhi').','), (bsnl ' name/**/2_dummy_imin,name/**/2_dummy_max, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INTBOUNDARIES(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTBOUNDARIES(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INTBOUNDARIES_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL_DECLARE(name/**/_intboundaries)'), (bsnl ' && integer :: name/**/2_blo([DIM]), name/**/2_bhi([DIM])'), (bsnl ' && integer :: name/**/2_bboxlo([DIM]), name/**/2_bboxhi([DIM])'), (bsnl ' && integer :: name/**/2_istr'), (rpt (bsnl ' && integer :: name/**/2_[C]dir')), (bsnl ' && logical :: name/**/2_any_bbox, name/**/2_all_bbox'), (bsnl ' && integer :: name/**/2_bmin([DIM]), name/**/2_bmax([DIM])'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INTBOUNDARIES_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL_OMP_PRIVATE(name/**/_intboundaries)'), (bsnl ' && !$omp private (name/**/2_any_bbox, name/**/2_all_bbox)'), (bsnl ' && !$omp private (name/**/2_bmin, name/**/2_bmax'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INTBOUNDARIES(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'cctki2_[C]blo').','), (bsnl ' '.(crpt 'cctki2_[C]bhi').','), (bsnl ' '.(crpt 'cctki2_[C]bboxlo').','), (bsnl ' '.(crpt 'cctki2_[C]bboxhi').','), (bsnl ' imin,imax, cctki2_istr)'), (bsnl ' && name/**/2_blo = (/ '.(crpt 'cctki2_[C]blo').' /)'), (bsnl ' && name/**/2_bhi = (/ '.(crpt 'cctki2_[C]bhi').' /)'), (bsnl ' && name/**/2_bboxlo = (/ '.(crpt 'cctki2_[C]bboxlo').' /)'), (bsnl ' && name/**/2_bboxhi = (/ '.(crpt 'cctki2_[C]bboxhi').' /)'), (bsnl ' && name/**/2_istr = (cctki2_istr)'), # Loop over all faces, edges, and corners (reverse (rpt (bsnl ' && do name/**/2_[C]dir=-1, +1'))), (bsnl ' && name/**/2_any_bbox = .false.'), (rpt (bsnl ' && if (name/**/2_[C]dir<0) name/**/2_any_bbox = name/**/2_any_bbox .or. name/**/2_bboxlo([I+1]) /= 0')), (rpt (bsnl ' && if (name/**/2_[C]dir>0) name/**/2_any_bbox = name/**/2_any_bbox .or. name/**/2_bboxhi([I+1]) /= 0')), (bsnl ' && name/**/2_all_bbox = .true.'), (rpt (bsnl ' && if (name/**/2_[C]dir<0) name/**/2_all_bbox = name/**/2_all_bbox .and. name/**/2_bboxlo([I+1]) /= 0')), (rpt (bsnl ' && if (name/**/2_[C]dir>0) name/**/2_all_bbox = name/**/2_all_bbox .and. name/**/2_bboxhi([I+1]) /= 0')), (bsnl ' && if (name/**/2_all_bbox .and. name/**/2_any_bbox) then'), (rpt (bsnl ' && name/**/2_bmin([I+1]) = name/**/2_blo([I+1])+1')), (rpt (bsnl ' && if (name/**/2_[C]dir<0) name/**/2_bmin([I+1]) = 1')), (rpt (bsnl ' && if (name/**/2_[C]dir>0) name/**/2_bmin([I+1]) = cctk_lsh([I+1]) - name/**/2_bhi([I+1])')), (rpt (bsnl ' && name/**/2_bmax([I+1]) = cctk_lsh([I+1]) - name/**/2_bhi([I+1])')), (rpt (bsnl ' && if (name/**/2_[C]dir<0) name/**/2_bmax([I+1]) = name/**/2_blo([I+1])')), (rpt (bsnl ' && if (name/**/2_[C]dir>0) name/**/2_bmax([I+1]) = cctk_lsh([I+1])')), (bsnl ' && CCTK_LOOP[DIM]STR_NORMAL(name/**/_intboundaries,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'name/**/2_[C]dir').','), (bsnl ' '.(crpt 'name/**/2_bmin([I+1])').','), (bsnl ' '.(crpt 'name/**/2_bmax([I+1])').','), (rpt (bsnl ' cctk_ash([I+1]),')), (bsnl ' imin,imax, name/**/2_istr)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INTBOUNDARIES(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_NORMAL(name/**/_intboundaries)'), (bsnl ' && end if /* bbox */'), (rpt (bsnl ' && end do /* dir */')), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_ALL */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_ALL_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_ALL_DECLARE(name)'), (bsnl ' && integer :: name/**/3_dummy_imin, name/**/3_dummy_imax'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_ALL_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_ALL_OMP_PRIVATE(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_ALL(name,'), (bsnl ' '.(crpt '[C]').')'), (bsnl ' CCTK_LOOP[DIM]STR_ALL(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' name/**/3_dummy_imin,name/**/3_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_ALL(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_ALL(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_ALL_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_DECLARE(name/**/_all)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_ALL_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_OMP_PRIVATE(name/**/_all)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_ALL(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' imin,imax, cctki3_istr)'), (bsnl ' CCTK_LOOP[DIM]STR(name/**/_all,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt '1').','), (bsnl ' '.(crpt 'cctk_lsh([I+1])').','), (bsnl ' '.(crpt 'cctk_ash([I+1])').','), (bsnl ' imin,imax, cctki3_istr)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_ALL(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR(name/**/_all)'), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_INT */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INT_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INT_DECLARE(name)'), (bsnl ' && integer :: name/**/3_dummy_imin, name/**/3_dummy_imax'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INT_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INT_OMP_PRIVATE(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INT(name,'), (bsnl ' '.(crpt '[C]').')'), (bsnl ' CCTK_LOOP[DIM]STR_INT(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' name/**/3_dummy_imin,name/**/3_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INT(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INT(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INT_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTERIOR_DECLARE(name/**/_int)'), (bsnl ' && integer :: name/**/3_bndsize ([2*DIM])'), (bsnl ' && integer :: name/**/3_is_ghostbnd([2*DIM])'), (bsnl ' && integer :: name/**/3_is_symbnd ([2*DIM])'), (bsnl ' && integer :: name/**/3_is_physbnd ([2*DIM])'), (bsnl ' && integer :: name/**/3_ierr'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INT_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTERIOR_OMP_PRIVATE(name/**/_int)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INT(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' imin,imax, cctki3_istr)'), (bsnl ' && !$omp single'), (bsnl ' && name/**/3_ierr = GetBoundarySizesAndTypes'), (bsnl ' (cctkGH, [2*DIM], name/**/3_bndsize, name/**/3_is_ghostbnd, name/**/3_is_symbnd, name/**/3_is_physbnd)'), (bsnl ' && !$omp end single copyprivate(name/**/3_bndsize)'), (bsnl ' && CCTK_LOOP[DIM]STR_INTERIOR(name/**/_int,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'name/**/3_bndsize([2*I+1]+1)').','), (bsnl ' '.(crpt 'name/**/3_bndsize([2*I+2])').','), (bsnl ' imin,imax, (cctki3_istr))'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INT(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTERIOR(name/**/_int)'), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_BND */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_BND_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_BND_DECLARE(name)'), (bsnl ' && integer :: name/**/3_dummy_imin, name/**/3_dummy_imax'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_BND_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_BND_OMP_PRIVATE(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_BND(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').')'), (bsnl ' CCTK_LOOP[DIM]STR_BND(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' name/**/3_dummy_imin,name/**/3_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_BND(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_BND(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_BND_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_BOUNDARIES_DECLARE(name/**/_bnd)'), (bsnl ' && integer :: name/**/3_bndsize ([2*DIM])'), (bsnl ' && integer :: name/**/3_is_ghostbnd([2*DIM])'), (bsnl ' && integer :: name/**/3_is_symbnd ([2*DIM])'), (bsnl ' && integer :: name/**/3_is_physbnd ([2*DIM])'), (bsnl ' && integer :: name/**/3_ierr'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_BND_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_BOUNDARIES_OMP_PRIVATE(name/**/_bnd)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_BND(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' imin,imax, cctki3_istr)'), (bsnl ' && !$omp single'), (bsnl ' && name/**/3_ierr = GetBoundarySizesAndTypes'), (bsnl ' (cctkGH, [2*DIM], name/**/3_bndsize, name/**/3_is_ghostbnd, name/**/3_is_symbnd, name/**/3_is_physbnd)'), (bsnl ' && !$omp end single copyprivate(name/**/3_bndsize, name/**/3_is_physbnd)'), (bsnl ' && CCTK_LOOP[DIM]STR_BOUNDARIES(name/**/_bnd,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'name/**/3_bndsize([2*I+1])+1').','), (bsnl ' '.(crpt 'name/**/3_bndsize([2*I+2])').','), (bsnl ' '.(crpt 'name/**/3_is_physbnd([2*I+1])').','), (bsnl ' '.(crpt 'name/**/3_is_physbnd([2*I+2])').','), (bsnl ' imin,imax, (cctki3_istr))'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_BND(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_BOUNDARIES(name/**/_bnd)'), (nl ''), (nl ''), (nl ''), (nl ''), (nl ''), (nl ''), (nl '/* LOOP_INTBND */'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTBND_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTBND_DECLARE(name)'), (bsnl ' && integer :: name/**/3_dummy_imin, name/**/3_dummy_imax'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTBND_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTBND_OMP_PRIVATE(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTBND(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').')'), (bsnl ' CCTK_LOOP[DIM]STR_INTBND(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' name/**/3_dummy_imin,name/**/3_dummy_imax, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INTBND(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTBND(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INTBND_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTBOUNDARIES_DECLARE(name/**/_bnd)'), (bsnl ' && integer :: name/**/3_bndsize ([2*DIM])'), (bsnl ' && integer :: name/**/3_is_ghostbnd([2*DIM])'), (bsnl ' && integer :: name/**/3_is_symbnd ([2*DIM])'), (bsnl ' && integer :: name/**/3_is_physbnd ([2*DIM])'), (bsnl ' && integer :: name/**/3_ierr'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INTBND_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTBOUNDARIES_OMP_PRIVATE(name/**/_bnd)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INTBND(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' imin,imax, cctki3_istr)'), (bsnl ' && !$omp single'), (bsnl ' && name/**/3_ierr = GetBoundarySizesAndTypes'), (bsnl ' (cctkGH, [2*DIM], name/**/3_bndsize, name/**/3_is_ghostbnd, name/**/3_is_symbnd, name/**/3_is_physbnd)'), (bsnl ' && !$omp end single copyprivate(name/**/3_bndsize, name/**/3_is_physbnd)'), (bsnl ' && CCTK_LOOP[DIM]STR_INTBOUNDARIES(name/**/_bnd,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt 'name/**/3_bndsize([2*I+1]+1)').','), (bsnl ' '.(crpt 'name/**/3_bndsize([2*I+2])').','), (bsnl ' '.(crpt 'name/**/3_is_physbnd([2*I+1])').','), (bsnl ' '.(crpt 'name/**/3_is_physbnd([2*I+2])').','), (bsnl ' imin,imax, (cctki3_istr))'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INTBND(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTBOUNDARIES(name/**/_bnd)'), (nl ''), (nl '#endif /* #ifdef FCODE */'), ); } # for dim # Output footer push @lines, ( (nl ''), (nl ''), (nl ''), (nl '#endif /* #ifndef _CCTK_LOOP_H_ */'), ); # Write file open FILE, '>', 'cctk_Loop.h' or die; print FILE @lines; close FILE; print "Regenerated \"cctk_Loop.h\".\n";