The issue is the shifted indexes for input data X and qconst.
When ADMB runs the Procedure_Section, the following happens in this order.
1. X and qconst are shifted to the zero index.
2. The function etf_f is called which puts the call to adjoint deriv_eta_f function on the gradient stack.
3. X and qconst are shifted back to the original 1 index.
Next the gradients are computed. They are done in reverse starting from the top of the gradient stack. When the
adjoint function derive_eta_f is called, it depends on that X and qconst were shifted to zero. Since they were
re-shifted to 1 at the end of the procedure section, it resulted in index errors for the run. To resolve this, the shifting
should only be done once. The prelimary_calcs_section is called only once before the procedure_section. It can
be used to organize the input model data. In this case, shifting the indexes.
The attached tpl shows how it can be used with the model. Although it can be done in other ways, this is the simplest
and easiest approach.
Also, another neat method is to use save_int_value() and restore_int_value() functions. If you need to just save and
Let me know if you need more details.