original_code:
void int_NVT_ISOK(CLASS *class,BONDED *bonded,GENERAL_DATA *general_data)
{
typedef struct communicate{
  int np_beads,np_states,np_forc,np_forc_trg,np_forc_src;
  int myid,np;
  int myid_bead_forc;
  int myid_bead;
  int myid_bead_prime;
  int myid_state;
  int myid_forc;
  int myid_forc_source;
  int myid_forc_target;
  int world;
  int comm_beads;
  int comm_beads_forc;
  int comm_states;
  int comm_forc;
  int comm_forc_source;
  int comm_forc_target;
  int comm_faux;
} COMMUNICATE;
typedef char NAME[50];
typedef char LINE[100];
typedef struct class_plimpton_ind {
   int num_proc_source;
   int num_proc_target;
   int myid_source;
   int myid_target;
  int natoms_tot;
   int *index_src;
   int *index_src_even;
   int *index_src_odd;
   int *index_trg;
   int *index_trg_even;
   int *index_trg_odd;
   int *displs_atm_trg,*counts_atm_trg;
   int *displs_atm_src,*counts_atm_src;
   int *src_odd_end;
   int *src_even_end;
   int *trg_odd_end;
   int *trg_even_end;
   int *src_odd_begin;
   int *src_even_begin;
   int *trg_odd_begin;
   int *trg_even_begin;
   int my_src_odd_counts;
   int my_src_even_counts;
   int my_trg_odd_counts;
   int my_trg_even_counts;
   int *my_src_odd;
   int *my_src_even;
   int *my_trg_odd;
   int *my_trg_even;
   int **jmax;
   int *jmin;
   int **imax;
   int source;
   int target;
} CLASS_PLIMPTON_IND;
typedef struct class_comm_forc_pkg {
   int num_proc;
   int myid;
   int myatm_start,myatm_end;
   int mytherm_start,mytherm_end;
   int *displs_atm,*recv_count_atm;
   int *displs_therm,*recv_count_therm;
   int comm;
   int world;
   double dbl_num_proc;
  CLASS_PLIMPTON_IND plimpton_ind;
} CLASS_COMM_FORC_PKG;
typedef struct clatoms_info{
  int natm_tot;
  int pi_beads;
  int pi_beads_proc;
  int pi_beads_proc_st;
  int pi_beads_proc_end;
  int nfree;
  int nfree_pimd;
  int nchrg;
  int pi_beads_full_ter;
  int pi_beads_res_ter;
  int pi_beads_full_tra;
  int pi_beads_res_tra;
  int cg_reset_flag;
  int natm_mall;
  int nchrg_mall;
  int hess_calc;
  int natm_proc;
  int N_H2;
  int i_H2_start;
  int nab_initio;
  int myatm_start,myatm_end;
  double gamma_adb;
  double wght_pimd;
  double pi_temperature;
  double pi_beads_full_ter_wght;
  double pi_beads_res_ter_wght;
  double pi_beads_full_tra_wght;
  double pi_beads_res_tra_wght;
  double rcut_spread;
  double mass_sc_fact;
  int *ip_lab;
  int *ichrg;
  int *cp_vlnc_up,*cp_vlnc_dn;
  int *cp_atm_flag;
  double *mass;
  double *q;
  double *alp_pol;
  double *b_neut;
  double *roll_sc;
  double *text_atm;
  double *text_mol;
  double *xold,*yold,*zold;
  double *prekf;
  double *xmod,*ymod,*zmod;
  double alp_ewd;
} CLATOMS_INFO;
typedef struct clatoms_tran{
  int pi_beads_proc;
  int pi_atm_proc;
  int pi_atm_proc_use;
  int pi_proc_rem;
  int nwork;
  int *sendcounts,*recvcounts;
  int *senddspls,*recvdspls;
  int *ifax;
  double *rat1_stag,*rat2_stag;
  double *path_eig;
  double *work,*work2;
  double *work3,*work4;
  double *x_trans,*y_trans,*z_trans;
  double *x_temp,*y_temp,*z_temp;
  double *xt_temp,*yt_temp,*zt_temp;
} CLATOMS_TRAN;
typedef struct clatoms_pos{
  double *mass;
  double *x,*y,*z;
  double *vx,*vy,*vz;
  double *fx,*fy,*fz;
  double *fxt,*fyt,*fzt;
  double *fxm,*fym,*fzm;
  double *hess_xx,*hess_xy,*hess_xz,*hess_yy,*hess_yz,*hess_zz;
} CLATOMS_POS;
typedef struct ghost_atoms{
  int nghost_tot;
  int natm_comp_max;
  int nghost_mall;
  int nghost_old;
  int ncomp_mall;
  int ncomp_old;
  int *ighost_map;
  int *natm_comp;
  int **iatm_comp;
  double **coef;
} GHOST_ATOMS;
typedef struct atommaps{
  int nmol_typ;
  int nres_typ;
  int natm_typ;
  int nfreeze;
  int nfreeze_mall;
  int natm_typ_mall;
  int nres_typ_max;
  int nres_max;
  int nres_tot;
  int nres_sum;
  int pimd_freez_typ;
  NAME *atm_typ;
  NAME *res_typ;
  NAME *mol_typ;
  int *nmol_jmol_typ;
  int *nres_1mol_jmol_typ;
  int *jatm_jmol_typ_strt;
  int *jres_jmol_typ_strt;
  int *ires_typ_jres_jmol_typ;
  int *jatm_jres_1mol_jmol_typ_strt;
  int *natm_1mol_jmol_typ;
  int *natm_jres_jmol_typ;
  int *nfree_1mol_jmol_typ;
  int *nfree_jres_jmol_typ;
  int *icons_jmol_typ;
  int *icons_jres_jmol_typ;
  int *natm_jmol_typ;
  int *iatm_mol_typ;
  int *iatm_res_typ;
  int *iatm_atm_typ;
  int *iatm_atm_typ_nl;
  int *iatm_atm_typ_nl_rev;
  int *imap_atm_typ_nl;
  int *imap_atm_typ_nl_gh;
  int *iatm_mol_num;
  int *iatm_proc_num;
  int *iatm_res_num;
  int *ighost_flag;
  int *freeze_flag;
  int *freeze_map;
  int *atom_label;
  int *cp_atm_lst;
} ATOMMAPS;
typedef struct therm_info{
  int num_nhc;
  int len_nhc;
  int nres_nhc;
  int nyosh_nhc;
  int therm_typ;
  int num_nhc_proc;
  int num_nhc_share;
  int mytherm_start,mytherm_end;
  double dt_nhc,dti_nhc,wght;
  int *inhc_x,*inhc_y,*inhc_z;
  int *itherm_nshare;
  double *ditherm_nshare_i;
  int *map_share;
  double *text_nhc;
  double *wdti,*wdti2,*wdti4,*wdti8,*wdti16;
  double **mass_nhc,**gkt;
} THERM_INFO;
typedef struct therm_pos{
  double **x_nhc,**v_nhc,**f_nhc;
  double x_nhc_tot;
} THERM_POS;
typedef struct vel_samp_class{
  int ivel_smpl_on;
  int ivel_scale_on;
  int nvx_smpl;
  int nvx_scale;
  int nvnhc_smpl;
  int iseed,iseed2;
  double qseed;
} VEL_SAMP_CLASS;
typedef struct energy_ctrl{
   int pme_on;
   int int_res_ter,int_res_tra;
   int isep_vvdw;
   int iswit_vdw;
   int block_std_on,block_con_on,nblock_min;
   int iget_pe_real_inter_freq;
   int iget_pe_real_inter,iget_pv_real_inter;
   int itime;
   int iget_full_inter,iget_res_inter;
   int iget_full_intra,iget_res_intra;
   int iget_full_pimd,iget_res_pimd;
} ENERGY_CTRL;
  typedef struct verlist{
    int iver_init;
    int iver_fill,iver_count;
    int nolst_ver_update,lnk_ver_update;
    int jver_pad;
    int nmem_min_lst;
    int nver_lst;
    int nver_lst_res;
    int nver_lst_now;
    int nver_lst_now_res;
    int *nter;
    int *jter;
    int *jver_off;
    int *nter_res;
    int *jter_res;
    int *jver_off_res;
    double mem_safe;
  }VERLIST;
typedef struct lnklist {
    int ilnk_init;
    int lnk_for_odd;
    int ncell_div_avg;
    int lnk_excl_safe;
    int lnk_vol_safe;
    int ncell_a,ncell_b,ncell_c;
    int natm_cell_max;
    int lnk_list_dim;
    int nshft_lnk;
    int nshft_lnk_res;
    double vol_lnk_map;
    double rcut_max,rcut_max_res,rexl_max;
    int *lnk_list;
    int *ishft_a,*ishft_b,*ishft_c;
    int *iexl_chk;
    int *ishft_a_res,*ishft_b_res,*ishft_c_res;
    int *iexl_chk_res;
    int *natm_cell;
    double *shft_wght;
    double *shft_wght_res;
    double *hmat_lnk,*hmati_lnk;
  }LNKLIST;
typedef struct brnch_root {
 int nbrnch_tot;
 int nroot_tot;
 int natm_add_tot;
 int nbrnch_root_max;
 double brnch_root_dist_max;
 double cutdif_min_brnch_root;
 double cutdif_min_brnch_brnch;
 double cutdif_min_brnch_root_res;
 double cutdif_min_brnch_brnch_res;
 double r2_nocheck_dist;
 double r2_nocheck_dist_res;
 double cutskin_bb_min;
 double cutskin_bb_min_res;
 int *brnch_atm_list;
 int *brnch_atm_root;
 int *root_atm_list;
 int *root_atm_map;
 int *brnch_atm_map;
 int *nbrnch_of_root_big;
 int *nbrnch_of_root;
 int **ibrnch_of_root;
 int *natm_add;
 int *iatm_add;
 int *iatm_add_off;
} BRNCH_ROOT;
typedef struct nbr_list {
  int iver;
  int ilnk;
  int nolst;
  int brnch_root_list_opt;
  double *x0,*y0,*z0;
  VERLIST verlist;
  LNKLIST lnklist;
  BRNCH_ROOT brnch_root;
} NBR_LIST;
typedef struct interact {
  int nsplin;
  int iswit_vdw;
  int dielectric_opt;
  int ishave_opt;
  int nter_typ;
  int nsplin_tot;
  int ninter_mall;
  int nsplin_mall_tot;
  int *inter_map_index;
  double dielectric_rheal;
  double dielectric_cut;
  double dielectric_eps;
  double brnch_root_skin;
  double skin;
  double brnch_root_cut;
  double rheal_res;
  double pten_inter_guess;
  double pten_kin_guess;
  double clong;
  double clong_res;
  double spread_now, spread;
  double spread_lnk;
  double brnch_root_skin_lnk;
  double cutoff_max;
  double *cutoff;
  double *cutoff_res;
  double *cutti;
  double *cutskin;
  double *cutskin_res;
  double *cutskin_root;
  double *cutskin_root_res;
  double *vcut_coul;
  double *rmin_spl;
  double *dr_spl,*dri_spl;
  double *cv0,*cv1,*cv2,*cv3;
  double *cdv0,*cdv1,*cdv2,*cdv3;
  double *cv0_c, *cv1_c,*cv2_c, *cv3_c;
  double *cdv0_c,*cdv1_c,*cdv2_c,*cdv3_c;
} INTERACT;
typedef struct therm_scr {
  double *sc;
  double *atm_kin;
}THERM_SCR;
typedef struct int_scr {
  double v_lnv;
  double *x,*y,*z;
  double *vx,*vy,*vz;
  double *gx,*gy,*gz;
  double **x_nhc,**v_nhc,**f_nhc;
  double *vgmat;
  double *x_vol_nhc,*v_vol_nhc,*f_vol_nhc;
  double *sc;
  double *sc_temp;
  double *atm_kin;
  double *step_up,*step_dn;
  THERM_SCR *therm_scr;
} INT_SCR;
typedef struct ewd_scr {
  double *q;
  double *x,*y,*z;
  double *fx,*fy,*fz;
  double *heli,*helr;
  double *cossc,*sinsc;
  double *fx2,*fy2,*fz2;
  double *temp;
  double *helr_now,*heli_now,*vtemp_now;
} EWD_SCR;
typedef struct for_scr {
  int nlen;
  int nsplin_t;
  int num_brk;
  int intact;
  double wght_lnk;
  double wght_ter;
  double wght_ter_res;
  double wght_tra;
  double wght_tra_res;
  double wght_pimd;
  int *j_indext,*i_indext;
  int *i_indext2;
  int *j_lnk,*i_lnk,*k_lnk;
  int *j_index,*i_index;
  int *num_brk_i;
  int *iexcl;
  int *index_atm;
} FOR_SCR;
typedef struct part_mesh{
  int pme_on;
  int kmax_pme;
  int n_interp;
  int pme_res_on;
  int kmax_pme_res;
  int n_interp_res;
  int pme_para_opt;
  int nlen_pme;
  int nktot_pme;
  int ngrid_a,ngrid_b,ngrid_c;
  int nktot_pme_res;
  int ngrid_a_res,ngrid_b_res,ngrid_c_res;
  int ninterp_mall;
  int ninterp_tot_mall;
  int *iatemp,*ibtemp,*ictemp;
  int *nc,*ioff_c;
  int **igrid_a,**igrid_b,**igrid_c;
  int **igrid_now;
  double ecut;
  double ecut_res;
  double *bweight_tot_res;
  double *bweight_tot;
  double *qgrid;
  double *qgrid_scr;
  double *qgrid_tmp_real;
  double *qgrid_tmp_imag;
  double *frac_a,*frac_b,*frac_c;
  double *aj,*rn,*rn1;
  double **ua,**ub,**uc;
  double **mn_a,**mn_b,**mn_c;
  double **dmn_a,**dmn_b,**dmn_c;
  double **qgrid_now;
} PART_MESH;
typedef struct surface {
  int isurf_on;
  int natm_typ;
  int nsplin_surf;
  int nsplin_tot;
  double zheal;
  double surface_height;
  double *surface_pot;
  double *surface_forc;
  double *zcut_off;
  double *dz_spl;
  double *dzi_spl;
  double *zmin_spl;
  NAME surface_type;
} SURFACE;
typedef struct class {
  CLATOMS_INFO clatoms_info;
  CLATOMS_TRAN clatoms_tran;
  CLATOMS_POS *clatoms_pos;
  GHOST_ATOMS ghost_atoms;
  ATOMMAPS atommaps;
  THERM_INFO therm_info_class;
  THERM_INFO therm_info_bead;
  THERM_POS therm_class;
  THERM_POS *therm_bead;
  VEL_SAMP_CLASS vel_samp_class;
  ENERGY_CTRL energy_ctrl;
  NBR_LIST nbr_list;
  INTERACT interact;
  INT_SCR int_scr;
  EWD_SCR ewd_scr;
  FOR_SCR for_scr;
  double tot_memory;
  PART_MESH part_mesh;
  SURFACE surface;
  COMMUNICATE communicate;
  CLASS_COMM_FORC_PKG class_comm_forc_pkg;
} CLASS;
typedef struct bond {
  int npow;
  int ntyp_pow;
  int ncon;
  int ntyp_con;
  int nbond_pow_mall;
  int nbond_typ_pow_mall;
  int nbond_con_mall;
  int nbond_typ_con_mall;
  int block_pow_on, block_con_on;
  int ncon_tot;
  int ncon_max;
  int nblock_pow, nblock_size_pow;
  int nblock_con, nblock_size_con;
  int *j1_pow,*j2_pow;
  int *jtyp_pow;
  int *j1_con,*j2_con;
  int *jtyp_con;
  int *iblock_pow_size;
  int *iblock_pow_conflict_1,*iblock_pow_conflict_2;
  int *iblock_con_size;
  int *iblock_con_conflict_1,*iblock_con_conflict_2;
  double *eq_pow;
  double *eq_pow_res;
  double *c_0,*c_1,*c_2,*c_3,*c_4,*c_5,*c_6;
  double *dc_0,*dc_1,*dc_2,*dc_3,*dc_4,*dc_5,*dc_6;
  double *al_con;
  double *eq_con;
} BOND;
typedef struct grp_bond_con {
  int num_33;
  int num_21;
  int num_43;
  int ntyp_33;
  int num_23;
  int ntyp_23,ntyp_21,ntyp_43;
  int num_46;
  int ntyp_46;
  int max_iter;
  int ngrp_21_mall;
  int ngrp_33_mall;
  int ngrp_43_mall;
  int ngrp_23_mall;
  int ngrp_46_mall;
  int ngrp_typ_21_mall;
  int ngrp_typ_33_mall;
  int ngrp_typ_43_mall;
  int ngrp_typ_23_mall;
  int ngrp_typ_46_mall;
  int num_21_tot,num_23_tot,num_33_tot,num_43_tot,num_46_tot;
  double tol;
  int *j1_33,*j2_33,*j3_33;
  int *j1_21,*j1_43,*j2_21;
  int *j2_43,*j3_43,*j4_43;
  int *jtyp_33,*jtyp_21,*jtyp_43;
  int *j1_23,*j2_23,*j3_23;
  int *jtyp_23;
  int *j1_46,*j2_46,*j3_46,*j4_46;
  int *jtyp_46;
  double **al_33,**eq_33;
  double **al_23,**eq_23;
  double **al_21,**al_43;
  double **eq_21,**eq_43;
  double **al_46,**eq_46;
  int ncons_gather_tot;
  int ncons_gather;
  int ncons_gather_max;
  int *ind_gather_fwd;
  int *ind_gather_bck;
  int *ind_gather_scr;
} GRP_BOND_CON;
typedef struct grp_bond_watts {
  int num_33;
  int num_33_tot;
  int ntyp_33;
  int ngrp_33_mall;
  int ngrp_typ_33_mall;
  int *j1_33,*j2_33,*j3_33;
  int *jtyp_33;
  double *cos_thet0_2,*sin_thet0_2;
  double **eq_33;
  double **c_0_33,**c_1_33,**c_2_33,**c_3_33;
  double **c_4_33,**c_5_33,**c_6_33;
  double **dc_0_33,**dc_1_33,**dc_2_33,**dc_3_33;
  double **dc_4_33,**dc_5_33,**dc_6_33;
} GRP_BOND_WATTS;
typedef struct constrnt{
  int iconstrnt;
  int iroll;
  int max_iter;
  double tolshake;
  double tolratl;
} CONSTRNT;
typedef struct bond_free {
  int num;
  int j1,j2;
  int npow;
  int nhist;
  double fk;
  double eq;
  double del;
  double rmin;
  double rmax;
  char *file;
  double *hist;
} BOND_FREE;
typedef struct bend {
  int npow;
  int ntyp_pow;
  int ncon;
  int ntyp_con;
  int nbend_pow_mall;
  int nbend_typ_pow_mall;
  int nbend_con_mall;
  int nbend_typ_con_mall;
  int block_pow_on,block_con_on;
  int ncon_tot;
  int nblock_pow, nblock_size_pow;
  int nblock_con, nblock_size_con;
  int *j1_pow,*j2_pow,*j3_pow;
  int *jtyp_pow;
  int *j1_con,*j2_con,*j3_con;
  int *jtyp_con;
  int *iblock_pow_size;
  int *iblock_pow_conflict_1,*iblock_pow_conflict_2;
  int *iblock_pow_conflict_3;
  int *iblock_con_size;
  int *iblock_con_conflict_1,*iblock_con_conflict_2;
  int *iblock_con_conflict_3;
  double *eq_pow;
  double *c_0,*c_1,*c_2,*c_3,*c_4,*c_5,*c_6;
  double *s_0,*s_1,*s_2,*s_3,*s_4,*s_5,*s_6;
  double *dc_0,*dc_1,*dc_2,*dc_3,*dc_4,*dc_5,*dc_6;
  double *ds_0,*ds_1,*ds_2,*ds_3,*ds_4,*ds_5,*ds_6;
  double *al_con;
  double *eq_con;
} BEND;
typedef struct bend_free {
  int num;
  int j1,j2,j3;
  int npow;
  int nhist;
  double fk;
  double eq;
  double del;
  char *file;
  double *hist;
} BEND_FREE;
typedef struct bend_bnd {
  int num;
  int ntyp;
  int nbend_bnd_mall;
  int nbend_bnd_typ_mall;
  int block_on;
  int nblock,nblock_size;
  int *j1,*j2,*j3;
  int *jtyp;
  int *iblock_size;
  int *iblock_conflict_1,*iblock_conflict_2;
  int *iblock_conflict_3;
  double *eq_bond;
  double *eq_bend;
  double *cbond_0,*cbond_1,*cbond_2,*cbond_3,*cbond_4,*cbond_5,*cbond_6;
  double *dcbond_0,*dcbond_1,*dcbond_2,*dcbond_3,*dcbond_4,*dcbond_5,*dcbond_6;
  double *cbend_0,*cbend_1,*cbend_2,*cbend_3,*cbend_4,*cbend_5,*cbend_6;
  double *sbend_0,*sbend_1,*sbend_2,*sbend_3,*sbend_4,*sbend_5,*sbend_6;
  double *dcbend_0,*dcbend_1,*dcbend_2,*dcbend_3,*dcbend_4,*dcbend_5,*dcbend_6;
  double *dsbend_0,*dsbend_1,*dsbend_2,*dsbend_3,*dsbend_4,*dsbend_5,*dsbend_6;
} BEND_BND;
typedef struct tors {
  int npow;
  int ntyp_pow;
  int nimpr;
  int ncon;
  int ntyp_con;
  int ntors_pow_mall;
  int ntors_typ_pow_mall;
  int ntors_con_mall;
  int ntors_typ_con_mall;
  int block_pow_on;
  int block_con_on;
  int ncon_tot;
  int nblock_pow,nblock_size_pow;
  int nblock_con,nblock_size_con;
  int *j1_pow,*j2_pow,*j3_pow,*j4_pow;
  int *jtyp_pow;
  int *j1_con,*j2_con,*j3_con,*j4_con;
  int *jtyp_con;
  int *iblock_pow_size;
  int *iblock_pow_conflict_1,*iblock_pow_conflict_2;
  int *iblock_pow_conflict_3,*iblock_pow_conflict_4;
  int *iblock_con_size;
  int *iblock_con_conflict_1,*iblock_con_conflict_2;
  int *iblock_con_conflict_3,*iblock_con_conflict_4;
  double *c_0,*c_1,*c_2,*c_3,*c_4,*c_5,*c_6;
  double *s_0,*s_1,*s_2,*s_3,*s_4,*s_5,*s_6;
  double *dc_0,*dc_1,*dc_2,*dc_3,*dc_4,*dc_5,*dc_6;
  double *ds_0,*ds_1,*ds_2,*ds_3,*ds_4,*ds_5,*ds_6;
  double *eq_pow;
  double *al_con;
  double *eq_con;
} TORS;
typedef struct tors_free {
  int num;
  int npow;
  int nhist;
  int j1[3],j2[3],j3[3],j4[3];
  double fk;
  double eq[3];
  double del;
  char *file;
  double *hist;
  double **hist_2d;
} TORS_FREE;
typedef struct rbar_sig_free {
  int nfree;
  int nhist_bar,nhist_sig;
  int iopt;
  int *j1,*j2;
  double fk_bar;
  double fk_sigma;
  double eq_bar;
  double eq_sigma;
  double del_bar,del_sig;
  double rmin,rmax;
  double smin,smax;
  double rnfree;
  double **hist;
  double **hist_rn;
  char *file;
} RBAR_SIG_FREE;
typedef struct onfo{
  int num;
  int ntyp;
  int nonfo_mall;
  int nonfo_typ_mall;
  int block_on;
  int nblock, nblock_size;
  int *j1,*j2;
  int *jtyp;
  int *iblock_size;
  int *iblock_conflict_1,*iblock_conflict_2;
  double *feps;
  double *s6;
  double *sc;
} ONFO;
typedef struct ecor{
  int nsplin,nsplin_m2;
  int num;
  int block_on;
  int nblock, nblock_size;
  int nktot_res;
  int necor_mall;
  double alp_ewd;
  double ecut,ecut_res;
  double rmin_spl;
  double rmax_spl;
  double dr_spl,dri_spl;
  int *j1,*j2;
  int *iblock_size;
  int *iblock_conflict_1,*iblock_conflict_2;
  double *cv0,*cdv0,*cdv0_res;
} ECOR;
typedef struct excl {
  int nlst;
  int nlst_root;
  int num_cp;
  int *num,*num_root;
  int *j,*j_root;
  int *j_off,*j_off_root;
  int *j1_cp,*j2_cp;
} EXCL;
typedef struct intra_scr{
  int nlen;
  double wght_ter;
  double wght_ter_res;
  double wght_tra;
  double wght_tra_res;
  double int_res_inter;
  int *iatm_typ;
  int *jatm_typ;
  double *vpot;
  double *p11,*p12,*p13;
  double *p21,*p22,*p23;
  double *p31,*p32,*p33;
  double *x1,*y1,*z1;
  double *x2,*y2,*z2;
  double *x3,*y3,*z3;
  double *x4,*y4,*z4;
  double *x5,*y5,*z5;
  double *x6,*y6,*z6;
  double *x7,*y7,*z7;
  double *x8,*y8,*z8;
  double *fx1,*fy1,*fz1;
  double *fx2,*fy2,*fz2;
  double *fx3,*fy3,*fz3;
  double *fx4,*fy4,*fz4;
  double *dx12,*dy12,*dz12;
  double *dx13,*dy13,*dz13;
  double *dx23,*dy23,*dz23;
  double *dx42,*dy42,*dz42;
  double *dx43,*dy43,*dz43;
  double *dx56,*dy56,*dz56;
  double *dx57,*dy57,*dz57;
  double *dx67,*dy67,*dz67;
  double *dx86,*dy86,*dz86;
  double *dx87,*dy87,*dz87;
  double *c_0,*c_1,*c_2,*c_3,*c_4,*c_5,*c_6;
  double *dc_0,*dc_1,*dc_2,*dc_3,*dc_4,*dc_5,*dc_6;
  double *ds_0,*ds_1,*ds_2,*ds_3,*ds_4,*ds_5,*ds_6;
  double *s_0,*s_1,*s_2,*s_3,*s_4,*s_5,*s_6;
  double *eq;
  double *m1,*m2;
  double *vx1,*vy1,*vz1;
  double *vx2,*vy2,*vz2;
  double *sc_1, *sc_2;
  double *sc,*feps,*s6;
  double *q1,*q2;
  double *rmin, *dr, *cutoff;
  double *dri;
  double *vcut_coul,*r, *r3;
  double *del_r,*del_rc;
  double *swit,*cut,*spl_tmp;
  double *cutoff_res;
} INTRA_SCR;
typedef struct bonded {
  BOND bond;
  GRP_BOND_CON grp_bond_con;
  GRP_BOND_WATTS grp_bond_watts;
  CONSTRNT constrnt;
  BOND_FREE bond_free;
  BEND bend;
  BEND_FREE bend_free;
  BEND_BND bend_bnd;
  TORS tors;
  TORS_FREE tors_free;
  RBAR_SIG_FREE rbar_sig_free;
  ONFO onfo;
  ECOR ecor;
  EXCL excl;
  INTRA_SCR intra_scr;
} BONDED;
typedef struct statepoint{
  double pext,t_ext, stens_ext;
} STATEPOINT;
typedef struct cell{
  int iperd;
  int intra_perds;
  int cubic_box_flag;
  int hmat_int_typ;
  int hmat_cons_typ;
  int imov_cp_box;
  double vol;
  double vol_cp;
  double vol0;
  double area;
  double alpha_conv_dual;
  double *hmat,*hmati;
  double *hmat_ewd,*hmat_ewd_cp;
  double *hmat_cp,*hmati_cp;
  double *cp_box_center;
  double *cp_box_center_rel;
  double *cp_vbox_center;
  double *cp_fbox_center;
} CELL;
typedef struct timeinfo{
  int ntime,itime;
  int ix_respa;
  int int_res_ter,int_res_tra;
  int nres_ter,nres_tra;
  int int_res_tor,nres_tor;
  int int_res_pimd,nres_pimd;
  int iget_pe_real_inter_freq;
  int exit_flag;
  double dt;
} TIMEINFO;
typedef struct baro {
  int len_nhc;
  double x_lnv,v_lnv;
  double v_lnv_glob;
  double v_lnv_g;
  double f_lnv_p,f_lnv_v;
  double vol;
  double mass_lnv;
  double c2_lnv;
  double roll_scv;
  double roll_scg;
  double roll_scg0;
  double x_lnv_o;
  double v_lnv_g_wght;
  double area;
  double *x_vol_nhc,*v_vol_nhc;
  double *f_vol_nhc,*mass_vol_nhc,*gkt_vol;
  double *hmato;
} BARO;
typedef struct par_rahman{
  double vol;
  double mass_hm;
  double c1_hm;
  double roll_scg;
  double roll_scg0;
  double area;
  double *vgmat,*vgmat_g;
  double *vgmat_glob;
  double *fgmat_p,*fgmat_v;
  double *roll_mtv,*roll_mtx;
  double *roll_mtvv;
  double *vtemps,*veigv,*veig;
  double *vexpdt,*vsindt;
  double *vtempx, *vtempv;
  double *hmat_t, *hmato;
  double *fv1,*fv2;
  double *vgmat_g_wght;
} PAR_RAHMAN;
typedef struct ptens {
  double *tvten;
  double *pvten,*pvten_tot;
  double *pvten_inc,*pvten_tmp;
  double *pvten_tmp_res ;
  double *pvten_inc_t1,*pvten_inc_t2,*pvten_inc_t3,*pvten_inc_t4;
  double *pvten_inc_a;
  double *pvten_inc_old;
  double *count_inc;
  double *pvten_inc_glob,*pvten_inc_whol,*pvten_inc_std;
  double *pvten_mode,*pvten_mode_tot;
} PTENS;
typedef struct stat_avg {
  int nexclt;
  int iter_shake, iter_ratl;
  int iswit_vdw;
  int itime_update,itime_update_w;
  int iter_shake_cp,iter_ratl_cp;
  int write_cp_atm_flag;
  double vintert,aivintert,avintert;
  double vintrat,aivintrat,avintrat;
  double vsurft;
  double vbondt,vbendt,vtorst,vonfot;
  double vbend_bndt;
  double vbend_bnd_bond,vbend_bnd_bend;
  double vbondt_watts,vbendt_watts,vtot_watts;
  double vreal,vrecip;
  double vvdw,vcoul;
  double vlong;
  double vbond_free,vbend_free,vtors_free;
  double vbar_free;
  double kinet,aikinet,akinet;
  double kinet_v,aikinet_v,akinet_v;
  double vol,aivol,avol;
  double kinet_nhc,aikinet_nhc,akinet_nhc;
  double kinet_nhc_bead;
  double aikinet_nhc_bead;
  double akinet_nhc_bead;
  double vpot_v;
  double vpotnhc;
  double aiter_shake,aiter_ratl;
  double iter_23, iter_33, iter_46, iter_43, iter_21;
  double aiter_23,aiter_33, aiter_46;
  double aiter_21,aiter_43;
  double iter_23r, iter_33r, iter_46r, iter_43r, iter_21r;
  double aiter_23r,aiter_33r, aiter_46r;
  double aiter_21r,aiter_43r;
  double acella,acellb,acellc;
  double aicella,aicellb,aicellc;
  double acellab,acellbc,acellac;
  double aicellab,aicellbc,aicellac;
  double apress,aipress;
  double press_inter,press_intra;
  double apress_inter,aipress_inter;
  double apress_intra,aipress_intra;
  double press_kin;
  double apress_kin,aipress_kin;
  double econv0,econv;
  double cp_kconv0,cp_kconv;
  double cpu1,cpu2,acpu,cpu_now;
  double updates,updates_w;
  double kinet_cp_up,aikinet_cp_up,akinet_cp_up;
  double kinet_cp_dn,aikinet_cp_dn,akinet_cp_dn;
  double kinet_cp,aikinet_cp,akinet_cp;
  double kinet_nhc_cp,aikinet_nhc_cp,akinet_nhc_cp;
  double vpotnhc_cp;
  double cp_ehart,aicp_ehart,acp_ehart;
  double cp_eext,aicp_eext,acp_eext;
  double cp_exc,aicp_exc,acp_exc;
  double cp_muxc;
  double cp_eke,aicp_eke,acp_eke;
  double cp_enl,aicp_enl,acp_enl;
  double aiter_shake_cp,aiter_ratl_cp;
  double maxfc,maxf;
  double pi_ke_prim,pi_ke_vir;
  double api_ke_prim,api_ke_vir;
  double aipi_ke_prim,aipi_ke_vir;
  double kin_harm,akin_harm,aikin_harm;
  double *apten, *aipten, *apten_out;
  double fc_mag_up,fc_mag_dn;
  double fc_max_up,fc_max_dn;
  double fatm_max,fatm_mag;
  double count_diag_srot;
  double econv_now;
  double isokconv,isokconv_now, isok0;
} STAT_AVG;
typedef struct ewald {
  int nsplin_g;
  int nktot;
  int nktot_res;
  int nktot_mall;
  int nktot_res_mall;
  int nkc_max;
  int nkb_max;
  double alp_ewd;
  double self_erf;
  double ecut,ecut_res;
  double ecut_clus;
  double alp_clus;
  double gs_max;
  int *kastr,*kbstr,*kcstr;
  int *ibrk1,*ibrk2,*ibrk3;
  int *kastr_res,*kbstr_res,*kcstr_res;
  int *ibrk1_res,*ibrk2_res;
  double *clus_corr_r,*dclus_corr_r;
  double *clus_corr_r_res,*dclus_corr_r_res;
  double *cvgs_2d0,*cvgs_2d1,*cvgs_2d2,*cvgs_2d3,*vgc_2d;
  double *vgc_1d_y,*vgc_1d_z;
} EWALD;
typedef struct simopts {
  int md;
  int pimd;
  int minimize;
  int cp;
  int cp_pimd;
  int cp_wave;
  int cp_wave_pimd;
  int cp_wave_min_pimd;
  int cp_min;
  int cp_wave_min;
  int debug;
  int debug_pimd;
  int debug_cp;
  int debug_cp_pimd;
  int pi_beads;
  int pi_md_typ;
  int initial_spread_opt;
  int anneal_opt;
  double ann_rate;
  double ann_start_temp;
  double ann_target_temp;
} SIMOPTS;
typedef struct minopts {
  int min_std;
  int min_cg;
  int min_diis;
  int diis_hist_len;
  int cp_min_std;
  int cp_min_cg;
  int cp_min_diis;
  int cp_diis_hist_len;
  int cp_cg_line_min_len;
  int min_atm_com_fix_opt;
  double tol_coef;
  double tol_atom;
} MINOPTS;
typedef struct ensopts{
  int nve,nvt,nvt_isok,npt_i,npt_f,nst;
} ENSOPTS;
typedef struct filenames {
  char *iname;
  char *dname;
  char *dnamec;
  char *cpname;
  char *ksname;
  char *elfname;
  char *cvname;
  char *ccname;
  char *cpparname;
  char *centname;
  char *forcename;
  int low_lim_par;
  int high_lim_par;
  int iwrite_screen;
  int iwrite_inst;
  int iwrite_dump;
  int iwrite_kseigs;
  int iwrite_confv;
  int iwrite_confp;
  int iwrite_par_confp;
  int iwrite_confc;
  int iwrite_path_cent;
  int ifile_open;
  int iwrite_conf_binary;
  int iwrite_units;
  int iwrite_atm_for;
  int iwrite_elf;
} FILENAMES;
typedef struct para_fft_pkg3d {
   int nktot,ncoef,ncoef_proc;
   int ncoef_use,icoef_off,icoef_strt;
   int nfft_size;
   int nfft,nfft_proc;
   int igeneric_opt;
   int scale_opt;
   int len_ifax;
   int nwork1,nwork2;
   double ecut;
   int comm;
   int num_proc,myid,myidp1;
   int *map_proc,*map_c_proc,*map_proc_post;
  int *recv_counts_rho,*displs_rho;
  int *recv_counts_coef,*recv_dspls_coef;
  int *map_pme_dn,nrecv_dn;
  int *recvcounts_pme_dn,*recvdspls_pme_dn;
  int *sendcounts_pme_dn,*senddspls_pme_dn;
  int *map_pme_up,nrecv_up,nrecv_up_max;
  int *recvcounts_pme_up,*recvdspls_pme_up;
  int *sendcounts_pme_up,*senddspls_pme_up;
   int ndata_kc;
   int nkf3,nfft_kc,nfft_kc_proc;
   int str_fft_kc_proc,end_fft_kc_proc;
   int ska_fft_kc_proc,eka_fft_kc_proc;
   int skb_fft_kc_proc,ekb_fft_kc_proc;
   int *sendcounts_fft_kc,*senddspls_fft_kc;
   int *recvcounts_fft_kc,*recvdspls_fft_kc;
   int *sum_fft_kc_proc;
   int nka_fft_kc, *nkb_fft_kc;
   int *ka_fft_kc,*kb_fft_kc,*ka_fft_kc_red;
   int *ifax_c_f,*ifax_c_r;
   double *work_1c_f,*work_2c_f;
   double *work_1c_r,*work_2c_r;
   int ndata_kb;
   int nkf2, nfft_kb,nfft_kb_proc;
   int str_fft_kb_proc,end_fft_kb_proc;
   int ska_fft_kb_proc,eka_fft_kb_proc;
   int skc_fft_kb_proc,ekc_fft_kb_proc;
   int *ska_fft_kb_proc_all,*eka_fft_kb_proc_all;
   int *skc_fft_kb_proc_all,*ekc_fft_kb_proc_all;
   int *sendcounts_fft_kb,*senddspls_fft_kb;
   int *recvcounts_fft_kb,*recvdspls_fft_kb;
   int *sum_fft_kb_proc;
   int *ifax_b_f,*ifax_b_r;
   double *work_1b_f,*work_2b_f;
   double *work_1b_r,*work_2b_r;
   int ndata_ka;
   int nkf1,nfft_ka,nfft_ka_proc;
   int str_fft_ka_proc,end_fft_ka_proc;
   int skb_fft_ka_proc,ekb_fft_ka_proc;
   int skc_fft_ka_proc,ekc_fft_ka_proc;
   int *skb_fft_ka_proc_all,*ekb_fft_ka_proc_all;
   int *skc_fft_ka_proc_all,*ekc_fft_ka_proc_all;
   int *sendcounts_fft_ka,*senddspls_fft_ka;
   int *recvcounts_fft_ka,*recvdspls_fft_ka;
   int *ifax_a_f,*ifax_a_r;
   double *work_1a_f,*work_2a_f;
   double *work_1a_r,*work_2a_r;
   int *send_counts_row_big_small;
   int *recv_counts_row_big_small;
   int *sdispls_row_big_small;
   int *rdispls_row_big_small;
   int *send_counts_dual_map;
   int *recv_counts_dual_map;
   int *sdispls_dual_map;
   int *rdispls_dual_map;
   int *send_counts_row_big_small_upack;
   int *recv_counts_row_big_small_upack;
   int *sdispls_row_big_small_upack;
   int *rdispls_row_big_small_upack;
   int *send_counts_dual_map_upack;
   int *recv_counts_dual_map_upack;
   int *sdispls_dual_map_upack;
   int *rdispls_dual_map_upack;
   int *send_counts_ioff_big_small;
   int *recv_counts_ioff_big_small;
   int *sdispls_ioff_big_small;
   int *rdispls_ioff_big_small;
 } PARA_FFT_PKG3D;
typedef struct general_data {
  SIMOPTS simopts;
  MINOPTS minopts;
  ENSOPTS ensopts;
  FILENAMES filenames;
  STATEPOINT statepoint;
  CELL cell;
  TIMEINFO timeinfo;
  BARO baro;
  PAR_RAHMAN par_rahman;
  PTENS ptens;
  STAT_AVG stat_avg;
  EWALD ewald;
  PARA_FFT_PKG3D pme_fft_pkg;
  PARA_FFT_PKG3D pme_res_fft_pkg;
  int error_check_on;
} GENERAL_DATA;
   int iii;
    int i,ipart,iflag;
    int ifirst = 1;
    int exit_flag = 0;
    double dt,dti,dt2,tol_glob;
    int natm_tot,ichain,inhc;
    int iflag_mass = 1;
    double ann_rate = general_data->simopts.ann_rate;
    int num_nhc = class->therm_info_class.num_nhc;
    int len_nhc = class->therm_info_class.len_nhc;
    int ir_tra = 1;
    int ir_tor = 1;
    int ir_ter = 1;
    int anneal_opt = general_data->simopts.anneal_opt;
    double anneal_target_temp = general_data->simopts.ann_target_temp;
    double **therm_gkt = class->therm_info_class.gkt;
    double **therm_mass = class->therm_info_class.mass_nhc;
    double *class_clatoms_vx = class->clatoms_pos[1].vx;
    double *class_clatoms_vy = class->clatoms_pos[1].vy;
    double *class_clatoms_vz = class->clatoms_pos[1].vz;
    double *class_clatoms_fx = class->clatoms_pos[1].fx;
    double *class_clatoms_fy = class->clatoms_pos[1].fy;
    double *class_clatoms_fz = class->clatoms_pos[1].fz;
    double *class_clatoms_mass = class->clatoms_info.mass;
    double cst1,cst2,cst3;
    double **therm_v2 = class->therm_class.v_nhc;
    double **therm_v1 = class->therm_class.x_nhc;
    int *inhc_x = class->therm_info_class.inhc_x;
    int *inhc_y = class->therm_info_class.inhc_y;
    int *inhc_z = class->therm_info_class.inhc_z;
    double lennhc = (double)len_nhc;
    natm_tot = class->clatoms_info.natm_tot;
    (general_data->timeinfo.int_res_tra) = 0;
    (general_data->timeinfo.int_res_ter) = 0;
    dt = (general_data->timeinfo.dt);
    dti = dt;
    dt2 = dt/2.0;
    class->therm_info_class.dt_nhc = dt;
    class->therm_info_class.dti_nhc = dt/( (double)(
                             class->therm_info_class.nres_nhc) );
    set_yosh(class->therm_info_class.nyosh_nhc,
             class->therm_info_class.dti_nhc,class->therm_info_class.wdti,
             class->therm_info_class.wdti2,class->therm_info_class.wdti4,
             class->therm_info_class.wdti8,
             class->therm_info_class.wdti16);
    zero_constrt_iters(&(general_data->stat_avg));
    general_data->timeinfo.exit_flag = 0;
    int_0_to_dt2_nvt_isok(class,bonded,general_data,ir_tra,ir_tor,ir_ter,dt);
    (class->energy_ctrl.iget_full_inter)= 1;
    (class->energy_ctrl.iget_res_inter) = 0;
    (class->energy_ctrl.iget_full_intra)= 1;
    (class->energy_ctrl.iget_res_intra) = 0;
    energy_control(class,bonded,general_data);
    int_dt2_to_dt_nvt_isok(class,bonded,general_data,ir_tra,ir_tor,ir_ter,dt);
  iflag=0;
  if(anneal_opt == 1){
    anneal_class(class,ann_rate,iflag,iflag_mass,anneal_target_temp,&exit_flag);
    general_data->timeinfo.exit_flag = exit_flag;
  }
   int_final_class(class,bonded,general_data,iflag);
               }

canonical_original_code:
void int_NVT_ISOK(struct class *class, struct bonded *bonded, struct general_data *general_data)
{
typedef struct communicate{
  int np_beads,np_states,np_forc,np_forc_trg,np_forc_src;
  int myid,np;
  int myid_bead_forc;
  int myid_bead;
  int myid_bead_prime;
  int myid_state;
  int myid_forc;
  int myid_forc_source;
  int myid_forc_target;
  int world;
  int comm_beads;
  int comm_beads_forc;
  int comm_states;
  int comm_forc;
  int comm_forc_source;
  int comm_forc_target;
  int comm_faux;
} COMMUNICATE;
typedef char NAME[50];
typedef char LINE[100];
typedef struct class_plimpton_ind {
   int num_proc_source;
   int num_proc_target;
   int myid_source;
   int myid_target;
  int natoms_tot;
   int *index_src;
   int *index_src_even;
   int *index_src_odd;
   int *index_trg;
   int *index_trg_even;
   int *index_trg_odd;
   int *displs_atm_trg,*counts_atm_trg;
   int *displs_atm_src,*counts_atm_src;
   int *src_odd_end;
   int *src_even_end;
   int *trg_odd_end;
   int *trg_even_end;
   int *src_odd_begin;
   int *src_even_begin;
   int *trg_odd_begin;
   int *trg_even_begin;
   int my_src_odd_counts;
   int my_src_even_counts;
   int my_trg_odd_counts;
   int my_trg_even_counts;
   int *my_src_odd;
   int *my_src_even;
   int *my_trg_odd;
   int *my_trg_even;
   int **jmax;
   int *jmin;
   int **imax;
   int source;
   int target;
} CLASS_PLIMPTON_IND;
typedef struct class_comm_forc_pkg {
   int num_proc;
   int myid;
   int myatm_start,myatm_end;
   int mytherm_start,mytherm_end;
   int *displs_atm,*recv_count_atm;
   int *displs_therm,*recv_count_therm;
   int comm;
   int world;
   double dbl_num_proc;
  CLASS_PLIMPTON_IND plimpton_ind;
} CLASS_COMM_FORC_PKG;
typedef struct clatoms_info{
  int natm_tot;
  int pi_beads;
  int pi_beads_proc;
  int pi_beads_proc_st;
  int pi_beads_proc_end;
  int nfree;
  int nfree_pimd;
  int nchrg;
  int pi_beads_full_ter;
  int pi_beads_res_ter;
  int pi_beads_full_tra;
  int pi_beads_res_tra;
  int cg_reset_flag;
  int natm_mall;
  int nchrg_mall;
  int hess_calc;
  int natm_proc;
  int N_H2;
  int i_H2_start;
  int nab_initio;
  int myatm_start,myatm_end;
  double gamma_adb;
  double wght_pimd;
  double pi_temperature;
  double pi_beads_full_ter_wght;
  double pi_beads_res_ter_wght;
  double pi_beads_full_tra_wght;
  double pi_beads_res_tra_wght;
  double rcut_spread;
  double mass_sc_fact;
  int *ip_lab;
  int *ichrg;
  int *cp_vlnc_up,*cp_vlnc_dn;
  int *cp_atm_flag;
  double *mass;
  double *q;
  double *alp_pol;
  double *b_neut;
  double *roll_sc;
  double *text_atm;
  double *text_mol;
  double *xold,*yold,*zold;
  double *prekf;
  double *xmod,*ymod,*zmod;
  double alp_ewd;
} CLATOMS_INFO;
typedef struct clatoms_tran{
  int pi_beads_proc;
  int pi_atm_proc;
  int pi_atm_proc_use;
  int pi_proc_rem;
  int nwork;
  int *sendcounts,*recvcounts;
  int *senddspls,*recvdspls;
  int *ifax;
  double *rat1_stag,*rat2_stag;
  double *path_eig;
  double *work,*work2;
  double *work3,*work4;
  double *x_trans,*y_trans,*z_trans;
  double *x_temp,*y_temp,*z_temp;
  double *xt_temp,*yt_temp,*zt_temp;
} CLATOMS_TRAN;
typedef struct clatoms_pos{
  double *mass;
  double *x,*y,*z;
  double *vx,*vy,*vz;
  double *fx,*fy,*fz;
  double *fxt,*fyt,*fzt;
  double *fxm,*fym,*fzm;
  double *hess_xx,*hess_xy,*hess_xz,*hess_yy,*hess_yz,*hess_zz;
} CLATOMS_POS;
typedef struct ghost_atoms{
  int nghost_tot;
  int natm_comp_max;
  int nghost_mall;
  int nghost_old;
  int ncomp_mall;
  int ncomp_old;
  int *ighost_map;
  int *natm_comp;
  int **iatm_comp;
  double **coef;
} GHOST_ATOMS;
typedef struct atommaps{
  int nmol_typ;
  int nres_typ;
  int natm_typ;
  int nfreeze;
  int nfreeze_mall;
  int natm_typ_mall;
  int nres_typ_max;
  int nres_max;
  int nres_tot;
  int nres_sum;
  int pimd_freez_typ;
  NAME *atm_typ;
  NAME *res_typ;
  NAME *mol_typ;
  int *nmol_jmol_typ;
  int *nres_1mol_jmol_typ;
  int *jatm_jmol_typ_strt;
  int *jres_jmol_typ_strt;
  int *ires_typ_jres_jmol_typ;
  int *jatm_jres_1mol_jmol_typ_strt;
  int *natm_1mol_jmol_typ;
  int *natm_jres_jmol_typ;
  int *nfree_1mol_jmol_typ;
  int *nfree_jres_jmol_typ;
  int *icons_jmol_typ;
  int *icons_jres_jmol_typ;
  int *natm_jmol_typ;
  int *iatm_mol_typ;
  int *iatm_res_typ;
  int *iatm_atm_typ;
  int *iatm_atm_typ_nl;
  int *iatm_atm_typ_nl_rev;
  int *imap_atm_typ_nl;
  int *imap_atm_typ_nl_gh;
  int *iatm_mol_num;
  int *iatm_proc_num;
  int *iatm_res_num;
  int *ighost_flag;
  int *freeze_flag;
  int *freeze_map;
  int *atom_label;
  int *cp_atm_lst;
} ATOMMAPS;
typedef struct therm_info{
  int num_nhc;
  int len_nhc;
  int nres_nhc;
  int nyosh_nhc;
  int therm_typ;
  int num_nhc_proc;
  int num_nhc_share;
  int mytherm_start,mytherm_end;
  double dt_nhc,dti_nhc,wght;
  int *inhc_x,*inhc_y,*inhc_z;
  int *itherm_nshare;
  double *ditherm_nshare_i;
  int *map_share;
  double *text_nhc;
  double *wdti,*wdti2,*wdti4,*wdti8,*wdti16;
  double **mass_nhc,**gkt;
} THERM_INFO;
typedef struct therm_pos{
  double **x_nhc,**v_nhc,**f_nhc;
  double x_nhc_tot;
} THERM_POS;
typedef struct vel_samp_class{
  int ivel_smpl_on;
  int ivel_scale_on;
  int nvx_smpl;
  int nvx_scale;
  int nvnhc_smpl;
  int iseed,iseed2;
  double qseed;
} VEL_SAMP_CLASS;
typedef struct energy_ctrl{
   int pme_on;
   int int_res_ter,int_res_tra;
   int isep_vvdw;
   int iswit_vdw;
   int block_std_on,block_con_on,nblock_min;
   int iget_pe_real_inter_freq;
   int iget_pe_real_inter,iget_pv_real_inter;
   int itime;
   int iget_full_inter,iget_res_inter;
   int iget_full_intra,iget_res_intra;
   int iget_full_pimd,iget_res_pimd;
} ENERGY_CTRL;
  typedef struct verlist{
    int iver_init;
    int iver_fill,iver_count;
    int nolst_ver_update,lnk_ver_update;
    int jver_pad;
    int nmem_min_lst;
    int nver_lst;
    int nver_lst_res;
    int nver_lst_now;
    int nver_lst_now_res;
    int *nter;
    int *jter;
    int *jver_off;
    int *nter_res;
    int *jter_res;
    int *jver_off_res;
    double mem_safe;
  }VERLIST;
typedef struct lnklist {
    int ilnk_init;
    int lnk_for_odd;
    int ncell_div_avg;
    int lnk_excl_safe;
    int lnk_vol_safe;
    int ncell_a,ncell_b,ncell_c;
    int natm_cell_max;
    int lnk_list_dim;
    int nshft_lnk;
    int nshft_lnk_res;
    double vol_lnk_map;
    double rcut_max,rcut_max_res,rexl_max;
    int *lnk_list;
    int *ishft_a,*ishft_b,*ishft_c;
    int *iexl_chk;
    int *ishft_a_res,*ishft_b_res,*ishft_c_res;
    int *iexl_chk_res;
    int *natm_cell;
    double *shft_wght;
    double *shft_wght_res;
    double *hmat_lnk,*hmati_lnk;
  }LNKLIST;
typedef struct brnch_root {
 int nbrnch_tot;
 int nroot_tot;
 int natm_add_tot;
 int nbrnch_root_max;
 double brnch_root_dist_max;
 double cutdif_min_brnch_root;
 double cutdif_min_brnch_brnch;
 double cutdif_min_brnch_root_res;
 double cutdif_min_brnch_brnch_res;
 double r2_nocheck_dist;
 double r2_nocheck_dist_res;
 double cutskin_bb_min;
 double cutskin_bb_min_res;
 int *brnch_atm_list;
 int *brnch_atm_root;
 int *root_atm_list;
 int *root_atm_map;
 int *brnch_atm_map;
 int *nbrnch_of_root_big;
 int *nbrnch_of_root;
 int **ibrnch_of_root;
 int *natm_add;
 int *iatm_add;
 int *iatm_add_off;
} BRNCH_ROOT;
typedef struct nbr_list {
  int iver;
  int ilnk;
  int nolst;
  int brnch_root_list_opt;
  double *x0,*y0,*z0;
  VERLIST verlist;
  LNKLIST lnklist;
  BRNCH_ROOT brnch_root;
} NBR_LIST;
typedef struct interact {
  int nsplin;
  int iswit_vdw;
  int dielectric_opt;
  int ishave_opt;
  int nter_typ;
  int nsplin_tot;
  int ninter_mall;
  int nsplin_mall_tot;
  int *inter_map_index;
  double dielectric_rheal;
  double dielectric_cut;
  double dielectric_eps;
  double brnch_root_skin;
  double skin;
  double brnch_root_cut;
  double rheal_res;
  double pten_inter_guess;
  double pten_kin_guess;
  double clong;
  double clong_res;
  double spread_now, spread;
  double spread_lnk;
  double brnch_root_skin_lnk;
  double cutoff_max;
  double *cutoff;
  double *cutoff_res;
  double *cutti;
  double *cutskin;
  double *cutskin_res;
  double *cutskin_root;
  double *cutskin_root_res;
  double *vcut_coul;
  double *rmin_spl;
  double *dr_spl,*dri_spl;
  double *cv0,*cv1,*cv2,*cv3;
  double *cdv0,*cdv1,*cdv2,*cdv3;
  double *cv0_c, *cv1_c,*cv2_c, *cv3_c;
  double *cdv0_c,*cdv1_c,*cdv2_c,*cdv3_c;
} INTERACT;
typedef struct therm_scr {
  double *sc;
  double *atm_kin;
}THERM_SCR;
typedef struct int_scr {
  double v_lnv;
  double *x,*y,*z;
  double *vx,*vy,*vz;
  double *gx,*gy,*gz;
  double **x_nhc,**v_nhc,**f_nhc;
  double *vgmat;
  double *x_vol_nhc,*v_vol_nhc,*f_vol_nhc;
  double *sc;
  double *sc_temp;
  double *atm_kin;
  double *step_up,*step_dn;
  THERM_SCR *therm_scr;
} INT_SCR;
typedef struct ewd_scr {
  double *q;
  double *x,*y,*z;
  double *fx,*fy,*fz;
  double *heli,*helr;
  double *cossc,*sinsc;
  double *fx2,*fy2,*fz2;
  double *temp;
  double *helr_now,*heli_now,*vtemp_now;
} EWD_SCR;
typedef struct for_scr {
  int nlen;
  int nsplin_t;
  int num_brk;
  int intact;
  double wght_lnk;
  double wght_ter;
  double wght_ter_res;
  double wght_tra;
  double wght_tra_res;
  double wght_pimd;
  int *j_indext,*i_indext;
  int *i_indext2;
  int *j_lnk,*i_lnk,*k_lnk;
  int *j_index,*i_index;
  int *num_brk_i;
  int *iexcl;
  int *index_atm;
} FOR_SCR;
typedef struct part_mesh{
  int pme_on;
  int kmax_pme;
  int n_interp;
  int pme_res_on;
  int kmax_pme_res;
  int n_interp_res;
  int pme_para_opt;
  int nlen_pme;
  int nktot_pme;
  int ngrid_a,ngrid_b,ngrid_c;
  int nktot_pme_res;
  int ngrid_a_res,ngrid_b_res,ngrid_c_res;
  int ninterp_mall;
  int ninterp_tot_mall;
  int *iatemp,*ibtemp,*ictemp;
  int *nc,*ioff_c;
  int **igrid_a,**igrid_b,**igrid_c;
  int **igrid_now;
  double ecut;
  double ecut_res;
  double *bweight_tot_res;
  double *bweight_tot;
  double *qgrid;
  double *qgrid_scr;
  double *qgrid_tmp_real;
  double *qgrid_tmp_imag;
  double *frac_a,*frac_b,*frac_c;
  double *aj,*rn,*rn1;
  double **ua,**ub,**uc;
  double **mn_a,**mn_b,**mn_c;
  double **dmn_a,**dmn_b,**dmn_c;
  double **qgrid_now;
} PART_MESH;
typedef struct surface {
  int isurf_on;
  int natm_typ;
  int nsplin_surf;
  int nsplin_tot;
  double zheal;
  double surface_height;
  double *surface_pot;
  double *surface_forc;
  double *zcut_off;
  double *dz_spl;
  double *dzi_spl;
  double *zmin_spl;
  NAME surface_type;
} SURFACE;
typedef struct class {
  CLATOMS_INFO clatoms_info;
  CLATOMS_TRAN clatoms_tran;
  CLATOMS_POS *clatoms_pos;
  GHOST_ATOMS ghost_atoms;
  ATOMMAPS atommaps;
  THERM_INFO therm_info_class;
  THERM_INFO therm_info_bead;
  THERM_POS therm_class;
  THERM_POS *therm_bead;
  VEL_SAMP_CLASS vel_samp_class;
  ENERGY_CTRL energy_ctrl;
  NBR_LIST nbr_list;
  INTERACT interact;
  INT_SCR int_scr;
  EWD_SCR ewd_scr;
  FOR_SCR for_scr;
  double tot_memory;
  PART_MESH part_mesh;
  SURFACE surface;
  COMMUNICATE communicate;
  CLASS_COMM_FORC_PKG class_comm_forc_pkg;
} CLASS;
typedef struct bond {
  int npow;
  int ntyp_pow;
  int ncon;
  int ntyp_con;
  int nbond_pow_mall;
  int nbond_typ_pow_mall;
  int nbond_con_mall;
  int nbond_typ_con_mall;
  int block_pow_on, block_con_on;
  int ncon_tot;
  int ncon_max;
  int nblock_pow, nblock_size_pow;
  int nblock_con, nblock_size_con;
  int *j1_pow,*j2_pow;
  int *jtyp_pow;
  int *j1_con,*j2_con;
  int *jtyp_con;
  int *iblock_pow_size;
  int *iblock_pow_conflict_1,*iblock_pow_conflict_2;
  int *iblock_con_size;
  int *iblock_con_conflict_1,*iblock_con_conflict_2;
  double *eq_pow;
  double *eq_pow_res;
  double *c_0,*c_1,*c_2,*c_3,*c_4,*c_5,*c_6;
  double *dc_0,*dc_1,*dc_2,*dc_3,*dc_4,*dc_5,*dc_6;
  double *al_con;
  double *eq_con;
} BOND;
typedef struct grp_bond_con {
  int num_33;
  int num_21;
  int num_43;
  int ntyp_33;
  int num_23;
  int ntyp_23,ntyp_21,ntyp_43;
  int num_46;
  int ntyp_46;
  int max_iter;
  int ngrp_21_mall;
  int ngrp_33_mall;
  int ngrp_43_mall;
  int ngrp_23_mall;
  int ngrp_46_mall;
  int ngrp_typ_21_mall;
  int ngrp_typ_33_mall;
  int ngrp_typ_43_mall;
  int ngrp_typ_23_mall;
  int ngrp_typ_46_mall;
  int num_21_tot,num_23_tot,num_33_tot,num_43_tot,num_46_tot;
  double tol;
  int *j1_33,*j2_33,*j3_33;
  int *j1_21,*j1_43,*j2_21;
  int *j2_43,*j3_43,*j4_43;
  int *jtyp_33,*jtyp_21,*jtyp_43;
  int *j1_23,*j2_23,*j3_23;
  int *jtyp_23;
  int *j1_46,*j2_46,*j3_46,*j4_46;
  int *jtyp_46;
  double **al_33,**eq_33;
  double **al_23,**eq_23;
  double **al_21,**al_43;
  double **eq_21,**eq_43;
  double **al_46,**eq_46;
  int ncons_gather_tot;
  int ncons_gather;
  int ncons_gather_max;
  int *ind_gather_fwd;
  int *ind_gather_bck;
  int *ind_gather_scr;
} GRP_BOND_CON;
typedef struct grp_bond_watts {
  int num_33;
  int num_33_tot;
  int ntyp_33;
  int ngrp_33_mall;
  int ngrp_typ_33_mall;
  int *j1_33,*j2_33,*j3_33;
  int *jtyp_33;
  double *cos_thet0_2,*sin_thet0_2;
  double **eq_33;
  double **c_0_33,**c_1_33,**c_2_33,**c_3_33;
  double **c_4_33,**c_5_33,**c_6_33;
  double **dc_0_33,**dc_1_33,**dc_2_33,**dc_3_33;
  double **dc_4_33,**dc_5_33,**dc_6_33;
} GRP_BOND_WATTS;
typedef struct constrnt{
  int iconstrnt;
  int iroll;
  int max_iter;
  double tolshake;
  double tolratl;
} CONSTRNT;
typedef struct bond_free {
  int num;
  int j1,j2;
  int npow;
  int nhist;
  double fk;
  double eq;
  double del;
  double rmin;
  double rmax;
  char *file;
  double *hist;
} BOND_FREE;
typedef struct bend {
  int npow;
  int ntyp_pow;
  int ncon;
  int ntyp_con;
  int nbend_pow_mall;
  int nbend_typ_pow_mall;
  int nbend_con_mall;
  int nbend_typ_con_mall;
  int block_pow_on,block_con_on;
  int ncon_tot;
  int nblock_pow, nblock_size_pow;
  int nblock_con, nblock_size_con;
  int *j1_pow,*j2_pow,*j3_pow;
  int *jtyp_pow;
  int *j1_con,*j2_con,*j3_con;
  int *jtyp_con;
  int *iblock_pow_size;
  int *iblock_pow_conflict_1,*iblock_pow_conflict_2;
  int *iblock_pow_conflict_3;
  int *iblock_con_size;
  int *iblock_con_conflict_1,*iblock_con_conflict_2;
  int *iblock_con_conflict_3;
  double *eq_pow;
  double *c_0,*c_1,*c_2,*c_3,*c_4,*c_5,*c_6;
  double *s_0,*s_1,*s_2,*s_3,*s_4,*s_5,*s_6;
  double *dc_0,*dc_1,*dc_2,*dc_3,*dc_4,*dc_5,*dc_6;
  double *ds_0,*ds_1,*ds_2,*ds_3,*ds_4,*ds_5,*ds_6;
  double *al_con;
  double *eq_con;
} BEND;
typedef struct bend_free {
  int num;
  int j1,j2,j3;
  int npow;
  int nhist;
  double fk;
  double eq;
  double del;
  char *file;
  double *hist;
} BEND_FREE;
typedef struct bend_bnd {
  int num;
  int ntyp;
  int nbend_bnd_mall;
  int nbend_bnd_typ_mall;
  int block_on;
  int nblock,nblock_size;
  int *j1,*j2,*j3;
  int *jtyp;
  int *iblock_size;
  int *iblock_conflict_1,*iblock_conflict_2;
  int *iblock_conflict_3;
  double *eq_bond;
  double *eq_bend;
  double *cbond_0,*cbond_1,*cbond_2,*cbond_3,*cbond_4,*cbond_5,*cbond_6;
  double *dcbond_0,*dcbond_1,*dcbond_2,*dcbond_3,*dcbond_4,*dcbond_5,*dcbond_6;
  double *cbend_0,*cbend_1,*cbend_2,*cbend_3,*cbend_4,*cbend_5,*cbend_6;
  double *sbend_0,*sbend_1,*sbend_2,*sbend_3,*sbend_4,*sbend_5,*sbend_6;
  double *dcbend_0,*dcbend_1,*dcbend_2,*dcbend_3,*dcbend_4,*dcbend_5,*dcbend_6;
  double *dsbend_0,*dsbend_1,*dsbend_2,*dsbend_3,*dsbend_4,*dsbend_5,*dsbend_6;
} BEND_BND;
typedef struct tors {
  int npow;
  int ntyp_pow;
  int nimpr;
  int ncon;
  int ntyp_con;
  int ntors_pow_mall;
  int ntors_typ_pow_mall;
  int ntors_con_mall;
  int ntors_typ_con_mall;
  int block_pow_on;
  int block_con_on;
  int ncon_tot;
  int nblock_pow,nblock_size_pow;
  int nblock_con,nblock_size_con;
  int *j1_pow,*j2_pow,*j3_pow,*j4_pow;
  int *jtyp_pow;
  int *j1_con,*j2_con,*j3_con,*j4_con;
  int *jtyp_con;
  int *iblock_pow_size;
  int *iblock_pow_conflict_1,*iblock_pow_conflict_2;
  int *iblock_pow_conflict_3,*iblock_pow_conflict_4;
  int *iblock_con_size;
  int *iblock_con_conflict_1,*iblock_con_conflict_2;
  int *iblock_con_conflict_3,*iblock_con_conflict_4;
  double *c_0,*c_1,*c_2,*c_3,*c_4,*c_5,*c_6;
  double *s_0,*s_1,*s_2,*s_3,*s_4,*s_5,*s_6;
  double *dc_0,*dc_1,*dc_2,*dc_3,*dc_4,*dc_5,*dc_6;
  double *ds_0,*ds_1,*ds_2,*ds_3,*ds_4,*ds_5,*ds_6;
  double *eq_pow;
  double *al_con;
  double *eq_con;
} TORS;
typedef struct tors_free {
  int num;
  int npow;
  int nhist;
  int j1[3],j2[3],j3[3],j4[3];
  double fk;
  double eq[3];
  double del;
  char *file;
  double *hist;
  double **hist_2d;
} TORS_FREE;
typedef struct rbar_sig_free {
  int nfree;
  int nhist_bar,nhist_sig;
  int iopt;
  int *j1,*j2;
  double fk_bar;
  double fk_sigma;
  double eq_bar;
  double eq_sigma;
  double del_bar,del_sig;
  double rmin,rmax;
  double smin,smax;
  double rnfree;
  double **hist;
  double **hist_rn;
  char *file;
} RBAR_SIG_FREE;
typedef struct onfo{
  int num;
  int ntyp;
  int nonfo_mall;
  int nonfo_typ_mall;
  int block_on;
  int nblock, nblock_size;
  int *j1,*j2;
  int *jtyp;
  int *iblock_size;
  int *iblock_conflict_1,*iblock_conflict_2;
  double *feps;
  double *s6;
  double *sc;
} ONFO;
typedef struct ecor{
  int nsplin,nsplin_m2;
  int num;
  int block_on;
  int nblock, nblock_size;
  int nktot_res;
  int necor_mall;
  double alp_ewd;
  double ecut,ecut_res;
  double rmin_spl;
  double rmax_spl;
  double dr_spl,dri_spl;
  int *j1,*j2;
  int *iblock_size;
  int *iblock_conflict_1,*iblock_conflict_2;
  double *cv0,*cdv0,*cdv0_res;
} ECOR;
typedef struct excl {
  int nlst;
  int nlst_root;
  int num_cp;
  int *num,*num_root;
  int *j,*j_root;
  int *j_off,*j_off_root;
  int *j1_cp,*j2_cp;
} EXCL;
typedef struct intra_scr{
  int nlen;
  double wght_ter;
  double wght_ter_res;
  double wght_tra;
  double wght_tra_res;
  double int_res_inter;
  int *iatm_typ;
  int *jatm_typ;
  double *vpot;
  double *p11,*p12,*p13;
  double *p21,*p22,*p23;
  double *p31,*p32,*p33;
  double *x1,*y1,*z1;
  double *x2,*y2,*z2;
  double *x3,*y3,*z3;
  double *x4,*y4,*z4;
  double *x5,*y5,*z5;
  double *x6,*y6,*z6;
  double *x7,*y7,*z7;
  double *x8,*y8,*z8;
  double *fx1,*fy1,*fz1;
  double *fx2,*fy2,*fz2;
  double *fx3,*fy3,*fz3;
  double *fx4,*fy4,*fz4;
  double *dx12,*dy12,*dz12;
  double *dx13,*dy13,*dz13;
  double *dx23,*dy23,*dz23;
  double *dx42,*dy42,*dz42;
  double *dx43,*dy43,*dz43;
  double *dx56,*dy56,*dz56;
  double *dx57,*dy57,*dz57;
  double *dx67,*dy67,*dz67;
  double *dx86,*dy86,*dz86;
  double *dx87,*dy87,*dz87;
  double *c_0,*c_1,*c_2,*c_3,*c_4,*c_5,*c_6;
  double *dc_0,*dc_1,*dc_2,*dc_3,*dc_4,*dc_5,*dc_6;
  double *ds_0,*ds_1,*ds_2,*ds_3,*ds_4,*ds_5,*ds_6;
  double *s_0,*s_1,*s_2,*s_3,*s_4,*s_5,*s_6;
  double *eq;
  double *m1,*m2;
  double *vx1,*vy1,*vz1;
  double *vx2,*vy2,*vz2;
  double *sc_1, *sc_2;
  double *sc,*feps,*s6;
  double *q1,*q2;
  double *rmin, *dr, *cutoff;
  double *dri;
  double *vcut_coul,*r, *r3;
  double *del_r,*del_rc;
  double *swit,*cut,*spl_tmp;
  double *cutoff_res;
} INTRA_SCR;
typedef struct bonded {
  BOND bond;
  GRP_BOND_CON grp_bond_con;
  GRP_BOND_WATTS grp_bond_watts;
  CONSTRNT constrnt;
  BOND_FREE bond_free;
  BEND bend;
  BEND_FREE bend_free;
  BEND_BND bend_bnd;
  TORS tors;
  TORS_FREE tors_free;
  RBAR_SIG_FREE rbar_sig_free;
  ONFO onfo;
  ECOR ecor;
  EXCL excl;
  INTRA_SCR intra_scr;
} BONDED;
typedef struct statepoint{
  double pext,t_ext, stens_ext;
} STATEPOINT;
typedef struct cell{
  int iperd;
  int intra_perds;
  int cubic_box_flag;
  int hmat_int_typ;
  int hmat_cons_typ;
  int imov_cp_box;
  double vol;
  double vol_cp;
  double vol0;
  double area;
  double alpha_conv_dual;
  double *hmat,*hmati;
  double *hmat_ewd,*hmat_ewd_cp;
  double *hmat_cp,*hmati_cp;
  double *cp_box_center;
  double *cp_box_center_rel;
  double *cp_vbox_center;
  double *cp_fbox_center;
} CELL;
typedef struct timeinfo{
  int ntime,itime;
  int ix_respa;
  int int_res_ter,int_res_tra;
  int nres_ter,nres_tra;
  int int_res_tor,nres_tor;
  int int_res_pimd,nres_pimd;
  int iget_pe_real_inter_freq;
  int exit_flag;
  double dt;
} TIMEINFO;
typedef struct baro {
  int len_nhc;
  double x_lnv,v_lnv;
  double v_lnv_glob;
  double v_lnv_g;
  double f_lnv_p,f_lnv_v;
  double vol;
  double mass_lnv;
  double c2_lnv;
  double roll_scv;
  double roll_scg;
  double roll_scg0;
  double x_lnv_o;
  double v_lnv_g_wght;
  double area;
  double *x_vol_nhc,*v_vol_nhc;
  double *f_vol_nhc,*mass_vol_nhc,*gkt_vol;
  double *hmato;
} BARO;
typedef struct par_rahman{
  double vol;
  double mass_hm;
  double c1_hm;
  double roll_scg;
  double roll_scg0;
  double area;
  double *vgmat,*vgmat_g;
  double *vgmat_glob;
  double *fgmat_p,*fgmat_v;
  double *roll_mtv,*roll_mtx;
  double *roll_mtvv;
  double *vtemps,*veigv,*veig;
  double *vexpdt,*vsindt;
  double *vtempx, *vtempv;
  double *hmat_t, *hmato;
  double *fv1,*fv2;
  double *vgmat_g_wght;
} PAR_RAHMAN;
typedef struct ptens {
  double *tvten;
  double *pvten,*pvten_tot;
  double *pvten_inc,*pvten_tmp;
  double *pvten_tmp_res ;
  double *pvten_inc_t1,*pvten_inc_t2,*pvten_inc_t3,*pvten_inc_t4;
  double *pvten_inc_a;
  double *pvten_inc_old;
  double *count_inc;
  double *pvten_inc_glob,*pvten_inc_whol,*pvten_inc_std;
  double *pvten_mode,*pvten_mode_tot;
} PTENS;
typedef struct stat_avg {
  int nexclt;
  int iter_shake, iter_ratl;
  int iswit_vdw;
  int itime_update,itime_update_w;
  int iter_shake_cp,iter_ratl_cp;
  int write_cp_atm_flag;
  double vintert,aivintert,avintert;
  double vintrat,aivintrat,avintrat;
  double vsurft;
  double vbondt,vbendt,vtorst,vonfot;
  double vbend_bndt;
  double vbend_bnd_bond,vbend_bnd_bend;
  double vbondt_watts,vbendt_watts,vtot_watts;
  double vreal,vrecip;
  double vvdw,vcoul;
  double vlong;
  double vbond_free,vbend_free,vtors_free;
  double vbar_free;
  double kinet,aikinet,akinet;
  double kinet_v,aikinet_v,akinet_v;
  double vol,aivol,avol;
  double kinet_nhc,aikinet_nhc,akinet_nhc;
  double kinet_nhc_bead;
  double aikinet_nhc_bead;
  double akinet_nhc_bead;
  double vpot_v;
  double vpotnhc;
  double aiter_shake,aiter_ratl;
  double iter_23, iter_33, iter_46, iter_43, iter_21;
  double aiter_23,aiter_33, aiter_46;
  double aiter_21,aiter_43;
  double iter_23r, iter_33r, iter_46r, iter_43r, iter_21r;
  double aiter_23r,aiter_33r, aiter_46r;
  double aiter_21r,aiter_43r;
  double acella,acellb,acellc;
  double aicella,aicellb,aicellc;
  double acellab,acellbc,acellac;
  double aicellab,aicellbc,aicellac;
  double apress,aipress;
  double press_inter,press_intra;
  double apress_inter,aipress_inter;
  double apress_intra,aipress_intra;
  double press_kin;
  double apress_kin,aipress_kin;
  double econv0,econv;
  double cp_kconv0,cp_kconv;
  double cpu1,cpu2,acpu,cpu_now;
  double updates,updates_w;
  double kinet_cp_up,aikinet_cp_up,akinet_cp_up;
  double kinet_cp_dn,aikinet_cp_dn,akinet_cp_dn;
  double kinet_cp,aikinet_cp,akinet_cp;
  double kinet_nhc_cp,aikinet_nhc_cp,akinet_nhc_cp;
  double vpotnhc_cp;
  double cp_ehart,aicp_ehart,acp_ehart;
  double cp_eext,aicp_eext,acp_eext;
  double cp_exc,aicp_exc,acp_exc;
  double cp_muxc;
  double cp_eke,aicp_eke,acp_eke;
  double cp_enl,aicp_enl,acp_enl;
  double aiter_shake_cp,aiter_ratl_cp;
  double maxfc,maxf;
  double pi_ke_prim,pi_ke_vir;
  double api_ke_prim,api_ke_vir;
  double aipi_ke_prim,aipi_ke_vir;
  double kin_harm,akin_harm,aikin_harm;
  double *apten, *aipten, *apten_out;
  double fc_mag_up,fc_mag_dn;
  double fc_max_up,fc_max_dn;
  double fatm_max,fatm_mag;
  double count_diag_srot;
  double econv_now;
  double isokconv,isokconv_now, isok0;
} STAT_AVG;
typedef struct ewald {
  int nsplin_g;
  int nktot;
  int nktot_res;
  int nktot_mall;
  int nktot_res_mall;
  int nkc_max;
  int nkb_max;
  double alp_ewd;
  double self_erf;
  double ecut,ecut_res;
  double ecut_clus;
  double alp_clus;
  double gs_max;
  int *kastr,*kbstr,*kcstr;
  int *ibrk1,*ibrk2,*ibrk3;
  int *kastr_res,*kbstr_res,*kcstr_res;
  int *ibrk1_res,*ibrk2_res;
  double *clus_corr_r,*dclus_corr_r;
  double *clus_corr_r_res,*dclus_corr_r_res;
  double *cvgs_2d0,*cvgs_2d1,*cvgs_2d2,*cvgs_2d3,*vgc_2d;
  double *vgc_1d_y,*vgc_1d_z;
} EWALD;
typedef struct simopts {
  int md;
  int pimd;
  int minimize;
  int cp;
  int cp_pimd;
  int cp_wave;
  int cp_wave_pimd;
  int cp_wave_min_pimd;
  int cp_min;
  int cp_wave_min;
  int debug;
  int debug_pimd;
  int debug_cp;
  int debug_cp_pimd;
  int pi_beads;
  int pi_md_typ;
  int initial_spread_opt;
  int anneal_opt;
  double ann_rate;
  double ann_start_temp;
  double ann_target_temp;
} SIMOPTS;
typedef struct minopts {
  int min_std;
  int min_cg;
  int min_diis;
  int diis_hist_len;
  int cp_min_std;
  int cp_min_cg;
  int cp_min_diis;
  int cp_diis_hist_len;
  int cp_cg_line_min_len;
  int min_atm_com_fix_opt;
  double tol_coef;
  double tol_atom;
} MINOPTS;
typedef struct ensopts{
  int nve,nvt,nvt_isok,npt_i,npt_f,nst;
} ENSOPTS;
typedef struct filenames {
  char *iname;
  char *dname;
  char *dnamec;
  char *cpname;
  char *ksname;
  char *elfname;
  char *cvname;
  char *ccname;
  char *cpparname;
  char *centname;
  char *forcename;
  int low_lim_par;
  int high_lim_par;
  int iwrite_screen;
  int iwrite_inst;
  int iwrite_dump;
  int iwrite_kseigs;
  int iwrite_confv;
  int iwrite_confp;
  int iwrite_par_confp;
  int iwrite_confc;
  int iwrite_path_cent;
  int ifile_open;
  int iwrite_conf_binary;
  int iwrite_units;
  int iwrite_atm_for;
  int iwrite_elf;
} FILENAMES;
typedef struct para_fft_pkg3d {
   int nktot,ncoef,ncoef_proc;
   int ncoef_use,icoef_off,icoef_strt;
   int nfft_size;
   int nfft,nfft_proc;
   int igeneric_opt;
   int scale_opt;
   int len_ifax;
   int nwork1,nwork2;
   double ecut;
   int comm;
   int num_proc,myid,myidp1;
   int *map_proc,*map_c_proc,*map_proc_post;
  int *recv_counts_rho,*displs_rho;
  int *recv_counts_coef,*recv_dspls_coef;
  int *map_pme_dn,nrecv_dn;
  int *recvcounts_pme_dn,*recvdspls_pme_dn;
  int *sendcounts_pme_dn,*senddspls_pme_dn;
  int *map_pme_up,nrecv_up,nrecv_up_max;
  int *recvcounts_pme_up,*recvdspls_pme_up;
  int *sendcounts_pme_up,*senddspls_pme_up;
   int ndata_kc;
   int nkf3,nfft_kc,nfft_kc_proc;
   int str_fft_kc_proc,end_fft_kc_proc;
   int ska_fft_kc_proc,eka_fft_kc_proc;
   int skb_fft_kc_proc,ekb_fft_kc_proc;
   int *sendcounts_fft_kc,*senddspls_fft_kc;
   int *recvcounts_fft_kc,*recvdspls_fft_kc;
   int *sum_fft_kc_proc;
   int nka_fft_kc, *nkb_fft_kc;
   int *ka_fft_kc,*kb_fft_kc,*ka_fft_kc_red;
   int *ifax_c_f,*ifax_c_r;
   double *work_1c_f,*work_2c_f;
   double *work_1c_r,*work_2c_r;
   int ndata_kb;
   int nkf2, nfft_kb,nfft_kb_proc;
   int str_fft_kb_proc,end_fft_kb_proc;
   int ska_fft_kb_proc,eka_fft_kb_proc;
   int skc_fft_kb_proc,ekc_fft_kb_proc;
   int *ska_fft_kb_proc_all,*eka_fft_kb_proc_all;
   int *skc_fft_kb_proc_all,*ekc_fft_kb_proc_all;
   int *sendcounts_fft_kb,*senddspls_fft_kb;
   int *recvcounts_fft_kb,*recvdspls_fft_kb;
   int *sum_fft_kb_proc;
   int *ifax_b_f,*ifax_b_r;
   double *work_1b_f,*work_2b_f;
   double *work_1b_r,*work_2b_r;
   int ndata_ka;
   int nkf1,nfft_ka,nfft_ka_proc;
   int str_fft_ka_proc,end_fft_ka_proc;
   int skb_fft_ka_proc,ekb_fft_ka_proc;
   int skc_fft_ka_proc,ekc_fft_ka_proc;
   int *skb_fft_ka_proc_all,*ekb_fft_ka_proc_all;
   int *skc_fft_ka_proc_all,*ekc_fft_ka_proc_all;
   int *sendcounts_fft_ka,*senddspls_fft_ka;
   int *recvcounts_fft_ka,*recvdspls_fft_ka;
   int *ifax_a_f,*ifax_a_r;
   double *work_1a_f,*work_2a_f;
   double *work_1a_r,*work_2a_r;
   int *send_counts_row_big_small;
   int *recv_counts_row_big_small;
   int *sdispls_row_big_small;
   int *rdispls_row_big_small;
   int *send_counts_dual_map;
   int *recv_counts_dual_map;
   int *sdispls_dual_map;
   int *rdispls_dual_map;
   int *send_counts_row_big_small_upack;
   int *recv_counts_row_big_small_upack;
   int *sdispls_row_big_small_upack;
   int *rdispls_row_big_small_upack;
   int *send_counts_dual_map_upack;
   int *recv_counts_dual_map_upack;
   int *sdispls_dual_map_upack;
   int *rdispls_dual_map_upack;
   int *send_counts_ioff_big_small;
   int *recv_counts_ioff_big_small;
   int *sdispls_ioff_big_small;
   int *rdispls_ioff_big_small;
 } PARA_FFT_PKG3D;
typedef struct general_data {
  SIMOPTS simopts;
  MINOPTS minopts;
  ENSOPTS ensopts;
  FILENAMES filenames;
  STATEPOINT statepoint;
  CELL cell;
  TIMEINFO timeinfo;
  BARO baro;
  PAR_RAHMAN par_rahman;
  PTENS ptens;
  STAT_AVG stat_avg;
  EWALD ewald;
  PARA_FFT_PKG3D pme_fft_pkg;
  PARA_FFT_PKG3D pme_res_fft_pkg;
  int error_check_on;
} GENERAL_DATA;
   int iii;
    int i; int ipart; int iflag;
    int ifirst = 1;
    int exit_flag = 0;
    double dt; double dti; double dt2; double tol_glob;
    int natm_tot; int ichain; int inhc;
    int iflag_mass = 1;
    double ann_rate = general_data->simopts.ann_rate;
    int num_nhc = class->therm_info_class.num_nhc;
    int len_nhc = class->therm_info_class.len_nhc;
    int ir_tra = 1;
    int ir_tor = 1;
    int ir_ter = 1;
    int anneal_opt = general_data->simopts.anneal_opt;
    double anneal_target_temp = general_data->simopts.ann_target_temp;
    double **therm_gkt = class->therm_info_class.gkt;
    double **therm_mass = class->therm_info_class.mass_nhc;
    double *class_clatoms_vx = class->clatoms_pos[1].vx;
    double *class_clatoms_vy = class->clatoms_pos[1].vy;
    double *class_clatoms_vz = class->clatoms_pos[1].vz;
    double *class_clatoms_fx = class->clatoms_pos[1].fx;
    double *class_clatoms_fy = class->clatoms_pos[1].fy;
    double *class_clatoms_fz = class->clatoms_pos[1].fz;
    double *class_clatoms_mass = class->clatoms_info.mass;
    double cst1; double cst2; double cst3;
    double **therm_v2 = class->therm_class.v_nhc;
    double **therm_v1 = class->therm_class.x_nhc;
    int *inhc_x = class->therm_info_class.inhc_x;
    int *inhc_y = class->therm_info_class.inhc_y;
    int *inhc_z = class->therm_info_class.inhc_z;
    double lennhc = (double)len_nhc;
    natm_tot = class->clatoms_info.natm_tot;
    (general_data->timeinfo.int_res_tra) = 0;
    (general_data->timeinfo.int_res_ter) = 0;
    dt = (general_data->timeinfo.dt);
    dti = dt;
    dt2 = dt/2.0;
    class->therm_info_class.dt_nhc = dt;
    class->therm_info_class.dti_nhc = dt/( (double)(
                             class->therm_info_class.nres_nhc) );
    set_yosh(class->therm_info_class.nyosh_nhc,
             class->therm_info_class.dti_nhc,class->therm_info_class.wdti,
             class->therm_info_class.wdti2,class->therm_info_class.wdti4,
             class->therm_info_class.wdti8,
             class->therm_info_class.wdti16);
    zero_constrt_iters(&(general_data->stat_avg));
    general_data->timeinfo.exit_flag = 0;
    int_0_to_dt2_nvt_isok(class,bonded,general_data,ir_tra,ir_tor,ir_ter,dt);
    (class->energy_ctrl.iget_full_inter)= 1;
    (class->energy_ctrl.iget_res_inter) = 0;
    (class->energy_ctrl.iget_full_intra)= 1;
    (class->energy_ctrl.iget_res_intra) = 0;
    energy_control(class,bonded,general_data);
    int_dt2_to_dt_nvt_isok(class,bonded,general_data,ir_tra,ir_tor,ir_ter,dt);
  iflag=0;
  if(anneal_opt == 1){
    anneal_class(class,ann_rate,iflag,iflag_mass,anneal_target_temp,&exit_flag);
    general_data->timeinfo.exit_flag = exit_flag;
  }
   int_final_class(class,bonded,general_data,iflag);
               }

variable_types: struct bonded { struct bond { int npow; int ntyp_pow; int ncon; int ntyp_con; int nbond_pow_mall; int nbond_typ_pow_mall; int nbond_con_mall; int nbond_typ_con_mall; int block_pow_on; int ncon_tot; int ncon_max; int nblock_pow; int nblock_con; int *j1_pow; int *jtyp_pow; int *j1_con; int *jtyp_con; int *iblock_pow_size; int *iblock_pow_conflict_1; int *iblock_con_size; int *iblock_con_conflict_1; double *eq_pow; double *eq_pow_res; double *c_0; double *dc_0; double *al_con; double *eq_con; } bond; struct grp_bond_con { int num_33; int num_21; int num_43; int ntyp_33; int num_23; int ntyp_23; int num_46; int ntyp_46; int max_iter; int ngrp_21_mall; int ngrp_33_mall; int ngrp_43_mall; int ngrp_23_mall; int ngrp_46_mall; int ngrp_typ_21_mall; int ngrp_typ_33_mall; int ngrp_typ_43_mall; int ngrp_typ_23_mall; int ngrp_typ_46_mall; int num_21_tot; double tol; int *j1_33; int *j1_21; int *j2_43; int *jtyp_33; int *j1_23; int *jtyp_23; int *j1_46; int *jtyp_46; double **al_33; double **al_23; double **al_21; double **eq_21; double **al_46; int ncons_gather_tot; int ncons_gather; int ncons_gather_max; int *ind_gather_fwd; int *ind_gather_bck; int *ind_gather_scr; } grp_bond_con; struct grp_bond_watts { int num_33; int num_33_tot; int ntyp_33; int ngrp_33_mall; int ngrp_typ_33_mall; int *j1_33; int *jtyp_33; double *cos_thet0_2; double **eq_33; double **c_0_33; double **c_4_33; double **dc_0_33; double **dc_4_33; } grp_bond_watts; struct constrnt { int iconstrnt; int iroll; int max_iter; double tolshake; double tolratl; } constrnt; struct bond_free { int num; int j1; int npow; int nhist; double fk; double eq; double del; double rmin; double rmax; char *file; double *hist; } bond_free; struct bend { int npow; int ntyp_pow; int ncon; int ntyp_con; int nbend_pow_mall; int nbend_typ_pow_mall; int nbend_con_mall; int nbend_typ_con_mall; int block_pow_on; int ncon_tot; int nblock_pow; int nblock_con; int *j1_pow; int *jtyp_pow; int *j1_con; int *jtyp_con; int *iblock_pow_size; int *iblock_pow_conflict_1; int *iblock_pow_conflict_3; int *iblock_con_size; int *iblock_con_conflict_1; int *iblock_con_conflict_3; double *eq_pow; double *c_0; double *s_0; double *dc_0; double *ds_0; double *al_con; double *eq_con; } bend; struct bend_free { int num; int j1; int npow; int nhist; double fk; double eq; double del; char *file; double *hist; } bend_free; struct bend_bnd { int num; int ntyp; int nbend_bnd_mall; int nbend_bnd_typ_mall; int block_on; int nblock; int *j1; int *jtyp; int *iblock_size; int *iblock_conflict_1; int *iblock_conflict_3; double *eq_bond; double *eq_bend; double *cbond_0; double *dcbond_0; double *cbend_0; double *sbend_0; double *dcbend_0; double *dsbend_0; } bend_bnd; struct tors { int npow; int ntyp_pow; int nimpr; int ncon; int ntyp_con; int ntors_pow_mall; int ntors_typ_pow_mall; int ntors_con_mall; int ntors_typ_con_mall; int block_pow_on; int block_con_on; int ncon_tot; int nblock_pow; int nblock_con; int *j1_pow; int *jtyp_pow; int *j1_con; int *jtyp_con; int *iblock_pow_size; int *iblock_pow_conflict_1; int *iblock_pow_conflict_3; int *iblock_con_size; int *iblock_con_conflict_1; int *iblock_con_conflict_3; double *c_0; double *s_0; double *dc_0; double *ds_0; double *eq_pow; double *al_con; double *eq_con; } tors; struct tors_free { int num; int npow; int nhist; int j1[3]; double fk; double eq[3]; double del; char *file; double *hist; double **hist_2d; } tors_free; struct rbar_sig_free { int nfree; int nhist_bar; int iopt; int *j1; double fk_bar; double fk_sigma; double eq_bar; double eq_sigma; double del_bar; double rmin; double smin; double rnfree; double **hist; double **hist_rn; char *file; } rbar_sig_free; struct onfo { int num; int ntyp; int nonfo_mall; int nonfo_typ_mall; int block_on; int nblock; int *j1; int *jtyp; int *iblock_size; int *iblock_conflict_1; double *feps; double *s6; double *sc; } onfo; struct ecor { int nsplin; int num; int block_on; int nblock; int nktot_res; int necor_mall; double alp_ewd; double ecut; double rmin_spl; double rmax_spl; double dr_spl; int *j1; int *iblock_size; int *iblock_conflict_1; double *cv0; } ecor; struct excl { int nlst; int nlst_root; int num_cp; int *num; int *j; int *j_off; int *j1_cp; } excl; struct intra_scr { int nlen; double wght_ter; double wght_ter_res; double wght_tra; double wght_tra_res; double int_res_inter; int *iatm_typ; int *jatm_typ; double *vpot; double *p11; double *p21; double *p31; double *x1; double *x2; double *x3; double *x4; double *x5; double *x6; double *x7; double *x8; double *fx1; double *fx2; double *fx3; double *fx4; double *dx12; double *dx13; double *dx23; double *dx42; double *dx43; double *dx56; double *dx57; double *dx67; double *dx86; double *dx87; double *c_0; double *dc_0; double *ds_0; double *s_0; double *eq; double *m1; double *vx1; double *vx2; double *sc_1; double *sc; double *q1; double *rmin; double *dri; double *vcut_coul; double *del_r; double *swit; double *cutoff_res; } intra_scr; } *

variable_types: iii int

variable_types: i int

variable_types: ipart int

variable_types: iflag int

variable_types: ifirst int

variable_types: dt double

variable_types: dti double

variable_types: ichain int

variable_types: inhc int

variable_types: lennhc double

user_defined_types: struct bonded { struct bond bond; struct grp_bond_con grp_bond_con; struct grp_bond_watts grp_bond_watts; struct constrnt constrnt; struct bond_free bond_free; struct bend bend; struct bend_free bend_free; struct bend_bnd bend_bnd; struct tors tors; struct tors_free tors_free; struct rbar_sig_free rbar_sig_free; struct onfo onfo; struct ecor ecor; struct excl excl; struct intra_scr intra_scr; }

user_defined_types: struct clatoms_tran { int pi_beads_proc; int pi_atm_proc; int pi_atm_proc_use; int pi_proc_rem; int nwork; int *sendcounts; int *senddspls; int *ifax; double *rat1_stag; double *path_eig; double *work; double *work3; double *x_trans; double *x_temp; double *xt_temp; }

user_defined_types: struct ghost_atoms { int nghost_tot; int natm_comp_max; int nghost_mall; int nghost_old; int ncomp_mall; int ncomp_old; int *ighost_map; int *natm_comp; int **iatm_comp; double **coef; }

user_defined_types: struct therm_info { int num_nhc; int len_nhc; int nres_nhc; int nyosh_nhc; int therm_typ; int num_nhc_proc; int num_nhc_share; int mytherm_start; double dt_nhc; int *inhc_x; int *itherm_nshare; double *ditherm_nshare_i; int *map_share; double *text_nhc; double *wdti; double **mass_nhc; }

user_defined_types: struct therm_pos { double **x_nhc; double x_nhc_tot; }

user_defined_types: struct vel_samp_class { int ivel_smpl_on; int ivel_scale_on; int nvx_smpl; int nvx_scale; int nvnhc_smpl; int iseed; double qseed; }

user_defined_types: struct energy_ctrl { int pme_on; int int_res_ter; int isep_vvdw; int iswit_vdw; int block_std_on; int iget_pe_real_inter_freq; int iget_pe_real_inter; int itime; int iget_full_inter; int iget_full_intra; int iget_full_pimd; }

user_defined_types: struct ewd_scr { double *q; double *x; double *fx; double *heli; double *cossc; double *fx2; double *temp; double *helr_now; }

user_defined_types: struct for_scr { int nlen; int nsplin_t; int num_brk; int intact; double wght_lnk; double wght_ter; double wght_ter_res; double wght_tra; double wght_tra_res; double wght_pimd; int *j_indext; int *i_indext2; int *j_lnk; int *j_index; int *num_brk_i; int *iexcl; int *index_atm; }

user_defined_types: struct part_mesh { int pme_on; int kmax_pme; int n_interp; int pme_res_on; int kmax_pme_res; int n_interp_res; int pme_para_opt; int nlen_pme; int nktot_pme; int ngrid_a; int nktot_pme_res; int ngrid_a_res; int ninterp_mall; int ninterp_tot_mall; int *iatemp; int *nc; int **igrid_a; int **igrid_now; double ecut; double ecut_res; double *bweight_tot_res; double *bweight_tot; double *qgrid; double *qgrid_scr; double *qgrid_tmp_real; double *qgrid_tmp_imag; double *frac_a; double *aj; double **ua; double **mn_a; double **dmn_a; double **qgrid_now; }

user_defined_types: struct surface { int isurf_on; int natm_typ; int nsplin_surf; int nsplin_tot; double zheal; double surface_height; double *surface_pot; double *surface_forc; double *zcut_off; double *dz_spl; double *dzi_spl; double *zmin_spl; char surface_type[50]; }

user_defined_types: struct communicate { int np_beads; int myid; int myid_bead_forc; int myid_bead; int myid_bead_prime; int myid_state; int myid_forc; int myid_forc_source; int myid_forc_target; int world; int comm_beads; int comm_beads_forc; int comm_states; int comm_forc; int comm_forc_source; int comm_forc_target; int comm_faux; }

user_defined_types: struct cell { int iperd; int intra_perds; int cubic_box_flag; int hmat_int_typ; int hmat_cons_typ; int imov_cp_box; double vol; double vol_cp; double vol0; double area; double alpha_conv_dual; double *hmat; double *hmat_ewd; double *hmat_cp; double *cp_box_center; double *cp_box_center_rel; double *cp_vbox_center; double *cp_fbox_center; }

user_defined_types: struct timeinfo { int ntime; int ix_respa; int int_res_ter; int nres_ter; int int_res_tor; int int_res_pimd; int iget_pe_real_inter_freq; int exit_flag; double dt; }

user_defined_types: struct baro { int len_nhc; double x_lnv; double v_lnv_glob; double v_lnv_g; double f_lnv_p; double vol; double mass_lnv; double c2_lnv; double roll_scv; double roll_scg; double roll_scg0; double x_lnv_o; double v_lnv_g_wght; double area; double *x_vol_nhc; double *f_vol_nhc; double *hmato; }

user_defined_types: struct par_rahman { double vol; double mass_hm; double c1_hm; double roll_scg; double roll_scg0; double area; double *vgmat; double *vgmat_glob; double *fgmat_p; double *roll_mtv; double *roll_mtvv; double *vtemps; double *vexpdt; double *vtempx; double *hmat_t; double *fv1; double *vgmat_g_wght; }

user_defined_types: struct ptens { double *tvten; double *pvten; double *pvten_inc; double *pvten_tmp_res; double *pvten_inc_t1; double *pvten_inc_a; double *pvten_inc_old; double *count_inc; double *pvten_inc_glob; double *pvten_mode; }

user_defined_types: struct stat_avg { int nexclt; int iter_shake; int iswit_vdw; int itime_update; int iter_shake_cp; int write_cp_atm_flag; double vintert; double vintrat; double vsurft; double vbondt; double vbend_bndt; double vbend_bnd_bond; double vbondt_watts; double vreal; double vvdw; double vlong; double vbond_free; double vbar_free; double kinet; double kinet_v; double vol; double kinet_nhc; double kinet_nhc_bead; double aikinet_nhc_bead; double akinet_nhc_bead; double vpot_v; double vpotnhc; double aiter_shake; double iter_23; double aiter_23; double aiter_21; double iter_23r; double aiter_23r; double aiter_21r; double acella; double aicella; double acellab; double aicellab; double apress; double press_inter; double apress_inter; double apress_intra; double press_kin; double apress_kin; double econv0; double cp_kconv0; double cpu1; double updates; double kinet_cp_up; double kinet_cp_dn; double kinet_cp; double kinet_nhc_cp; double vpotnhc_cp; double cp_ehart; double cp_eext; double cp_exc; double cp_muxc; double cp_eke; double cp_enl; double aiter_shake_cp; double maxfc; double pi_ke_prim; double api_ke_prim; double aipi_ke_prim; double kin_harm; double *apten; double fc_mag_up; double fc_max_up; double fatm_max; double count_diag_srot; double econv_now; double isokconv; }

user_defined_types: struct ewald { int nsplin_g; int nktot; int nktot_res; int nktot_mall; int nktot_res_mall; int nkc_max; int nkb_max; double alp_ewd; double self_erf; double ecut; double ecut_clus; double alp_clus; double gs_max; int *kastr; int *ibrk1; int *kastr_res; int *ibrk1_res; double *clus_corr_r; double *clus_corr_r_res; double *cvgs_2d0; double *vgc_1d_y; }

user_defined_types: struct para_fft_pkg3d { int nktot; int ncoef_use; int nfft_size; int nfft; int igeneric_opt; int scale_opt; int len_ifax; int nwork1; double ecut; int comm; int num_proc; int *map_proc; int *recv_counts_rho; int *recv_counts_coef; int *map_pme_dn; int *recvcounts_pme_dn; int *sendcounts_pme_dn; int *map_pme_up; int *recvcounts_pme_up; int *sendcounts_pme_up; int ndata_kc; int nkf3; int str_fft_kc_proc; int ska_fft_kc_proc; int skb_fft_kc_proc; int *sendcounts_fft_kc; int *recvcounts_fft_kc; int *sum_fft_kc_proc; int nka_fft_kc; int *ka_fft_kc; int *ifax_c_f; double *work_1c_f; double *work_1c_r; int ndata_kb; int nkf2; int str_fft_kb_proc; int ska_fft_kb_proc; int skc_fft_kb_proc; int *ska_fft_kb_proc_all; int *skc_fft_kb_proc_all; int *sendcounts_fft_kb; int *recvcounts_fft_kb; int *sum_fft_kb_proc; int *ifax_b_f; double *work_1b_f; double *work_1b_r; int ndata_ka; int nkf1; int str_fft_ka_proc; int skb_fft_ka_proc; int skc_fft_ka_proc; int *skb_fft_ka_proc_all; int *skc_fft_ka_proc_all; int *sendcounts_fft_ka; int *recvcounts_fft_ka; int *ifax_a_f; double *work_1a_f; double *work_1a_r; int *send_counts_row_big_small; int *recv_counts_row_big_small; int *sdispls_row_big_small; int *rdispls_row_big_small; int *send_counts_dual_map; int *recv_counts_dual_map; int *sdispls_dual_map; int *rdispls_dual_map; int *send_counts_row_big_small_upack; int *recv_counts_row_big_small_upack; int *sdispls_row_big_small_upack; int *rdispls_row_big_small_upack; int *send_counts_dual_map_upack; int *recv_counts_dual_map_upack; int *sdispls_dual_map_upack; int *rdispls_dual_map_upack; int *send_counts_ioff_big_small; int *recv_counts_ioff_big_small; int *sdispls_ioff_big_small; int *rdispls_ioff_big_small; }

user_defined_types: struct class_plimpton_ind { int num_proc_source; int num_proc_target; int myid_source; int myid_target; int natoms_tot; int *index_src; int *index_src_even; int *index_src_odd; int *index_trg; int *index_trg_even; int *index_trg_odd; int *displs_atm_trg; int *displs_atm_src; int *src_odd_end; int *src_even_end; int *trg_odd_end; int *trg_even_end; int *src_odd_begin; int *src_even_begin; int *trg_odd_begin; int *trg_even_begin; int my_src_odd_counts; int my_src_even_counts; int my_trg_odd_counts; int my_trg_even_counts; int *my_src_odd; int *my_src_even; int *my_trg_odd; int *my_trg_even; int **jmax; int *jmin; int **imax; int source; int target; }


repo: TuckermanGroup/PINY

original_code:
void apply_NH_ISOK_par(CLATOMS_INFO *clatoms_info,CLATOMS_POS *clatoms_pos,
                       THERM_INFO *therm_info_class,THERM_POS *therm_class,
                       INT_SCR *int_scr,int iflag_mass,
                       CLASS_COMM_FORC_PKG *class_comm_forc_pkg)
{
  int MPI_INT = 1;
  int MPI_DOUBLE = 1;
  int MPI_CHAR = 1;
  int MPI_MAX = 1;
  int MPI_SUM = 1;
  int MPI_ANY_TAG = 1;
  int MPI_ANY_SOURCE = 1;
  int *MPI_BOTTOM = {0};
    int ipart,inhc,ichain;
    int iresn,iyosh;
    double arg,arg2,aa;
    int iii;
    double cst1, cst2, cst3;
      double *int_scr_atm_kin = int_scr->atm_kin;
      double *int_scr_sc = int_scr->sc;
      double *int_scr_sc_temp = int_scr->sc_temp;
      int *inhc_x = therm_info_class->inhc_x;
      int *inhc_y = therm_info_class->inhc_y;
      int *inhc_z = therm_info_class->inhc_z;
      double **therm_f = therm_class->f_nhc;
      double **therm_v2 = therm_class->v_nhc;
      double **therm_v1 = therm_class->x_nhc;
      double **therm_gkt = therm_info_class->gkt;
      double **therm_mass = therm_info_class->mass_nhc;
      double *clatoms_vx = clatoms_pos->vx;
      double *clatoms_vy = clatoms_pos->vy;
      double *clatoms_vz = clatoms_pos->vz;
      double *therm_wdti2 = therm_info_class->wdti2;
      double *therm_wdti4 = therm_info_class->wdti4;
      double *therm_wdti8 = therm_info_class->wdti8;
      int len_nhc = therm_info_class->len_nhc;
      double lennhc = (double)len_nhc;
      double *clatoms_mass = clatoms_info->mass;
      int natm_tot = clatoms_info->natm_tot;;
      int *map_share = therm_info_class->map_share;
      int num_nhc_share = therm_info_class->num_nhc_share;
      int np_forc = class_comm_forc_pkg->num_proc;
      int comm_forc = class_comm_forc_pkg->comm;
      int world = class_comm_forc_pkg->world;
      double len_fac = ((double)(len_nhc))/(((double)(len_nhc))+1.0);
      double kinetic = 0.0;
      double k_BT = therm_gkt[1][inhc_x[1]];
      double LkT = lennhc*k_BT;
      double mass_factor = 1.0;
   for(iresn=1;iresn<=therm_info_class->nres_nhc;iresn++){
    for(iyosh=1;iyosh<=therm_info_class->nyosh_nhc;iyosh++){
      for(ipart=1;ipart<=natm_tot;ipart++){
       for(ichain=1;ichain<=len_nhc;ichain++){
              therm_f[ichain][inhc_x[ipart]] =
                therm_mass[ichain][inhc_x[ipart]]*therm_v1[ichain][inhc_x[ipart]]*
                therm_v1[ichain][inhc_x[ipart]]-k_BT;
              therm_v2[ichain][inhc_x[ipart]]+=
                therm_wdti4[iyosh]*therm_f[ichain][inhc_x[ipart]]/(mass_factor*therm_mass[ichain][inhc_x[ipart]]);
              therm_f[ichain][inhc_y[ipart]] =
                therm_mass[ichain][inhc_y[ipart]]*therm_v1[ichain][inhc_y[ipart]]*
                therm_v1[ichain][inhc_y[ipart]]-k_BT;
              therm_v2[ichain][inhc_y[ipart]]+=
                therm_wdti4[iyosh]*therm_f[ichain][inhc_y[ipart]]/(mass_factor*therm_mass[ichain][inhc_y[ipart]]);
              therm_f[ichain][inhc_z[ipart]] =
                therm_mass[ichain][inhc_z[ipart]]*therm_v1[ichain][inhc_z[ipart]]*
                therm_v1[ichain][inhc_z[ipart]]-k_BT;
              therm_v2[ichain][inhc_z[ipart]]+=
                therm_wdti4[iyosh]*therm_f[ichain][inhc_z[ipart]]/(mass_factor*therm_mass[ichain][inhc_z[ipart]]);
                                         } }
      for(ipart=1;ipart<=natm_tot;ipart++){
       aa = 0.0;
       arg=(clatoms_vx[ipart]*clatoms_vx[ipart]*clatoms_mass[ipart]);
          for(ichain=1;ichain<=len_nhc;ichain++){
          aa+=(len_fac*therm_mass[ichain][inhc_x[ipart]]*therm_v1[ichain][inhc_x[ipart]]
         *therm_v1[ichain][inhc_x[ipart]]
         *exp(-2.0*therm_wdti2[iyosh]*therm_v2[ichain][inhc_x[ipart]]));
          }
          arg +=aa;
          arg2=sqrt(LkT/arg);
       clatoms_vx[ipart]*=arg2;
       for(ichain=1;ichain<=len_nhc;ichain++){
       therm_v1[ichain][inhc_x[ipart]]*=arg2
         *exp(-therm_wdti2[iyosh]*therm_v2[ichain][inhc_x[ipart]]);
       }
       aa = 0.0;
          arg=(clatoms_vy[ipart]*clatoms_vy[ipart]*clatoms_mass[ipart]);
       for(ichain=1;ichain<=len_nhc;ichain++){
          aa+=(len_fac*therm_mass[ichain][inhc_y[ipart]]*therm_v1[ichain][inhc_y[ipart]]
             *therm_v1[ichain][inhc_y[ipart]]
             *exp(-2.0*therm_wdti2[iyosh]*therm_v2[ichain][inhc_y[ipart]]));
       }
       arg+=aa;
          arg2=sqrt(LkT/arg);
       clatoms_vy[ipart]*=arg2;
       for(ichain=1;ichain<=len_nhc;ichain++){
       therm_v1[ichain][inhc_y[ipart]]*=arg2
         *exp(-therm_wdti2[iyosh]*therm_v2[ichain][inhc_y[ipart]]);
       }
       aa = 0.0;
          arg=(clatoms_vz[ipart]*clatoms_vz[ipart]*clatoms_mass[ipart]);
       for(ichain=1;ichain<=len_nhc;ichain++){
          aa+=(len_fac*therm_mass[ichain][inhc_z[ipart]]*therm_v1[ichain][inhc_z[ipart]]
             *therm_v1[ichain][inhc_z[ipart]]
             *exp(-2.0*therm_wdti2[iyosh]*therm_v2[ichain][inhc_z[ipart]]));
       }
       arg+=aa;
          arg2=sqrt(LkT/arg);
       clatoms_vz[ipart]*=arg2;
       for(ichain=1;ichain<=len_nhc;ichain++){
       therm_v1[ichain][inhc_z[ipart]]*=arg2
         *exp(-therm_wdti2[iyosh]*therm_v2[ichain][inhc_z[ipart]]);
       }
      }
      for(ipart=1;ipart<=natm_tot;ipart++){
       for(ichain=1;ichain<=len_nhc;ichain++){
              therm_f[ichain][inhc_x[ipart]] =
                therm_mass[ichain][inhc_x[ipart]]*therm_v1[ichain][inhc_x[ipart]]*
                therm_v1[ichain][inhc_x[ipart]]-k_BT;
              therm_v2[ichain][inhc_x[ipart]]+=
   therm_wdti4[iyosh]*therm_f[ichain][inhc_x[ipart]]/(mass_factor*therm_mass[ichain][inhc_x[ipart]]);
              therm_f[ichain][inhc_y[ipart]] =
                therm_mass[ichain][inhc_y[ipart]]*therm_v1[ichain][inhc_y[ipart]]*
                therm_v1[ichain][inhc_y[ipart]]-k_BT;
              therm_v2[ichain][inhc_y[ipart]]+=
   therm_wdti4[iyosh]*therm_f[ichain][inhc_y[ipart]]/(mass_factor*therm_mass[ichain][inhc_y[ipart]]);
              therm_f[ichain][inhc_z[ipart]] =
                therm_mass[ichain][inhc_z[ipart]]*therm_v1[ichain][inhc_z[ipart]]*
                therm_v1[ichain][inhc_z[ipart]]-k_BT;
              therm_v2[ichain][inhc_z[ipart]]+=
   therm_wdti4[iyosh]*therm_f[ichain][inhc_z[ipart]]/(mass_factor*therm_mass[ichain][inhc_z[ipart]]);
                                         }}
    }}
                  }

canonical_original_code:
void apply_NH_ISOK_par(struct clatoms_info *clatoms_info, struct clatoms_pos *clatoms_pos, struct therm_info *therm_info_class, struct therm_pos *therm_class, struct int_scr *int_scr, int iflag_mass, struct class_comm_forc_pkg *class_comm_forc_pkg)
{
  int MPI_INT = 1;
  int MPI_DOUBLE = 1;
  int MPI_CHAR = 1;
  int MPI_MAX = 1;
  int MPI_SUM = 1;
  int MPI_ANY_TAG = 1;
  int MPI_ANY_SOURCE = 1;
  int *MPI_BOTTOM = {0};
    int ipart; int inhc; int ichain;
    int iresn; int iyosh;
    double arg; double arg2; double aa;
    int iii;
    double cst1; double cst2; double cst3;
      double *int_scr_atm_kin = int_scr->atm_kin;
      double *int_scr_sc = int_scr->sc;
      double *int_scr_sc_temp = int_scr->sc_temp;
      int *inhc_x = therm_info_class->inhc_x;
      int *inhc_y = therm_info_class->inhc_y;
      int *inhc_z = therm_info_class->inhc_z;
      double **therm_f = therm_class->f_nhc;
      double **therm_v2 = therm_class->v_nhc;
      double **therm_v1 = therm_class->x_nhc;
      double **therm_gkt = therm_info_class->gkt;
      double **therm_mass = therm_info_class->mass_nhc;
      double *clatoms_vx = clatoms_pos->vx;
      double *clatoms_vy = clatoms_pos->vy;
      double *clatoms_vz = clatoms_pos->vz;
      double *therm_wdti2 = therm_info_class->wdti2;
      double *therm_wdti4 = therm_info_class->wdti4;
      double *therm_wdti8 = therm_info_class->wdti8;
      int len_nhc = therm_info_class->len_nhc;
      double lennhc = (double)len_nhc;
      double *clatoms_mass = clatoms_info->mass;
      int natm_tot = clatoms_info->natm_tot;;
      int *map_share = therm_info_class->map_share;
      int num_nhc_share = therm_info_class->num_nhc_share;
      int np_forc = class_comm_forc_pkg->num_proc;
      int comm_forc = class_comm_forc_pkg->comm;
      int world = class_comm_forc_pkg->world;
      double len_fac = ((double)(len_nhc))/(((double)(len_nhc))+1.0);
      double kinetic = 0.0;
      double k_BT = therm_gkt[1][inhc_x[1]];
      double LkT = lennhc*k_BT;
      double mass_factor = 1.0;
   for(iresn=1;iresn<=therm_info_class->nres_nhc;iresn++){
    for(iyosh=1;iyosh<=therm_info_class->nyosh_nhc;iyosh++){
      for(ipart=1;ipart<=natm_tot;ipart++){
       for(ichain=1;ichain<=len_nhc;ichain++){
              therm_f[ichain][inhc_x[ipart]] =
                therm_mass[ichain][inhc_x[ipart]]*therm_v1[ichain][inhc_x[ipart]]*
                therm_v1[ichain][inhc_x[ipart]]-k_BT;
              therm_v2[ichain][inhc_x[ipart]]+=
                therm_wdti4[iyosh]*therm_f[ichain][inhc_x[ipart]]/(mass_factor*therm_mass[ichain][inhc_x[ipart]]);
              therm_f[ichain][inhc_y[ipart]] =
                therm_mass[ichain][inhc_y[ipart]]*therm_v1[ichain][inhc_y[ipart]]*
                therm_v1[ichain][inhc_y[ipart]]-k_BT;
              therm_v2[ichain][inhc_y[ipart]]+=
                therm_wdti4[iyosh]*therm_f[ichain][inhc_y[ipart]]/(mass_factor*therm_mass[ichain][inhc_y[ipart]]);
              therm_f[ichain][inhc_z[ipart]] =
                therm_mass[ichain][inhc_z[ipart]]*therm_v1[ichain][inhc_z[ipart]]*
                therm_v1[ichain][inhc_z[ipart]]-k_BT;
              therm_v2[ichain][inhc_z[ipart]]+=
                therm_wdti4[iyosh]*therm_f[ichain][inhc_z[ipart]]/(mass_factor*therm_mass[ichain][inhc_z[ipart]]);
                                         } }
      for(ipart=1;ipart<=natm_tot;ipart++){
       aa = 0.0;
       arg=(clatoms_vx[ipart]*clatoms_vx[ipart]*clatoms_mass[ipart]);
          for(ichain=1;ichain<=len_nhc;ichain++){
          aa+=(len_fac*therm_mass[ichain][inhc_x[ipart]]*therm_v1[ichain][inhc_x[ipart]]
         *therm_v1[ichain][inhc_x[ipart]]
         *exp(-2.0*therm_wdti2[iyosh]*therm_v2[ichain][inhc_x[ipart]]));
          }
          arg +=aa;
          arg2=sqrt(LkT/arg);
       clatoms_vx[ipart]*=arg2;
       for(ichain=1;ichain<=len_nhc;ichain++){
       therm_v1[ichain][inhc_x[ipart]]*=arg2
         *exp(-therm_wdti2[iyosh]*therm_v2[ichain][inhc_x[ipart]]);
       }
       aa = 0.0;
          arg=(clatoms_vy[ipart]*clatoms_vy[ipart]*clatoms_mass[ipart]);
       for(ichain=1;ichain<=len_nhc;ichain++){
          aa+=(len_fac*therm_mass[ichain][inhc_y[ipart]]*therm_v1[ichain][inhc_y[ipart]]
             *therm_v1[ichain][inhc_y[ipart]]
             *exp(-2.0*therm_wdti2[iyosh]*therm_v2[ichain][inhc_y[ipart]]));
       }
       arg+=aa;
          arg2=sqrt(LkT/arg);
       clatoms_vy[ipart]*=arg2;
       for(ichain=1;ichain<=len_nhc;ichain++){
       therm_v1[ichain][inhc_y[ipart]]*=arg2
         *exp(-therm_wdti2[iyosh]*therm_v2[ichain][inhc_y[ipart]]);
       }
       aa = 0.0;
          arg=(clatoms_vz[ipart]*clatoms_vz[ipart]*clatoms_mass[ipart]);
       for(ichain=1;ichain<=len_nhc;ichain++){
          aa+=(len_fac*therm_mass[ichain][inhc_z[ipart]]*therm_v1[ichain][inhc_z[ipart]]
             *therm_v1[ichain][inhc_z[ipart]]
             *exp(-2.0*therm_wdti2[iyosh]*therm_v2[ichain][inhc_z[ipart]]));
       }
       arg+=aa;
          arg2=sqrt(LkT/arg);
       clatoms_vz[ipart]*=arg2;
       for(ichain=1;ichain<=len_nhc;ichain++){
       therm_v1[ichain][inhc_z[ipart]]*=arg2
         *exp(-therm_wdti2[iyosh]*therm_v2[ichain][inhc_z[ipart]]);
       }
      }
      for(ipart=1;ipart<=natm_tot;ipart++){
       for(ichain=1;ichain<=len_nhc;ichain++){
              therm_f[ichain][inhc_x[ipart]] =
                therm_mass[ichain][inhc_x[ipart]]*therm_v1[ichain][inhc_x[ipart]]*
                therm_v1[ichain][inhc_x[ipart]]-k_BT;
              therm_v2[ichain][inhc_x[ipart]]+=
   therm_wdti4[iyosh]*therm_f[ichain][inhc_x[ipart]]/(mass_factor*therm_mass[ichain][inhc_x[ipart]]);
              therm_f[ichain][inhc_y[ipart]] =
                therm_mass[ichain][inhc_y[ipart]]*therm_v1[ichain][inhc_y[ipart]]*
                therm_v1[ichain][inhc_y[ipart]]-k_BT;
              therm_v2[ichain][inhc_y[ipart]]+=
   therm_wdti4[iyosh]*therm_f[ichain][inhc_y[ipart]]/(mass_factor*therm_mass[ichain][inhc_y[ipart]]);
              therm_f[ichain][inhc_z[ipart]] =
                therm_mass[ichain][inhc_z[ipart]]*therm_v1[ichain][inhc_z[ipart]]*
                therm_v1[ichain][inhc_z[ipart]]-k_BT;
              therm_v2[ichain][inhc_z[ipart]]+=
   therm_wdti4[iyosh]*therm_f[ichain][inhc_z[ipart]]/(mass_factor*therm_mass[ichain][inhc_z[ipart]]);
                                         }}
    }}
                  }

variable_types: struct clatoms_info { int natm_tot; int pi_beads; int pi_beads_proc; int pi_beads_proc_st; int pi_beads_proc_end; int nfree; int nfree_pimd; int nchrg; int pi_beads_full_ter; int pi_beads_res_ter; int pi_beads_full_tra; int pi_beads_res_tra; int cg_reset_flag; int natm_mall; int nchrg_mall; int hess_calc; int natm_proc; int N_H2; int i_H2_start; int nab_initio; int myatm_start; double gamma_adb; double wght_pimd; double pi_temperature; double pi_beads_full_ter_wght; double pi_beads_res_ter_wght; double pi_beads_full_tra_wght; double pi_beads_res_tra_wght; double rcut_spread; double mass_sc_fact; int *ip_lab; int *ichrg; int *cp_vlnc_up; int *cp_atm_flag; double *mass; double *q; double *alp_pol; double *b_neut; double *roll_sc; double *text_atm; double *text_mol; double *xold; double *prekf; double *xmod; double alp_ewd; } *

variable_types: struct clatoms_pos { double *mass; double *x; double *vx; double *fx; double *fxt; double *fxm; double *hess_xx; } *

variable_types: struct therm_info { int num_nhc; int len_nhc; int nres_nhc; int nyosh_nhc; int therm_typ; int num_nhc_proc; int num_nhc_share; int mytherm_start; double dt_nhc; int *inhc_x; int *itherm_nshare; double *ditherm_nshare_i; int *map_share; double *text_nhc; double *wdti; double **mass_nhc; } *

variable_types: struct therm_pos { double **x_nhc; double x_nhc_tot; } *

variable_types: struct int_scr { double v_lnv; double *x; double *vx; double *gx; double **x_nhc; double *vgmat; double *x_vol_nhc; double *sc; double *sc_temp; double *atm_kin; double *step_up; struct therm_scr { double *sc; double *atm_kin; } *therm_scr; } *

variable_types: struct class_comm_forc_pkg { int num_proc; int myid; int myatm_start; int mytherm_start; int *displs_atm; int *displs_therm; int comm; int world; double dbl_num_proc; struct class_plimpton_ind { int num_proc_source; int num_proc_target; int myid_source; int myid_target; int natoms_tot; int *index_src; int *index_src_even; int *index_src_odd; int *index_trg; int *index_trg_even; int *index_trg_odd; int *displs_atm_trg; int *displs_atm_src; int *src_odd_end; int *src_even_end; int *trg_odd_end; int *trg_even_end; int *src_odd_begin; int *src_even_begin; int *trg_odd_begin; int *trg_even_begin; int my_src_odd_counts; int my_src_even_counts; int my_trg_odd_counts; int my_trg_even_counts; int *my_src_odd; int *my_src_even; int *my_trg_odd; int *my_trg_even; int **jmax; int *jmin; int **imax; int source; int target; } plimpton_ind; } *

variable_types: iresn int

variable_types: iyosh int

variable_types: arg double

variable_types: aa double

variable_types: world int

variable_types: kinetic double

variable_types: LkT double

return_type: void

user_defined_types: struct int_scr { double v_lnv; double *x; double *vx; double *gx; double **x_nhc; double *vgmat; double *x_vol_nhc; double *sc; double *sc_temp; double *atm_kin; double *step_up; struct therm_scr *therm_scr; }

user_defined_types: struct class_comm_forc_pkg { int num_proc; int myid; int myatm_start; int mytherm_start; int *displs_atm; int *displs_therm; int comm; int world; double dbl_num_proc; struct class_plimpton_ind plimpton_ind; }