diff options
Diffstat (limited to 'src/include/cctk_Loop.h.pl')
-rwxr-xr-x | src/include/cctk_Loop.h.pl | 193 |
1 files changed, 115 insertions, 78 deletions
diff --git a/src/include/cctk_Loop.h.pl b/src/include/cctk_Loop.h.pl index 479b2fba..10ade053 100755 --- a/src/include/cctk_Loop.h.pl +++ b/src/include/cctk_Loop.h.pl @@ -78,9 +78,16 @@ our $dim; 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; } @@ -111,6 +118,7 @@ sub rpt ($) 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; @@ -118,6 +126,12 @@ sub rpt ($) $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; @@ -212,7 +226,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '([C]min)').','), (bsnl ' '.(crpt '([C]max)').','), (bsnl ' '.(crpt '([C]ash)').','), - (bsnl ' 1)'), + (bsnl ' cctki0_imin_,cctki0_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_NORMAL(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_NORMAL(name)'), @@ -221,19 +235,25 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt '[C]dir').','), - (bsnl ' '.(crpt '[C]min').','), - (bsnl ' '.(crpt '[C]max').','), + (bsnl ' '.(crpt '[C]min_').','), + (bsnl ' '.(crpt '[C]max_').','), (bsnl ' '.(crpt '[C]ash').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' do {'), (bsnl ' typedef int cctki0_loop[DIM]_normal_##name;'), (rpt (bsnl ' int const cctki0_[C]dir = ([C]dir);')), - (rpt (bsnl ' int const cctki0_[C]min = ([C]min);')), - (rpt (bsnl ' int const cctki0_[C]max = ([C]max);')), - (bsnl ' int const cctki0_istr CCTK_ATTRIBUTE_UNUSED = (istr);'), - (bsnl ' assert(cctki0_istr == 1);'), - (bsnl ' _Pragma("omp for")'), # collapse([DIM]) - (reverse (rpt (bsnl ' for (int [C]=cctki0_[C]min; [C]<cctki0_[C]max; ++[C]) {'))), + (rpt (bsnl ' int const cctki0_[C]min = ([C]min_);')), + (rpt (bsnl ' int const cctki0_[C]max = ([C]max_);')), + (rpt (bsnl ' int const cctki0_[C]ash = ([C]ash);')), + (bsnl ' int const cctki0_istr = (istr);'), + # Export loop bounds in the i direction + (bsnl ' int const imin = cctki0_imin;'), + (bsnl ' int const imax = cctki0_imax;'), + (bsnl ' _Pragma("omp for[DIM==1?: collapse([DIM-1])]")'), + (reverse (rpt (bsnl (' for (int [C]=cctki0_[C]min' . + # Align i-loop to vector size + '[I==1? - ' . (sep '', rpt '[I==1?(imin:+cctki0_[C-1]ash*([C]]') . (sep '', rpt ')') . ' % cctki0_istr:]' . + '; [C]<cctki0_[C]max; [I==1?[C]+=cctki0_[C]str:++[C]]) {')))), (rpt (bsnl ' int const n[C] CCTK_ATTRIBUTE_UNUSED = cctki0_[C]dir<0 ? [C]+1 : cctki0_[C]dir==0 ? 0 : cctki0_[C]max-[C];')), (bsnl ' {'), (nl ''), @@ -255,25 +275,25 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '([C]min)').','), (bsnl ' '.(crpt '([C]max)').','), (bsnl ' '.(crpt '([C]ash)').','), - (bsnl ' 1)'), + (bsnl ' cctki1_imin_,cctki1_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM](name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR(name)'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR(name,'), (bsnl ' '.(crpt '[C]').','), - (bsnl ' '.(crpt '[C]min').','), - (bsnl ' '.(crpt '[C]max').','), + (bsnl ' '.(crpt '[C]min_').','), + (bsnl ' '.(crpt '[C]max_').','), (bsnl ' '.(crpt '[C]ash').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'cctki1_n[C]').','), (bsnl ' '.(crpt '0').','), - (bsnl ' '.(crpt '[C]min').','), - (bsnl ' '.(crpt '[C]max').','), + (bsnl ' '.(crpt '[C]min_').','), + (bsnl ' '.(crpt '[C]max_').','), (bsnl ' '.(crpt '[C]ash').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_NORMAL(name)'), @@ -290,7 +310,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt '([C]blo)').','), (bsnl ' '.(crpt '([C]bhi)').','), - (bsnl ' 1)'), + (bsnl ' cctki2_imin_,cctki2_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INTERIOR(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTERIOR(name)'), @@ -299,7 +319,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt '[C]blo').','), (bsnl ' '.(crpt '[C]bhi').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' do {'), (bsnl ' typedef int cctki2_loop[DIM]_interior_##name;'), (bsnl ' cGH const *restrict const cctki2_cctkGH = (cctkGH);'), @@ -313,7 +333,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '([C]blo)').','), (rpt (bsnl ' cctki2_cctkGH->cctk_lsh[[I]]-([C]bhi),')), (rpt (bsnl ' cctki2_cctkGH->cctk_ash[[I]],')), - (bsnl ' (istr)) {'), + (bsnl ' imin,imax, (istr)) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INTERIOR(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR(name##_interior);'), @@ -338,7 +358,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '([C]bhi)').','), (bsnl ' '.(crpt '([C]bboxlo)').','), (bsnl ' '.(crpt '([C]bboxhi)').','), - (bsnl ' 1)'), + (bsnl ' cctki2_imin_,cctki2_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_BOUNDARIES(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_BOUNDARIES(name)'), @@ -350,7 +370,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]bhi').','), (bsnl ' '.(crpt '[C]bboxlo').','), (bsnl ' '.(crpt '[C]bboxhi').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' do {'), (bsnl ' typedef int cctki2_loop[DIM]_boundaries_##name;'), (bsnl ' cGH const *restrict const cctki2_cctkGH = (cctkGH);'), @@ -364,7 +384,7 @@ for $dim (1,2,3,4) { (bsnl ' int const cctki2_bbox[] = { '.(crpt '([C]bboxlo), ([C]bboxhi)').' };'), (bsnl ' int const cctki2_lsh[] = { '.(crpt 'cctki2_cctkGH->cctk_lsh[[I]]').' };'), (bsnl ' int const cctki2_istr CCTK_ATTRIBUTE_UNUSED = (istr);'), - (bsnl ' /* Loop over all faces, edges, and corners */'), + # 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==-1 ? cctki2_bbox[[2*I]] : 0) || (cctki2_[C]dir==+1 ? cctki2_bbox[[2*I+1]] : 0)'], '||', ';'), @@ -382,7 +402,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt 'cctki2_bmin[[I]]').','), (bsnl ' '.(crpt 'cctki2_bmax[[I]]').','), (rpt (bsnl ' cctki2_cctkGH->cctk_ash[[I]],')), - (bsnl ' cctki2_istr) {'), + (bsnl ' imin,imax, cctki2_istr) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_BOUNDARIES(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR_NORMAL(name##_boundaries);'), @@ -409,7 +429,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '([C]bhi)').','), (bsnl ' '.(crpt '([C]bboxlo)').','), (bsnl ' '.(crpt '([C]bboxhi)').','), - (bsnl ' 1)'), + (bsnl ' cctki2_imin_,cctki2_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INTBOUNDARIES(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTBOUNDARIES(name)'), @@ -421,7 +441,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]bhi').','), (bsnl ' '.(crpt '[C]bboxlo').','), (bsnl ' '.(crpt '[C]bboxhi').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' do {'), (bsnl ' typedef int cctki2_loop[DIM]_intboundaries_##name;'), (bsnl ' cGH const *restrict const cctki2_cctkGH = (cctkGH);'), @@ -435,7 +455,7 @@ for $dim (1,2,3,4) { (bsnl ' int const cctki2_bbox[] = { '.(crpt '([C]bboxlo), ([C]bboxhi)').' };'), (bsnl ' int const cctki2_lsh[] = { '.(crpt 'cctki2_cctkGH->cctk_lsh[[I]]').' };'), (bsnl ' int const cctki2_istr CCTK_ATTRIBUTE_UNUSED = (istr);'), - (bsnl ' /* Loop over all faces, edges, and corners */'), + # 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==-1 ? cctki2_bbox[[2*I]] : 0) || (cctki2_[C]dir==+1 ? cctki2_bbox[[2*I+1]] : 0)'], '||', ';'), @@ -455,7 +475,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt 'cctki2_bmin[[I]]').','), (bsnl ' '.(crpt 'cctki2_bmax[[I]]').','), (rpt (bsnl ' cctki2_cctkGH->cctk_ash[[I]],')), - (bsnl ' cctki2_istr) {'), + (bsnl ' imin,imax, cctki2_istr) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INTBOUNDARIES(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR_NORMAL(name##_intboundaries);'), @@ -472,14 +492,14 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]').')'), (bsnl ' CCTK_LOOP[DIM]STR_ALL(name, (cctkGH),'), (bsnl ' '.(crpt '[C]').','), - (bsnl ' 1)'), + (bsnl ' cctki3_imin_,cctki3_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, cctkGH,'), (bsnl ' '.(crpt '[C]').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' do {'), (bsnl ' typedef int cctki3_loop[DIM]_all_##name;'), (bsnl ' cGH const *restrict const cctki3_cctkGH = (cctkGH);'), @@ -493,7 +513,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '0').','), (rpt (bsnl ' cctki3_cctkGH->cctk_lsh[[I]],')), (rpt (bsnl ' cctki3_cctkGH->cctk_ash[[I]],')), - (bsnl ' (istr)) {'), + (bsnl ' imin,imax, (istr)) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_ALL(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR(name##_all);'), @@ -508,14 +528,14 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]').')'), (bsnl ' CCTK_LOOP[DIM]STR_INT(name, (cctkGH),'), (bsnl ' '.(crpt '[C]').','), - (bsnl ' 1)'), + (bsnl ' cctki3_imin_,cctki3_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, cctkGH,'), (bsnl ' '.(crpt '[C]').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' do {'), (bsnl ' typedef int cctki3_loop[DIM]_int_##name;'), (bsnl ' cGH const *restrict const cctki3_cctkGH = (cctkGH);'), @@ -536,7 +556,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'cctki3_bndsize[[2*I]]').','), (bsnl ' '.(crpt 'cctki3_bndsize[[2*I+1]]').','), - (bsnl ' (istr)) {'), + (bsnl ' imin,imax, (istr)) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INT(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR_INTERIOR(name##_int);'), @@ -553,7 +573,7 @@ for $dim (1,2,3,4) { (bsnl ' CCTK_LOOP[DIM]STR_BND(name, (cctkGH),'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), - (bsnl ' 1)'), + (bsnl ' cctki3_imin_,cctki3_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_BND(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_BND(name)'), @@ -561,7 +581,7 @@ for $dim (1,2,3,4) { (bsnl '#define CCTK_LOOP[DIM]STR_BND(name, cctkGH,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' do {'), (bsnl ' typedef int cctki3_loop[DIM]_bnd_##name;'), (bsnl ' cGH const *restrict const cctki3_cctkGH = (cctkGH);'), @@ -585,7 +605,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt 'cctki3_bndsize[[2*I+1]]').','), (bsnl ' '.(crpt 'cctki3_is_physbnd[[2*I]]').','), (bsnl ' '.(crpt 'cctki3_is_physbnd[[2*I+1]]').','), - (bsnl ' (istr)) {'), + (bsnl ' imin,imax, (istr)) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_BND(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR_BOUNDARIES(name##_bnd);'), @@ -602,7 +622,7 @@ for $dim (1,2,3,4) { (bsnl ' CCTK_LOOP[DIM]STR_INTBND(name, (cctkGH),'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), - (bsnl ' 1)'), + (bsnl ' cctki3_imin_,cctki3_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INTBND(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTBND(name)'), @@ -610,7 +630,7 @@ for $dim (1,2,3,4) { (bsnl '#define CCTK_LOOP[DIM]STR_INTBND(name, cctkGH,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' do {'), (bsnl ' typedef int cctki3_loop[DIM]_intbnd_##name;'), (bsnl ' cGH const *restrict const cctki3_cctkGH = (cctkGH);'), @@ -634,7 +654,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt 'cctki3_bndsize[[2*I+1]]').','), (bsnl ' '.(crpt 'cctki3_is_physbnd[[2*I]]').','), (bsnl ' '.(crpt 'cctki3_is_physbnd[[2*I+1]]').','), - (bsnl ' (istr)) {'), + (bsnl ' imin,imax, (istr)) {'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INTBND(name)'), (bsnl ' } CCTK_ENDLOOP[DIM]STR_INTBOUNDARIES(name##_intbnd);'), @@ -651,6 +671,7 @@ for $dim (1,2,3,4) { (nl ''), (bsnl '#define CCTK_LOOP[DIM]_NORMAL_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL_DECLARE(name)'), + (bsnl ' && integer :: name/**/0_imin_, name/**/0_imax_'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_NORMAL_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL_OMP_PRIVATE(name)'), @@ -669,7 +690,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]min').','), (bsnl ' '.(crpt '[C]max').','), (bsnl ' '.(crpt '[C]ash').','), - (bsnl ' 1)'), + (bsnl ' name/**/0_imin_,name/**/0_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_NORMAL(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_NORMAL(name)'), @@ -678,6 +699,7 @@ for $dim (1,2,3,4) { (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)'), @@ -688,16 +710,23 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), (bsnl ' '.(crpt '[C]dir').','), - (bsnl ' '.(crpt '[C]min').','), - (bsnl ' '.(crpt '[C]max').','), + (bsnl ' '.(crpt '[C]min_').','), + (bsnl ' '.(crpt '[C]max_').','), (bsnl ' '.(crpt '[C]ash').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (rpt (bsnl ' && name/**/0_[C]dir = [C]dir')), - (rpt (bsnl ' && name/**/0_[C]min = [C]min')), - (rpt (bsnl ' && name/**/0_[C]max = [C]max')), + (rpt (bsnl ' && name/**/0_[C]min = [C]min_')), + (rpt (bsnl ' && name/**/0_[C]max = [C]max_')), + (rpt (bsnl ' && name/**/0_[C]ash = [C]ash')), (bsnl ' && name/**/0_istr = istr'), - (bsnl ' && !$omp do'), # collapse([DIM]) - (reverse (rpt (bsnl ' && do [C] = name/**/0_[C]min, name/**/0_[C]max'))), + # 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')))), (rpt (bsnl ' && if (name/**/0_[C]dir< 0) n[C] = [C]')), (rpt (bsnl ' && if (name/**/0_[C]dir==0) n[C] = 0')), (rpt (bsnl ' && if (name/**/0_[C]dir> 0) n[C] = name/**/0_[C]max+1-[C]')), @@ -709,6 +738,7 @@ for $dim (1,2,3,4) { (nl ''), (bsnl '#define CCTK_LOOP[DIM]_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_DECLARE(name)'), + (bsnl ' && integer :: name/**/1_imin_, name/**/1_imax_'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_OMP_PRIVATE(name)'), @@ -723,7 +753,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]min').','), (bsnl ' '.(crpt '[C]max').','), (bsnl ' '.(crpt '[C]ash').','), - (bsnl ' 1)'), + (bsnl ' name/**/1_imin_,name/**/1_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM](name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR(name)'), @@ -737,18 +767,18 @@ for $dim (1,2,3,4) { (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR(name,'), (bsnl ' '.(crpt '[C]').','), - (bsnl ' '.(crpt '[C]min').','), - (bsnl ' '.(crpt '[C]max').','), + (bsnl ' '.(crpt '[C]min_').','), + (bsnl ' '.(crpt '[C]max_').','), (bsnl ' '.(crpt '[C]ash').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' CCTK_LOOP[DIM]STR_NORMAL(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'name/**/1_n[C]').','), (bsnl ' '.(crpt '0').','), - (bsnl ' '.(crpt '[C]min').','), - (bsnl ' '.(crpt '[C]max').','), + (bsnl ' '.(crpt '[C]min_').','), + (bsnl ' '.(crpt '[C]max_').','), (bsnl ' '.(crpt '[C]ash').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_NORMAL(name)'), @@ -759,6 +789,7 @@ for $dim (1,2,3,4) { (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTERIOR_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTERIOR_DECLARE(name)'), + (bsnl ' && integer :: name/**/2_imin_, name/**/2_imax_'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTERIOR_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTERIOR_OMP_PRIVATE(name)'), @@ -771,7 +802,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt '[C]blo').','), (bsnl ' '.(crpt '[C]bhi').','), - (bsnl ' 1)'), + (bsnl ' name/**/2_imin_,name/**/2_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INTERIOR(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTERIOR(name)'), @@ -786,13 +817,13 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt '[C]blo').','), (bsnl ' '.(crpt '[C]bhi').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' CCTK_LOOP[DIM]STR(name/**/_interior,'), (bsnl ' '.(crpt '[C]').','), (rpt (bsnl ' ([C]blo)+1,')), (rpt (bsnl ' cctk_lsh([I+1])-([C]bhi),')), (bsnl ' '.(crpt 'cctk_ash([I+1])').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INTERIOR(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR(name/**/_interior)'), @@ -803,6 +834,7 @@ for $dim (1,2,3,4) { (nl ''), (bsnl '#define CCTK_LOOP[DIM]_BOUNDARIES_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_BOUNDARIES_DECLARE(name)'), + (bsnl ' && integer :: name/**/2_imin_, name/**/2_imax_'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_BOUNDARIES_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_BOUNDARIES_OMP_PRIVATE(name)'), @@ -821,7 +853,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]bhi').','), (bsnl ' '.(crpt '[C]bboxlo').','), (bsnl ' '.(crpt '[C]bboxhi').','), - (bsnl ' 1)'), + (bsnl ' name/**/2_imin_,name/**/2_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_BOUNDARIES(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_BOUNDARIES(name)'), @@ -845,13 +877,13 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]bhi').','), (bsnl ' '.(crpt '[C]bboxlo').','), (bsnl ' '.(crpt '[C]bboxhi').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' && name/**/2_blo = (/ '.(crpt '[C]blo').' /)'), (bsnl ' && name/**/2_bhi = (/ '.(crpt '[C]bhi').' /)'), (bsnl ' && name/**/2_bboxlo = (/ '.(crpt '[C]bboxlo').' /)'), (bsnl ' && name/**/2_bboxhi = (/ '.(crpt '[C]bboxhi').' /)'), (bsnl ' && name/**/2_istr = (istr)'), - (bsnl ' && /* Loop over all faces, edges, and corners */'), + # 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==-1) name/**/2_any_bbox = name/**/2_any_bbox .or. name/**/2_bboxlo([I+1]) /= 0')), @@ -870,7 +902,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt 'name/**/2_bmin([I+1])').','), (bsnl ' '.(crpt 'name/**/2_bmax([I+1])').','), (rpt (bsnl ' cctk_ash([I+1]),')), - (bsnl ' name/**/2_istr)'), + (bsnl ' imin,imax, name/**/2_istr)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_BOUNDARIES(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_NORMAL(name/**/_boundaries)'), @@ -883,6 +915,7 @@ for $dim (1,2,3,4) { (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTBOUNDARIES_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTBOUNDARIES_DECLARE(name)'), + (bsnl ' && integer :: name/**/2_imin_, name/**/2_imax_'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTBOUNDARIES_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTBOUNDARIES_OMP_PRIVATE(name)'), @@ -901,7 +934,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]bhi').','), (bsnl ' '.(crpt '[C]bboxlo').','), (bsnl ' '.(crpt '[C]bboxhi').','), - (bsnl ' 1)'), + (bsnl ' name/**/2_imin_,name/**/2_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INTBOUNDARIES(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTBOUNDARIES(name)'), @@ -925,13 +958,13 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]bhi').','), (bsnl ' '.(crpt '[C]bboxlo').','), (bsnl ' '.(crpt '[C]bboxhi').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, istr)'), (bsnl ' && name/**/2_blo = (/ '.(crpt '[C]blo').' /)'), (bsnl ' && name/**/2_bhi = (/ '.(crpt '[C]bhi').' /)'), (bsnl ' && name/**/2_bboxlo = (/ '.(crpt '[C]bboxlo').' /)'), (bsnl ' && name/**/2_bboxhi = (/ '.(crpt '[C]bboxhi').' /)'), (bsnl ' && name/**/2_istr = (istr)'), - (bsnl ' && /* Loop over all faces, edges, and corners */'), + # 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==-1) name/**/2_any_bbox = name/**/2_any_bbox .or. name/**/2_bboxlo([I+1]) /= 0')), @@ -953,7 +986,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt 'name/**/2_bmin([I+1])').','), (bsnl ' '.(crpt 'name/**/2_bmax([I+1])').','), (rpt (bsnl ' cctk_ash([I+1]),')), - (bsnl ' name/**/2_istr)'), + (bsnl ' imin,imax, name/**/2_istr)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INTBOUNDARIES(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_NORMAL(name/**/_intboundaries)'), @@ -966,6 +999,7 @@ for $dim (1,2,3,4) { (nl ''), (bsnl '#define CCTK_LOOP[DIM]_ALL_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_ALL_DECLARE(name)'), + (bsnl ' && integer :: name/**/3_imin_, name/**/3_imax_'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_ALL_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_ALL_OMP_PRIVATE(name)'), @@ -974,7 +1008,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]').')'), (bsnl ' CCTK_LOOP[DIM]STR_ALL(name,'), (bsnl ' '.(crpt '[C]').','), - (bsnl ' 1)'), + (bsnl ' name/**/3_imin_,name/**/3_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_ALL(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_ALL(name)'), @@ -987,13 +1021,13 @@ for $dim (1,2,3,4) { (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_ALL(name,'), (bsnl ' '.(crpt '[C]').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, 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 ' istr)'), + (bsnl ' imin,imax, istr)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_ALL(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR(name/**/_all)'), @@ -1004,6 +1038,7 @@ for $dim (1,2,3,4) { (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INT_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INT_DECLARE(name)'), + (bsnl ' && integer :: name/**/3_imin_, name/**/3_imax_'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INT_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INT_OMP_PRIVATE(name)'), @@ -1012,7 +1047,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]').')'), (bsnl ' CCTK_LOOP[DIM]STR_INT(name,'), (bsnl ' '.(crpt '[C]').','), - (bsnl ' 1)'), + (bsnl ' name/**/3_imin_,name/**/3_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INT(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INT(name)'), @@ -1030,7 +1065,7 @@ for $dim (1,2,3,4) { (nl ''), (bsnl '#define CCTK_LOOP[DIM]STR_INT(name,'), (bsnl ' '.(crpt '[C]').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, 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)'), @@ -1039,7 +1074,7 @@ for $dim (1,2,3,4) { (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'name/**/3_bndsize([2*I+1]+1)').','), (bsnl ' '.(crpt 'name/**/3_bndsize([2*I+2])').','), - (bsnl ' (istr))'), + (bsnl ' imin,imax, (istr))'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INT(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTERIOR(name/**/int)'), @@ -1050,6 +1085,7 @@ for $dim (1,2,3,4) { (nl ''), (bsnl '#define CCTK_LOOP[DIM]_BND_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_BND_DECLARE(name)'), + (bsnl ' && integer :: name/**/3_imin_, name/**/3_imax_'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_BND_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_BND_OMP_PRIVATE(name)'), @@ -1060,7 +1096,7 @@ for $dim (1,2,3,4) { (bsnl ' CCTK_LOOP[DIM]STR_BND(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), - (bsnl ' 1)'), + (bsnl ' name/**/3_imin_,name/**/3_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_BND(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_BND(name)'), @@ -1079,7 +1115,7 @@ for $dim (1,2,3,4) { (bsnl '#define CCTK_LOOP[DIM]STR_BND(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, 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)'), @@ -1091,7 +1127,7 @@ for $dim (1,2,3,4) { (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 ' (istr))'), + (bsnl ' imin,imax, (istr))'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_BND(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_BOUNDARIES(name/**/_bnd)'), @@ -1105,6 +1141,7 @@ for $dim (1,2,3,4) { (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTBND_DECLARE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTBND_DECLARE(name)'), + (bsnl ' && integer :: name/**/3_imin_, name/**/3_imax_'), (nl ''), (bsnl '#define CCTK_LOOP[DIM]_INTBND_OMP_PRIVATE(name)'), (bsnl ' CCTK_LOOP[DIM]STR_INTBND_OMP_PRIVATE(name)'), @@ -1115,7 +1152,7 @@ for $dim (1,2,3,4) { (bsnl ' CCTK_LOOP[DIM]STR_INTBND(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), - (bsnl ' 1)'), + (bsnl ' name/**/3_imin_,name/**/3_imax_, 1)'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]_INTBND(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTBND(name)'), @@ -1134,7 +1171,7 @@ for $dim (1,2,3,4) { (bsnl '#define CCTK_LOOP[DIM]STR_INTBND(name,'), (bsnl ' '.(crpt '[C]').','), (bsnl ' '.(crpt 'n[C]').','), - (bsnl ' istr)'), + (bsnl ' imin,imax, 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)'), @@ -1146,7 +1183,7 @@ for $dim (1,2,3,4) { (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 ' (istr))'), + (bsnl ' imin,imax, (istr))'), (nl ''), (bsnl '#define CCTK_ENDLOOP[DIM]STR_INTBND(name)'), (bsnl ' CCTK_ENDLOOP[DIM]STR_INTBOUNDARIES(name/**/_bnd)'), |