Integral in model block

Dear All

I need to introduce several integrations in the model block. One of them looks like this: z=logncum(0,zhat,m,v). the variable zhat is time variant, and the dynamic of this variable depends on equilibrum wage and interest rate. For other integrations, I use quad function, and again, it needs the input of “zhat.” I defined external function logncum and quad. In this way, Dynare 4.2.0 can give results of steady state, but can’t produce results of transitional path.

I kept receiving the following message:
Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 3.635023e-040.

In sim1 at 83
In simul at 93

After several interation, another err message appears:
Warning: Infinite or Not-a-Number function value encountered.

In quad at 109
In fzmanager at 2
In jacob_element at 45
In policy_bgp_final_prices_dynamic at 39
In sim1 at 78
In simul at 93
In policy_bgp_final_prices at 222
In dynare at 132

Is it becasue Dynare 4.2.0 can’t allow integration in model block? If so, is there any way to sovle this problem?

Thanks a lot for your help! I really appreciate it.