Thanks Mark for the suggestions. The reason for doing it this way is that I need to have multiple force evalulations per step. I figured out the cause of my problem though, which was that the GMX_FORCE_NS flag was passed to do_force in the second call, and if I removed it everything is working fine.
P.S. Thanks for the pointer to the gmx-developers list, I wasn't aware of it.