Fixed C matmodel code to handle python input file generation