summaryrefslogtreecommitdiff
path: root/lib/sbin/GridFuncStuff.pl
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2001-10-07 09:53:27 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2001-10-07 09:53:27 +0000
commit54771fb1ec134434839fb30ab65a5e776259b3a4 (patch)
treea5fced94446b46bc6b514439a8e3d83e3e4fd369 /lib/sbin/GridFuncStuff.pl
parent25d3924f2ff5ad0ac523999508dc84cf7190f7dc (diff)
Preliminary support for 'vector' Grid Variables -
defined as <type> <group_name>[<size>] ... as per a normal 1 variable group except with an extra argument. This creates a vector of GVS, with an extra index (the last one for a GA or GF) corresponding to the element in the vector. For scalars this creates an array similar to a DISTRIB=CONSTANT GA. <size> may be either an integer or an integer-valued parameter (which must not be steerable). So, fortran sees REAL foo[param] TYPE=GF DIM=3 as CCTK_REAL foo(nx,ny,nz,param) and in C it should be accessed as foo[CCTK_GFINDEX3D(cctkGH,i,j,k)*l] When we have COMPACT groups you will also be able to make the extra index the first one rather than the last one. Please treat this as volatile until it is documented, and let me know if you are using it. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@2393 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/GridFuncStuff.pl')
-rw-r--r--lib/sbin/GridFuncStuff.pl138
1 files changed, 110 insertions, 28 deletions
diff --git a/lib/sbin/GridFuncStuff.pl b/lib/sbin/GridFuncStuff.pl
index b5befda2..8cbb6291 100644
--- a/lib/sbin/GridFuncStuff.pl
+++ b/lib/sbin/GridFuncStuff.pl
@@ -247,10 +247,23 @@ sub GetThornArguments
$type = "$vtype";
+ my $vararraysize = $rhinterface_db->{"\U$thorn GROUP $group\E VARARRAY_SIZE"};
+ my $compactgroup = $rhinterface_db->{"\U$thorn GROUP $group\E COMPACT"};
+
if($gtype eq "GF" || $gtype eq "ARRAY")
{
$type .= " (";
- $sep = "";
+
+ if(defined($vararraysize) && $compactgroup == 1)
+ {
+ $type .= "${group}_length";
+ $sep = ",";
+ }
+ else
+ {
+ $sep = "";
+ }
+
for($dim =0; $dim < $rhinterface_db->{"\U$thorn GROUP $group DIM\E"}; $dim++)
{
$type .= "$sep$group$dim";
@@ -264,7 +277,23 @@ sub GetThornArguments
$arguments{"$group$dim"} = "(STORAGESIZE($imp\::$group, $dim))";
}
}
+ if(defined($vararraysize) && $compactgroup == 0)
+ {
+ $type .= "$sep${group}_length";
+ }
$type .= ")";
+
+ if(defined($vararraysize))
+ {
+ if($block eq "PRIVATE")
+ {
+ $arguments{"${group}_length"} = "(GROUPLENGTH($thorn\::$group)";
+ }
+ else
+ {
+ $arguments{"${group}_length"} = "(GROUPLENGTH($imp\::$group)";
+ }
+ }
}
if($block eq "PRIVATE")
@@ -278,11 +307,20 @@ sub GetThornArguments
$type .="!$ntimelevels";
+ if(defined($vararraysize))
+ {
+ $type .= "![0]";
+ }
+ else
+ {
+ $type .= "!";
+ }
+
# print "Group is $group, resulting type is $type\n";
foreach $variable (split(" ", $rhinterface_db->{"\U$thorn GROUP $group\E"}))
{
- $arguments{$variable} = $type;
+ $arguments{$variable} = $type;
}
}
}
@@ -320,20 +358,26 @@ sub CreateFortranArgumentDeclarations
{
push(@declarations, "INTEGER $argument");
}
+ if($arguments{$argument} =~ m:GROUPLENGTH:)
+ {
+ push(@declarations, "INTEGER $argument");
+ }
}
# Now deal with the rest of the arguments
foreach $argument (sort keys %arguments)
{
$suffix = "";
- if($arguments{$argument} !~ m:STORAGESIZE:)
+ if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:)
{
- $arguments{$argument} =~ m:([^ ]*) ?(.*)?!(.*)!(.*):;
+ $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*)!([^!]*):;
$type = $1;
$dimensions = $2;
$ntimelevels = $4;
+# print "var $argument - type \"$arguments{$argument}\" - tl $ntimelevels \n";
+
for($level = 1; $level <= $ntimelevels; $level++)
{
# Modify the name for the time level
@@ -398,13 +442,14 @@ sub CreateCArgumentDeclarations
foreach $argument (sort keys %arguments)
{
$suffix = "";
- if($arguments{$argument} !~ m:STORAGESIZE:)
+ if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:)
{
- $arguments{$argument} =~ m\([^ ]*) ?(.*)?!(.*)::(.*)!(.*)\;
+ $arguments{$argument} =~ m\^([^! ]+) ?([^!]*)?!([^!]*)::([^!]*)!([^!]*)!([^!]*)\;
$type = $1;
$thorn = $3;
$ntimelevels = $5;
+ $varsuffix = $6;
for($level = 1; $level <= $ntimelevels; $level++)
{
@@ -427,7 +472,7 @@ sub CreateCArgumentDeclarations
&CST_error(1,"CCTK_CHAR is replaced by CCTK_BYTE, please change your code","",__LINE__,__FILE__);
}
- push(@declarations, "CCTK_$type *$argument$suffix=(CCTK_$type *)(cctkGH->data[CCTK_VarIndex(\"$thorn\::$argument\")][$levelmone]);");
+ push(@declarations, "CCTK_$type *$argument$suffix=(CCTK_$type *)(cctkGH->data[CCTK_VarIndex(\"$thorn\::$argument$varsuffix\")][$levelmone]);");
}
else
{
@@ -469,9 +514,9 @@ sub CreateCArgumentUses
foreach $argument (sort keys %arguments)
{
$suffix = "";
- if($arguments{$argument} !~ m:STORAGESIZE:)
+ if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:)
{
- $arguments{$argument} =~ m\([^ ]*) ?(.*)?!(.*)::(.*)!(.*)\;
+ $arguments{$argument} =~ m\^([^! ]+) ?([^!]*)?!([^!]*)::([^!]*)!([^!]*)\;
$ntimelevels = $5;
@@ -530,17 +575,22 @@ sub CreateFortranArgumentList
$argumentlist .= "$sep$argument";
$sep = ",";
}
+ if($arguments{$argument} =~ m:GROUPLENGTH:)
+ {
+ $argumentlist .= "$sep$argument";
+ $sep = ",";
+ }
}
# Now deal with the rest of the arguments
foreach $argument (sort keys %arguments)
{
- if($arguments{$argument} !~ m:STORAGESIZE:)
+ if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:)
{
$suffix = "";
- if($arguments{$argument} !~ m:STORAGESIZE:)
+ if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:)
{
- $arguments{$argument} =~ m:([^ ]*) ?(.*)?!(.*)!(.*):;
+ $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*)!([^!]*):;
$ntimelevels = $4;
@@ -591,11 +641,14 @@ sub CreateCArgumentStatics
foreach $argument (sort keys %arguments)
{
- if($arguments{$argument} !~ m:STORAGESIZE:)
+ if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:)
{
push(@declarations, "static int CCTKARGNUM_$argument = -1");
- $arguments{$argument} =~ /::(.*)![0-9]*$/;
+ $arguments{$argument} =~ /::([^!]+)![0-9]+/;
$group = $1;
+
+# print "ARG is $arguments{$argument}, group is $group\n";
+
if ($allgroups !~ / $group /)
{
$allgroups .= " $group ";
@@ -631,15 +684,19 @@ sub CreateCArgumentInitialisers
my($allgroups) = "";
my($group);
my($qualifier);
+ my($suffix);
foreach $argument (sort keys %arguments)
{
- if($arguments{$argument} !~ m:STORAGESIZE:)
+ if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:)
{
- $arguments{$argument} =~ m,([^ ]*) ?(.*)?!(.*)\::(.*)!(.*),;
+ $arguments{$argument} =~ m,^([^! ]+) ?([^!]*)?!([^!]*)\::([^!]*)!([^!]*)!([^!]*),;
$qualifier = $3;
- push(@initialisers, "if(CCTKARGNUM_$argument == -1) CCTKARGNUM_$argument = CCTK_VarIndex(\"$qualifier\::$argument\")");
- $arguments{$argument} =~ /::(.*)![0-9]*$/;
+ $varsuffix = $6;
+
+ push(@initialisers, "if(CCTKARGNUM_$argument == -1) CCTKARGNUM_$argument = CCTK_VarIndex(\"$qualifier\::$argument$varsuffix\")");
+
+ $arguments{$argument} =~ /\::([^!]+)/;
$group = $1;
if ($allgroups !~ / $group /)
{
@@ -685,20 +742,25 @@ sub CreateCArgumentPrototype
$prototype .= "$sep"."const int *";
$sep = ",";
}
+ if($arguments{$argument} =~ m:GROUPLENGTH:)
+ {
+ $prototype .= "$sep"."const int *";
+ $sep = ",";
+ }
}
# Now deal with the rest of the arguments
foreach $argument (sort keys %arguments)
{
- if($arguments{$argument} !~ m:STORAGESIZE:)
+ if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:)
{
- $arguments{$argument} =~ m:([^ ]*) ?(.*)?!(.*):;
+ $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*):;
$suffix = "";
- if($arguments{$argument} !~ m:STORAGESIZE:)
+ if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:)
{
- $arguments{$argument} =~ m:([^ ]*) ?(.*)?!(.*)!(.*):;
+ $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*)!([^!]*):;
$type = $1;
$ntimelevels = $4;
@@ -756,19 +818,24 @@ sub CreateCArgumentList
$arglist .= "$sep"."(const int *)(CCTKGROUPNUM_$2<0 ? &(_cctk_one) : (CCTK_STORAGESIZE(xGH, $3, \"$1::$2\")))";
$sep = ",";
}
+ if($arguments{$argument} =~ m/GROUPLENGTH\(([^:]*)::([^)]*)\)/)
+ {
+ $arglist .= "$sep"."(const int *)(CCTKGROUPNUM_$2<0 ? &(_cctk_one) : (CCTK_GROUPLENGTH(xGH, \"$1::$2\")))";
+ $sep = ",";
+ }
}
# Now deal with the rest of the arguments
foreach $argument (sort keys %arguments)
{
- if($arguments{$argument} !~ m:STORAGESIZE:)
+ if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:)
{
- $arguments{$argument} =~ m:([^ ]*) ?(.*)?!(.*):;
+ $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*):;
$suffix = "";
- if($arguments{$argument} !~ m:STORAGESIZE:)
+ if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:)
{
- $arguments{$argument} =~ m:([^ ]*) ?(.*)?!(.*)!(.*):;
+ $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*)!([^!]*):;
$type = $1;
$ntimelevels = $4;
@@ -1165,13 +1232,28 @@ sub CreateThornGroupInitialisers
. " \"" . $rhinterface_db->{"\U$thorn GROUP $group\E STYPE"} . "\",\n"
. " \"" . $rhinterface_db->{"\U$thorn GROUP $group\E DISTRIB"} . "\",\n"
. " \"" . $rhinterface_db->{"\U$thorn GROUP $group\E SIZE"} . "\",\n"
- . " \"" . $rhinterface_db->{"\U$thorn GROUP $group\E GHOSTSIZE"} . "\",\n"
- . " ". scalar(@variables);
+ . " \"" . $rhinterface_db->{"\U$thorn GROUP $group\E GHOSTSIZE"} . "\",\n";
+
+ if(defined($rhinterface_db->{"\U$thorn GROUP $group\E VARARRAY_SIZE"}))
+ {
+ $line .= " -1";
+ }
+ else
+ {
+ $line .= " " . scalar(@variables);
+ }
+
foreach $variable (@variables)
{
$line .= ",\n \"$variable\"";
}
+ # Pass in the size of the GV array, which may be an integer or a parameter
+ if(defined($rhinterface_db->{"\U$thorn GROUP $group\E VARARRAY_SIZE"}))
+ {
+ $line .= ",\n \"" . $rhinterface_db->{"\U$thorn GROUP $group\E VARARRAY_SIZE"} . "\"";
+ }
+
$line .= ")==1)\n";
$line .= "{\n";