<div dir="ltr">Regarding Mark's Richardson function: should the interior of the function be "sandwiched" between RETURN_ARRAYS_INCREMENT and RETURN_ARRAYS_DECREMENT macros because the function creates and returns a dvariable?<div>
<br></div><div>Buck Stockhausen</div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><font face="courier new, monospace">***************************************************<br>* Dr. William T. Stockhausen                      *<br>
***************************************************<br>* Resource Ecology and Fisheries Management       *<br>* Alaska Fisheries Science Center                 *<br>* National Marine Fisheries Service               *<br>* National Oceanic and Atmospheric Administration *<br>
* 7600 Sand Point Way N.E.                        *<br>* Seattle, Washington 98115-6349                  *<br>***************************************************<br>* email: <a href="mailto:William.Stockhausen@noaa.gov" target="_blank">William.Stockhausen@noaa.gov</a>             *<br>
* voice: 206-526-4241 fax: 206-526-6723           *<br>* web  : <a href="http://www.afsc.noaa.gov" target="_blank">http://www.afsc.noaa.gov</a>                 *<br>***************************************************<br>All models are wrong, some are useful.--G.E.P. Box<br>
Beware of geeks bearing equations.    --W. Buffett<br>***************************************************<br>Disclaimer: The opinions expressed above are personal <br>and do not necessarily reflect official NOAA policy.<br>
</font><br><br></div></div>
<br><br><div class="gmail_quote">On Mon, Aug 11, 2014 at 4:26 PM, John Sibert <span dir="ltr"><<a href="mailto:johnrsibert@gmail.com" target="_blank">johnrsibert@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The message is caused because the compiler does not know anything about class model_parameters, as would be the case if #include<CAPAM_Growth.hpp> were included in the GLOBALS_SECTION of a tpl file.<br>
<br>
If I read your function correctly, there is no need for Richards(...) to be a member of the model_parameters class. All of the required variables are passed as arguments. So I would suggest simply making it a global function.<br>

dvariable Richards(const dvariable &age, const dvariable &Linf, const dvariable &K, const dvariable &t0, const dvariable &p)<br>
<br>
If you want to be a more restrictive (and perhaps a bit safer in case there is some other function with the same protoype), you might consider using a namespace. For instance<br>
namespace CAPAM<br>
{<br>
   dvariable Richards(const dvariable &age, const dvariable &Linf, const dvariable &K,   const dvariable &t0, const dvariable &p)<br>
   {<br>
<br>
   }<br>
<br>
}<br>
<br>
To invoke it your could call<br>
dvariable y = CAPAM::Richards(...)<br>
<br>
Or insert a using statement in the GLOBALS_SECTION of your tpl like<br>
using namesapce CAPAM;<br>
<br>
and simply call the function without the namespace qualifier.<br>
 dvariable y = Richards(...)<br>
<br>
The innertube has information on the use of namespace.<br>
<a href="http://www.cplusplus.com/doc/tutorial/namespaces/" target="_blank">http://www.cplusplus.com/doc/<u></u>tutorial/namespaces/</a><div class=""><br>
<br>
<br>
On 08/11/2014 12:49 PM, Mark Maunder wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
<br>
Why do I get an error if I put the following function in the file CAPAM_Growth.hpp and include it using #include<CAPAM_Growth.hpp> but if I put it in the tpl using the FUNCTION section I do not? The translator appears to just put it in the cpp with no changes<br>

<br>
dvariable model_parameters::Richards(<u></u>const dvariable &age, const dvariable &Linf, const dvariable &K, const dvariable &t0, const dvariable &p)<br>
<br>
{<br>
<br>
  {<br>
<br>
    dvariable Length=Linf*pow((1+(1/p)*exp(-<u></u>K*(age-t0))),-p);<br>
<br>
    return(Length);<br>
<br>
  }<br>
<br>
}<br>
<br>
The errors I get are<br>
<br>
In file included from igm.cpp:3:0:<br>
<br>
./CAPAM_Growth.hpp:130:142: error: invalid use of incomplete type 'struct model_parameters'<br>
<br>
c:/ADMB/admb101-gcc452-win32\<u></u>include/admodel.h:107:9: error: forward declaration of 'struct model_parameters'<br>
<br>
igm.cpp: In member function 'virtual void model_parameters::<u></u>userfunction()':<br>
<br>
igm.cpp:127:46: error: no matching function for call to 'Richards(prevariable, named_dvariable&, named_dvariable&, param_init_number&, named_dvariable&)'<br>
<br>
igm.cpp:128:58: error: no matching function for call to 'Richards(prevariable&, named_dvariable&, named_dvariable&, param_init_number&, named_dvariable&)'<br>
<br>
igm.cpp:139:49: error: no matching function for call to 'Richards(double&, named_dvariable&, named_dvariable&, param_init_number&, named_dvariable&)'<br>
<br>
The selectivity special issue of the journal Fisheries Research is now published<br>
<br>
<a href="http://www.sciencedirect.com/science/journal/01657836/158/supp/C" target="_blank">http://www.sciencedirect.com/<u></u>science/journal/01657836/158/<u></u>supp/C</a><br>
<br>
The Stock Synthesis special issue of the journal Fisheries Research<br>
<br>
<a href="http://www.sciencedirect.com/science/journal/01657836/142" target="_blank">http://www.sciencedirect.com/<u></u>science/journal/01657836/142</a><br>
<br>
Mark Maunder<br>
<br>
Head of the Stock Assessment Program<br>
<br>
Inter-American  Tropical Tuna Commission<br>
<br>
8901 La Jolla Shores Dr.<br>
<br>
La Jolla, CA  92037-1508, USA<br>
<br>
Tel: <a href="tel:%28858%29%20546-7027" value="+18585467027" target="_blank">(858) 546-7027</a><br>
<br>
Fax: <a href="tel:%28858%29%20546-7133" value="+18585467133" target="_blank">(858) 546-7133</a><br>
<br>
</div><a href="mailto:mmaunder@iattc.org" target="_blank">mmaunder@iattc.org</a> <mailto:<a href="mailto:mmaunder@iattc.org" target="_blank">mmaunder@iattc.org</a>><div class=""><br>
<br>
<a href="http://www.fisheriesstockassessment.com/TikiWiki/tiki-index.php?page=Mark+Maunder" target="_blank">http://www.<u></u>fisheriesstockassessment.com/<u></u>TikiWiki/tiki-index.php?page=<u></u>Mark+Maunder</a><br>
<br>
Visit the Center for the Advancement of Population Assessment Methodology at<br>
<br>
<a href="http://www.capamresearch.org/" target="_blank">http://www.capamresearch.org/</a><br>
<br>
Visit the AD Model Builder project at<br>
<br>
<a href="http://admb-project.org/" target="_blank">http://admb-project.org/</a><br>
<br>
See the following website for information on fisheries stock assessment <a href="http://www.fisheriesstockassessment.com/" target="_blank">http://www.<u></u>fisheriesstockassessment.com/</a><br>
<br></div><span class="HOEnZb"><font color="#888888">
-- <br>
You received this message because you are subscribed to the Google Groups "admb-users" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:admb-users%2Bunsubscribe@googlegroups.com" target="_blank">admb-users+unsubscribe@<u></u>googlegroups.com</a> <mailto:<a href="mailto:admb-users%2Bunsubscribe@googlegroups.com" target="_blank">admb-users+<u></u>unsubscribe@googlegroups.com</a>>.<br>

To post to this group, send email to <a href="mailto:admb-users@googlegroups.com" target="_blank">admb-users@googlegroups.com</a> <mailto:<a href="mailto:admb-users@googlegroups.com" target="_blank">admb-users@<u></u>googlegroups.com</a>>.<br>

Visit this group at <a href="http://groups.google.com/group/admb-users" target="_blank">http://groups.google.com/<u></u>group/admb-users</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank">https://groups.google.com/d/<u></u>optout</a>.<br>
</font></span></blockquote><div class="HOEnZb"><div class="h5">
<br>
______________________________<u></u>_________________<br>
Developers mailing list<br>
<a href="mailto:Developers@admb-project.org" target="_blank">Developers@admb-project.org</a><br>
<a href="http://lists.admb-project.org/mailman/listinfo/developers" target="_blank">http://lists.admb-project.org/<u></u>mailman/listinfo/developers</a><br>
</div></div></blockquote></div><br></div>