+ /* act according to state */
+
+insert:
+
+ /* assigne values */
+ steps=INS_RELAX;
+ tau=INS_TAU;
+
+ /* check temperature */
+ dt=md->t_avg-md->t_ref;
+ dp=md->p_avg-md->p_ref;
+ if(dt<0)
+ dt=-dt;
+ if(dp<0)
+ dp=-dp;
+ if((dt>INS_DELTA_TC)|(dp>INS_DELTA_PC))
+ goto addsched;
+
+ /* immediately go on if no job is to be done */
+ if(hp->insert_count==INS_RUNS) {
+ printf(" --- leaving insert state ---\n");
+ hp->state=STATE_POSTRUN;
+ goto postrun;
+ }
+
+ /* else -> insert atoms */
+ hp->insert_count+=1;
+ printf(" ### insert atoms (%d/%d) ###\n",
+ hp->insert_count*INS_ATOMS,INS_RUNS*INS_ATOMS);
+ insert_atoms(md);
+ goto addsched;
+
+postrun:
+
+ /* assigne values */
+ steps=POST_RELAX;
+ tau=POST_TAU;
+
+ /* check temperature */
+ dt=md->t_avg-md->t_ref;
+ dp=md->p_avg-md->p_ref;
+ if(dt<0)
+ dt=-dt;
+ if(dp<0)
+ dp=-dp;
+ if((dt>POST_DELTA_TC)|(dp>POST_DELTA_PC))
+ goto addsched;
+
+ /* immediately return if no job is to be done */
+ if(hp->postrun_count==POST_RUNS) {
+ printf(" --- leaving post run state ---\n");
+ return 0;
+ }
+
+ /* postrun action */
+ hp->postrun_count+=1;
+ printf(" ### postrun (%d/%d) ###\n",
+ hp->postrun_count,POST_RUNS);
+ set_temperature(md,md->t_ref-POST_DT);
+
+addsched:
+