# GMAT: What causes the error "ArrayTemplate error : dimension error"?

I have made various scripts that work with GMAT, but once in a while I get an "ArrayTemplate error : dimension error" error. I do not know what causes it, as in this case my script appears to be correct (it is a multiple-shooting/patch point script, and all the trajectories appear correct and meet at the patch points). There is zero information about it online, so in the context of GMAT's code/functionality, what causes it throw that error?

The only way I've been able to replicate it/force GMAT to throw it in other, working scripts is by using a very high perturbation value in the vary command, which isn't the case here. The only references to it online are in this source code file from GMAT's Sourceforge page, and this page from the same place, both of which I cannot interpret.

My theory: I assume that "array" in this case refers to the state vector of the spacecraft, so maybe this is an error relating to the spacecraft being in some kind of non-physical/mathematically undefinable trajectory (like asking GMAT to propagate the spacecraft to periapsis, but constraining the true anomaly to 350 degrees)? But this doesn't change the fact that this doesn't seem to be the case here.

The GMAT source code is written in C++. Those are C++ exceptions. They are invoked by a throw ArrayTemplateExceptions::DimensionError(); statement in the C++ source.
There are only a few places in the GMAT source code where this exception is thrown. Trying to assign a 3 vector to a 6 vector (or vice versa) would do it. So would adding a 3 vector to a 6 vector (or vice versa). So would multiplying a 3 vector by a 6x6 matrix. (Multiplying a 6x6 matrix by a 3 vector results in a TableTemplateExceptions::DimensionError exception.) In general, the ArrayTemplateExceptions::DimensionError exception is thrown where an operation is attempted to be performed on a pair of objects, the first of which is a one dimensional array, and the second object is dimensionally inconsistent with the first object and the operation at hand.
• @kardalos I don't use GMAT. I do know the concept, but I use other tools. I looked at copies of GMAT imported to GitHub for where ArrayTemplateExceptions::DimensionError was thrown. GitHub has much better search tools than does SourceForge. GitHub does not have ads. Editorial: I don't know why anyone uses SourceForge anymore. (continued) Jun 4, 2022 at 23:51
• I've worked with people who do use GMAT, and I know GMAT uses a home-brewed scripting language. So I then looked at the GMAT user guides. I quickly saw that one can create arrays (vectors) and tables (matrices) in the GMAT scripting language. Using those user-created vectors and matrices in a dimensionally inconsistent management will result in throw in the C++ code. That such errors are caught in the C++ code that underlies the GMAT scripting language interpreter is far and away how GMAT handles user errors. Jun 4, 2022 at 23:54