diff options
Diffstat (limited to 'lib/sbin/GridFuncStuff.pl')
-rw-r--r-- | lib/sbin/GridFuncStuff.pl | 158 |
1 files changed, 94 insertions, 64 deletions
diff --git a/lib/sbin/GridFuncStuff.pl b/lib/sbin/GridFuncStuff.pl index c587e7e6..fde9dfce 100644 --- a/lib/sbin/GridFuncStuff.pl +++ b/lib/sbin/GridFuncStuff.pl @@ -43,68 +43,97 @@ sub CreateVariableBindings WriteFile("include/$thorn\_Arguments.h",\$dataout); } - @data = (); - push(@data, '/*@@'); - push(@data, ' @header cctk_Arguments.h'); - push(@data, ' @author Automatically generated by GridFuncStuff.pl'); - push(@data, ' @desc'); - push(@data, ' Defines the CCTK_ARGUMENTS macro for all thorns'); - push(@data, ' @enddesc'); - push(@data, ' @@*/'); - push(@data, ''); - push(@data, ''); + my @thorns = split(" ",$rhinterface_db->{"THORNS"}); + foreach my $thorn (@thorns) + { + @data = (); + push(@data, "#ifndef CCTK_ARGUMENTS_H_"); + push(@data, "#define CCTK_ARGUMENTS_H_ 1"); + push(@data, '/*@@'); + push(@data, ' @header cctk_Arguments.h'); + push(@data, ' @author Automatically generated by GridFuncStuff.pl'); + push(@data, ' @desc'); + push(@data, ' Defines the CCTK_ARGUMENTS macro for all thorns'); + push(@data, ' @enddesc'); + push(@data, ' @@*/'); + push(@data, ''); + push(@data, ''); + push(@data, "#include \"${thorn}_Arguments.h\""); - push(@data, '/* get the CCTK datatype definitions */'); - push(@data, '#include "cctk_Types.h"'); - push(@data, ''); - push(@data, '#ifdef CCODE'); - - push(@data, '/* prototype for CCTKi_VarDataPtr() goes here'); - push(@data, ' because we don\'t want to include another CCTK header file */'); - push(@data, '#include "cGH.h"'); - push(@data, '#ifdef __cplusplus'); - push(@data, 'extern "C"'); - push(@data, '#endif'); - push(@data, 'void *CCTKi_VarDataPtr(const cGH *GH, int timelevel,'); - push(@data, ' const char *implementation, const char *varname);'); - push(@data, ''); + push(@data, '/* get the CCTK datatype definitions */'); + push(@data, '#include "cctk_Types.h"'); + push(@data, ''); + push(@data, '#ifdef CCODE'); + push(@data, '/* prototype for CCTKi_VarDataPtr() goes here'); + push(@data, ' because we don\'t want to include another CCTK header file */'); + push(@data, '#include "cGH.h"'); + push(@data, '#ifdef __cplusplus'); + push(@data, 'extern "C"'); + push(@data, '#endif'); + push(@data, 'void *CCTKi_VarDataPtr(const cGH *GH, int timelevel,'); + push(@data, ' const char *implementation, const char *varname);'); + push(@data, ''); - push(@data, '#define PASS_GROUPSIZE(group, dir) CCTKGROUPNUM_##group >= 0 ? \\'); - push(@data, ' CCTK_ArrayGroupSizeI(GH, dir, CCTKGROUPNUM_##group) : &_cctk_zero'); - push(@data, ''); - push(@data, '#define PASS_GROUPLEN(thorn, group) CCTKGROUPNUM_##group >= 0 ? \\'); - push(@data, ' CCTKi_GroupLengthAsPointer(#thorn "::" #group) : &_cctk_zero'); - push(@data, ''); - push(@data, '#define PASS_REFERENCE(var, level) CCTKARGNUM_##var >= 0 ? \\'); - push(@data, ' GH->data[CCTKARGNUM_##var][level] : 0'); - push(@data, ''); + push(@data, '#define PASS_GROUPSIZE(group, dir) CCTKGROUPNUM_##group >= 0 ? \\'); + push(@data, ' CCTK_ArrayGroupSizeI(GH, dir, CCTKGROUPNUM_##group) : &_cctk_zero'); + push(@data, ''); + push(@data, '#define PASS_GROUPLEN(thorn, group) CCTKGROUPNUM_##group >= 0 ? \\'); + push(@data, ' CCTKi_GroupLengthAsPointer(#thorn "::" #group) : &_cctk_zero'); + push(@data, ''); + push(@data, '#define PASS_REFERENCE(var, level) CCTKARGNUM_##var >= 0 ? \\'); + push(@data, ' GH->data[CCTKARGNUM_##var][level] : 0'); + push(@data, ''); - push(@data, '#define CCTK_ARGUMENTS CCTK_CARGUMENTS'); - push(@data, '#define _CCTK_ARGUMENTS _CCTK_CARGUMENTS'); - push(@data, '#define DECLARE_CCTK_ARGUMENTS DECLARE_CCTK_CARGUMENTS'); - push(@data, '#endif'); - push(@data, ''); - push(@data, '#ifdef FCODE'); - push(@data, '#define CCTK_ARGUMENTS CCTK_FARGUMENTS'); - push(@data, '#define _CCTK_ARGUMENTS _CCTK_FARGUMENTS'); - push(@data, '#define DECLARE_CCTK_ARGUMENTS DECLARE_CCTK_FARGUMENTS'); - push(@data, '#endif'); + push(@data, "#define CCTK_ARGUMENTS \U${thorn}_CARGUMENTS"); + push(@data, '#define _CCTK_ARGUMENTS _CCTK_CARGUMENTS'); + push(@data, "#define DECLARE_CCTK_ARGUMENTS DECLARE_\U${thorn}_CARGUMENTS"); + push(@data, '#endif'); + push(@data, ''); + push(@data, '#ifdef FCODE'); + push(@data, "#define CCTK_ARGUMENTS \U${thorn}_FARGUMENTS"); + push(@data, '#define _CCTK_ARGUMENTS _CCTK_FARGUMENTS'); + push(@data, "#define DECLARE_CCTK_ARGUMENTS DECLARE_\U${thorn}_FARGUMENTS"); + push(@data, '#endif'); - foreach my $thorn (split(" ",$rhinterface_db->{"THORNS"})) - { push(@data, ''); - push(@data, "#ifdef THORN_IS_$thorn"); - push(@data, "#include \"${thorn}_Arguments.h\""); push(@data, "#define CCTK_FARGUMENTS \U$thorn" . '_FARGUMENTS'); push(@data, "#define DECLARE_CCTK_FARGUMENTS DECLARE_\U$thorn" . '_FARGUMENTS'); push(@data, "#define CCTK_CARGUMENTS \U$thorn" . '_CARGUMENTS'); push(@data, "#define DECLARE_CCTK_CARGUMENTS DECLARE_\U$thorn" . '_CARGUMENTS'); - push(@data, '#endif'); - } - push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline + push(@data, "#endif"); + push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline - my $dataout = join ("\n", @data); - WriteFile("include/cctk_Arguments.h",\$dataout); + my $dataout = join ("\n", @data); + unless(-d "include/$thorn") { + mkdir("include/$thorn"); + } + WriteFile("include/$thorn/cctk_Arguments.h",\$dataout); + if($thorn eq "Cactus") { + unless(-d "include/CactusBindings") { + mkdir("include/CactusBindings"); + } + WriteFile("include/CactusBindings/cctk_Arguments.h",\$dataout); + } + @data = (); + # alternate + push @data, "#ifndef _CCTK_H_"; + push @data, "#define _CCTK_H_ 1"; + push @data, "#include \"${thorn}/definethisthorn.h\""; + push @data, ""; + push @data, "/* Include prototypes for scheduled functions */"; + push @data, "#include \"${thorn}/cctk_ScheduleFunctions.h\""; + push @data, "#include \"cctk_core.h\""; + push @data, "#endif"; + push @data, ""; + $dataout = join ("\n", @data); + WriteFile("include/$thorn/cctk.h",\$dataout); + if($thorn eq "Cactus") { + unless(-d "include/CactusBindings") { + mkdir("include/CactusBindings"); + } + WriteFile("include/CactusBindings/cctk.h",\$dataout); + } + } if(! -d "Variables") { @@ -166,16 +195,17 @@ sub CreateVariableBindings push(@data, ''); push(@data, ''); - push(@data, "#define THORN_IS_$thorn 1"); + #push(@data, "#define THORN_IS_$thorn 1"); push(@data, ''); push(@data, '#include <stddef.h>'); push(@data, ''); - push(@data, '#include "cctk.h"'); - push(@data, '#include "cctk_Arguments.h"'); - push(@data, '#include "cctk_Parameter.h"'); + push(@data, "#include \"$thorn/cctk.h\""); + push(@data, "#include \"$thorn/cctk_Arguments.h\""); + push(@data, "#include \"cctk_Parameter.h\""); push(@data, '#include "cctk_WarnLevel.h"'); push(@data, '#include "cctki_Groups.h"'); push(@data, '#include "cctki_FortranWrappers.h"'); + push(@data, "#include \"$thorn/cctk_ScheduleFunctions.h\""); push(@data, ''); push(@data, "int CactusBindingsVariables_${thorn}_Initialise(void);"); @@ -354,20 +384,20 @@ sub GetThornArguments $sep = ','; if ($gtype ne 'GF') { - if($block eq 'PRIVATE') - { + if($block eq 'PRIVATE') + { # FIXME: quick hack to shorten argument names # $arguments{"cctkv$dim$group"} = "(STORAGESIZE($thorn\::$group, $dim))"; - $arguments{"X$dim$group"} = "(STORAGESIZE($thorn\::$group, $dim))"; - } - else - { + $arguments{"X$dim$group"} = "(STORAGESIZE($thorn\::$group, $dim))"; + } + else + { # FIXME: quick hack to shorten argument names # $arguments{"cctkv$dim$group"} = "(STORAGESIZE($imp\::$group, $dim))"; - $arguments{"X$dim$group"} = "(STORAGESIZE($imp\::$group, $dim))"; - } + $arguments{"X$dim$group"} = "(STORAGESIZE($imp\::$group, $dim))"; } } + } if(defined($vararraysize) && $compactgroup == 0) { $type .= "$sep${group}_length"; |