diff options
author | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-01-26 12:51:06 +0000 |
---|---|---|
committer | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-01-26 12:51:06 +0000 |
commit | c9178e6a95d8a95b8e1d8370669ca88ddf293ab4 (patch) | |
tree | b2e259b5c0cf016717d3f61c2b47623363aa41b7 /lib/sbin/GridFuncStuff.pl | |
parent | b0208925a5ff9e861d75df8acea210460be391e6 (diff) |
Added rest of subroutines necessary to generate argument lists.
Still need to add output routines, etc.
Tom
git-svn-id: http://svn.cactuscode.org/flesh/trunk@120 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/GridFuncStuff.pl')
-rw-r--r-- | lib/sbin/GridFuncStuff.pl | 234 |
1 files changed, 233 insertions, 1 deletions
diff --git a/lib/sbin/GridFuncStuff.pl b/lib/sbin/GridFuncStuff.pl index 86149e2b..29c3e6db 100644 --- a/lib/sbin/GridFuncStuff.pl +++ b/lib/sbin/GridFuncStuff.pl @@ -6,6 +6,7 @@ # @desc # # @enddesc +# @version $Id$ #@@*/ #/*@@ @@ -232,9 +233,11 @@ sub GetThornArguments $type .= ")"; } + $type .= "!$thorn:$group"; + # print "Group is $group, resulting type is $type\n"; - foreach $variable (split(" ", $interface_data{"\U$thorn GROUP $group\E"})) + foreach $variable (split(" ", $interface_database{"\U$thorn GROUP $group\E"})) { $arguments{$variable} = $type; } @@ -245,5 +248,234 @@ sub GetThornArguments } +sub CreateFortranArgumentDeclarations +{ + local(%arguments) = @_; + local($argument); + local(@declarations) = (); + + # Put all storage arguments first. + foreach $argument (sort keys %arguments) + { + if($arguments{$argument} =~ m:STORAGESIZE:) + { + push(@declarations, "INTEGER $argument"); + } + } + + # Now deal with the rest of the arguments + foreach $argument (sort keys %arguments) + { + if($arguments{$argument} !~ m:STORAGESIZE:) + { + $arguments{$argument} =~ m:([^ ]*) ?(.*)?!(.*):; + + if($1 eq "CHAR") + { + push(@declarations, "CHARACTER $argument$2"); + } + elsif ($1 eq REAL) + { + push(@declarations, "REAL $argument$2"); + } + elsif ($1 eq COMPLEX) + { + push(@declarations, "COMPLEX $argument$2"); + } + elsif ($1 eq INTEGER) + { + push(@declarations, "INTEGER $argument$2"); + } + else + { + print STDERR "Unknown argument type $1\n"; + } + } + } + + return @declarations; + +} + +sub CreateFortranArgumentList +{ + local(%arguments) = @_; + local($argument); + local($argumentlist) = ""; + local($sep); + + $sep = ""; + # Put all storage arguments first. + foreach $argument (sort keys %arguments) + { + if($arguments{$argument} =~ m:STORAGESIZE:) + { + $argumentlist .= "$sep$argument"; + $sep = ","; + } + } + + # Now deal with the rest of the arguments + foreach $argument (sort keys %arguments) + { + if($arguments{$argument} !~ m:STORAGESIZE:) + { + $argumentlist .= "$sep$argument"; + $sep = ","; + } + } + + return $argumentlist; +} + +sub CreateCArgumentStatics +{ + local(%arguments) = @_; + local($argument); + local(@declarations) = (); + + foreach $argument (sort keys %arguments) + { + if($arguments{$argument} !~ m:STORAGESIZE:) + { + push(@declarations, "static int CCTKARGNUM_$argument = -1"); + } + } + + return @declarations; +} + + +sub CreateCArgumentInitialisers +{ + local(%arguments) = @_; + local($argument); + local(@initialisers) = (); + + foreach $argument (sort keys %arguments) + { + if($arguments{$argument} !~ m:STORAGESIZE:) + { + $arguments{$argument} =~ m:([^ ]*) ?(.*)?!(.*):; + + push(@initialisers, "if(CCTKARGNUM_$argument == -1) CCTKARGNUM_$argument = CCTK_GetVarNum(\"$3\")"); + } + } + + return @initialisers; +} + +sub CreateCArgumentPrototype +{ + local(%arguments) = @_; + local($argument); + local($prototype) = ""; + local($sep); + + $sep = ""; + + # Put all storage arguments first. + foreach $argument (sort keys %arguments) + { + if($arguments{$argument} =~ m:STORAGESIZE:) + { + $prototype .= "$sep"."int *"; + $sep = ","; + } + } + + # Now deal with the rest of the arguments + foreach $argument (sort keys %arguments) + { + if($arguments{$argument} !~ m:STORAGESIZE:) + { + $arguments{$argument} =~ m:([^ ]*) ?(.*)?!(.*):; + + if($1 eq "CHAR") + { + $prototype .="$sep". "char *"; + $sep = ","; + } + elsif ($1 eq REAL) + { + $prototype .="$sep". "Double *"; + $sep = ","; + } + elsif ($1 eq COMPLEX) + { + $prototype .="$sep". "Complex *"; + $sep = ","; + } + elsif ($1 eq INTEGER) + { + $prototype .="$sep". "int *"; + $sep = ","; + } + else + { + print STDERR "Unknown argument type $1\n"; + } + } + } + + return $prototype; +} + + +sub CreateCArgumentList +{ + local(%arguments) = @_; + local($argument); + local($arglist) = ""; + local($sep); + + $sep = ""; + + # Put all storage arguments first. + foreach $argument (sort keys %arguments) + { + if($arguments{$argument} =~ m:STORAGESIZE\(([^,]*),\s*(\d+):) + { + $arglist .= "$sep"."(int *)(CCTK_STORAGESIZE(xGH, \"$1\",$2)"; + $sep = ","; + } + } + + # Now deal with the rest of the arguments + foreach $argument (sort keys %arguments) + { + if($arguments{$argument} !~ m:STORAGESIZE:) + { + $arguments{$argument} =~ m:([^ ]*) ?(.*)?!(.*):; + + if($1 eq "CHAR") + { + $arglist .= "$sep"."(char *)((xGH)->data[CCTKARGNUM_$argument])"; + $sep = ","; + } + elsif ($1 eq REAL) + { + $arglist .= "$sep"."(Double *)((xGH)->data[CCTKARGNUM_$argument])"; + $sep = ","; + } + elsif ($1 eq COMPLEX) + { + $arglist .= "$sep"."(Complex *)((xGH)->data[CCTKARGNUM_$argument])"; + $sep = ","; + } + elsif ($1 eq INTEGER) + { + $arglist .= "$sep"."(int *)((xGH)->data[CCTKARGNUM_$argument])"; + $sep = ","; + } + else + { + print STDERR "Unknown argument type $1\n"; + } + } + } + + return $arglist; +} 1; |