diff options
author | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2002-06-21 15:54:21 +0000 |
---|---|---|
committer | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2002-06-21 15:54:21 +0000 |
commit | 05e48ecf983c5b8a51ad808d662adf3dfc1c481d (patch) | |
tree | 71becb6b40a5c0bfc640cdffecbcfc7200749ba7 /lib/sbin/GridFuncStuff.pl | |
parent | aa0a339405f907e5dd39f9cb8af8e7c1a13966a1 (diff) |
Changed the definition of the DECLARE_CCTK_<THORN>_CARGUMENTS macros:
they call the flesh-internal routine CCTKi_VarDataPtr() now to obtain the
data pointer for a given variable. This replaces a call to CCTK_VarIndex()
which returned an invalid index for non-existing variables and thus was a
potential source for a code crash. Calling CCTKi_VarDataPtr() should also
be faster than CCTK_VarIndex() and makes the macros a bit shorter.
Also cleaned up the other CST generated code a bit, added a grdoc header.
You must also update src/main/Groups.c and lib/sbin/GridFuncStuff.pl now
and do a 'make <configuration>-clean; make <configuration>-rebuild;'.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@2912 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/GridFuncStuff.pl')
-rw-r--r-- | lib/sbin/GridFuncStuff.pl | 996 |
1 files changed, 408 insertions, 588 deletions
diff --git a/lib/sbin/GridFuncStuff.pl b/lib/sbin/GridFuncStuff.pl index d50f5f9d..54bde9b3 100644 --- a/lib/sbin/GridFuncStuff.pl +++ b/lib/sbin/GridFuncStuff.pl @@ -21,8 +21,8 @@ sub CreateVariableBindings { my($bindings_dir, $rhinterface_db, $rhparameter_db) = @_; - my($thorn, @data); - my($line, $block, $filelist); + my(@data); + my($thorn, $line, $block, $filelist); if(! -d $bindings_dir) { @@ -39,45 +39,59 @@ sub CreateVariableBindings foreach $thorn (split(" ",$rhinterface_db->{"THORNS"})) { - @data = &CreateThornArgumentHeaderFile($thorn, $rhinterface_db); - - $dataout = ""; - - foreach $line (@data) - { - $dataout .= "$line\n"; - } - + $dataout = join ("\n", @data); &WriteFile("include/$thorn\_arguments.h",\$dataout); } - $dataout = "/* get the CCTK datatype definitions */\n"; - $dataout .= "#include \"cctk_Types.h\"\n\n"; - $dataout .= "#ifdef CCODE\n"; - $dataout .= "#define CCTK_ARGUMENTS CCTK_CARGUMENTS\n"; - $dataout .= "#define _CCTK_ARGUMENTS _CCTK_CARGUMENTS\n"; - $dataout .= "#define DECLARE_CCTK_ARGUMENTS DECLARE_CCTK_CARGUMENTS \\\n"; - $dataout .= " USE_CCTK_CARGUMENTS\n"; - $dataout .= "#endif\n\n"; - $dataout .= "#ifdef FCODE\n"; - $dataout .= "#define CCTK_ARGUMENTS CCTK_FARGUMENTS\n"; - $dataout .= "#define _CCTK_ARGUMENTS _CCTK_FARGUMENTS\n"; - $dataout .= "#define DECLARE_CCTK_ARGUMENTS DECLARE_CCTK_FARGUMENTS\n"; - $dataout .= "#endif\n\n"; + @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, ''); + + 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, '#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, '#define CCTK_ARGUMENTS CCTK_CARGUMENTS'); + push(@data, '#define _CCTK_ARGUMENTS _CCTK_CARGUMENTS'); + push(@data, '#define DECLARE_CCTK_ARGUMENTS DECLARE_CCTK_CARGUMENTS USE_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'); foreach $thorn (split(" ",$rhinterface_db->{"THORNS"})) { - $dataout .= "#ifdef THORN_IS_$thorn\n"; - $dataout .= "#include \"$thorn"."_arguments.h\"\n"; - $dataout .= "#define CCTK_FARGUMENTS \U$thorn"."_FARGUMENTS\n"; - $dataout .= "#define DECLARE_CCTK_FARGUMENTS DECLARE_\U$thorn"."_FARGUMENTS\n"; - $dataout .= "#define CCTK_CARGUMENTS \U$thorn"."_CARGUMENTS\n"; - $dataout .= "#define DECLARE_CCTK_CARGUMENTS DECLARE_\U$thorn"."_CARGUMENTS\n"; - $dataout .= "#define USE_CCTK_CARGUMENTS USE_\U$thorn"."_CARGUMENTS\n"; - $dataout .= "#endif\n\n"; + 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, "#define USE_CCTK_CARGUMENTS USE_\U$thorn" . '_CARGUMENTS'); + push(@data, '#endif'); } + push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline + $dataout = join ("\n", @data); &WriteFile("include/cctk_Arguments.h",\$dataout); if(! -d "Variables") @@ -87,57 +101,85 @@ sub CreateVariableBindings $filelist = "BindingsVariables.c"; - $dataout = ""; - - $dataout .= "#include \"cctk_ActiveThorns.h\"\n"; + @data = (); + push(@data, '/*@@'); + push(@data, ' @file BindingsVariables.c'); + push(@data, ' @author Automatically generated by GridFuncStuff.pl'); + push(@data, ' @desc'); + push(@data, ' Calls the variable binding routines for all thorns'); + push(@data, ' @enddesc'); + push(@data, ' @@*/'); + push(@data, ''); + push(@data, ''); + + push(@data, '#include <string.h>'); + push(@data, '#include "cctk_ActiveThorns.h"'); + push(@data, ''); foreach $thorn (split(" ",$rhinterface_db->{"THORNS"})) { - $dataout .= "int CactusBindingsVariables_$thorn"."_Initialise(void);\n"; + push(@data, "int CactusBindingsVariables_${thorn}_Initialise(void);"); } - $dataout .= "\n"; - - $dataout .= "int CCTKi_BindingsVariablesInitialise(void);\n\n"; - - $dataout .= "int CCTKi_BindingsVariablesInitialise(void)\n{\n"; + push(@data, ''); + push(@data, 'int CCTKi_BindingsVariablesInitialise(void);'); + push(@data, ''); + push(@data, 'int CCTKi_BindingsVariablesInitialise(void)'); + push(@data, '{'); foreach $thorn (split(" ",$rhinterface_db->{"THORNS"})) { - $dataout .= " if(CCTK_IsThornActive(\"$thorn\"))\n {\n"; - $dataout .= " CactusBindingsVariables_$thorn"."_Initialise();\n"; - $dataout .= " }\n"; + push(@data, " if (CCTK_IsThornActive(\"$thorn\"))"); + push(@data, ' {'); + push(@data, " CactusBindingsVariables_${thorn}_Initialise();"); + push(@data, ' }'); } - $dataout .= " return 0;\n}\n\n"; + push(@data, ' return 0;'); + push(@data, '}'); + push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline + $dataout = join ("\n", @data); &WriteFile("Variables/BindingsVariables.c",\$dataout); foreach $thorn (split(" ",$rhinterface_db->{"THORNS"})) { - $dataout = ""; - $dataout .= "\#include \"cctk_Types.h\"\n"; - $dataout .= "\#include \"cctk_WarnLevel.h\"\n"; - $dataout .= "\#include \"cctk_Parameter.h\"\n"; - $dataout .= "\#include \"cctki_Groups.h\"\n"; - $dataout .= "\#include \"cctki_FortranWrappers.h\"\n"; - $dataout .= "int CCTKi_BindingsFortranWrapper$thorn(void *GH, void *fpointer);\n"; - - $dataout .= "int CactusBindingsVariables_$thorn"."_Initialise(void);\n"; - $dataout .= "int CactusBindingsVariables_$thorn"."_Initialise(void)\n{\n"; + @data = (); + push(@data, '/*@@'); + push(@data, " \@file $thorn.c"); + push(@data, ' @author Automatically generated by GridFuncStuff.pl'); + push(@data, ' @desc'); + push(@data, " Creates the CCTK variables for thorn $thorn"); + push(@data, ' @enddesc'); + push(@data, ' @@*/'); + push(@data, ''); + push(@data, ''); + + push(@data, '#include "cctk_Types.h"'); + push(@data, '#include "cctk_WarnLevel.h"'); + push(@data, '#include "cctk_Parameter.h"'); + push(@data, '#include "cctki_Groups.h"'); + push(@data, '#include "cctki_FortranWrappers.h"'); + push(@data, ''); + + push(@data, "int CCTKi_BindingsFortranWrapper$thorn(void *GH, void *fpointer);"); + push(@data, ''); + push(@data, "int CactusBindingsVariables_${thorn}_Initialise(void);"); + push(@data, "int CactusBindingsVariables_${thorn}_Initialise(void)"); + push(@data, '{'); foreach $block ("PUBLIC", "PROTECTED", "PRIVATE") { - @data = &CreateThornGroupInitialisers($thorn, $block, $rhinterface_db, $rhparameter_db); - - foreach $line (@data) - { - $dataout .= "$line\n"; - } + push(@data, &CreateThornGroupInitialisers($thorn, $block, $rhinterface_db, $rhparameter_db)); } - $dataout .= " CCTKi_RegisterFortranWrapper(\"$thorn\", CCTKi_BindingsFortranWrapper$thorn);\n\n"; + push(@data, ''); + push(@data, " CCTKi_RegisterFortranWrapper(\"$thorn\", CCTKi_BindingsFortranWrapper$thorn);"); - $dataout .= " return 0;\n}\n"; + push(@data, ''); + push(@data, ' return 0;'); + push(@data, '}'); + push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline + $dataout = join ("\n", @data); &WriteFile("Variables/$thorn.c",\$dataout); $filelist .= " $thorn.c"; @@ -145,16 +187,12 @@ sub CreateVariableBindings foreach $thorn (split(" ",$rhinterface_db->{"THORNS"})) { - $dataout = ""; - @data = &CreateThornFortranWrapper($thorn); + push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline - foreach $line (@data) - { - $dataout .= "$line\n"; - } - + $dataout = join ("\n", @data); &WriteFile("Variables/$thorn\_FortranWrapper.c",\$dataout); + $filelist .= " $thorn\_FortranWrapper.c"; } @@ -179,9 +217,7 @@ sub GetThornArguments my($this_thorn, $block, $rhinterface_db) = @_; my(%arguments); my(@other_imps); - my($my_imp); - my($imp); - my($thorn, $group, $variable, $vtype, $gtype, $type); + my($my_imp, $imp, $thorn, $group, $variable, $vtype, $gtype, $type); $my_imp = $rhinterface_db->{"\U$this_thorn IMPLEMENTS"}; @@ -196,7 +232,6 @@ sub GetThornArguments elsif($block eq "PRIVATE") { @other_imps = (); - } else { @@ -233,18 +268,18 @@ sub GetThornArguments 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") + if($gtype eq 'GF' || $gtype eq 'ARRAY') { - $type .= " ("; + $type .= ' ('; if(defined($vararraysize) && $compactgroup == 1) { $type .= "${group}_length"; - $sep = ","; + $sep = ','; } else { - $sep = ""; + $sep = ''; } for($dim =0; $dim < $rhinterface_db->{"\U$thorn GROUP $group DIM\E"}; $dim++) @@ -252,8 +287,8 @@ sub GetThornArguments # FIXME: quick hack to shorten argument names # $type .= "${sep}cctkv$group$dim"; $type .= "${sep}X$group$dim"; - $sep = ","; - if($block eq "PRIVATE") + $sep = ','; + if($block eq 'PRIVATE') { # FIXME: quick hack to shorten argument names # $arguments{"cctkv$group$dim"} = "(STORAGESIZE($thorn\::$group, $dim))"; @@ -270,11 +305,11 @@ sub GetThornArguments { $type .= "$sep${group}_length"; } - $type .= ")"; + $type .= ')'; if(defined($vararraysize)) { - if($block eq "PRIVATE") + if($block eq 'PRIVATE') { $arguments{"${group}_length"} = "(GROUPLENGTH($thorn\::$group)"; } @@ -285,7 +320,7 @@ sub GetThornArguments } } - if($block eq "PRIVATE") + if($block eq 'PRIVATE') { $type .= "!$thorn\::$group"; } @@ -298,11 +333,11 @@ sub GetThornArguments if(defined($vararraysize)) { - $type .= "![0]"; + $type .= '![0]'; } else { - $type .= "!"; + $type .= '!'; } # print "Group is $group, resulting type is $type\n"; @@ -331,16 +366,11 @@ sub CreateFortranArgumentDeclarations my(%arguments) = @_; my($argument); my(@declarations) = (); - my($suffix); # Put all storage arguments first. foreach $argument (sort keys %arguments) { - if($arguments{$argument} =~ m:STORAGESIZE:) - { - push(@declarations, "INTEGER $argument"); - } - if($arguments{$argument} =~ m:GROUPLENGTH:) + if($arguments{$argument} =~ m:STORAGESIZE|GROUPLENGTH:) { push(@declarations, "INTEGER $argument"); } @@ -349,46 +379,38 @@ sub CreateFortranArgumentDeclarations # Now deal with the rest of the arguments foreach $argument (sort keys %arguments) { - $suffix = ""; - if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:) - { - $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*)!([^!]*):; + next if ($arguments{$argument} =~ m:STORAGESIZE|GROUPLENGTH:); - $type = $1; - $dimensions = $2; - $ntimelevels = $4; + $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 - if($level == 1) - { - $suffix = ""; - } - else - { - $suffix .= "_p"; - } + for($level = 0; $level < $ntimelevels; $level++) + { + push(@declarations, "CCTK_$type $argument$dimensions"); - if($type =~ /^(CHAR|BYTE|INT|INT2|INT4|INT8|REAL|REAL4|REAL8|REAL16|COMPLEX|COMPLEX8|COMPLEX16|COMPLEX32)$/) - { - # DEPRECATED IN BETA 10 - if($type eq 'CHAR') - { - &CST_error(1,"CCTK_CHAR is replaced by CCTK_BYTE, please change your code","",__LINE__,__FILE__); - } + # Modify the name for the time level + $argument .= '_p'; + } - push(@declarations, "CCTK_$type $argument$suffix$dimensions"); - } - else - { - &CST_error(0,"Unknown argument type \"$type\"","",__LINE__,__FILE__); - } + if($type =~ /^(CHAR|BYTE|INT|INT2|INT4|INT8|REAL|REAL4|REAL8|REAL16|COMPLEX|COMPLEX8|COMPLEX16|COMPLEX32)$/) + { + # DEPRECATED IN BETA 10 + if($type eq 'CHAR') + { + &CST_error(1,"CCTK_CHAR is replaced by CCTK_BYTE, please change your code","",__LINE__,__FILE__); } } + else + { + &CST_error(0,"Unknown argument type \"$type\"","",__LINE__,__FILE__); + } } + push(@declarations, ''); return @declarations; @@ -406,51 +428,42 @@ sub CreateFortranArgumentDeclarations sub CreateCArgumentDeclarations { my(%arguments) = @_; - my($argument); + my($varname, $imp, $type, $fullname, $ntimelevels); my(@declarations) = (); - my($suffix); - my($imp); - my($type, $thorn, $ntimelevels); # Now deal with the rest of the arguments - foreach $argument (sort keys %arguments) + foreach $varname (sort keys %arguments) { - $suffix = ""; - if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:) - { - $arguments{$argument} =~ m\^([^! ]+) ?([^!]*)?!([^!]*)::([^!]*)!([^!]*)!([^!]*)\; + next if ($arguments{$varname} =~ m:STORAGESIZE|GROUPLENGTH:); - $type = $1; - $thorn = $3; - $ntimelevels = $5; - $varsuffix = $6; - $suffix = ''; + $arguments{$varname} =~ m\^([^! ]+) ?([^!]*)?!([^!]*)::([^!]*)!([^!]*)!([^!]*)\; - for($level = 0; $level < $ntimelevels; $level++) - { - # Modify the name for the time level - if($level > 0) - { - $suffix .= '_p'; - } + $type = $1; + $implementation = "\U\"$3\""; + $ntimelevels = $5; + $var = "\"$varname$6\""; - if($type =~ /^(CHAR|BYTE|INT|INT2|INT4|INT8|REAL|REAL4|REAL8|REAL16|COMPLEX|COMPLEX8|COMPLEX16|COMPLEX32)$/) - { - # DEPRECATED IN BETA 10 */ - if($type eq 'CHAR') - { - &CST_error(1,"CCTK_CHAR is replaced by CCTK_BYTE, please change your code","",__LINE__,__FILE__); - } + for($level = 0; $level < $ntimelevels; $level++) + { + push(@declarations, "CCTK_$type *$varname = (CCTK_$type *) CCTKi_VarDataPtr(cctkGH, $level, $implementation, $var);"); - push(@declarations, "CCTK_$type *$argument$suffix=(CCTK_$type *)CCTK_VarDataPtr(cctkGH,$level,\"$thorn\::$argument$varsuffix\");"); - } - else - { - &CST_error(0,"Unknown argument type $type","",__LINE__,__FILE__); - } + # Modify the name for the time level + $varname .= '_p'; + } + + if($type =~ /^(CHAR|BYTE|INT|INT2|INT4|INT8|REAL|REAL4|REAL8|REAL16|COMPLEX|COMPLEX8|COMPLEX16|COMPLEX32)$/) + { + # DEPRECATED IN BETA 10 */ + if($type eq 'CHAR') + { + &CST_error(1,"CCTK_CHAR is replaced by CCTK_BYTE, please change your code","",__LINE__,__FILE__); } } + else + { + &CST_error(0,"Unknown argument type $type","",__LINE__,__FILE__); + } } return @declarations; @@ -468,37 +481,24 @@ sub CreateCArgumentDeclarations sub CreateCArgumentUses { my(%arguments) = @_; - my($argument); + my($varname, $suffix, $imp); my(@declarations) = (); - my($suffix); - my($imp); - # Now deal with the rest of the arguments - foreach $argument (sort keys %arguments) + foreach $varname (sort keys %arguments) { - $suffix = ""; - if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:) - { - $arguments{$argument} =~ m\^([^! ]+) ?([^!]*)?!([^!]*)::([^!]*)!([^!]*)\; + next if ($arguments{$varname} =~ m:STORAGESIZE|GROUPLENGTH:); - $ntimelevels = $5; + $arguments{$varname} =~ m\^([^! ]+) ?([^!]*)?!([^!]*)::([^!]*)!([^!]*)\; - for($level = 1; $level <= $ntimelevels; $level++) - { - # Modify the name for the time level - if($level == 1) - { - $suffix = ""; - } - else - { - $suffix .= "_p"; - } + $ntimelevels = $5; - push(@declarations, "(void) ($argument$suffix + 0);"); + for($level = 0; $level < $ntimelevels; $level++) + { + push(@declarations, "(void) ($varname + 0);"); - } + # Modify the name for the time level + $varname .= '_p'; } } @@ -517,57 +517,37 @@ sub CreateCArgumentUses sub CreateFortranArgumentList { my(%arguments) = @_; - my($argument); - my($argumentlist) = ""; - my($sep); + my($argument, $varname); + my(@argumentlist) = (); - $sep = ""; # Put all storage arguments first. foreach $argument (sort keys %arguments) { - if($arguments{$argument} =~ m:STORAGESIZE:) + if($arguments{$argument} =~ m:STORAGESIZE|GROUPLENGTH:) { - $argumentlist .= "$sep$argument"; - $sep = ","; - } - if($arguments{$argument} =~ m:GROUPLENGTH:) - { - $argumentlist .= "$sep$argument"; - $sep = ","; + push(@argumentlist, $argument); } } # Now deal with the rest of the arguments - foreach $argument (sort keys %arguments) + foreach $varname (sort keys %arguments) { - if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:) - { - $suffix = ""; - if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:) - { - $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*)!([^!]*):; + next if ($arguments{$varname} =~ m:STORAGESIZE|GROUPLENGTH:); - $ntimelevels = $4; + $arguments{$varname} =~ m:^([^! ]+) ?([^!]*)?!([^!]*)!([^!]*):; - for($level = 1; $level <= $ntimelevels; $level++) - { - # Modify the name for the time level - if($level == 1) - { - $suffix = ""; - } - else - { - $suffix .= "_p"; - } + $ntimelevels = $4; - $argumentlist .= "$sep$argument$suffix"; - $sep = ","; - } - } + for($level = 0; $level < $ntimelevels; $level++) + { + push(@argumentlist, $varname); + + # Modify the name for the time level + $varname .= '_p'; } } - return $argumentlist; + + return join(',', @argumentlist); } #/*@@ @@ -582,26 +562,24 @@ sub CreateFortranArgumentList sub CreateCArgumentStatics { my(%arguments) = @_; - my($argument); + my($argument, $group, $allgroups); my(@declarations) = (); - my($allgroups) = ""; - my($group); + $allgroups = ''; foreach $argument (sort keys %arguments) { - if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:) - { - push(@declarations, "static int CCTKARGNUM_$argument = -1"); - $arguments{$argument} =~ /::([^!]+)![0-9]+/; - $group = $1; + next if ($arguments{$argument} =~ m:STORAGESIZE|GROUPLENGTH:); -# print "ARG is $arguments{$argument}, group is $group\n"; + push(@declarations, "static int CCTKARGNUM_$argument = -1;"); + $arguments{$argument} =~ /::([^!]+)![0-9]+/; + $group = $1; - if ($allgroups !~ / $group /) - { - $allgroups .= " $group "; - push(@declarations, "static int CCTKGROUPNUM_$group = -1"); - } +# print "ARG is $arguments{$argument}, group is $group\n"; + + if ($allgroups !~ / $group /) + { + $allgroups .= " $group "; + push(@declarations, "static int CCTKGROUPNUM_$group = -1;"); } } @@ -620,30 +598,26 @@ sub CreateCArgumentStatics sub CreateCArgumentInitialisers { my(%arguments) = @_; - my($argument); + my($argument, $allgroups, $group, $qualifier); my(@initialisers) = (); - my($allgroups) = ""; - my($group); - my($qualifier); - my($suffix); + $allgroups = ''; foreach $argument (sort keys %arguments) { - if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:) - { - $arguments{$argument} =~ m,^([^! ]+) ?([^!]*)?!([^!]*)\::([^!]*)!([^!]*)!([^!]*),; - $qualifier = $3; - $varsuffix = $6; + next if ($arguments{$argument} =~ m:STORAGESIZE|GROUPLENGTH:); - push(@initialisers, "if(CCTKARGNUM_$argument == -1) CCTKARGNUM_$argument = CCTK_VarIndex(\"$qualifier\::$argument$varsuffix\")"); + $arguments{$argument} =~ m,^([^! ]+) ?([^!]*)?!([^!]*)\::([^!]*)!([^!]*)!([^!]*),; + $qualifier = $3; + $varsuffix = $6; - $arguments{$argument} =~ /\::([^!]+)/; - $group = $1; - if ($allgroups !~ / $group /) - { - $allgroups .= " $group "; - push(@initialisers, "if(CCTKGROUPNUM_$group == -1) CCTKGROUPNUM_$group = CCTK_GroupIndex(\"$qualifier\::$group\")"); - } + push(@initialisers, "if(CCTKARGNUM_$argument == -1) CCTKARGNUM_$argument = CCTK_VarIndex(\"$qualifier\::$argument$varsuffix\");"); + + $arguments{$argument} =~ /\::([^!]+)/; + $group = $1; + if ($allgroups !~ / $group /) + { + $allgroups .= " $group "; + push(@initialisers, "if(CCTKGROUPNUM_$group == -1) CCTKGROUPNUM_$group = CCTK_GroupIndex(\"$qualifier\::$group\");"); } } @@ -661,60 +635,45 @@ sub CreateCArgumentInitialisers sub CreateCArgumentPrototype { my(%arguments) = @_; - my($argument); - my($prototype) = ""; - my($sep); - my($type, $ntimelevels); - - $sep = ""; + my(@prototype) = (); + my($argument, $type, $ntimelevels); # Put all storage arguments first. foreach $argument (sort keys %arguments) { - if($arguments{$argument} =~ m:STORAGESIZE:) + if($arguments{$argument} =~ m:STORAGESIZE|GROUPLENGTH:) { - $prototype .= "$sep"."const int *"; - $sep = ","; - } - if($arguments{$argument} =~ m:GROUPLENGTH:) - { - $prototype .= "$sep"."const int *"; - $sep = ","; + push(@prototype, 'const int *'); } } # Now deal with the rest of the arguments foreach $argument (sort keys %arguments) { + next if ($arguments{$argument} =~ m:STORAGESIZE|GROUPLENGTH:); + + $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*):; if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:) { - $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*):; + $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*)!([^!]*):; - $suffix = ""; - if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:) - { - $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*)!([^!]*):; + $type = $1; + $ntimelevels = $4; - $type = $1; - $ntimelevels = $4; + for($level = 0; $level < $ntimelevels; $level++) + { + push(@prototype, "CCTK_$type *"); + } - for($level = 1; $level <= $ntimelevels; $level++) - { - if($type =~ /^(CHAR|BYTE|INT|INT2|INT4|INT8|REAL|REAL4|REAL8|REAL16|COMPLEX|COMPLEX8|COMPLEX16|COMPLEX32)$/) - { - $prototype .="$sep". "CCTK_$type *"; - $sep = ','; - } - else - { - &CST_error(0,"Unknown argument type $type","",__LINE__,__FILE__); - } - } + if($type !~ /^(CHAR|BYTE|INT|INT2|INT4|INT8|REAL|REAL4|REAL8|REAL16|COMPLEX|COMPLEX8|COMPLEX16|COMPLEX32)$/) + { + &CST_error(0,"Unknown argument type $type","",__LINE__,__FILE__); } } } - return $prototype; + + return join(',', @prototype); } @@ -730,65 +689,55 @@ sub CreateCArgumentPrototype sub CreateCArgumentList { my(%arguments) = @_; - my($argument); - my($arglist) = ""; - my($sep); - my($type, $ntimelevels); + my(@arglist) = (); + my(@argument, $type, $ntimelevels); - $sep = ""; # Put all storage arguments first. foreach $argument (sort keys %arguments) { - if($arguments{$argument} =~ m/STORAGESIZE\(([^,]*)::([^,]*),\s*(\d+)/) + if($arguments{$argument} =~ m/STORAGESIZE\([^,]*::([^,]*),\s*(\d+)/) { - $arglist .= "$sep"."(const int *)(CCTKGROUPNUM_$2<0 ? &(_cctk_one) : (CCTK_STORAGESIZE(xGH, $3, \"$1::$2\")))"; - $sep = ","; + push(@arglist, "CCTKGROUPNUM_$1 >= 0 ? CCTK_ArrayGroupSizeI(GH, $2, CCTKGROUPNUM_$1) : &_cctk_zero"); } - if($arguments{$argument} =~ m/GROUPLENGTH\(([^:]*)::([^)]*)\)/) + elsif($arguments{$argument} =~ m/GROUPLENGTH\(([^:]*)::([^)]*)\)/) { - $arglist .= "$sep"."(const int *)(CCTKGROUPNUM_$2<0 ? &(_cctk_one) : (CCTK_GROUPLENGTH(xGH, \"$1::$2\")))"; - $sep = ","; + push(@arglist, "CCTKGROUPNUM_$2 >= 0 ? CCTKi_GroupLengthAsPointer(\"$1::$2\") : &_cctk_zero"); } } # Now deal with the rest of the arguments foreach $argument (sort keys %arguments) { - if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:) - { - $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*):; + next if ($arguments{$argument} =~ m:STORAGESIZE|GROUPLENGTH:); - $suffix = ""; - if($arguments{$argument} !~ m:STORAGESIZE|GROUPLENGTH:) - { - $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*)!([^!]*):; + $arguments{$argument} =~ m:^([^! ]+) ?([^!]*)?!([^!]*)!([^!]*):; - $type = $1; - $ntimelevels = $4; + $type = $1; + $ntimelevels = $4; + $arguments{$argument} =~ /\::([^!]+)/; + $group = $1; - for($level = 1; $level <= $ntimelevels; $level++) - { - if($type =~ /^(CHAR|BYTE|INT|INT2|INT4|INT8|REAL|REAL4|REAL8|REAL16|COMPLEX|COMPLEX8|COMPLEX16|COMPLEX32)$/) - { - # DEPRECATED IN BETA 10 - if($type eq 'CHAR') - { - &CST_error(1,"CCTK_CHAR is replaced by CCTK_BYTE, please change your code","",__LINE__,__FILE__); - } - - $arglist .= "$sep"."(CCTK_$type *)(CCTKARGNUM_$argument<0 ? NULL : (xGH)->data[CCTKARGNUM_$argument][$level-1])"; - $sep = ','; - } - else - { - &CST_error(0,"Unknown argument type $type","",__LINE__,__FILE__); - } - } + for($level = 0; $level < $ntimelevels; $level++) + { + push(@arglist, "CCTKGROUPNUM_$group >= 0 ? GH->data[CCTKARGNUM_$argument][$level] : 0"); + } + + if($type =~ /^(CHAR|BYTE|INT|INT2|INT4|INT8|REAL|REAL4|REAL8|REAL16|COMPLEX|COMPLEX8|COMPLEX16|COMPLEX32)$/) + { + # DEPRECATED IN BETA 10 + if($type eq 'CHAR') + { + &CST_error(1,"CCTK_CHAR is replaced by CCTK_BYTE, please change your code","",__LINE__,__FILE__); } } + else + { + &CST_error(0,"Unknown argument type $type","",__LINE__,__FILE__); + } } - return $arglist; + + return join(",\\\n", @arglist); } #/*@@ @@ -801,293 +750,158 @@ sub CreateCArgumentList #@@*/ sub CreateThornArgumentHeaderFile { - my($thorn, $rhinterface_db) = @_; - my($line); + my($this_thorn, $rhinterface_db) = @_; + my($line, $thorn); my(@returndata) = (); my(%hasvars); - # Create the basic thorn block definitions + # Header Data + push(@returndata, '/*@@'); + push(@returndata, " \@header ${this_thorn}_arguments.h"); + push(@returndata, ' @author Automatically generated by GridFuncStuff.pl'); + push(@returndata, ' @desc'); + push(@returndata, ' Defines macros to declare/define/pass function arguments'); + push(@returndata, " in calls from C to Fortran for thorn $this_thorn"); + push(@returndata, ' @enddesc'); + push(@returndata, ' @@*/'); + push(@returndata, ''); + push(@returndata, ''); + $thorn = "\U$this_thorn"; + + # Create the basic thorn block definitions foreach $block ("PRIVATE", "PROTECTED", "PUBLIC") { - %data = &GetThornArguments($thorn, $block, $rhinterface_db); + %data = &GetThornArguments($this_thorn, $block, $rhinterface_db); # $print_data = 1; - if ($print_data) - { - foreach $arg (keys %data) - { - print "$thorn data: $arg : $data{\"$arg\"}\n"; - } - } +# if ($print_data) +# { +# foreach $arg (keys %data) +# { +# print "$this_thorn data: $arg : $data{\"$arg\"}\n"; +# } +# } # Remember if there actually are any arguments here. $hasvars{$block} = 1 if(keys %data > 0) ; # Do the fortran definitions - push(@returndata, "#ifdef FCODE"); + push(@returndata, '#ifdef FCODE'); # Create the fortran argument declarations - + push(@returndata, "#define DECLARE_${thorn}_${block}_FARGUMENTS \\"); @data = &CreateFortranArgumentDeclarations(%data); - - push(@returndata, "#define \UDECLARE_$thorn"."_$block"."_FARGUMENTS \\"); - - foreach $line (@data) - { - push(@returndata, "$line&&\\"); - } - - push(@returndata, ("","")); + push(@returndata, join ("&&\\\n", @data)); + push(@returndata, ''); # Create the fortran argument list - - push(@returndata, "#define \U$thorn"."_$block"."_FARGUMENTS \\"); - + push(@returndata, "#define ${thorn}_${block}_FARGUMENTS \\"); push(@returndata, &CreateFortranArgumentList(%data)); + push(@returndata, ''); - push(@returndata, ("","")); - - push(@returndata, "#endif /*FCODE*/"); - - push(@returndata, ("","")); + push(@returndata, '#endif /* FCODE */'); + push(@returndata, ''); ########################################################## # Do the C definitions - push(@returndata, "#ifdef CCODE"); + push(@returndata, '#ifdef CCODE'); # Create the C argument declarations - + push(@returndata, "#define DECLARE_${thorn}_${block}_CARGUMENTS \\"); @data = &CreateCArgumentDeclarations(%data); - - push(@returndata, "#define \UDECLARE_$thorn"."_$block"."_CARGUMENTS \\"); - - foreach $line (@data) - { - push(@returndata, "$line \\"); - } - - push(@returndata, ("","")); + push(@returndata, join (" \\\n", @data)); + push(@returndata, ''); # Create code to use each C argument variable - + push(@returndata, "#define USE_${thorn}_${block}_CARGUMENTS \\"); @data = &CreateCArgumentUses(%data); - - push(@returndata, "#define \UUSE_$thorn"."_$block"."_CARGUMENTS \\"); - - foreach $line (@data) - { - push(@returndata, "$line \\"); - } - - push(@returndata, ("","")); + push(@returndata, join (" \\\n", @data)); + push(@returndata, ''); # Create the C argument variable number statics - - push(@returndata, "#define \UDECLARE_$thorn"."_$block"."_C2F \\"); - + push(@returndata, "#define DECLARE_${thorn}_${block}_C2F \\"); @data = &CreateCArgumentStatics(%data); - foreach $line (@data) - { - push(@returndata, "$line; \\"); - } - push(@returndata, ("","")); - + push(@returndata, join (" \\\n", @data)); + push(@returndata, ''); # Create the C argument variable number statics initialisers - push(@returndata, "#define \UINITIALISE_$thorn"."_$block"."_C2F \\"); + push(@returndata, "#define INITIALISE_${thorn}_${block}_C2F \\"); @data = &CreateCArgumentInitialisers(%data); - foreach $line (@data) - { - push(@returndata,"$line; \\"); - } - - push(@returndata, ("","")); + push(@returndata, join (" \\\n", @data)); + push(@returndata, ''); # Create the C argument prototypes - push(@returndata, "#define \U$thorn"."_$block"."_C2F_PROTO \\"); - + push(@returndata, "#define ${thorn}_${block}_C2F_PROTO \\"); push(@returndata, &CreateCArgumentPrototype(%data)); - - push(@returndata, ("","")); + push(@returndata, ''); # Create the C argument list - push(@returndata, "#define \UPASS_$thorn"."_$block"."_C2F(xGH) \\"); - + push(@returndata, "#define PASS_${thorn}_${block}_C2F(GH) \\"); push(@returndata, &CreateCArgumentList(%data)); - push(@returndata, ("","")); - - push(@returndata, "#endif /*CCODE*/"); - - push(@returndata, ("","")); - + push(@returndata, ''); + push(@returndata, '#endif /* CCODE */'); + push(@returndata, ''); } ################################################################ - # Create the final thorn argument macros - # Do the Fortran argument lists - push(@returndata, "#ifdef FCODE"); - - $sep = ","; - - push(@returndata, "#define \U$thorn"."_FARGUMENTS _CCTK_FARGUMENTS\\"); - $sep = ","; - - foreach $block ("PRIVATE", "PROTECTED", "PUBLIC") - { - if($hasvars{$block}) - { - push(@returndata, "$sep"."\U$thorn"."_$block"."_FARGUMENTS\\"); - $sep = ","; - } - } - - push(@returndata, ("","")); - - # Do the fortran declarations - push(@returndata, "#define \UDECLARE_$thorn"."_FARGUMENTS _DECLARE_CCTK_FARGUMENTS \\"); - - foreach $block ("PRIVATE", "PROTECTED", "PUBLIC") - { - if($hasvars{$block}) - { - push(@returndata, "DECLARE_\U$thorn"."_$block"."_FARGUMENTS \\"); - } - } - - push(@returndata, ("","")); - - push(@returndata, "#endif /*FCODE*/"); - - push(@returndata, ("","")); - - - - push(@returndata, "#ifdef CCODE"); - - # Don't need C arguments - - # Do the C declarations - push(@returndata, "#define \UDECLARE_$thorn"."_CARGUMENTS _DECLARE_CCTK_CARGUMENTS \\"); - - foreach $block ("PRIVATE", "PROTECTED", "PUBLIC") - { - if($hasvars{$block}) - { - push(@returndata, "DECLARE_\U$thorn"."_$block"."_CARGUMENTS \\"); - } - } - - push(@returndata, ("","")); - - # Do the C declarations - push(@returndata, "#define \UUSE_$thorn"."_CARGUMENTS _USE_CCTK_CARGUMENTS \\"); - - foreach $block ("PRIVATE", "PROTECTED", "PUBLIC") - { - if($hasvars{$block}) - { - push(@returndata, "USE_\U$thorn"."_$block"."_CARGUMENTS \\"); - } - } - - push(@returndata, ("","")); - - push(@returndata, "#endif /*CCODE*/"); - - push(@returndata, ("","")); - - - ################################################ - - # Do the C definitions - push(@returndata, "#ifdef CCODE"); - - $sep = ""; - - # Argument prototypes - push(@returndata, "#define \U$thorn"."_C2F_PROTO _CCTK_C2F_PROTO\\"); - $sep = ","; - + $fortran_arguments = "#define ${thorn}_FARGUMENTS _CCTK_FARGUMENTS"; + $fortran_declarations = "#define DECLARE_${thorn}_FARGUMENTS _DECLARE_CCTK_FARGUMENTS"; + $c_declarations = "#define \UDECLARE_${thorn}_CARGUMENTS _DECLARE_CCTK_CARGUMENTS"; + $c_use_arguments = "#define \UUSE_${thorn}_CARGUMENTS _USE_CCTK_CARGUMENTS"; + $c_argument_prototypes = "#define \U${thorn}_C2F_PROTO _CCTK_C2F_PROTO"; + $c_argument_lists = "#define PASS_\U${thorn}_C2F(GH) _PASS_CCTK_C2F(GH)"; + $c_declare_statics = "#define DECLARE_\U${thorn}_C2F _DECLARE_CCTK_C2F"; + $c_initialize_statics = "#define INITIALISE_\U${thorn}_C2F _INITIALISE_CCTK_C2F"; foreach $block ("PRIVATE", "PROTECTED", "PUBLIC") { if($hasvars{$block}) { - push(@returndata, "$sep"."\U$thorn"."_$block"."_C2F_PROTO\\"); + $fortran_arguments .= ", ${thorn}_${block}_FARGUMENTS"; + $fortran_declarations .= " DECLARE_${thorn}_${block}_FARGUMENTS"; + $c_declarations .= " DECLARE_${thorn}_${block}_CARGUMENTS"; + $c_use_arguments .= " USE_${thorn}_${block}_CARGUMENTS"; + $c_argument_prototypes .= ", ${thorn}_${block}_C2F_PROTO"; + $c_argument_lists .= ", PASS_${thorn}_${block}_C2F(GH)"; + $c_declare_statics .= " DECLARE_${thorn}_${block}_C2F"; + $c_initialize_statics .= " INITIALISE_${thorn}_${block}_C2F"; } } - push(@returndata, ("","")); - - # Argument lists - $sep = ""; - - push(@returndata, "#define PASS_\U$thorn"."_C2F(xGH) _PASS_CCTK_C2F(xGH)\\"); - $sep = ","; - - foreach $block ("PRIVATE", "PROTECTED", "PUBLIC") - { - if($hasvars{$block}) - { - push(@returndata, "$sep"."PASS_\U$thorn"."_$block"."_C2F(xGH)\\"); - } - } - - push(@returndata, ("","")); - - # Declare statics - - push(@returndata, "#define DECLARE_\U$thorn"."_C2F _DECLARE_CCTK_C2F \\"); - - foreach $block ("PRIVATE", "PROTECTED", "PUBLIC") - { - if($hasvars{$block}) - { - push(@returndata, "DECLARE_\U$thorn"."_$block"."_C2F \\"); - } - } - - push(@returndata, ("","")); - - # Initialise statics - - push(@returndata, "#define INITIALISE_\U$thorn"."_C2F _INITIALISE_CCTK_C2F \\"); - - foreach $block ("PRIVATE", "PROTECTED", "PUBLIC") - { - if($hasvars{$block}) - { - push(@returndata, "INITIALISE_\U$thorn"."_$block"."_C2F \\"); - } - } - - push(@returndata, ("","")); - - # Dummy C declarations - - push(@returndata, "#define \U$thorn"."_CARGUMENTS cGH *cctkGH "); - -# push(@returndata, "#define \UDECLARE_$thorn"."_CARGUMENTS \\"); - -# foreach $block ("PRIVATE", "PROTECTED", "PUBLIC") -# { -# if($hasvars{$block}) -# { -# push(@returndata, "\UDECLARE_$thorn_$block"."_CARGUMENTS \\"); -# } -# } - - push(@returndata, ("","")); - - push(@returndata, "#endif /*CCODE*/"); + # Do the Fortran argument lists + push(@returndata, '#ifdef FCODE'); + push(@returndata, $fortran_arguments); + push(@returndata, ''); + push(@returndata, $fortran_declarations); + push(@returndata, ''); + push(@returndata, '#endif /* FCODE */'); + push(@returndata, ''); - push(@returndata, ("","")); + # Do the Fortran argument lists + push(@returndata, '#ifdef CCODE'); + push(@returndata, $c_declarations); + push(@returndata, ''); + push(@returndata, $c_use_arguments); + push(@returndata, ''); + push(@returndata, $c_argument_prototypes); + push(@returndata, ''); + push(@returndata, $c_argument_lists); + push(@returndata, ''); + push(@returndata, $c_declare_statics); + push(@returndata, ''); + push(@returndata, $c_initialize_statics); + push(@returndata, ''); + push(@returndata, "#define ${thorn}_CARGUMENTS cGH *cctkGH"); + push(@returndata, ''); + push(@returndata, '#endif /* CCODE */'); + + push(@returndata, ''); return @returndata; } @@ -1105,11 +919,8 @@ sub CreateThornArgumentHeaderFile sub CreateThornGroupInitialisers { my($thorn, $block, $rhinterface_db, $rhparameter_db) = @_; - my($imp); - my($group, @variables); - my($line); - my(@definitions); - my ($dim,$string,$numsize,$message,$type); + my(@variables, @definitions); + my($imp, $line, $group, $dim, $string, $numsize, $message, $type); $imp = $rhinterface_db->{"\U$thorn\E IMPLEMENTS"}; @@ -1174,24 +985,22 @@ sub CreateThornGroupInitialisers $line .= ")==1)\n"; - $line .= "{\n"; - $line .= " int param_type;\n"; - $line .= " const CCTK_INT *allow_mixeddim_gfs;\n"; - $line .= " allow_mixeddim_gfs = (const CCTK_INT *) CCTK_ParameterGet(\"allow_mixeddim_gfs\",\"Cactus\",\¶m_type);\n"; - $line .= " if (*allow_mixeddim_gfs)\n"; $line .= " {\n"; - $line .= " CCTK_VWarn(2,__LINE__,__FILE__,\"Cactus\"\n,"; - $line .= " \"CCTKi_CreateGroup: Working dimension already set,\"\n"; - $line .= " \" creating GF group $group with different dimension $rhinterface_db->{\"\U$thorn GROUP $group\E DIM\"}\");\n"; + $line .= " const CCTK_INT *allow_mixeddim_gfs;\n"; + $line .= " allow_mixeddim_gfs = (const CCTK_INT *) CCTK_ParameterGet(\"allow_mixeddim_gfs\",\"Cactus\",0);\n"; + $line .= " if (allow_mixeddim_gfs && *allow_mixeddim_gfs)\n"; + $line .= " {\n"; + $line .= " CCTK_VWarn(2,__LINE__,__FILE__,\"Cactus\"\n,"; + $line .= " \"CCTKi_CreateGroup: Working dimension already set,\"\n"; + $line .= " \" creating GF group $group with different dimension $rhinterface_db->{\"\U$thorn GROUP $group\E DIM\"}\");\n"; + $line .= " }\n"; + $line .= " else\n"; + $line .= " {\n"; + $line .= " CCTK_VWarn(0,__LINE__,__FILE__,\"Cactus\"\n,"; + $line .= " \"CCTKi_CreateGroup: Working dimension already set,\"\n"; + $line .= " \" cannot create GF group $group with dimension $rhinterface_db->{\"\U$thorn GROUP $group\E DIM\"}\");\n"; + $line .= " }\n"; $line .= " }\n"; - $line .= " else\n"; - $line .= " {\n"; - $line .= " CCTK_VWarn(0,__LINE__,__FILE__,\"Cactus\"\n,"; - $line .= " \"CCTKi_CreateGroup: Working dimension already set,\"\n"; - $line .= " \" cannot create GF group $group with dimension $rhinterface_db->{\"\U$thorn GROUP $group\E DIM\"}\");\n"; - $line .= " }\n"; - $line .= "}\n\n"; - push(@definitions, $line); } @@ -1205,31 +1014,42 @@ sub CreateThornFortranWrapper my($thorn) = @_; my(@data); - push(@data, "#define THORN_IS_$thorn"); - push(@data, "#include \"cctk.h\""); - push(@data, "#include \"cctk_Flesh.h\""); - push(@data, "#include \"cctk_Groups.h\""); - push(@data, "#include \"cctk_Comm.h\""); - push(@data, "#include \"cctk_Arguments.h\""); - push(@data, ""); - - push(@data, "int CCTKi_BindingsFortranWrapper$thorn(cGH *GH, void *fpointer);\n"); + @data = (); + push(@data, '/*@@'); + push(@data, " \@file ${thorn}_FortranWrapper.c"); + push(@data, ' @author Automatically generated by GridFuncStuff.pl'); + push(@data, ' @desc'); + push(@data, " Defines the fortran wrappers for scheduled fortran routines of thorn $thorn"); + push(@data, ' @enddesc'); + push(@data, ' @@*/'); + push(@data, ''); + push(@data, ''); + + push(@data, "#define THORN_IS_$thorn 1"); + push(@data, ''); + push(@data, '#include "cctk.h"'); + push(@data, '#include "cctk_Flesh.h"'); + push(@data, '#include "cctk_Groups.h"'); + push(@data, '#include "cctk_Comm.h"'); + push(@data, '#include "cctk_Arguments.h"'); + push(@data, ''); + + push(@data, "int CCTKi_BindingsFortranWrapper$thorn(cGH *GH, void *fpointer);"); + push(@data, ''); push(@data, "int CCTKi_BindingsFortranWrapper$thorn(cGH *GH, void *fpointer)"); - push(@data, "{"); + push(@data, '{'); + push(@data, ' const int _cctk_zero = 0;'); push(@data, " void (*function)(\U$thorn\E_C2F_PROTO);"); - push(@data, ""); push(@data, " DECLARE_\U$thorn\E_C2F"); push(@data, " INITIALISE_\U$thorn\E_C2F"); - push(@data, ""); + push(@data, ' (void) (_cctk_zero + 0);'); + push(@data, ''); push(@data, " function = (void (*)(\U$thorn\E_C2F_PROTO))fpointer;"); - push(@data, ""); push(@data, " function(PASS_\U$thorn\E_C2F(GH));"); - push(@data, ""); - push(@data, " return 0;"); - push(@data, ""); - - push(@data, "}"); + push(@data, ''); + push(@data, ' return 0;'); + push(@data, '}'); return (@data); } |