1. Bug fix.
2. Add nout check in cwrapper.cc