#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.