Dear Ernesto,
indeed I figured out that the problem was related to the integer size.
I was compiling with the gfortran option
-fdefault-integer-8
which is required to let some other FORTRAN routine to work when
interfacing with C++. Now,I suspect that the macros used by ALGENCAN
to interface C and FORTRAN do a similar work and then that option is
not only useless but even harmful. What have been happening was that
the integer values were pushed as 64bit but ALGENCAN expected 32bit I
guess, or the other way round. Thus when ALGENCAN got the values from
the stack they were flipped, this being due to the integer alignment.
That was why a small value (even 0) could turn out to be a huge one.
Best,
Andrea