The error seems to be at the line 378, but the code has 367 lines only!
If I add “cout<<“hello”<<endl;” before “c->cd(3)”, I get no more errors and the script works as expected.
You have an error in your code at lines: char hgeom_name[40];
sprintf(hgeom_name,"#font[42]{Geometrical emittance surface @ %.0f%%}",P);
The sprintf is writing more than 40 chars in hgeom_name. Increase the dimension.