[ET Trac] [Einstein Toolkit] #2195: Multipole Thorn: Why is max_vars set to 10?

Einstein Toolkit trac-noreply at einsteintoolkit.org
Wed Oct 3 10:02:19 CDT 2018


#2195: Multipole Thorn: Why is max_vars set to 10?
-------------------------+---------------------------------
  Reporter:  zachetie@…  |      Owner:  (none)
      Type:  defect      |     Status:  confirmed
  Priority:  minor       |  Milestone:
 Component:  Other       |    Version:  development version
Resolution:              |   Keywords:
-------------------------+---------------------------------
Changes (by Roland Haas):

 * priority:  unset => minor
 * status:  new => confirmed


Comment:

 There should certainly be a nice error message if the user specified list
 of variables is longer than the maximum hard-coded in the source file.

 I assume the error that you saw as the assert:
 {{{
 assert(vs->n_vars < max_vars); // Too many variables in the variables list
 }}}
 which at least in the source code shows what went wrong. Certainly not the
 nicest way of handling an error that can be triggered by user inpu.

 This can be changed easily to something like:
 {{{
 if(vs->n_vars >= max_vars)
   CCTK_VERROR("More than %d variables used in %s::variables parameter.",
 CCTK_THORNSTRING, max_vars);
 }}}
 for a nicer error message (since it contains the allowed maximum value).

 As far as making that a runtime parameter goes, you can certainly give it
 a try and see what is required to make max_vars a CCTK_INT parameter, then
 propose a pull request. My guess is that technically you are leaving what
 C++ allows you to do, since at least "old" versions of C++ do not allow
 things like:
 {{{
 void foo(int n) {
   int array[n];
 }
 }}}
 even if C99 does allow this but most compilers are fine with this. You may
 have to use std::vector to achieve the same effect in this case though
 since max_vars is used to size a static variable in Multipole_Calc.

-- 
Ticket URL: <https://trac.einsteintoolkit.org/ticket/2195#comment:1>
Einstein Toolkit <http://einsteintoolkit.org>
The Einstein Toolkit


More information about the Trac mailing list