batch_run() /* avoid interpreter overhead */ { double tstop, tstep, tnext; char* filename; char* comment; tstopunset; tstop = chkarg(1,0.,1e20); tstep = chkarg(2, 0., 1e20); if (ifarg(3)) { filename = gargstr(3); }else{ filename = 0; } if (ifarg(4)) { comment = gargstr(4); }else{ comment = ""; } if (tree_changed) { setup_topology(); } #if VECTORIZE if (v_structure_change) { v_setup_vectors(); } #endif batch_open(filename, tstop, tstep, comment); batch_out(); if (cvode_active_) { while (t < tstop) { cvode_fadvance(t+tstep); batch_out(); } }else{ tstep -= dt/4.; tstop -= dt/4.; tnext = t + tstep; while (t < tstop) { nrn_fixed_step(); if (t > tnext) { batch_out(); tnext = t + tstep; } if (stoprun) { tstopunset; break; } } } batch_close(); ret(1.); }
// 把 batch 中的所有回调函数,依次执行 // 如果有一个返回false,只uverify()提示,依然执行后面的callback // return: all callback return true? // false, error & any callback return false bool batch_exec_close( int id ){ uverify( id_valid( id ) ); batch_t* const batch = (batch_t*)id; bool all_ok = true; int i = 0; for( i=0; i<batch->num; i++ ){ callback_arg_t* const p = &(batch->list[i]); if( !callback_arg_exec( p ) ){ all_ok = false; uverify( false ); } } return_false_if( !batch_close( id ) ); return all_ok; }