diff options
author | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-01-28 14:53:29 +0000 |
---|---|---|
committer | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-01-28 14:53:29 +0000 |
commit | 75b15c04bcd028e26c95472ce81ffab95b1fb496 (patch) | |
tree | 9bd33717fe40a38c4f996ade8e07c29d2d47957b /lib/sbin/GridFuncStuff.pl | |
parent | 101589136eeb45be35f22c9bb5ba9a7c155ec353 (diff) |
Finished the perl to make groups.
Tidied some stuff up and put in more comments.
Tom
git-svn-id: http://svn.cactuscode.org/flesh/trunk@128 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/GridFuncStuff.pl')
-rw-r--r-- | lib/sbin/GridFuncStuff.pl | 358 |
1 files changed, 249 insertions, 109 deletions
diff --git a/lib/sbin/GridFuncStuff.pl b/lib/sbin/GridFuncStuff.pl index d37e1a6c..e04f5f36 100644 --- a/lib/sbin/GridFuncStuff.pl +++ b/lib/sbin/GridFuncStuff.pl @@ -9,168 +9,152 @@ # @version $Id$ #@@*/ + #/*@@ -# @routine CreateGroups -# @date Tue Jan 12 11:08:19 1999 +# @routine CreateVariableBindings +# @date Thu Jan 28 15:14:20 1999 # @author Tom Goodale # @desc -# +# Creates all the binding files for the variables. # @enddesc # @calls # @calledby # @history # # @endhistory +# #@@*/ -sub CreateGroups +sub CreateVariableBindings { - local(%interface_database) = @_; - local(@interfaces); - local(%thorns); - local(@group_initialisers); - local(@indata); - + local($bindings_dir, %interface_database) = @_; + local($thorn, @data); + local($line, $block, $filelist); - @interfaces = split(" ", $interface_database{"IMPLEMENTATIONS"}); - - foreach $interface (@interfaces) + if(! -d $bindings_dir) { - @indata = &create_interface_group_initialisers($interface, %interface_database); - - push(@group_initialisers, @indata); - - foreach $thorn (split(" ",$interface_database{"IMPLEMENTATION \U$interface\E THORNS"})) - { - $thorns{"\U$thorn\E"} = 1; - } + mkdir("$bindings_dir", 0755) || die "Unable to create $bindings_dir"; } + $start_dir = `pwd`; + chdir $bindings_dir; - foreach $thorn (keys %thorns) + # Create the header files + if(! -d "include") { - - @indata = &create_thorn_group_initialisers($thorn, "PRIVATE", %interface_database); - - push(@group_initialisers, @indata); - + mkdir("include", 0755) || die "Unable to create include directory"; } + chdir "include"; - @group_initialisers = &sort_groups(@group_initialisers); - return @group_initialisers; -} + foreach $thorn (split(" ",$interface_database{"THORNS"})) + { -#/*@@ -# @routine create_interface_group_initialisers -# @date Tue Jan 12 11:08:41 1999 -# @author Tom Goodale -# @desc -# -# @enddesc -# @calls -# @calledby -# @history -# -# @endhistory -#@@*/ + @data = &CreateThornArgumentHeaderFile($thorn, %interface_database); -sub create_interface_group_initialisers -{ - local($interface, %interface_database) = @_; - local($thorn); - local(@definitions); - local(@indata); + open(OUT, ">$thorn"."_arguments.h"); - - $interface_database{"IMPLEMENTATION \U$interface\E THORNS"} =~ m:([^ ]+):; + foreach $line (@data) + { + print OUT "$line\n"; + } - $thorn = $1; + close OUT; + } - @indata = &create_thorn_group_initialisers($thorn, "PUBLIC", %interface_database); + open(OUT, ">declare_arguments.h"); + + foreach $thorn (split(" ",$interface_database{"THORNS"})) + { + print OUT "#ifdef THORN_IS_$thorn\n"; + print OUT "#include $thorn"."_arguments.h\n"; + print OUT "#define CCTK_FARGUMENTS \U$thorn"."_FARGUMENTS\n"; + print OUT "#define DECLARE_CCTK_FARGUMENTS DECLARE_\U$thorn"."_FARGUMENTS\n"; + print OUT "#define CCTK_CARGUMENTS \U$thorn"."_CARGUMENTS\n"; + print OUT "#define DECLARE_CCTK_CARGUMENTS DECLARE_\U$thorn"."_CARGUMENTS\n"; + print OUT "#endif\n\n"; + } - push(@definitions, @indata); + close OUT; + + chdir ".."; - @indata = &create_thorn_group_initialisers($thorn, "PROTECTED", %interface_database); + if(! -d "Variables") + { + mkdir("Variables", 0755) || die "Unable to create Variables directory"; + } + chdir "Variables"; - push(@definitions, @indata); + open (OUT, ">Bindings.c") || die "Cannot open Bindings.c"; - return @definitions; - -} - -#/*@@ -# @routine create_thorn_group_initialisers -# @date Tue Jan 12 11:09:08 1999 -# @author Tom Goodale -# @desc -# -# @enddesc -# @calls -# @calledby -# @history -# -# @endhistory -#@@*/ -sub create_thorn_group_initialisers -{ - local($thorn, $block, %interface_database) = @_; - local(@definitions); - local($base_name); - local($group); - local($variable,@variables); - if($block eq "PRIVATE") + $filelist = "Bindings.c"; + + foreach $thorn (split(" ",$interface_database{"THORNS"})) { - $base_name = "\$$thorn"; + print OUT "int CactusBindingsVariables_$thorn"."_Initialise(void);\n"; } - else + + print OUT "\n"; + + print OUT "int CCTK_BindingsVariablesInitialise(void)\n{\n"; + + foreach $thorn (split(" ",$interface_database{"THORNS"})) { - $base_name = $interface_database{"\U$thorn\E IMPLEMENTS"}; - } - - foreach $group (split(" ", $interface_database{"\U$thorn $block GROUPS"})) + print OUT " CactusBindingsVariables_$thorn"."_Initialise();\n"; + } + + print OUT " return 0;\n}\n\n"; + + close OUT; + + foreach $thorn (split(" ",$interface_database{"THORNS"})) { - @variables = split(" ", $interface_database{"\U$thorn GROUP $group\E"}); + open(OUT, ">$thorn.c") || die "Cannot create $thorn.c"; - $line = " CCTK_CreateGroup(\"\U$base_name::$group\E\",\n" - . " \"" . $interface_database{"\U$thorn GROUP $group\E GTYPE"} . "\",\n" - . " \"" . $interface_database{"\U$thorn GROUP $group\E VTYPE"} . "\",\n" - . " ". scalar(@variables); - foreach $variable (@variables) +# print OUT "#include \"flesh.h\"\n"; +# print OUT "#include \"StoreVariableData.h\"\n\n"; + + print OUT "int CactusBindingsVariables_$thorn"."_Initialise(void)\n{\n"; + foreach $block ("PUBLIC", "PROTECTED", "PRIVATE") { - $line .= ",\n \"\U$variable\E\""; + @data = &CreateThornGroupInitialisers($thorn, $block, %interface_database); + + foreach $line (@data) + { + print OUT "$line\n"; + } } - $line .= ");\n\n"; + print OUT " return 0;\n};\n"; + close OUT; - push(@definitions, $line); + $filelist .= " $thorn.c"; } - return @definitions; - + open (OUT, ">make.code.defn") || die "Cannot open make.code.defn"; + print OUT "SRCS = $filelist\n"; + + close OUT; + + chdir $start_dir; } + #/*@@ -# @routine sort_groups -# @date Tue Jan 12 11:09:26 1999 +# @routine GetThornArguments +# @date Thu Jan 28 14:31:38 1999 # @author Tom Goodale # @desc -# +# Gets a list of all the variables available for a thorn in a +# particular block. # @enddesc # @calls # @calledby # @history # # @endhistory +# #@@*/ -sub sort_groups -{ - local(@group_initialisers) = @_; - - return @group_initialisers; -} - - sub GetThornArguments { local($this_thorn, $block, %interface_database) = @_; @@ -248,6 +232,21 @@ sub GetThornArguments } +#/*@@ +# @routine CreateFortranArgumentDeclarations +# @date Thu Jan 28 14:32:57 1999 +# @author Tom Goodale +# @desc +# Creates the requisite argument list declarations for Fortran. +# @enddesc +# @calls +# @calledby +# @history +# +# @endhistory +# +#@@*/ + sub CreateFortranArgumentDeclarations { local(%arguments) = @_; @@ -297,6 +296,21 @@ sub CreateFortranArgumentDeclarations } +#/*@@ +# @routine CreateFortranArgumentList +# @date Thu Jan 28 14:33:50 1999 +# @author Tom Goodale +# @desc +# Creates the argument list a Fortran subroutine sees. +# @enddesc +# @calls +# @calledby +# @history +# +# @endhistory +# +#@@*/ + sub CreateFortranArgumentList { local(%arguments) = @_; @@ -328,6 +342,22 @@ sub CreateFortranArgumentList return $argumentlist; } +#/*@@ +# @routine CreateCArgumentStatics +# @date Thu Jan 28 14:33:50 1999 +# @author Tom Goodale +# @desc +# Creates the declarations of static variables used to speed up +# construction of arguments to pass to Fortran. +# @enddesc +# @calls +# @calledby +# @history +# +# @endhistory +# +#@@*/ + sub CreateCArgumentStatics { local(%arguments) = @_; @@ -346,6 +376,21 @@ sub CreateCArgumentStatics } +#/*@@ +# @routine CreateCArgumentInitialisers +# @date Thu Jan 28 14:33:50 1999 +# @author Tom Goodale +# @desc +# Creates the code to initialise the statics. +# @enddesc +# @calls +# @calledby +# @history +# +# @endhistory +# +#@@*/ + sub CreateCArgumentInitialisers { local(%arguments) = @_; @@ -365,6 +410,21 @@ sub CreateCArgumentInitialisers return @initialisers; } +#/*@@ +# @routine CreateCArgumentPrototype +# @date Thu Jan 28 14:36:25 1999 +# @author Tom Goodale +# @desc +# Creates the prototype needed to call a Fortran function from C. +# @enddesc +# @calls +# @calledby +# @history +# +# @endhistory +# +#@@*/ + sub CreateCArgumentPrototype { local(%arguments) = @_; @@ -422,6 +482,22 @@ sub CreateCArgumentPrototype } + +#/*@@ +# @routine CreateCArgumentList +# @date Thu Jan 28 14:37:07 1999 +# @author Tom Goodale +# @desc +# Creates the argument list used to call a Fortran function from C. +# @enddesc +# @calls +# @calledby +# @history +# +# @endhistory +# +#@@*/ + sub CreateCArgumentList { local(%arguments) = @_; @@ -479,6 +555,21 @@ sub CreateCArgumentList } +#/*@@ +# @routine CreateThornArgumentHeaderFile +# @date Thu Jan 28 14:37:58 1999 +# @author Tom Goodale +# @desc +# Creates all the argument list stuff necessary to call Fortran from C +# @enddesc +# @calls +# @calledby +# @history +# +# @endhistory +# +#@@*/ + sub CreateThornArgumentHeaderFile { local($thorn, %interface_database) = @_; @@ -693,5 +784,54 @@ sub CreateThornArgumentHeaderFile return @returndata; } + + + +#/*@@ +# @routine CreateThornGroupInitialisers +# @date Thu Jan 28 14:38:56 1999 +# @author Tom Goodale +# @desc +# Creates the calls used to setup groups for a particular thorn block. +# @enddesc +# @calls +# @calledby +# @history +# +# @endhistory +# +#@@*/ + +sub CreateThornGroupInitialisers +{ + local($thorn, $block, %interface_database) = @_; + local($imp); + local($group, @variables); + local($line); + local(@definitions); + + $imp = $interface_database{"\U$thorn\E IMPLEMENTS"}; + + foreach $group (split(" ", $interface_database{"\U$thorn $block GROUPS"})) + { + @variables = split(" ", $interface_database{"\U$thorn GROUP $group\E"}); + + $line = " CCTK_CreateGroup(\"\U$group\",\"$thorn\",\"$imp\",\n" + . " \"" . $interface_database{"\U$thorn GROUP $group\E GTYPE"} . "\",\n" + . " \"" . $interface_database{"\U$thorn GROUP $group\E VTYPE"} . "\",\n" + . " ". scalar(@variables); + foreach $variable (@variables) + { + $line .= ",\n \"\U$variable\E\""; + } + + $line .= ");\n\n"; + + push(@definitions, $line); + } + + return @definitions; +} + 1; |