On exit

mode

may be used to indicate that you are unable or unwilling to  evaluate the objective function at the current x.  (Similarly for the constraint functions.)

During the linesearch, the functions are evaluated at points of the form x = xk+apk after they have already been evaluated satisfactorily at xk.  At any such a, if you set mode to -1, SNOPT will evaluate the functions at some point closer to xk (where they are more likely to be defined).

If for some reason you wish to terminate solution of the current problem, set mode to a negative value (other than -1).

fObj

must contain the computed value of f(x) (except perhaps if mode = 1).

gObj(nnObj)

must contain the known components of the gradient vector g(x), i.e., gObj(j) contains the partial derivative f/xj (except perhaps if mode = 0).