[ADMB Users] can't run model compiled using MinGW when path to exe file starts with ".."

William Stockhausen William.Stockhausen at noaa.gov
Tue Jul 12 14:56:21 PDT 2011


Greetings all,

I've just switched over from using the Borland & Visual C++ versions of 
ADMB to the MinGW version and stumbled over a problem.  When I try to 
run a model compiled with MinGW from the DOS prompt when the path to the 
model starts with "." (as in "..\code\ss_spm.exe"), the program fails 
immediately (from ad_comm::allocate(), as it turns out) with the message:

     Error: Invalid index 0 used for array range [1,18] in "adstring 
adstring::operator()(int i, int j)".

Under MinGW, this occurs in ad_comm::allocate(void) in the file 
src/nh99/model7.cpp (at line 338 in the 10.1 source code).  At this 
point, allocate() has attempted to remove any extension(i.e., ".exe") 
from the program name by looking for a "." not followed by a "\" (on 
Windows) starting at the first character and incrementing through all 
characters until it finds a "." not followed by a "\", at which point it 
truncates the adstring array to the characters to the left of the "." 
(line 338: adprogram_name=adprogram_name(1,n);).  If the model was run 
using a path to the executable that starts with "..", the attempted 
truncation fails with the above error (because n=0). [Note that this 
does not happen using the Borland and Visual C++ compilers because the 
path is removed from the full program name before the extension is 
removed (the code chunk responsible for this, starting at line 316 in 
the cpp file, is skipped n MinGW because the __SPDLL__ macro is turned 
on for the MinGW build).]

Presumably, in addition to skipping over ".\" combinations in truncating 
the program name in ad_comm::allocate(), it would also make sense to 
skip over ".." combinations, as well.  It might also make sense to 
search right-to-left for the extension, rather than left to right.  
Perhaps the developers can deal with this issue.

Hope this is helpful.

Best regards,

Buck Stockhausen

-- 
***************************************************
* Dr. William T. Stockhausen                      *
*_________________________________________________*
* Resource Ecology and Fisheries Management       *
* Alaska Fisheries Science Center                 *
* National Marine Fisheries Service               *
* National Oceanic and Atmospheric Administration *
* 7600 Sand Point Way N.E.                        *
* Seattle, Washington 98115-6349                  *
*_________________________________________________*
* email: William.Stockhausen at noaa.gov             *
* voice: 206-526-4241 fax: 206-526-6723           *
* web  : http://www.afsc.noaa.gov                 *
***************************************************
All models are wrong, some are useful.--G.E.P. Box
Beware of geeks bearing equations.    --W. Buffett
***************************************************
Disclaimer: The opinions expressed above are personal
and do not necessarily reflect official NOAA policy.




More information about the Users mailing list