+ t_hp *hp;
+ t_moldyn *md;
+ int steps;
+ double tau;
+ double dt;
+ double dp;
+
+ hp=hook_params;
+ md=moldyn;
+
+ tau=1.0;
+ steps=0;
+
+ /* switch on t scaling */
+ if(md->schedule.count==0)
+ set_pt_scale(md,P_SCALE_BERENDSEN,P_SCALE_TAU,
+ T_SCALE_BERENDSEN,T_SCALE_TAU);
+
+ /* my lousy state machine ! */
+
+ /* switch to insert state immediately */
+ if(hp->state==STATE_PRERUN)
+ hp->state=STATE_INSERT;
+
+ switch(hp->state) {
+ case STATE_INSERT:
+ goto insert;
+ break;
+ case STATE_POSTRUN:
+ goto postrun;
+ break;
+ default:
+ printf("[sic hook] unknown state\n");
+ return -1;
+ }
+
+ /* 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;