diff options
author | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-02-23 16:59:00 +0000 |
---|---|---|
committer | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-02-23 16:59:00 +0000 |
commit | f879ef22846f7c4636e18fb5866d5491d22ce929 (patch) | |
tree | 8e47a588bdd6e2162c947459e3c56f30db9aff02 /src/main/Groups.c | |
parent | e1a996e693904fac95abdd41bc48e1c14c6d07fe (diff) |
Added
> const char *CCTK_GetGroupFromVar(int var);
>
> const char *CCTK_GetImplementationFromVar(int var);
>
perhaps these should take the name rather than the index, but then
I have to split up the name and use the implementation ???
Also amended GetVarNum so that the group name is optional, pass NULL
to leave it out
git-svn-id: http://svn.cactuscode.org/flesh/trunk@333 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main/Groups.c')
-rw-r--r-- | src/main/Groups.c | 99 |
1 files changed, 83 insertions, 16 deletions
diff --git a/src/main/Groups.c b/src/main/Groups.c index b5317126..810dc2da 100644 --- a/src/main/Groups.c +++ b/src/main/Groups.c @@ -67,8 +67,6 @@ int CCTK_CreateGroup(const char *gname, const char *thorn, const char *imp, int retval; va_list ap; - char *position; - char *variable_name; cGroupDefinition *group; @@ -291,37 +289,55 @@ int CCTK_GetGroupNum(const char *implementation, @@*/ int CCTK_GetVarNum(const char *implementation, - const char *group_name, + const char *group_name, const char *variable_name) { int retval; - int group_num; + int gnum,group_num; int variable; retval = -1; - group_num = CCTK_GetGroupNum(implementation, group_name); - - if(group_num > -1) - { - for(variable=0; variable<groups[group_num].n_variables;variable++) - { - if(CCTK_Equals(variable_name, groups[group_num].variables[variable].name)) + if (group_name == NULL) + { + for (gnum = 0; gnum < n_groups; gnum++) + { + + for(variable=0; variable<groups[group_num].n_variables;variable++) { - retval = groups[group_num].variables[variable].number; - break; + if(CCTK_Equals(variable_name, groups[group_num].variables[variable].name) + && CCTK_Equals(implementation,groups[group_num].implementation)) + { + retval = groups[group_num].variables[variable].number; + break; + } } } - } + } else { - retval = -2; + group_num = CCTK_GetGroupNum(implementation, group_name); + + if(group_num > -1) + { + for(variable=0; variable<groups[group_num].n_variables;variable++) + { + if(CCTK_Equals(variable_name, groups[group_num].variables[variable].name)) + { + retval = groups[group_num].variables[variable].number; + break; + } + } + } + else + { + retval = -2; + } } return retval; } - /*@@ @routine CCTK_GetMaxDim @date Mon Feb 8 12:04:01 1999 @@ -380,6 +396,57 @@ int CCTK_GetNumGroups(void) return n_groups; } + /*@@ + @routine CCTK_GetGroupFromVar + @date Mon Feb 22 + @author Gabrielle Allen + @desc + Given a variable index return a group name. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +const char *CCTK_GetGroupFromVar(int var) +{ + const char *retval; + int group_num; + + group_num = group_of_variable[var]; + retval = groups[group_num].name; + + return retval; +} + + /*@@ + @routine CCTK_GetImplementationFromVar + @date Mon Feb 22 + @author Gabrielle Allen + @desc + Given a variable index return a implementation name. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +const char *CCTK_GetImplementationFromVar(int var) +{ + const char *retval; + int group_num; + + group_num = group_of_variable[var]; + retval = groups[group_num].implementation; + + return retval; +} + + /*@@ @routine CCTK_ArrayGroupSize |