admb-project / admb

AD Model Builder
http://admb-project.org
Other
64 stars 19 forks source link

remove message "Error trying to open data input file *.dat" when using alternative file #117

Closed iantaylor-NOAA closed 4 years ago

iantaylor-NOAA commented 4 years ago

As discussed at length on the ADMB Users forum in 2013 (link to thread: https://groups.google.com/forum/#!topic/admb-users/vHIVPb_2bJ0), it would be nice for users of models that have custom data input filename to avoid the message Error trying to open data input file *.dat.

I think the ideal change would not be to remove the warning (ore rename from error to warning), but test for a change like ad_comm::change_datafile_name("newfilenamehere"); and adapt the warning to occur only if the new data file is missing rather than model.dat.

A work-around to avoid this message repeating numerous times in simulation analyses has been to create a dummy .dat file which isn't used by the model, but the fix to ADMB is presumably not too hard for anyone who is comfortable editing the code.

This is obviously not high priority and no action need be taken for the ADMB 12.1 release.

iantaylor-NOAA commented 4 years ago

Thanks @johnoel!

I compile from source including the commit 2990e79d93da6d3b769e14f30809a4d3c508cabb to fix this issue. Everything seems to work well. In the catage example, which uses the default catage.dat name for the input data, removing that input file results in the following reasonable error message

 Error trying to read in model data
 This is usual caused by a missing DAT file

In Stock Synthesis, which uses

  ad_comm::change_datafile_name("starter.ss");

and has user-defined data and control files specified in the starter.ss file, you no longer have to see the message Error trying to open data input file ss.dat every time the model is run. If either starter.ss or one of the other input listed in starter.ss are missing, you get an informative error message,

Error trying to open data input file starter.ss

only without the potential confusing extra one about ss.dat.