original_code:
void convert_pimd_pos_stag_par(
              CLATOMS_INFO *clatoms_info, CLATOMS_POS *clatoms_pos,
              CLATOMS_TRAN *clatoms_tran, COMMUNICATE *communicate)
{
  int ip,ipart,ip1,iii,iopt,ioff,ipart_1,ipart_ip,ipart_ip1;
  int pi_beads = clatoms_info->pi_beads;
  int pi_atm_proc_use = clatoms_tran->pi_atm_proc_use;
  int natm_tot = clatoms_info->natm_tot;
  double *rat1 = clatoms_tran->rat1_stag;
  double *rat2 = clatoms_tran->rat2_stag;
  double *x = clatoms_tran->x_temp;
  double *y = clatoms_tran->y_temp;
  double *z = clatoms_tran->z_temp;
  double xadd,yadd,zadd;
  if(pi_beads!=1){
    iopt = 1;
    pimd_trans_comm_fwd(clatoms_info,clatoms_pos,clatoms_tran,
                                                communicate,iopt);
    ip = pi_beads;
    for(ipart=1;ipart<=pi_atm_proc_use;ipart++){
      ioff = (ipart-1)*pi_beads;
      ipart_1 = ioff+1;
      ipart_ip = ioff+ip;
      x[ipart_ip] += x[ipart_1];
      y[ipart_ip] += y[ipart_1];
      z[ipart_ip] += z[ipart_1];
    }
    ioff = 0;
    for(ipart=1;ipart<=pi_atm_proc_use;ipart++){
      ipart_1 = ioff+1;
      for(ip=pi_beads-1;ip>=2;ip--){
        ipart_ip = ioff+ip;
        ipart_ip1 = ioff+ip+1;
        xadd = rat1[ip]*x[ipart_ip1]+x[ipart_1]*rat2[ip];
        yadd = rat1[ip]*y[ipart_ip1]+y[ipart_1]*rat2[ip];
        zadd = rat1[ip]*z[ipart_ip1]+z[ipart_1]*rat2[ip];
        x[ipart_ip] += xadd;
        y[ipart_ip] += yadd;
        z[ipart_ip] += zadd;
      }
      ioff += pi_beads;
    }
    pimd_trans_comm_bck(clatoms_info,clatoms_pos,clatoms_tran,
                                                communicate,iopt);
  }
}

canonical_original_code:
void convert_pimd_pos_stag_par(struct clatoms_info *clatoms_info, struct clatoms_pos *clatoms_pos, struct clatoms_tran *clatoms_tran, struct communicate *communicate)
{
  int ip; int ipart; int ip1; int iii; int iopt; int ioff; int ipart_1; int ipart_ip; int ipart_ip1;
  int pi_beads = clatoms_info->pi_beads;
  int pi_atm_proc_use = clatoms_tran->pi_atm_proc_use;
  int natm_tot = clatoms_info->natm_tot;
  double *rat1 = clatoms_tran->rat1_stag;
  double *rat2 = clatoms_tran->rat2_stag;
  double *x = clatoms_tran->x_temp;
  double *y = clatoms_tran->y_temp;
  double *z = clatoms_tran->z_temp;
  double xadd; double yadd; double zadd;
  if(pi_beads!=1){
    iopt = 1;
    pimd_trans_comm_fwd(clatoms_info,clatoms_pos,clatoms_tran,
                                                communicate,iopt);
    ip = pi_beads;
    for(ipart=1;ipart<=pi_atm_proc_use;ipart++){
      ioff = (ipart-1)*pi_beads;
      ipart_1 = ioff+1;
      ipart_ip = ioff+ip;
      x[ipart_ip] += x[ipart_1];
      y[ipart_ip] += y[ipart_1];
      z[ipart_ip] += z[ipart_1];
    }
    ioff = 0;
    for(ipart=1;ipart<=pi_atm_proc_use;ipart++){
      ipart_1 = ioff+1;
      for(ip=pi_beads-1;ip>=2;ip--){
        ipart_ip = ioff+ip;
        ipart_ip1 = ioff+ip+1;
        xadd = rat1[ip]*x[ipart_ip1]+x[ipart_1]*rat2[ip];
        yadd = rat1[ip]*y[ipart_ip1]+y[ipart_1]*rat2[ip];
        zadd = rat1[ip]*z[ipart_ip1]+z[ipart_1]*rat2[ip];
        x[ipart_ip] += xadd;
        y[ipart_ip] += yadd;
        z[ipart_ip] += zadd;
      }
      ioff += pi_beads;
    }
    pimd_trans_comm_bck(clatoms_info,clatoms_pos,clatoms_tran,
                                                communicate,iopt);
  }
}

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: iii int

variable_types:
x
double *

variable_types:
y
double *

variable_types:
z
double *

variable_types: xadd double

variable_types: yadd double

variable_types: zadd double


repo: TuckermanGroup/PINY

original_code:
void shake_control_cp(CP *cp,int *iter_shake, double dt,int ip)
   {
 int iii;
  int cp_norb = cp->cpopts.cp_norb;
  int cp_lsda = cp->cpopts.cp_lsda;
  int np_states = cp->communicate.np_states;
  double c_tolshake = cp->cpconstrnt.c_tolshake;
  int *cpcoeffs_ioff_upt = cp->cpcoeffs_info.ioff_upt;
  int *cpcoeffs_ioff_dnt = cp->cpcoeffs_info.ioff_dnt;
  double *cpcoeffs_cre_up = cp->cpcoeffs_pos[ip].cre_up;
  double *cpcoeffs_cim_up = cp->cpcoeffs_pos[ip].cim_up;
  double *cpcoeffs_cre_dn = cp->cpcoeffs_pos[ip].cre_dn;
  double *cpcoeffs_cim_dn = cp->cpcoeffs_pos[ip].cim_dn;
  double *cpcoeffs_vcre_up = cp->cpcoeffs_pos[ip].vcre_up;
  double *cpcoeffs_vcim_up = cp->cpcoeffs_pos[ip].vcim_up;
  double *cpcoeffs_vcre_dn = cp->cpcoeffs_pos[ip].vcre_dn;
  double *cpcoeffs_vcim_dn = cp->cpcoeffs_pos[ip].vcim_dn;
  int icoef_form_up = cp->cpcoeffs_pos[ip].icoef_form_up;
  int icoef_form_old_up = cp->cpcoeffs_pos[ip].icoef_form_up;
  int icoef_orth_up = cp->cpcoeffs_pos[ip].icoef_orth_up;
  int ivcoef_form_up = cp->cpcoeffs_pos[ip].ivcoef_form_up;
  int icoef_form_dn = cp->cpcoeffs_pos[ip].icoef_form_dn;
  int icoef_form_old_dn = cp->cpcoeffs_pos[ip].icoef_form_dn;
  int icoef_orth_dn = cp->cpcoeffs_pos[ip].icoef_orth_dn;
  int ivcoef_form_dn = cp->cpcoeffs_pos[ip].ivcoef_form_dn;
  int nstate_up = cp->cpcoeffs_info.nstate_up;
  int nstate_dn = cp->cpcoeffs_info.nstate_dn;
  double *cpcoeffs_cmass = cp->cpcoeffs_info.cmass;
  int icmass_unif = cp->cpcoeffs_info.icmass_unif;
  double *occ_up = cp->cpopts.occ_up;
  double *occ_dn = cp->cpopts.occ_dn;
  double *rocc_sum_up = cp->cpopts.rocc_sum_up;
  double *rocc_sum_dn = cp->cpopts.rocc_sum_dn;
  double *cpscr_cre_up = cp->cpscr.cpscr_wave.cre_up;
  double *cpscr_cim_up = cp->cpscr.cpscr_wave.cim_up;
  double *cpscr_cre_dn = cp->cpscr.cpscr_wave.cre_dn;
  double *cpscr_cim_dn = cp->cpscr.cpscr_wave.cim_dn;
 if(cp_norb <= 1) {
  if(icmass_unif == 1) {
    cp_shake(cpcoeffs_cre_up,cpcoeffs_cim_up,icoef_form_up,icoef_orth_up,
             cpcoeffs_vcre_up,cpcoeffs_vcim_up,ivcoef_form_up,
             cpscr_cre_up,cpscr_cim_up,icoef_form_old_up,
             c_tolshake,dt,&(cp->cpscr.cpscr_ovmat),
             cpcoeffs_ioff_upt,occ_up,rocc_sum_up,cp_norb,
             iter_shake,&(cp->cp_comm_state_pkg_up));
    if(cp_lsda == 1 && nstate_dn != 0) {
      cp_shake(cpcoeffs_cre_dn,cpcoeffs_cim_dn,icoef_form_dn,icoef_orth_dn,
               cpcoeffs_vcre_dn,cpcoeffs_vcim_dn,ivcoef_form_dn,
               cpscr_cre_dn,cpscr_cim_dn,icoef_form_old_dn,
               c_tolshake,dt,&(cp->cpscr.cpscr_ovmat),
               cpcoeffs_ioff_dnt,occ_dn,rocc_sum_dn,cp_norb,
               iter_shake,&(cp->cp_comm_state_pkg_dn));
    }
  } else {
    cp_shake_mass(cpcoeffs_cre_up,cpcoeffs_cim_up,icoef_form_up,icoef_orth_up,
                  cpcoeffs_vcre_up,cpcoeffs_vcim_up,ivcoef_form_up,
                  cpscr_cre_up,cpscr_cim_up,icoef_form_old_up,
                  cpcoeffs_cmass,
                  c_tolshake,dt,&(cp->cpscr.cpscr_ovmat),
                  cpcoeffs_ioff_upt,occ_up,rocc_sum_up,cp_norb,
                  iter_shake,&(cp->cp_comm_state_pkg_up));
    if(cp_lsda == 1 && nstate_dn != 0){
     cp_shake_mass(cpcoeffs_cre_dn,cpcoeffs_cim_dn,icoef_form_dn,icoef_orth_dn,
                   cpcoeffs_vcre_dn,cpcoeffs_vcim_dn,ivcoef_form_dn,
                   cpscr_cre_dn,cpscr_cim_dn,icoef_form_old_dn,
                   cpcoeffs_cmass,
                   c_tolshake,dt,&(cp->cpscr.cpscr_ovmat),
                   cpcoeffs_ioff_dnt,occ_dn,rocc_sum_dn,cp_norb,
                   iter_shake,&(cp->cp_comm_state_pkg_dn));
    }
  }
 }
 if(cp_norb== 2){
  cp_shake_norb(cpcoeffs_cre_up,cpcoeffs_cim_up,icoef_form_up,icoef_orth_up,
                cpcoeffs_vcre_up,cpcoeffs_vcim_up,ivcoef_form_up,
                cpscr_cre_up,cpscr_cim_up,icoef_form_old_up,
                dt,cpcoeffs_ioff_upt,occ_up,cpcoeffs_cmass,icmass_unif,
                &(cp->cpscr.cpscr_ovmat),
                &(cp->cp_comm_state_pkg_dn));
  if(cp_lsda == 1 && nstate_dn != 0) {
    cp_shake_norb(cpcoeffs_cre_dn,cpcoeffs_cim_dn,icoef_form_dn,icoef_orth_dn,
                  cpcoeffs_vcre_dn,cpcoeffs_vcim_dn,ivcoef_form_dn,
                  cpscr_cre_dn,cpscr_cim_dn,icoef_form_old_dn,
                  dt,cpcoeffs_ioff_dnt,occ_dn,cpcoeffs_cmass,icmass_unif,
                  &(cp->cpscr.cpscr_ovmat),
                  &(cp->cp_comm_state_pkg_dn));
  }
 }
   }

canonical_original_code:
void shake_control_cp(struct cp *cp, int *iter_shake, double dt, int ip)
   {
 int iii;
  int cp_norb = cp->cpopts.cp_norb;
  int cp_lsda = cp->cpopts.cp_lsda;
  int np_states = cp->communicate.np_states;
  double c_tolshake = cp->cpconstrnt.c_tolshake;
  int *cpcoeffs_ioff_upt = cp->cpcoeffs_info.ioff_upt;
  int *cpcoeffs_ioff_dnt = cp->cpcoeffs_info.ioff_dnt;
  double *cpcoeffs_cre_up = cp->cpcoeffs_pos[ip].cre_up;
  double *cpcoeffs_cim_up = cp->cpcoeffs_pos[ip].cim_up;
  double *cpcoeffs_cre_dn = cp->cpcoeffs_pos[ip].cre_dn;
  double *cpcoeffs_cim_dn = cp->cpcoeffs_pos[ip].cim_dn;
  double *cpcoeffs_vcre_up = cp->cpcoeffs_pos[ip].vcre_up;
  double *cpcoeffs_vcim_up = cp->cpcoeffs_pos[ip].vcim_up;
  double *cpcoeffs_vcre_dn = cp->cpcoeffs_pos[ip].vcre_dn;
  double *cpcoeffs_vcim_dn = cp->cpcoeffs_pos[ip].vcim_dn;
  int icoef_form_up = cp->cpcoeffs_pos[ip].icoef_form_up;
  int icoef_form_old_up = cp->cpcoeffs_pos[ip].icoef_form_up;
  int icoef_orth_up = cp->cpcoeffs_pos[ip].icoef_orth_up;
  int ivcoef_form_up = cp->cpcoeffs_pos[ip].ivcoef_form_up;
  int icoef_form_dn = cp->cpcoeffs_pos[ip].icoef_form_dn;
  int icoef_form_old_dn = cp->cpcoeffs_pos[ip].icoef_form_dn;
  int icoef_orth_dn = cp->cpcoeffs_pos[ip].icoef_orth_dn;
  int ivcoef_form_dn = cp->cpcoeffs_pos[ip].ivcoef_form_dn;
  int nstate_up = cp->cpcoeffs_info.nstate_up;
  int nstate_dn = cp->cpcoeffs_info.nstate_dn;
  double *cpcoeffs_cmass = cp->cpcoeffs_info.cmass;
  int icmass_unif = cp->cpcoeffs_info.icmass_unif;
  double *occ_up = cp->cpopts.occ_up;
  double *occ_dn = cp->cpopts.occ_dn;
  double *rocc_sum_up = cp->cpopts.rocc_sum_up;
  double *rocc_sum_dn = cp->cpopts.rocc_sum_dn;
  double *cpscr_cre_up = cp->cpscr.cpscr_wave.cre_up;
  double *cpscr_cim_up = cp->cpscr.cpscr_wave.cim_up;
  double *cpscr_cre_dn = cp->cpscr.cpscr_wave.cre_dn;
  double *cpscr_cim_dn = cp->cpscr.cpscr_wave.cim_dn;
 if(cp_norb <= 1) {
  if(icmass_unif == 1) {
    cp_shake(cpcoeffs_cre_up,cpcoeffs_cim_up,icoef_form_up,icoef_orth_up,
             cpcoeffs_vcre_up,cpcoeffs_vcim_up,ivcoef_form_up,
             cpscr_cre_up,cpscr_cim_up,icoef_form_old_up,
             c_tolshake,dt,&(cp->cpscr.cpscr_ovmat),
             cpcoeffs_ioff_upt,occ_up,rocc_sum_up,cp_norb,
             iter_shake,&(cp->cp_comm_state_pkg_up));
    if(cp_lsda == 1 && nstate_dn != 0) {
      cp_shake(cpcoeffs_cre_dn,cpcoeffs_cim_dn,icoef_form_dn,icoef_orth_dn,
               cpcoeffs_vcre_dn,cpcoeffs_vcim_dn,ivcoef_form_dn,
               cpscr_cre_dn,cpscr_cim_dn,icoef_form_old_dn,
               c_tolshake,dt,&(cp->cpscr.cpscr_ovmat),
               cpcoeffs_ioff_dnt,occ_dn,rocc_sum_dn,cp_norb,
               iter_shake,&(cp->cp_comm_state_pkg_dn));
    }
  } else {
    cp_shake_mass(cpcoeffs_cre_up,cpcoeffs_cim_up,icoef_form_up,icoef_orth_up,
                  cpcoeffs_vcre_up,cpcoeffs_vcim_up,ivcoef_form_up,
                  cpscr_cre_up,cpscr_cim_up,icoef_form_old_up,
                  cpcoeffs_cmass,
                  c_tolshake,dt,&(cp->cpscr.cpscr_ovmat),
                  cpcoeffs_ioff_upt,occ_up,rocc_sum_up,cp_norb,
                  iter_shake,&(cp->cp_comm_state_pkg_up));
    if(cp_lsda == 1 && nstate_dn != 0){
     cp_shake_mass(cpcoeffs_cre_dn,cpcoeffs_cim_dn,icoef_form_dn,icoef_orth_dn,
                   cpcoeffs_vcre_dn,cpcoeffs_vcim_dn,ivcoef_form_dn,
                   cpscr_cre_dn,cpscr_cim_dn,icoef_form_old_dn,
                   cpcoeffs_cmass,
                   c_tolshake,dt,&(cp->cpscr.cpscr_ovmat),
                   cpcoeffs_ioff_dnt,occ_dn,rocc_sum_dn,cp_norb,
                   iter_shake,&(cp->cp_comm_state_pkg_dn));
    }
  }
 }
 if(cp_norb== 2){
  cp_shake_norb(cpcoeffs_cre_up,cpcoeffs_cim_up,icoef_form_up,icoef_orth_up,
                cpcoeffs_vcre_up,cpcoeffs_vcim_up,ivcoef_form_up,
                cpscr_cre_up,cpscr_cim_up,icoef_form_old_up,
                dt,cpcoeffs_ioff_upt,occ_up,cpcoeffs_cmass,icmass_unif,
                &(cp->cpscr.cpscr_ovmat),
                &(cp->cp_comm_state_pkg_dn));
  if(cp_lsda == 1 && nstate_dn != 0) {
    cp_shake_norb(cpcoeffs_cre_dn,cpcoeffs_cim_dn,icoef_form_dn,icoef_orth_dn,
                  cpcoeffs_vcre_dn,cpcoeffs_vcim_dn,ivcoef_form_dn,
                  cpscr_cre_dn,cpscr_cim_dn,icoef_form_old_dn,
                  dt,cpcoeffs_ioff_dnt,occ_dn,cpcoeffs_cmass,icmass_unif,
                  &(cp->cpscr.cpscr_ovmat),
                  &(cp->cp_comm_state_pkg_dn));
  }
 }
   }

variable_types: struct cp { struct cpopts { int cp_lda; int cp_sic; int cp_gga; int cp_nonint; int cp_norb; int cp_gauss; int cp_ptens_calc; int cp_init_orthog; int cp_gs; int cp_ngrid_skip; int cp_hess_calc; int zero_cp_vel; int iwrite_coef_binary; int iread_coef_binary; int icheck_perd_size; int icheck_dual_size; int cp_para_opt; int cp_becke; int cp_pw91x; int cp_fila_1x; int cp_fila_2x; int cp_pbe_x; int cp_revpbe_x; int cp_rpbe_x; int cp_xpbe_x; int cp_brx89; int cp_brx2k; int cp_lyp; int cp_lypm1; int cp_pw91c; int cp_pbe_c; int cp_xpbe_c; int cp_tau1_c; int cp_debug_xc; int cp_dual_grid_opt; int cp_isok_opt; double te_ext; double tol_edge_dist; double tol_coef; double *occ_up; double *rocc_sum_up; double *rocc_sum_dn; } cpopts; struct cpcoeffs_info { int pi_beads; int nstate_up; int icmass_unif; int ks_rot_on; int n_ks_rot; int cp_ke_dens_on; int cp_tau_functional; int cp_elf_calc_frq; int cp_laplacian_on; int cp_nfree; int cp_nfree_up; int cp_nfree_dn; int pi_beads_proc; int pi_beads_proc_st; int pi_beads_proc_end; int nstate_up_proc; int istate_up_st; int istate_up_end; int cg_reset_flag; int diis_reset_flag; int ncoef; int ncoef_l; int ncoef_l_dens_cp_box; int icoef_start_up; int nstate_ncoef_proc_up; int nstate_ncoef_proc_max_up; int icoef_start_dn; int nstate_ncoef_proc_dn; int nstate_ncoef_proc_max_dn; int *ioff_up; int *ioff_upt; double ecut; double ecut_dens_cp_box; double cp_hess_cut; double pseud_hess_loc; double max_off_diag; double max_diag; double *cmass; double k0_up; } cpcoeffs_info; struct cpcoeffs_pos { double *cre_up; double *cre_dn; double *vcre_up; double *vcre_dn; double *fcre_up; double *fcre_dn; double *cp_hess_re_up; double *cp_hess_im_up; double *cp_hess_re_dn; double *cp_hess_im_dn; double *ksmat_up; double *ksmat_eig_up; double *ksmat_eig_dn; double ks_offset; double *norbmat_up; double *norbmati_up; double *ovmat_eigv_up; double *ovmat_eigv_dn; int icoef_form_up; int ivcoef_form_up; int ifcoef_form_up; int icoef_orth_up; int ivcoef_orth_up; int ifcoef_orth_up; double max_diag; } *cpcoeffs_pos; struct cptherm_info { int num_c_nhc; int num_c_nhc_proc; int num_c_nhc_norm; int len_c_nhc; int nres_c_nhc; int nyosh_c_nhc; int massiv_flag; int istate_nhc_opt; double cp_therm_heat_fact; double dt_nhc; double c_gkt_massiv; double cmass_nhc_massiv; int *icmapup_nhc; int *icmapdn_nhc; double *wdti; double **c_gkt; double **cmass_nhc; } cptherm_info; struct cptherm_pos { double c_nhc_massiv; double **c_nhc; double **vc_nhc; double **fc_nhc; int itherm_form_up; int itherm_form_dn; } *cptherm_pos; struct electronic_properties { double *cp_elf_up; } electronic_properties; struct cpewald { int nktot_sm; int nktot_dens_cp_box; int nktot_cp_mall; int nktot_cp_sm_mall; int nktot_dens_cp_box_mall; int box_rat; double dbox_rat; double gw_gmin; double gw_gmin_dens_cp_box; int *kmax_cp; int *kmax_cp_dens_cp_box; int *kastr_sm; int *kastr_dens_cp_box; int *ibrk1_sm; int *ibrk1_dens_cp_box; double *ak2; double *ak2_dens_cp_box; } cpewald; struct cpconstrnt { double c_tolshake; double c_tolratl; double c_tolnorb; } cpconstrnt; struct pseudo { int n_ang_max; int n_ang_max_gh; int n_ang_max_kb; int n_rad_max; int nsplin_g; int nsplin_g_tot; int num_nl_lst; int nl_cut_on; int n_ang_mall; int nsplin_g_mall; int nvpsnorm_mall; int nlist_mall; int n_interp_pme_dual; int natm_typ_nl; int natm_typ_gh; int ngh; double gmin_true; double gmin_spl; double gmax_spl; double dg_spl; double gga_cut; double nlvps_skin; double alpha_conv_dual; int *n_ang; int *nrad_0; int *nrad_max_l; int *loc_opt; int *ivps_label; int *np_nl; int *np_nl_gh; int **np_nl_rad_str; int **np_nl_rad_end; int *ip_nl; int *ip_nl_rev; int *ip_nl_gh; int *ip_nl_rev_gh; int *map_nl; int np_loc_cp_box; int np_nonloc_cp_box; int np_nonloc_cp_box_kb; int np_nonloc_cp_box_gh; int *ip_loc_cp_box; int *ip_nonloc_cp_box; double *vps0; double *dvps0; double *gzvps; double *gzvps0; double *vpsnorm; double *rcut_nl; double *rgh; double *x0w; double *q_pseud; char *vxc_typ; char *ggax_typ; char *ggac_typ; } pseudo; struct cpscr { struct cpscr_loc { double *vextr; double *vextr_dens_cp_box; double *dvextr; } cpscr_loc; struct cpscr_nonloc { int natm_nls_max; int nlscr_up; int nlscr_dn; double *vnlre_up; double *vnlre_dn; double *dvnlre_x_up; double *dvnlim_x_up; double *dvnlre_x_dn; double *dvnlim_x_dn; double *dvnlre_gxgx_up; double *dvnlre_gygy_up; double *dvnlre_gzgz_up; double *dvnlre_gxgy_up; double *dvnlre_gygz_up; double *dvnlre_gxgz_up; double *dvnlre_gxgx_dn; double *dvnlre_gygy_dn; double *dvnlre_gzgz_dn; double *dvnlre_gxgy_dn; double *dvnlre_gygz_dn; double *dvnlre_gxgz_dn; } cpscr_nonloc; struct cpscr_rho { int iset_map_flag; int iset_map_upack_flag; int iset_map_flag_pme; int iset_map_upack_flag_pme; int *map_dual; int *map_dual_upack; double *v_ks_up; double *v_ks_dn; double *v_ks_tau_up; double *v_ks_tau_dn; double *rho_up; double *rho_dn; double *rhocr_up; double *rhocr_scr; double *rhocr_up_dens_cp_box; double *rhocr_dn; double *rhocr_dn_dens_cp_box; } cpscr_rho; struct cpscr_grho { double *d2_rho_up; double *d2_rho_dn; double *d2_rho_up_store; double *d2_rho_dn_store; double *d_rhox_up; double *d_rhox_dn; double *dm_rhox_up; double *dm_rhox_dn; double *elec_ke_dens_up; double *g_rhor_x; double *g_rhoi_x; double *g2_rhor; double *rhocr_up_st; double *rhocr_dn_st; } cpscr_grho; struct cpscr_ovmat { double *ovlap1; double *ovlap3; double *ovlap5; double *ovlap7; double *state_vec1; double *state_vec2; double *state_vec3; double *state_vec4; double *state_vec5; double *state_vec6; double *state_vec7; } cpscr_ovmat; struct cpscr_wave { double *zfft; int zfft_mall_size; double *cre_up; double *cre_dn; } cpscr_wave; struct cpscr_therm { double *coef_kin; double *sc_cp; } cpscr_therm; struct cpscr_dual_pme { int *iatemp; int **igrid_a; int **igrid_now; double *a_pme; double *frac_a; double *aj; double **mn_a; double **ua; double *bw_r; int nfft_send_big_small; int nfft_recv_big_small; int num_rows_tot; int *ioff_lg_sm; int **joff_sm_lg; } cpscr_dual_pme; struct cpscr_atom_pme { int pme_on; int n_interp; int pme_para_opt; int nlen_pme; int nktot_pme; int nkf1; int ngrid_a; int *iatemp; int *nc; int **igrid_a; int **igrid_now; double *frac_a; double *aj; double **ua; double **mn_a; double **dmn_a; double **qgrid_now; double *qgrid; double *qgrid_scr; double *qgrid_tmp_real; double *qgrid_tmp_imag; double *bweight_tot; double *bw_r; } cpscr_atom_pme; } cpscr; 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; } communicate; 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; } cp_sclr_fft_pkg3d_sm; struct para_fft_pkg3d cp_para_fft_pkg3d_sm; struct para_fft_pkg3d cp_sclr_fft_pkg3d_dens_cp_box; struct para_fft_pkg3d cp_para_fft_pkg3d_dens_cp_box; struct para_fft_pkg3d cp_sclr_fft_pkg3d_lg; struct para_fft_pkg3d cp_para_fft_pkg3d_lg; struct cp_comm_state_pkg { int num_proc; int myid; int nstate; int nstate_max; int ncoef; int nstate_proc; int nstate_proc_max; int nstate_ncoef_proc_max; int nstate_ncoef_proc; int icoef_start; int comm; int world; int ioff_therm_norm[3]; } cp_comm_state_pkg_up; struct cp_comm_state_pkg cp_comm_state_pkg_dn; struct vel_samp_cp { int ivelc_smpl_on; int ivelc_scal_on; int nvc_smpl; int nvcnhc_smpl; int nvc_scal; int iseed; int iauto_vc_scal_opt; double qseed; double vc_scal_tol; double div_scal; } vel_samp_cp; } *

variable_types: dt double

variable_types: ip int

return_type: void

user_defined_types: struct cp { struct cpopts cpopts; struct cpcoeffs_info cpcoeffs_info; struct cpcoeffs_pos *cpcoeffs_pos; struct cptherm_info cptherm_info; struct cptherm_pos *cptherm_pos; struct electronic_properties electronic_properties; struct cpewald cpewald; struct cpconstrnt cpconstrnt; struct pseudo pseudo; struct cpscr cpscr; struct communicate communicate; struct para_fft_pkg3d cp_sclr_fft_pkg3d_sm; struct para_fft_pkg3d cp_para_fft_pkg3d_sm; struct para_fft_pkg3d cp_sclr_fft_pkg3d_dens_cp_box; struct para_fft_pkg3d cp_para_fft_pkg3d_dens_cp_box; struct para_fft_pkg3d cp_sclr_fft_pkg3d_lg; struct para_fft_pkg3d cp_para_fft_pkg3d_lg; struct cp_comm_state_pkg cp_comm_state_pkg_up; struct cp_comm_state_pkg cp_comm_state_pkg_dn; struct vel_samp_cp vel_samp_cp; }

user_defined_types: struct cpscr { struct cpscr_loc cpscr_loc; struct cpscr_nonloc cpscr_nonloc; struct cpscr_rho cpscr_rho; struct cpscr_grho cpscr_grho; struct cpscr_ovmat cpscr_ovmat; struct cpscr_wave cpscr_wave; struct cpscr_therm cpscr_therm; struct cpscr_dual_pme cpscr_dual_pme; struct cpscr_atom_pme cpscr_atom_pme; }


original_code:
void rattle_control_cp(CP *cp,int *iter_rattle,double dt,int ip)
{
  int iii;
  int cp_norb = cp->cpopts.cp_norb;
  int cp_lsda = cp->cpopts.cp_lsda;
  int np_states = cp->communicate.np_states;
  double c_tolratl = cp->cpconstrnt.c_tolratl;
  int *cpcoeffs_ioff_upt = cp->cpcoeffs_info.ioff_upt;
  int *cpcoeffs_ioff_dnt = cp->cpcoeffs_info.ioff_dnt;
  double *cpcoeffs_cre_up = cp->cpcoeffs_pos[ip].cre_up;
  double *cpcoeffs_cim_up = cp->cpcoeffs_pos[ip].cim_up;
  double *cpcoeffs_cre_dn = cp->cpcoeffs_pos[ip].cre_dn;
  double *cpcoeffs_cim_dn = cp->cpcoeffs_pos[ip].cim_dn;
  double *cpcoeffs_vcre_up = cp->cpcoeffs_pos[ip].vcre_up;
  double *cpcoeffs_vcim_up = cp->cpcoeffs_pos[ip].vcim_up;
  double *cpcoeffs_vcre_dn = cp->cpcoeffs_pos[ip].vcre_dn;
  double *cpcoeffs_vcim_dn = cp->cpcoeffs_pos[ip].vcim_dn;
  int icoef_form_up = cp->cpcoeffs_pos[ip].icoef_form_up;
  int icoef_orth_up = cp->cpcoeffs_pos[ip].icoef_orth_up;
  int ivcoef_form_up = cp->cpcoeffs_pos[ip].ivcoef_form_up;
  int icoef_form_dn = cp->cpcoeffs_pos[ip].icoef_form_dn;
  int icoef_orth_dn = cp->cpcoeffs_pos[ip].icoef_orth_dn;
  int ivcoef_form_dn = cp->cpcoeffs_pos[ip].ivcoef_form_dn;
  int nstate_up = cp->cpcoeffs_info.nstate_up;
  int nstate_dn = cp->cpcoeffs_info.nstate_dn;
  double *cpcoeffs_cmass = cp->cpcoeffs_info.cmass;
  int icmass_unif = cp->cpcoeffs_info.icmass_unif;
  double *occ_up = cp->cpopts.occ_up;
  double *occ_dn = cp->cpopts.occ_dn;
  double *rocc_sum_up = cp->cpopts.rocc_sum_up;
  double *rocc_sum_dn = cp->cpopts.rocc_sum_dn;
  double *cpscr_cre_up = cp->cpscr.cpscr_wave.cre_up;
  double *cpscr_cim_up = cp->cpscr.cpscr_wave.cim_up;
  double *cpscr_cre_dn = cp->cpscr.cpscr_wave.cre_dn;
  double *cpscr_cim_dn = cp->cpscr.cpscr_wave.cim_dn;
 if(cp_norb <= 1) {
  if(icmass_unif == 1) {
   cp_rattle(cpcoeffs_cre_up,cpcoeffs_cim_up,icoef_form_up,icoef_orth_up,
             cpcoeffs_vcre_up,cpcoeffs_vcim_up,ivcoef_form_up,
             &(cp->cpscr.cpscr_ovmat),
             cpcoeffs_ioff_upt,rocc_sum_up,&(cp->cp_comm_state_pkg_up),
             cp_norb);
   if(cp_lsda== 1 && nstate_dn != 0){
     cp_rattle(cpcoeffs_cre_dn,cpcoeffs_cim_dn,icoef_form_dn,icoef_orth_dn,
               cpcoeffs_vcre_dn,cpcoeffs_vcim_dn,ivcoef_form_dn,
               &(cp->cpscr.cpscr_ovmat),
               cpcoeffs_ioff_dnt,rocc_sum_dn,&(cp->cp_comm_state_pkg_dn),
               cp_norb);
   }
  } else {
    cp_rattle_mass(cpcoeffs_cre_up,cpcoeffs_cim_up,icoef_form_up,icoef_orth_up,
                   cpcoeffs_vcre_up,cpcoeffs_vcim_up,ivcoef_form_up,
                   cpscr_cre_up,cpscr_cim_up,c_tolratl,
                   cpcoeffs_cmass,&(cp->cpscr.cpscr_ovmat),
                   cpcoeffs_ioff_upt,occ_up,rocc_sum_up,
                   iter_rattle,&(cp->cp_comm_state_pkg_up),cp_norb);
   if(cp_lsda== 1 && nstate_dn != 0){
    cp_rattle_mass(cpcoeffs_cre_dn,cpcoeffs_cim_dn,icoef_form_dn,icoef_orth_dn,
                   cpcoeffs_vcre_dn,cpcoeffs_vcim_dn,ivcoef_form_dn,
                   cpscr_cre_dn,cpscr_cim_dn,c_tolratl,
                   cpcoeffs_cmass,&(cp->cpscr.cpscr_ovmat),
                   cpcoeffs_ioff_dnt,occ_dn,rocc_sum_dn,
                   iter_rattle,&(cp->cp_comm_state_pkg_dn),cp_norb);
   }
  }
 }
 if(cp_norb== 2){
  cp_rattle_norb(cpcoeffs_cre_up,cpcoeffs_cim_up,icoef_form_up,icoef_orth_up,
                 cpcoeffs_vcre_up,cpcoeffs_vcim_up,ivcoef_form_up,
                 cpscr_cre_up,cpscr_cim_up,
                 cpcoeffs_ioff_upt,occ_up,cpcoeffs_cmass,icmass_unif,
                 &(cp->cpscr.cpscr_ovmat),
                 &(cp->cp_comm_state_pkg_up));
  if(cp_lsda== 1 && nstate_dn != 0) {
    cp_rattle_norb(cpcoeffs_cre_dn,cpcoeffs_cim_dn,icoef_form_dn,icoef_orth_dn,
                   cpcoeffs_vcre_dn,cpcoeffs_vcim_dn,ivcoef_form_dn,
                   cpscr_cre_dn,cpscr_cim_dn,
                   cpcoeffs_ioff_dnt,occ_dn,cpcoeffs_cmass,icmass_unif,
                   &(cp->cpscr.cpscr_ovmat),
                   &(cp->cp_comm_state_pkg_dn));
  }
 }
   }

canonical_original_code:
void rattle_control_cp(struct cp *cp, int *iter_rattle, double dt, int ip)
{
  int iii;
  int cp_norb = cp->cpopts.cp_norb;
  int cp_lsda = cp->cpopts.cp_lsda;
  int np_states = cp->communicate.np_states;
  double c_tolratl = cp->cpconstrnt.c_tolratl;
  int *cpcoeffs_ioff_upt = cp->cpcoeffs_info.ioff_upt;
  int *cpcoeffs_ioff_dnt = cp->cpcoeffs_info.ioff_dnt;
  double *cpcoeffs_cre_up = cp->cpcoeffs_pos[ip].cre_up;
  double *cpcoeffs_cim_up = cp->cpcoeffs_pos[ip].cim_up;
  double *cpcoeffs_cre_dn = cp->cpcoeffs_pos[ip].cre_dn;
  double *cpcoeffs_cim_dn = cp->cpcoeffs_pos[ip].cim_dn;
  double *cpcoeffs_vcre_up = cp->cpcoeffs_pos[ip].vcre_up;
  double *cpcoeffs_vcim_up = cp->cpcoeffs_pos[ip].vcim_up;
  double *cpcoeffs_vcre_dn = cp->cpcoeffs_pos[ip].vcre_dn;
  double *cpcoeffs_vcim_dn = cp->cpcoeffs_pos[ip].vcim_dn;
  int icoef_form_up = cp->cpcoeffs_pos[ip].icoef_form_up;
  int icoef_orth_up = cp->cpcoeffs_pos[ip].icoef_orth_up;
  int ivcoef_form_up = cp->cpcoeffs_pos[ip].ivcoef_form_up;
  int icoef_form_dn = cp->cpcoeffs_pos[ip].icoef_form_dn;
  int icoef_orth_dn = cp->cpcoeffs_pos[ip].icoef_orth_dn;
  int ivcoef_form_dn = cp->cpcoeffs_pos[ip].ivcoef_form_dn;
  int nstate_up = cp->cpcoeffs_info.nstate_up;
  int nstate_dn = cp->cpcoeffs_info.nstate_dn;
  double *cpcoeffs_cmass = cp->cpcoeffs_info.cmass;
  int icmass_unif = cp->cpcoeffs_info.icmass_unif;
  double *occ_up = cp->cpopts.occ_up;
  double *occ_dn = cp->cpopts.occ_dn;
  double *rocc_sum_up = cp->cpopts.rocc_sum_up;
  double *rocc_sum_dn = cp->cpopts.rocc_sum_dn;
  double *cpscr_cre_up = cp->cpscr.cpscr_wave.cre_up;
  double *cpscr_cim_up = cp->cpscr.cpscr_wave.cim_up;
  double *cpscr_cre_dn = cp->cpscr.cpscr_wave.cre_dn;
  double *cpscr_cim_dn = cp->cpscr.cpscr_wave.cim_dn;
 if(cp_norb <= 1) {
  if(icmass_unif == 1) {
   cp_rattle(cpcoeffs_cre_up,cpcoeffs_cim_up,icoef_form_up,icoef_orth_up,
             cpcoeffs_vcre_up,cpcoeffs_vcim_up,ivcoef_form_up,
             &(cp->cpscr.cpscr_ovmat),
             cpcoeffs_ioff_upt,rocc_sum_up,&(cp->cp_comm_state_pkg_up),
             cp_norb);
   if(cp_lsda== 1 && nstate_dn != 0){
     cp_rattle(cpcoeffs_cre_dn,cpcoeffs_cim_dn,icoef_form_dn,icoef_orth_dn,
               cpcoeffs_vcre_dn,cpcoeffs_vcim_dn,ivcoef_form_dn,
               &(cp->cpscr.cpscr_ovmat),
               cpcoeffs_ioff_dnt,rocc_sum_dn,&(cp->cp_comm_state_pkg_dn),
               cp_norb);
   }
  } else {
    cp_rattle_mass(cpcoeffs_cre_up,cpcoeffs_cim_up,icoef_form_up,icoef_orth_up,
                   cpcoeffs_vcre_up,cpcoeffs_vcim_up,ivcoef_form_up,
                   cpscr_cre_up,cpscr_cim_up,c_tolratl,
                   cpcoeffs_cmass,&(cp->cpscr.cpscr_ovmat),
                   cpcoeffs_ioff_upt,occ_up,rocc_sum_up,
                   iter_rattle,&(cp->cp_comm_state_pkg_up),cp_norb);
   if(cp_lsda== 1 && nstate_dn != 0){
    cp_rattle_mass(cpcoeffs_cre_dn,cpcoeffs_cim_dn,icoef_form_dn,icoef_orth_dn,
                   cpcoeffs_vcre_dn,cpcoeffs_vcim_dn,ivcoef_form_dn,
                   cpscr_cre_dn,cpscr_cim_dn,c_tolratl,
                   cpcoeffs_cmass,&(cp->cpscr.cpscr_ovmat),
                   cpcoeffs_ioff_dnt,occ_dn,rocc_sum_dn,
                   iter_rattle,&(cp->cp_comm_state_pkg_dn),cp_norb);
   }
  }
 }
 if(cp_norb== 2){
  cp_rattle_norb(cpcoeffs_cre_up,cpcoeffs_cim_up,icoef_form_up,icoef_orth_up,
                 cpcoeffs_vcre_up,cpcoeffs_vcim_up,ivcoef_form_up,
                 cpscr_cre_up,cpscr_cim_up,
                 cpcoeffs_ioff_upt,occ_up,cpcoeffs_cmass,icmass_unif,
                 &(cp->cpscr.cpscr_ovmat),
                 &(cp->cp_comm_state_pkg_up));
  if(cp_lsda== 1 && nstate_dn != 0) {
    cp_rattle_norb(cpcoeffs_cre_dn,cpcoeffs_cim_dn,icoef_form_dn,icoef_orth_dn,
                   cpcoeffs_vcre_dn,cpcoeffs_vcim_dn,ivcoef_form_dn,
                   cpscr_cre_dn,cpscr_cim_dn,
                   cpcoeffs_ioff_dnt,occ_dn,cpcoeffs_cmass,icmass_unif,
                   &(cp->cpscr.cpscr_ovmat),
                   &(cp->cp_comm_state_pkg_dn));
  }
 }
   }

user_defined_types: struct cpopts { int cp_lda; int cp_sic; int cp_gga; int cp_nonint; int cp_norb; int cp_gauss; int cp_ptens_calc; int cp_init_orthog; int cp_gs; int cp_ngrid_skip; int cp_hess_calc; int zero_cp_vel; int iwrite_coef_binary; int iread_coef_binary; int icheck_perd_size; int icheck_dual_size; int cp_para_opt; int cp_becke; int cp_pw91x; int cp_fila_1x; int cp_fila_2x; int cp_pbe_x; int cp_revpbe_x; int cp_rpbe_x; int cp_xpbe_x; int cp_brx89; int cp_brx2k; int cp_lyp; int cp_lypm1; int cp_pw91c; int cp_pbe_c; int cp_xpbe_c; int cp_tau1_c; int cp_debug_xc; int cp_dual_grid_opt; int cp_isok_opt; double te_ext; double tol_edge_dist; double tol_coef; double *occ_up; double *rocc_sum_up; double *rocc_sum_dn; }

user_defined_types: struct cpcoeffs_info { int pi_beads; int nstate_up; int icmass_unif; int ks_rot_on; int n_ks_rot; int cp_ke_dens_on; int cp_tau_functional; int cp_elf_calc_frq; int cp_laplacian_on; int cp_nfree; int cp_nfree_up; int cp_nfree_dn; int pi_beads_proc; int pi_beads_proc_st; int pi_beads_proc_end; int nstate_up_proc; int istate_up_st; int istate_up_end; int cg_reset_flag; int diis_reset_flag; int ncoef; int ncoef_l; int ncoef_l_dens_cp_box; int icoef_start_up; int nstate_ncoef_proc_up; int nstate_ncoef_proc_max_up; int icoef_start_dn; int nstate_ncoef_proc_dn; int nstate_ncoef_proc_max_dn; int *ioff_up; int *ioff_upt; double ecut; double ecut_dens_cp_box; double cp_hess_cut; double pseud_hess_loc; double max_off_diag; double max_diag; double *cmass; double k0_up; }

user_defined_types: struct cptherm_info { int num_c_nhc; int num_c_nhc_proc; int num_c_nhc_norm; int len_c_nhc; int nres_c_nhc; int nyosh_c_nhc; int massiv_flag; int istate_nhc_opt; double cp_therm_heat_fact; double dt_nhc; double c_gkt_massiv; double cmass_nhc_massiv; int *icmapup_nhc; int *icmapdn_nhc; double *wdti; double **c_gkt; double **cmass_nhc; }

user_defined_types: struct electronic_properties { double *cp_elf_up; }

user_defined_types: struct cpewald { int nktot_sm; int nktot_dens_cp_box; int nktot_cp_mall; int nktot_cp_sm_mall; int nktot_dens_cp_box_mall; int box_rat; double dbox_rat; double gw_gmin; double gw_gmin_dens_cp_box; int *kmax_cp; int *kmax_cp_dens_cp_box; int *kastr_sm; int *kastr_dens_cp_box; int *ibrk1_sm; int *ibrk1_dens_cp_box; double *ak2; double *ak2_dens_cp_box; }

user_defined_types: struct cpconstrnt { double c_tolshake; double c_tolratl; double c_tolnorb; }

user_defined_types: struct pseudo { int n_ang_max; int n_ang_max_gh; int n_ang_max_kb; int n_rad_max; int nsplin_g; int nsplin_g_tot; int num_nl_lst; int nl_cut_on; int n_ang_mall; int nsplin_g_mall; int nvpsnorm_mall; int nlist_mall; int n_interp_pme_dual; int natm_typ_nl; int natm_typ_gh; int ngh; double gmin_true; double gmin_spl; double gmax_spl; double dg_spl; double gga_cut; double nlvps_skin; double alpha_conv_dual; int *n_ang; int *nrad_0; int *nrad_max_l; int *loc_opt; int *ivps_label; int *np_nl; int *np_nl_gh; int **np_nl_rad_str; int **np_nl_rad_end; int *ip_nl; int *ip_nl_rev; int *ip_nl_gh; int *ip_nl_rev_gh; int *map_nl; int np_loc_cp_box; int np_nonloc_cp_box; int np_nonloc_cp_box_kb; int np_nonloc_cp_box_gh; int *ip_loc_cp_box; int *ip_nonloc_cp_box; double *vps0; double *dvps0; double *gzvps; double *gzvps0; double *vpsnorm; double *rcut_nl; double *rgh; double *x0w; double *q_pseud; char *vxc_typ; char *ggax_typ; char *ggac_typ; }

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 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 cp_comm_state_pkg { int num_proc; int myid; int nstate; int nstate_max; int ncoef; int nstate_proc; int nstate_proc_max; int nstate_ncoef_proc_max; int nstate_ncoef_proc; int icoef_start; int comm; int world; int ioff_therm_norm[3]; }

user_defined_types: struct vel_samp_cp { int ivelc_smpl_on; int ivelc_scal_on; int nvc_smpl; int nvcnhc_smpl; int nvc_scal; int iseed; int iauto_vc_scal_opt; double qseed; double vc_scal_tol; double div_scal; }

user_defined_types: struct cpcoeffs_pos { double *cre_up; double *cre_dn; double *vcre_up; double *vcre_dn; double *fcre_up; double *fcre_dn; double *cp_hess_re_up; double *cp_hess_im_up; double *cp_hess_re_dn; double *cp_hess_im_dn; double *ksmat_up; double *ksmat_eig_up; double *ksmat_eig_dn; double ks_offset; double *norbmat_up; double *norbmati_up; double *ovmat_eigv_up; double *ovmat_eigv_dn; int icoef_form_up; int ivcoef_form_up; int ifcoef_form_up; int icoef_orth_up; int ivcoef_orth_up; int ifcoef_orth_up; double max_diag; }

user_defined_types: struct cptherm_pos { double c_nhc_massiv; double **c_nhc; double **vc_nhc; double **fc_nhc; int itherm_form_up; int itherm_form_dn; }

user_defined_types: struct cpscr_loc { double *vextr; double *vextr_dens_cp_box; double *dvextr; }

user_defined_types: struct cpscr_nonloc { int natm_nls_max; int nlscr_up; int nlscr_dn; double *vnlre_up; double *vnlre_dn; double *dvnlre_x_up; double *dvnlim_x_up; double *dvnlre_x_dn; double *dvnlim_x_dn; double *dvnlre_gxgx_up; double *dvnlre_gygy_up; double *dvnlre_gzgz_up; double *dvnlre_gxgy_up; double *dvnlre_gygz_up; double *dvnlre_gxgz_up; double *dvnlre_gxgx_dn; double *dvnlre_gygy_dn; double *dvnlre_gzgz_dn; double *dvnlre_gxgy_dn; double *dvnlre_gygz_dn; double *dvnlre_gxgz_dn; }

user_defined_types: struct cpscr_rho { int iset_map_flag; int iset_map_upack_flag; int iset_map_flag_pme; int iset_map_upack_flag_pme; int *map_dual; int *map_dual_upack; double *v_ks_up; double *v_ks_dn; double *v_ks_tau_up; double *v_ks_tau_dn; double *rho_up; double *rho_dn; double *rhocr_up; double *rhocr_scr; double *rhocr_up_dens_cp_box; double *rhocr_dn; double *rhocr_dn_dens_cp_box; }

user_defined_types: struct cpscr_grho { double *d2_rho_up; double *d2_rho_dn; double *d2_rho_up_store; double *d2_rho_dn_store; double *d_rhox_up; double *d_rhox_dn; double *dm_rhox_up; double *dm_rhox_dn; double *elec_ke_dens_up; double *g_rhor_x; double *g_rhoi_x; double *g2_rhor; double *rhocr_up_st; double *rhocr_dn_st; }

user_defined_types: struct cpscr_ovmat { double *ovlap1; double *ovlap3; double *ovlap5; double *ovlap7; double *state_vec1; double *state_vec2; double *state_vec3; double *state_vec4; double *state_vec5; double *state_vec6; double *state_vec7; }

user_defined_types: struct cpscr_wave { double *zfft; int zfft_mall_size; double *cre_up; double *cre_dn; }

user_defined_types: struct cpscr_therm { double *coef_kin; double *sc_cp; }

user_defined_types: struct cpscr_dual_pme { int *iatemp; int **igrid_a; int **igrid_now; double *a_pme; double *frac_a; double *aj; double **mn_a; double **ua; double *bw_r; int nfft_send_big_small; int nfft_recv_big_small; int num_rows_tot; int *ioff_lg_sm; int **joff_sm_lg; }

user_defined_types: struct cpscr_atom_pme { int pme_on; int n_interp; int pme_para_opt; int nlen_pme; int nktot_pme; int nkf1; int ngrid_a; int *iatemp; int *nc; int **igrid_a; int **igrid_now; double *frac_a; double *aj; double **ua; double **mn_a; double **dmn_a; double **qgrid_now; double *qgrid; double *qgrid_scr; double *qgrid_tmp_real; double *qgrid_tmp_imag; double *bweight_tot; double *bw_r; }


original_code:
void communicate_simpavg_cp_pimd(STAT_AVG *stat_avg, PTENS *ptens,
                                COMMUNICATE *communicate, SIMOPTS *simopts,
                                ENSOPTS *ensopts,int iconstrnt,int num_c_nhc)
{
  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 i,iii;
    double pvten_temp[10];
    double tvten_temp = 0.0;
    double cp_ehart=0.0;
    double cp_enl =0.0;
    double cp_eke =0.0;
    double cp_exc =0.0;
    double cp_muxc =0.0;
    double cp_eext =0.0;
    double kinet_cp=0.0;
    double kinet_nhc_cp=0.0;
    double vpotnhc_cp=0.0;
    double iter_shake_temp=0.0;
    double iter_ratl_temp=0.0;
    double iter_23_temp=0.0;
    double iter_33_temp=0.0;
    double iter_46_temp=0.0;
    double iter_23r_temp=0.0;
    double iter_33r_temp=0.0;
    double iter_46r_temp=0.0;
    double kinet_temp=0.0;
    double vintrat_temp=0.0;
    double kinet_nhc_temp=0.0;
    double vpotnhc_temp=0.0;
    double vlong_temp=0.0;
    double kinet_v_temp=0.0;
    double vpot_v_temp=0.0;
    double kinet_nhc_bead_temp=0.0;
    double kin_harm_temp=0.0;
    double pi_ke_prim=0.0;
    double pi_ke_vir=0.0;
    double press_inter_temp=0.0;
    double press_intra_temp=0.0;
    int np_states = communicate->np_states;
    int myid_state = communicate->myid_state;
    int world = communicate->world;
    int comm_beads = communicate->comm_beads;
    int comm_states = communicate->comm_states;
  if(iconstrnt==1){
   Reduce(&(stat_avg->iter_shake), &iter_shake_temp,1,MPI_INT,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_ratl), &iter_ratl_temp,1,MPI_INT,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_23), &iter_23_temp,1,MPI_DOUBLE,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_33), &iter_33_temp,1,MPI_DOUBLE,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_46), &iter_46_temp,1,MPI_DOUBLE,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_23r), &iter_23r_temp,1,MPI_DOUBLE,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_33r), &iter_33r_temp,1,MPI_DOUBLE,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_46r), &iter_46r_temp,1,MPI_DOUBLE,
                   MPI_MAX,0,world);
    stat_avg->iter_shake = iter_shake_temp;
    stat_avg->iter_ratl = iter_ratl_temp;
    stat_avg->iter_23 = iter_23_temp;
    stat_avg->iter_33 = iter_33_temp;
    stat_avg->iter_46 = iter_46_temp;
    stat_avg->iter_23r = iter_23r_temp;
    stat_avg->iter_33r = iter_33r_temp;
    stat_avg->iter_46r = iter_46r_temp;
  }
 if(myid_state==0){
   Reduce(&(stat_avg->vintrat), &vintrat_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,comm_beads);
   Reduce(&(stat_avg->kin_harm), &kin_harm_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,comm_beads);
   Reduce(&(stat_avg->pi_ke_prim), &pi_ke_prim,1,MPI_DOUBLE,
                   MPI_SUM,0,comm_beads);
   Reduce(&(stat_avg->pi_ke_vir), &pi_ke_vir,1,MPI_DOUBLE,
                   MPI_SUM,0,comm_beads);
   Reduce(&(stat_avg->kinet), &kinet_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,comm_beads);
   stat_avg->vintrat = vintrat_temp;
   stat_avg->kin_harm = kin_harm_temp;
   stat_avg->pi_ke_prim = pi_ke_prim;
   stat_avg->pi_ke_vir = pi_ke_vir;
   stat_avg->kinet = kinet_temp;
 }
if(simopts->cp == 1 || simopts->cp_pimd==1) {
  if((ensopts->nvt)==1){
   Reduce(&(stat_avg->kinet_nhc), &kinet_nhc_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->vpotnhc), &vpotnhc_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->kinet_nhc_bead), &kinet_nhc_bead_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   stat_avg->kinet_nhc = kinet_nhc_temp;
   stat_avg->vpotnhc = vpotnhc_temp;
   stat_avg->kinet_nhc_bead = kinet_nhc_bead_temp;
  }
  if((ensopts->npt_i)==1){
   Reduce(&(stat_avg->kinet_nhc), &kinet_nhc_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->vpotnhc), &vpotnhc_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->vpot_v), &vpot_v_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->kinet_nhc_bead), &kinet_nhc_bead_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
    Reduce(&(stat_avg->vlong), &vlong_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   stat_avg->vlong = vlong_temp;
   stat_avg->kinet_nhc = kinet_nhc_temp;
   stat_avg->vpotnhc = vpotnhc_temp;
   stat_avg->vpot_v = vpot_v_temp;
   stat_avg->kinet_nhc_bead = kinet_nhc_bead_temp;
 }
  if((ensopts->npt_f)==1) {
   Reduce(&(stat_avg->kinet_nhc), &kinet_nhc_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->vpotnhc), &vpotnhc_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->vpot_v), &vpot_v_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->kinet_nhc_bead), &kinet_nhc_bead_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
    Reduce(&(stat_avg->vlong), &vlong_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
    stat_avg->vlong = vlong_temp;
   stat_avg->kinet_nhc = kinet_nhc_temp;
   stat_avg->vpotnhc = vpotnhc_temp;
   stat_avg->vpot_v = vpot_v_temp;
   stat_avg->kinet_nhc_bead = kinet_nhc_bead_temp;
  }
}
   Reduce(&(stat_avg->press_inter),&press_inter_temp,1,MPI_DOUBLE,
                 MPI_SUM,0,world);
   Reduce(&(stat_avg->press_intra),&press_intra_temp,1,MPI_DOUBLE,
                 MPI_SUM,0,world);
   stat_avg->press_inter = press_inter_temp;
   stat_avg->press_intra = press_intra_temp;
   for ( i = 1;i<=9;i++){
      Reduce(&(ptens->tvten[i]), &tvten_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
      ptens->tvten[i] = tvten_temp;
   }
   if(simopts->cp_wave_min_pimd == 1 && np_states > 1){
     Reduce(&(stat_avg->cp_ehart), &cp_ehart,1,MPI_DOUBLE,
            MPI_SUM,0,comm_states);
     Reduce(&(stat_avg->cp_eext), &cp_eext,1,MPI_DOUBLE,
            MPI_SUM,0,comm_states);
     Reduce(&(stat_avg->cp_exc), &cp_exc,1,MPI_DOUBLE,
            MPI_SUM,0,comm_states);
     Reduce(&(stat_avg->cp_muxc), &cp_muxc,1,MPI_DOUBLE,
            MPI_SUM,0,comm_states);
     Reduce(&(stat_avg->cp_enl), &cp_enl,1,MPI_DOUBLE,
            MPI_SUM,0,comm_states);
     Reduce(&(stat_avg->cp_eke), &cp_eke,1,MPI_DOUBLE,
            MPI_SUM,0,comm_states);
     stat_avg->cp_ehart = cp_ehart;
     stat_avg->cp_eext = cp_eext;
     stat_avg->cp_exc = cp_exc;
     stat_avg->cp_muxc = cp_muxc;
     stat_avg->cp_enl = cp_enl;
     stat_avg->cp_eke = cp_eke;
   }
   if(simopts->cp_wave_min_pimd != 1){
      Reduce(&stat_avg->kinet_cp,&kinet_cp,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      Reduce(&stat_avg->cp_ehart,&cp_ehart,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      Reduce(&stat_avg->cp_eext,&cp_eext,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      Reduce(&stat_avg->cp_exc,&cp_exc,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      Reduce(&stat_avg->cp_muxc,&cp_muxc,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      Reduce(&stat_avg->cp_eke,&cp_eke,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      Reduce(&stat_avg->cp_enl,&cp_enl,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      stat_avg->kinet_cp = kinet_cp;
      stat_avg->cp_ehart = cp_ehart;
      stat_avg->cp_eext = cp_eext;
      stat_avg->cp_exc = cp_exc;
      stat_avg->cp_muxc = cp_muxc;
      stat_avg->cp_eke = cp_eke;
      stat_avg->cp_enl = cp_enl;
   }
  if(num_c_nhc > 0) {
    Reduce(&stat_avg->kinet_nhc_cp,&kinet_nhc_cp,1,MPI_DOUBLE,MPI_SUM,
              0,world);
    Reduce(&stat_avg->vpotnhc_cp,&vpotnhc_cp,1,MPI_DOUBLE,MPI_SUM,
              0,world);
    stat_avg->kinet_nhc_cp = kinet_nhc_cp;
    stat_avg->vpotnhc_cp = vpotnhc_cp;
  }
}

canonical_original_code:
void communicate_simpavg_cp_pimd(struct stat_avg *stat_avg, struct ptens *ptens, struct communicate *communicate, struct simopts *simopts, struct ensopts *ensopts, int iconstrnt, int num_c_nhc)
{
  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 i; int iii;
    double pvten_temp[10];
    double tvten_temp = 0.0;
    double cp_ehart = 0.0;
    double cp_enl = 0.0;
    double cp_eke = 0.0;
    double cp_exc = 0.0;
    double cp_muxc = 0.0;
    double cp_eext = 0.0;
    double kinet_cp = 0.0;
    double kinet_nhc_cp = 0.0;
    double vpotnhc_cp = 0.0;
    double iter_shake_temp = 0.0;
    double iter_ratl_temp = 0.0;
    double iter_23_temp = 0.0;
    double iter_33_temp = 0.0;
    double iter_46_temp = 0.0;
    double iter_23r_temp = 0.0;
    double iter_33r_temp = 0.0;
    double iter_46r_temp = 0.0;
    double kinet_temp = 0.0;
    double vintrat_temp = 0.0;
    double kinet_nhc_temp = 0.0;
    double vpotnhc_temp = 0.0;
    double vlong_temp = 0.0;
    double kinet_v_temp = 0.0;
    double vpot_v_temp = 0.0;
    double kinet_nhc_bead_temp = 0.0;
    double kin_harm_temp = 0.0;
    double pi_ke_prim = 0.0;
    double pi_ke_vir = 0.0;
    double press_inter_temp = 0.0;
    double press_intra_temp = 0.0;
    int np_states = communicate->np_states;
    int myid_state = communicate->myid_state;
    int world = communicate->world;
    int comm_beads = communicate->comm_beads;
    int comm_states = communicate->comm_states;
  if(iconstrnt==1){
   Reduce(&(stat_avg->iter_shake), &iter_shake_temp,1,MPI_INT,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_ratl), &iter_ratl_temp,1,MPI_INT,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_23), &iter_23_temp,1,MPI_DOUBLE,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_33), &iter_33_temp,1,MPI_DOUBLE,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_46), &iter_46_temp,1,MPI_DOUBLE,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_23r), &iter_23r_temp,1,MPI_DOUBLE,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_33r), &iter_33r_temp,1,MPI_DOUBLE,
                   MPI_MAX,0,world);
   Reduce(&(stat_avg->iter_46r), &iter_46r_temp,1,MPI_DOUBLE,
                   MPI_MAX,0,world);
    stat_avg->iter_shake = iter_shake_temp;
    stat_avg->iter_ratl = iter_ratl_temp;
    stat_avg->iter_23 = iter_23_temp;
    stat_avg->iter_33 = iter_33_temp;
    stat_avg->iter_46 = iter_46_temp;
    stat_avg->iter_23r = iter_23r_temp;
    stat_avg->iter_33r = iter_33r_temp;
    stat_avg->iter_46r = iter_46r_temp;
  }
 if(myid_state==0){
   Reduce(&(stat_avg->vintrat), &vintrat_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,comm_beads);
   Reduce(&(stat_avg->kin_harm), &kin_harm_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,comm_beads);
   Reduce(&(stat_avg->pi_ke_prim), &pi_ke_prim,1,MPI_DOUBLE,
                   MPI_SUM,0,comm_beads);
   Reduce(&(stat_avg->pi_ke_vir), &pi_ke_vir,1,MPI_DOUBLE,
                   MPI_SUM,0,comm_beads);
   Reduce(&(stat_avg->kinet), &kinet_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,comm_beads);
   stat_avg->vintrat = vintrat_temp;
   stat_avg->kin_harm = kin_harm_temp;
   stat_avg->pi_ke_prim = pi_ke_prim;
   stat_avg->pi_ke_vir = pi_ke_vir;
   stat_avg->kinet = kinet_temp;
 }
if(simopts->cp == 1 || simopts->cp_pimd==1) {
  if((ensopts->nvt)==1){
   Reduce(&(stat_avg->kinet_nhc), &kinet_nhc_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->vpotnhc), &vpotnhc_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->kinet_nhc_bead), &kinet_nhc_bead_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   stat_avg->kinet_nhc = kinet_nhc_temp;
   stat_avg->vpotnhc = vpotnhc_temp;
   stat_avg->kinet_nhc_bead = kinet_nhc_bead_temp;
  }
  if((ensopts->npt_i)==1){
   Reduce(&(stat_avg->kinet_nhc), &kinet_nhc_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->vpotnhc), &vpotnhc_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->vpot_v), &vpot_v_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->kinet_nhc_bead), &kinet_nhc_bead_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
    Reduce(&(stat_avg->vlong), &vlong_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   stat_avg->vlong = vlong_temp;
   stat_avg->kinet_nhc = kinet_nhc_temp;
   stat_avg->vpotnhc = vpotnhc_temp;
   stat_avg->vpot_v = vpot_v_temp;
   stat_avg->kinet_nhc_bead = kinet_nhc_bead_temp;
 }
  if((ensopts->npt_f)==1) {
   Reduce(&(stat_avg->kinet_nhc), &kinet_nhc_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->vpotnhc), &vpotnhc_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->vpot_v), &vpot_v_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
   Reduce(&(stat_avg->kinet_nhc_bead), &kinet_nhc_bead_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
    Reduce(&(stat_avg->vlong), &vlong_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
    stat_avg->vlong = vlong_temp;
   stat_avg->kinet_nhc = kinet_nhc_temp;
   stat_avg->vpotnhc = vpotnhc_temp;
   stat_avg->vpot_v = vpot_v_temp;
   stat_avg->kinet_nhc_bead = kinet_nhc_bead_temp;
  }
}
   Reduce(&(stat_avg->press_inter),&press_inter_temp,1,MPI_DOUBLE,
                 MPI_SUM,0,world);
   Reduce(&(stat_avg->press_intra),&press_intra_temp,1,MPI_DOUBLE,
                 MPI_SUM,0,world);
   stat_avg->press_inter = press_inter_temp;
   stat_avg->press_intra = press_intra_temp;
   for ( i = 1;i<=9;i++){
      Reduce(&(ptens->tvten[i]), &tvten_temp,1,MPI_DOUBLE,
                   MPI_SUM,0,world);
      ptens->tvten[i] = tvten_temp;
   }
   if(simopts->cp_wave_min_pimd == 1 && np_states > 1){
     Reduce(&(stat_avg->cp_ehart), &cp_ehart,1,MPI_DOUBLE,
            MPI_SUM,0,comm_states);
     Reduce(&(stat_avg->cp_eext), &cp_eext,1,MPI_DOUBLE,
            MPI_SUM,0,comm_states);
     Reduce(&(stat_avg->cp_exc), &cp_exc,1,MPI_DOUBLE,
            MPI_SUM,0,comm_states);
     Reduce(&(stat_avg->cp_muxc), &cp_muxc,1,MPI_DOUBLE,
            MPI_SUM,0,comm_states);
     Reduce(&(stat_avg->cp_enl), &cp_enl,1,MPI_DOUBLE,
            MPI_SUM,0,comm_states);
     Reduce(&(stat_avg->cp_eke), &cp_eke,1,MPI_DOUBLE,
            MPI_SUM,0,comm_states);
     stat_avg->cp_ehart = cp_ehart;
     stat_avg->cp_eext = cp_eext;
     stat_avg->cp_exc = cp_exc;
     stat_avg->cp_muxc = cp_muxc;
     stat_avg->cp_enl = cp_enl;
     stat_avg->cp_eke = cp_eke;
   }
   if(simopts->cp_wave_min_pimd != 1){
      Reduce(&stat_avg->kinet_cp,&kinet_cp,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      Reduce(&stat_avg->cp_ehart,&cp_ehart,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      Reduce(&stat_avg->cp_eext,&cp_eext,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      Reduce(&stat_avg->cp_exc,&cp_exc,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      Reduce(&stat_avg->cp_muxc,&cp_muxc,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      Reduce(&stat_avg->cp_eke,&cp_eke,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      Reduce(&stat_avg->cp_enl,&cp_enl,1,MPI_DOUBLE,MPI_SUM,
                0,world);
      stat_avg->kinet_cp = kinet_cp;
      stat_avg->cp_ehart = cp_ehart;
      stat_avg->cp_eext = cp_eext;
      stat_avg->cp_exc = cp_exc;
      stat_avg->cp_muxc = cp_muxc;
      stat_avg->cp_eke = cp_eke;
      stat_avg->cp_enl = cp_enl;
   }
  if(num_c_nhc > 0) {
    Reduce(&stat_avg->kinet_nhc_cp,&kinet_nhc_cp,1,MPI_DOUBLE,MPI_SUM,
              0,world);
    Reduce(&stat_avg->vpotnhc_cp,&vpotnhc_cp,1,MPI_DOUBLE,MPI_SUM,
              0,world);
    stat_avg->kinet_nhc_cp = kinet_nhc_cp;
    stat_avg->vpotnhc_cp = vpotnhc_cp;
  }
}

variable_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; } *

variable_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; } *

variable_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; } *

variable_types: 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; } *

variable_types:
ensopts
struct ensopts { int nve; } *

variable_types: iconstrnt int

variable_types: i int

variable_types: world int


original_code:
void set_wave_params(char *molsetname,char fun_key[],
       DICT_WORD wave_dict[], int num_wave_dict,
       CPOPTS *cpopts,CPCOEFFS_INFO *cpcoeffs_info,
                     CP_PARSE *cp_parse)
{
  int i,num,index,ifound;
  double dnum;
  for(i=1;i<num_wave_dict;i++){
    if(wave_dict[i].iuset==0 && wave_dict[i].key_type==1){
      keyword_miss(wave_dict,molsetname,fun_key,i);}
  }
  sscanf(wave_dict[1].keyarg,"%d",&num);
  cpcoeffs_info->nstate_up = num;
  index = 1;
  if((num <=0)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  sscanf(wave_dict[2].keyarg,"%d",&num);
  cpcoeffs_info->nstate_dn = num;
  if(cpopts->cp_lda == 1){
      cpcoeffs_info->nstate_dn = cpcoeffs_info->nstate_up;
  }
  index = 2;
  if(num < 0){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  if( (cpopts->cp_lda==1) &&
      (cpcoeffs_info->nstate_up != num)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  ifound = 0;
  if(strcasecmp(wave_dict[3].keyarg,"none")==0)
    {ifound=1;cp_parse->istate_nhc_opt=0;}
  if(strcasecmp(wave_dict[3].keyarg,"global")==0)
    {ifound=1;cp_parse->istate_nhc_opt=1;}
  if(strcasecmp(wave_dict[3].keyarg,"glob_st")==0)
    {ifound=1;cp_parse->istate_nhc_opt=2;}
  if(strcasecmp(wave_dict[3].keyarg,"ind_st")==0)
    {ifound=1;cp_parse->istate_nhc_opt=3;}
  if(strcasecmp(wave_dict[3].keyarg,"mass_coef")==0)
    {ifound=1;cp_parse->istate_nhc_opt=4;}
  index = 3;
  if(ifound==0){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  if(cp_parse->istate_nhc_opt==3 && cpopts->cp_norb < 2){
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      printf("The \"ind_st\" thermostatting option for the\n");
      printf("coefficients, specified in the set up file %s, \n",
              molsetname);
      printf("while most excellent, only works with \"cp_norb\", \n");
      printf("using either the \"norm_only\" or \"none\"\n");
      printf("constraint options\n");
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      fflush(stdout);
      exit(1);
  }
  if(cp_parse->istate_nhc_opt==4 && cpopts->cp_norb !=3){
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      printf("The \"mass_coef\" thermostatting option for the\n");
      printf("coefficients, specified in the set up file %s, \n",
              molsetname);
      printf("while most excellent, only works with \"cp_norb\", \n");
      printf("using the \"none\" constraint option\n");
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      fflush(stdout);
      exit(1);
 }
 if((cpopts->cp_isok_opt == 1) && (cp_parse->istate_nhc_opt != 0)){
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      printf("The CP isokinetic option, while most excellent,\n");
      printf("will not work in tandem with the CP Nose-Hoover chain\n");
      printf("thermostatting scheme.  Please set the CP_NHC_OPT\n");
      printf("option in your .set file to NONE\n");
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      fflush(stdout);
      exit(1);
 }
  sscanf(wave_dict[4].keyarg,"%lg",&dnum);
  cp_parse->cp_tau_nhc=dnum;
  index = 4;
  if((dnum <=0)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  sscanf(wave_dict[5].keyarg,"%lg",&dnum);
  cp_parse->cp_ecut=dnum;
  index = 5;
  if((dnum <=0)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  sscanf(wave_dict[6].keyarg,"%lg",&dnum);
  cp_parse->cp_mass_cut=dnum;
  index = 6;
  if((dnum <=0)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  sscanf(wave_dict[7].keyarg,"%lg",&dnum);
  cp_parse->cp_mass_tau=dnum;
  index = 7;
  if((dnum <=0)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  sscanf(wave_dict[8].keyarg,"%lg",&dnum);
  cp_parse->cp_ecut_dual_grid=dnum;
  index = 8;
  if((dnum <=0)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
}

canonical_original_code:
void set_wave_params(char *molsetname, char fun_key[], struct dict_word wave_dict[], int num_wave_dict, struct cpopts *cpopts, struct cpcoeffs_info *cpcoeffs_info, struct cp_parse *cp_parse)
{
  int i; int num; int index; int ifound;
  double dnum;
  for(i=1;i<num_wave_dict;i++){
    if(wave_dict[i].iuset==0 && wave_dict[i].key_type==1){
      keyword_miss(wave_dict,molsetname,fun_key,i);}
  }
  sscanf(wave_dict[1].keyarg,"%d",&num);
  cpcoeffs_info->nstate_up = num;
  index = 1;
  if((num <=0)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  sscanf(wave_dict[2].keyarg,"%d",&num);
  cpcoeffs_info->nstate_dn = num;
  if(cpopts->cp_lda == 1){
      cpcoeffs_info->nstate_dn = cpcoeffs_info->nstate_up;
  }
  index = 2;
  if(num < 0){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  if( (cpopts->cp_lda==1) &&
      (cpcoeffs_info->nstate_up != num)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  ifound = 0;
  if(strcasecmp(wave_dict[3].keyarg,"none")==0)
    {ifound=1;cp_parse->istate_nhc_opt=0;}
  if(strcasecmp(wave_dict[3].keyarg,"global")==0)
    {ifound=1;cp_parse->istate_nhc_opt=1;}
  if(strcasecmp(wave_dict[3].keyarg,"glob_st")==0)
    {ifound=1;cp_parse->istate_nhc_opt=2;}
  if(strcasecmp(wave_dict[3].keyarg,"ind_st")==0)
    {ifound=1;cp_parse->istate_nhc_opt=3;}
  if(strcasecmp(wave_dict[3].keyarg,"mass_coef")==0)
    {ifound=1;cp_parse->istate_nhc_opt=4;}
  index = 3;
  if(ifound==0){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  if(cp_parse->istate_nhc_opt==3 && cpopts->cp_norb < 2){
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      printf("The \"ind_st\" thermostatting option for the\n");
      printf("coefficients, specified in the set up file %s, \n",
              molsetname);
      printf("while most excellent, only works with \"cp_norb\", \n");
      printf("using either the \"norm_only\" or \"none\"\n");
      printf("constraint options\n");
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      fflush(stdout);
      exit(1);
  }
  if(cp_parse->istate_nhc_opt==4 && cpopts->cp_norb !=3){
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      printf("The \"mass_coef\" thermostatting option for the\n");
      printf("coefficients, specified in the set up file %s, \n",
              molsetname);
      printf("while most excellent, only works with \"cp_norb\", \n");
      printf("using the \"none\" constraint option\n");
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      fflush(stdout);
      exit(1);
 }
 if((cpopts->cp_isok_opt == 1) && (cp_parse->istate_nhc_opt != 0)){
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      printf("The CP isokinetic option, while most excellent,\n");
      printf("will not work in tandem with the CP Nose-Hoover chain\n");
      printf("thermostatting scheme.  Please set the CP_NHC_OPT\n");
      printf("option in your .set file to NONE\n");
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      fflush(stdout);
      exit(1);
 }
  sscanf(wave_dict[4].keyarg,"%lg",&dnum);
  cp_parse->cp_tau_nhc=dnum;
  index = 4;
  if((dnum <=0)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  sscanf(wave_dict[5].keyarg,"%lg",&dnum);
  cp_parse->cp_ecut=dnum;
  index = 5;
  if((dnum <=0)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  sscanf(wave_dict[6].keyarg,"%lg",&dnum);
  cp_parse->cp_mass_cut=dnum;
  index = 6;
  if((dnum <=0)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  sscanf(wave_dict[7].keyarg,"%lg",&dnum);
  cp_parse->cp_mass_tau=dnum;
  index = 7;
  if((dnum <=0)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
  sscanf(wave_dict[8].keyarg,"%lg",&dnum);
  cp_parse->cp_ecut_dual_grid=dnum;
  index = 8;
  if((dnum <=0)){
    keyarg_barf(wave_dict,molsetname,fun_key,index);
  }
}

variable_types:
molsetname
char *

variable_types: struct dict_word { int iflag; char keyword[50]; char error_mes[100]; } []

variable_types: struct cpopts { int cp_lda; int cp_sic; int cp_gga; int cp_nonint; int cp_norb; int cp_gauss; int cp_ptens_calc; int cp_init_orthog; int cp_gs; int cp_ngrid_skip; int cp_hess_calc; int zero_cp_vel; int iwrite_coef_binary; int iread_coef_binary; int icheck_perd_size; int icheck_dual_size; int cp_para_opt; int cp_becke; int cp_pw91x; int cp_fila_1x; int cp_fila_2x; int cp_pbe_x; int cp_revpbe_x; int cp_rpbe_x; int cp_xpbe_x; int cp_brx89; int cp_brx2k; int cp_lyp; int cp_lypm1; int cp_pw91c; int cp_pbe_c; int cp_xpbe_c; int cp_tau1_c; int cp_debug_xc; int cp_dual_grid_opt; int cp_isok_opt; double te_ext; double tol_edge_dist; double tol_coef; double *occ_up; double *rocc_sum_up; double *rocc_sum_dn; } *

variable_types: struct cpcoeffs_info { int pi_beads; int nstate_up; int icmass_unif; int ks_rot_on; int n_ks_rot; int cp_ke_dens_on; int cp_tau_functional; int cp_elf_calc_frq; int cp_laplacian_on; int cp_nfree; int cp_nfree_up; int cp_nfree_dn; int pi_beads_proc; int pi_beads_proc_st; int pi_beads_proc_end; int nstate_up_proc; int istate_up_st; int istate_up_end; int cg_reset_flag; int diis_reset_flag; int ncoef; int ncoef_l; int ncoef_l_dens_cp_box; int icoef_start_up; int nstate_ncoef_proc_up; int nstate_ncoef_proc_max_up; int icoef_start_dn; int nstate_ncoef_proc_dn; int nstate_ncoef_proc_max_dn; int *ioff_up; int *ioff_upt; double ecut; double ecut_dens_cp_box; double cp_hess_cut; double pseud_hess_loc; double max_off_diag; double max_diag; double *cmass; double k0_up; } *

variable_types: struct cp_parse { int istart_cp; int istate_nhc_opt; int ivc_smpl; int ivc_scale; double cp_mass_tau_def; double cp_mass_tau; double cp_tau_nhc_def; double cp_tau_nhc; double cp_ecut_def; double cp_mass_cut_def; double cp_ecut_dual_grid_def; double cp_ecut_dual_grid; } *

variable_types: num int

variable_types: index int

variable_types: ifound int

variable_types: dnum double


original_code:
void communicate_coeff_output(CP *cp, double *cre_temp,double *cim_temp,
                              int ip, int pflag,int source, int source_old,
                              COMMUNICATE *communicate,int pi_beads_proc)
  {
  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 nread_up,nread_dn,i,ii,tag,ip_loc,iii;
   int rank = communicate->myid;
   int numprocs = communicate->np;
   int world = communicate->world;
 nread_up = (cp->cpcoeffs_info.ncoef)*(cp->cpcoeffs_info.nstate_up);
 nread_dn = (cp->cpcoeffs_info.ncoef)*(cp->cpcoeffs_info.nstate_dn);
if(numprocs>1){
 tag=ip;
 ip_loc = ip - pi_beads_proc*(source_old+1);
 switch(pflag){
  case 1:
   if(rank==source){
     ii = 0;
     for(i=1;i<=nread_up;i++){
       ii++;
       cre_temp[ii] = cp->cpcoeffs_pos[ip_loc].cre_up[i];
       cim_temp[ii] = cp->cpcoeffs_pos[ip_loc].cim_up[i];
     }
   }
   Barrier(world);
    break;
  case 2:
   if(rank==source){
     ii = 0;
     for(i=1;i<=nread_up;i++){
       ii++;
       cre_temp[ii] = cp->cpcoeffs_pos[ip_loc].cre_dn[i];
       cim_temp[ii] = cp->cpcoeffs_pos[ip_loc].cim_dn[i];
     }
   }
   Barrier(world);
    break;
  case 3:
   if(rank==source){
     ii = 0;
     for(i=1;i<=nread_up;i++){
       ii++;
       cre_temp[ii] = cp->cpcoeffs_pos[ip_loc].vcre_up[i];
       cim_temp[ii] = cp->cpcoeffs_pos[ip_loc].vcim_up[i];
     }
   }
   Barrier(world);
    break;
  case 4:
   if(rank==source){
     ii = 0;
     for(i=1;i<=nread_up;i++){
       ii++;
       cre_temp[ii] = cp->cpcoeffs_pos[ip_loc].vcre_dn[i];
       cim_temp[ii] = cp->cpcoeffs_pos[ip_loc].vcim_dn[i];
     }
   }
   Barrier(world);
    break;
 }
 if(rank==source){
   Send(&(cre_temp[0]),nread_up+1,MPI_DOUBLE,0,tag,world);
   Send(&(cim_temp[0]),nread_up+1,MPI_DOUBLE,0,tag,world);
 }
 if(rank==0){
    Recv(&(cre_temp[0]),nread_up+1,MPI_DOUBLE,source,tag,world);
     Recv(&(cim_temp[0]),nread_up+1,MPI_DOUBLE,source,tag,world);
 }
}
}

canonical_original_code:
void communicate_coeff_output(struct cp *cp, double *cre_temp, double *cim_temp, int ip, int pflag, int source, int source_old, struct communicate *communicate, int pi_beads_proc)
  {
  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 nread_up; int nread_dn; int i; int ii; int tag; int ip_loc; int iii;
   int rank = communicate->myid;
   int numprocs = communicate->np;
   int world = communicate->world;
 nread_up = (cp->cpcoeffs_info.ncoef)*(cp->cpcoeffs_info.nstate_up);
 nread_dn = (cp->cpcoeffs_info.ncoef)*(cp->cpcoeffs_info.nstate_dn);
if(numprocs>1){
 tag=ip;
 ip_loc = ip - pi_beads_proc*(source_old+1);
 switch(pflag){
  case 1:
   if(rank==source){
     ii = 0;
     for(i=1;i<=nread_up;i++){
       ii++;
       cre_temp[ii] = cp->cpcoeffs_pos[ip_loc].cre_up[i];
       cim_temp[ii] = cp->cpcoeffs_pos[ip_loc].cim_up[i];
     }
   }
   Barrier(world);
    break;
  case 2:
   if(rank==source){
     ii = 0;
     for(i=1;i<=nread_up;i++){
       ii++;
       cre_temp[ii] = cp->cpcoeffs_pos[ip_loc].cre_dn[i];
       cim_temp[ii] = cp->cpcoeffs_pos[ip_loc].cim_dn[i];
     }
   }
   Barrier(world);
    break;
  case 3:
   if(rank==source){
     ii = 0;
     for(i=1;i<=nread_up;i++){
       ii++;
       cre_temp[ii] = cp->cpcoeffs_pos[ip_loc].vcre_up[i];
       cim_temp[ii] = cp->cpcoeffs_pos[ip_loc].vcim_up[i];
     }
   }
   Barrier(world);
    break;
  case 4:
   if(rank==source){
     ii = 0;
     for(i=1;i<=nread_up;i++){
       ii++;
       cre_temp[ii] = cp->cpcoeffs_pos[ip_loc].vcre_dn[i];
       cim_temp[ii] = cp->cpcoeffs_pos[ip_loc].vcim_dn[i];
     }
   }
   Barrier(world);
    break;
 }
 if(rank==source){
   Send(&(cre_temp[0]),nread_up+1,MPI_DOUBLE,0,tag,world);
   Send(&(cim_temp[0]),nread_up+1,MPI_DOUBLE,0,tag,world);
 }
 if(rank==0){
    Recv(&(cre_temp[0]),nread_up+1,MPI_DOUBLE,source,tag,world);
     Recv(&(cim_temp[0]),nread_up+1,MPI_DOUBLE,source,tag,world);
 }
}
}

variable_types: struct cp { struct cpopts { int cp_lda; int cp_sic; int cp_gga; int cp_nonint; int cp_norb; int cp_gauss; int cp_ptens_calc; int cp_init_orthog; int cp_gs; int cp_ngrid_skip; int cp_hess_calc; int zero_cp_vel; int iwrite_coef_binary; int iread_coef_binary; int icheck_perd_size; int icheck_dual_size; int cp_para_opt; int cp_becke; int cp_pw91x; int cp_fila_1x; int cp_fila_2x; int cp_pbe_x; int cp_revpbe_x; int cp_rpbe_x; int cp_xpbe_x; int cp_brx89; int cp_brx2k; int cp_lyp; int cp_lypm1; int cp_pw91c; int cp_pbe_c; int cp_xpbe_c; int cp_tau1_c; int cp_debug_xc; int cp_dual_grid_opt; int cp_isok_opt; double te_ext; double tol_edge_dist; double tol_coef; double *occ_up; double *rocc_sum_up; double *rocc_sum_dn; } cpopts; struct cpcoeffs_info { int pi_beads; int nstate_up; int icmass_unif; int ks_rot_on; int n_ks_rot; int cp_ke_dens_on; int cp_tau_functional; int cp_elf_calc_frq; int cp_laplacian_on; int cp_nfree; int cp_nfree_up; int cp_nfree_dn; int pi_beads_proc; int pi_beads_proc_st; int pi_beads_proc_end; int nstate_up_proc; int istate_up_st; int istate_up_end; int cg_reset_flag; int diis_reset_flag; int ncoef; int ncoef_l; int ncoef_l_dens_cp_box; int icoef_start_up; int nstate_ncoef_proc_up; int nstate_ncoef_proc_max_up; int icoef_start_dn; int nstate_ncoef_proc_dn; int nstate_ncoef_proc_max_dn; int *ioff_up; int *ioff_upt; double ecut; double ecut_dens_cp_box; double cp_hess_cut; double pseud_hess_loc; double max_off_diag; double max_diag; double *cmass; double k0_up; } cpcoeffs_info; struct cpcoeffs_pos { double *cre_up; double *cre_dn; double *vcre_up; double *vcre_dn; double *fcre_up; double *fcre_dn; double *cp_hess_re_up; double *cp_hess_im_up; double *cp_hess_re_dn; double *cp_hess_im_dn; double *ksmat_up; double *ksmat_eig_up; double *ksmat_eig_dn; double ks_offset; double *norbmat_up; double *norbmati_up; double *ovmat_eigv_up; double *ovmat_eigv_dn; int icoef_form_up; int ivcoef_form_up; int ifcoef_form_up; int icoef_orth_up; int ivcoef_orth_up; int ifcoef_orth_up; double max_diag; } *cpcoeffs_pos; struct cptherm_info { int num_c_nhc; int num_c_nhc_proc; int num_c_nhc_norm; int len_c_nhc; int nres_c_nhc; int nyosh_c_nhc; int massiv_flag; int istate_nhc_opt; double cp_therm_heat_fact; double dt_nhc; double c_gkt_massiv; double cmass_nhc_massiv; int *icmapup_nhc; int *icmapdn_nhc; double *wdti; double **c_gkt; double **cmass_nhc; } cptherm_info; struct cptherm_pos { double c_nhc_massiv; double **c_nhc; double **vc_nhc; double **fc_nhc; int itherm_form_up; int itherm_form_dn; } *cptherm_pos; struct electronic_properties { double *cp_elf_up; } electronic_properties; struct cpewald { int nktot_sm; int nktot_dens_cp_box; int nktot_cp_mall; int nktot_cp_sm_mall; int nktot_dens_cp_box_mall; int box_rat; double dbox_rat; double gw_gmin; double gw_gmin_dens_cp_box; int *kmax_cp; int *kmax_cp_dens_cp_box; int *kastr_sm; int *kastr_dens_cp_box; int *ibrk1_sm; int *ibrk1_dens_cp_box; double *ak2; double *ak2_dens_cp_box; } cpewald; struct cpconstrnt { double c_tolshake; double c_tolratl; double c_tolnorb; } cpconstrnt; struct pseudo { int n_ang_max; int n_ang_max_gh; int n_ang_max_kb; int n_rad_max; int nsplin_g; int nsplin_g_tot; int num_nl_lst; int nl_cut_on; int n_ang_mall; int nsplin_g_mall; int nvpsnorm_mall; int nlist_mall; int n_interp_pme_dual; int natm_typ_nl; int natm_typ_gh; int ngh; double gmin_true; double gmin_spl; double gmax_spl; double dg_spl; double gga_cut; double nlvps_skin; double alpha_conv_dual; int *n_ang; int *nrad_0; int *nrad_max_l; int *loc_opt; int *ivps_label; int *np_nl; int *np_nl_gh; int **np_nl_rad_str; int **np_nl_rad_end; int *ip_nl; int *ip_nl_rev; int *ip_nl_gh; int *ip_nl_rev_gh; int *map_nl; int np_loc_cp_box; int np_nonloc_cp_box; int np_nonloc_cp_box_kb; int np_nonloc_cp_box_gh; int *ip_loc_cp_box; int *ip_nonloc_cp_box; double *vps0; double *dvps0; double *gzvps; double *gzvps0; double *vpsnorm; double *rcut_nl; double *rgh; double *x0w; double *q_pseud; char *vxc_typ; char *ggax_typ; char *ggac_typ; } pseudo; struct cpscr { struct cpscr_loc { double *vextr; double *vextr_dens_cp_box; double *dvextr; } cpscr_loc; struct cpscr_nonloc { int natm_nls_max; int nlscr_up; int nlscr_dn; double *vnlre_up; double *vnlre_dn; double *dvnlre_x_up; double *dvnlim_x_up; double *dvnlre_x_dn; double *dvnlim_x_dn; double *dvnlre_gxgx_up; double *dvnlre_gygy_up; double *dvnlre_gzgz_up; double *dvnlre_gxgy_up; double *dvnlre_gygz_up; double *dvnlre_gxgz_up; double *dvnlre_gxgx_dn; double *dvnlre_gygy_dn; double *dvnlre_gzgz_dn; double *dvnlre_gxgy_dn; double *dvnlre_gygz_dn; double *dvnlre_gxgz_dn; } cpscr_nonloc; struct cpscr_rho { int iset_map_flag; int iset_map_upack_flag; int iset_map_flag_pme; int iset_map_upack_flag_pme; int *map_dual; int *map_dual_upack; double *v_ks_up; double *v_ks_dn; double *v_ks_tau_up; double *v_ks_tau_dn; double *rho_up; double *rho_dn; double *rhocr_up; double *rhocr_scr; double *rhocr_up_dens_cp_box; double *rhocr_dn; double *rhocr_dn_dens_cp_box; } cpscr_rho; struct cpscr_grho { double *d2_rho_up; double *d2_rho_dn; double *d2_rho_up_store; double *d2_rho_dn_store; double *d_rhox_up; double *d_rhox_dn; double *dm_rhox_up; double *dm_rhox_dn; double *elec_ke_dens_up; double *g_rhor_x; double *g_rhoi_x; double *g2_rhor; double *rhocr_up_st; double *rhocr_dn_st; } cpscr_grho; struct cpscr_ovmat { double *ovlap1; double *ovlap3; double *ovlap5; double *ovlap7; double *state_vec1; double *state_vec2; double *state_vec3; double *state_vec4; double *state_vec5; double *state_vec6; double *state_vec7; } cpscr_ovmat; struct cpscr_wave { double *zfft; int zfft_mall_size; double *cre_up; double *cre_dn; } cpscr_wave; struct cpscr_therm { double *coef_kin; double *sc_cp; } cpscr_therm; struct cpscr_dual_pme { int *iatemp; int **igrid_a; int **igrid_now; double *a_pme; double *frac_a; double *aj; double **mn_a; double **ua; double *bw_r; int nfft_send_big_small; int nfft_recv_big_small; int num_rows_tot; int *ioff_lg_sm; int **joff_sm_lg; } cpscr_dual_pme; struct cpscr_atom_pme { int pme_on; int n_interp; int pme_para_opt; int nlen_pme; int nktot_pme; int nkf1; int ngrid_a; int *iatemp; int *nc; int **igrid_a; int **igrid_now; double *frac_a; double *aj; double **ua; double **mn_a; double **dmn_a; double **qgrid_now; double *qgrid; double *qgrid_scr; double *qgrid_tmp_real; double *qgrid_tmp_imag; double *bweight_tot; double *bw_r; } cpscr_atom_pme; } cpscr; 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; } communicate; 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; } cp_sclr_fft_pkg3d_sm; struct para_fft_pkg3d cp_para_fft_pkg3d_sm; struct para_fft_pkg3d cp_sclr_fft_pkg3d_dens_cp_box; struct para_fft_pkg3d cp_para_fft_pkg3d_dens_cp_box; struct para_fft_pkg3d cp_sclr_fft_pkg3d_lg; struct para_fft_pkg3d cp_para_fft_pkg3d_lg; struct cp_comm_state_pkg { int num_proc; int myid; int nstate; int nstate_max; int ncoef; int nstate_proc; int nstate_proc_max; int nstate_ncoef_proc_max; int nstate_ncoef_proc; int icoef_start; int comm; int world; int ioff_therm_norm[3]; } cp_comm_state_pkg_up; struct cp_comm_state_pkg cp_comm_state_pkg_dn; struct vel_samp_cp { int ivelc_smpl_on; int ivelc_scal_on; int nvc_smpl; int nvcnhc_smpl; int nvc_scal; int iseed; int iauto_vc_scal_opt; double qseed; double vc_scal_tol; double div_scal; } vel_samp_cp; } *

variable_types: ip int

variable_types: pflag int

variable_types: source int

variable_types:
communicate
struct communicate *

variable_types: ii int

variable_types: tag int

variable_types: iii int

variable_types: rank int

variable_types: numprocs int

user_defined_types: struct cp { struct cpopts cpopts; struct cpcoeffs_info cpcoeffs_info; struct cpcoeffs_pos *cpcoeffs_pos; struct cptherm_info cptherm_info; struct cptherm_pos *cptherm_pos; struct electronic_properties electronic_properties; struct cpewald cpewald; struct cpconstrnt cpconstrnt; struct pseudo pseudo; struct cpscr cpscr; struct communicate communicate; struct para_fft_pkg3d cp_sclr_fft_pkg3d_sm; struct para_fft_pkg3d cp_para_fft_pkg3d_sm; struct para_fft_pkg3d cp_sclr_fft_pkg3d_dens_cp_box; struct para_fft_pkg3d cp_para_fft_pkg3d_dens_cp_box; struct para_fft_pkg3d cp_sclr_fft_pkg3d_lg; struct para_fft_pkg3d cp_para_fft_pkg3d_lg; struct cp_comm_state_pkg cp_comm_state_pkg_up; struct cp_comm_state_pkg cp_comm_state_pkg_dn; struct vel_samp_cp vel_samp_cp; }

user_defined_types: struct cpscr { struct cpscr_loc cpscr_loc; struct cpscr_nonloc cpscr_nonloc; struct cpscr_rho cpscr_rho; struct cpscr_grho cpscr_grho; struct cpscr_ovmat cpscr_ovmat; struct cpscr_wave cpscr_wave; struct cpscr_therm cpscr_therm; struct cpscr_dual_pme cpscr_dual_pme; struct cpscr_atom_pme cpscr_atom_pme; }


original_code:
void communicate_coeff_nhc_output(CP *cp, double *nhc_temp,int ip,
                                 int source,int source_old,
                                 COMMUNICATE *communicate,int pi_beads_proc)
   {
  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 ii,i,j,tag,ip_loc;
  int len_nhc = cp->cptherm_info.len_c_nhc;
  int num_nhc = cp->cptherm_info.num_c_nhc;
  int rank = communicate->myid;
  int rank_state = communicate->myid_state;
  int np_states = communicate->np_states;
  int num_proc = communicate->np;
  int world = communicate->world;
Barrier(world);
if(ip<=pi_beads_proc){
  if(rank==0){
    ii = 0;
    for(j=1;j<=len_nhc;j++){
      for(i=1;i<=num_nhc;i++){
        ii++;
        nhc_temp[ii] = cp->cptherm_pos[ip].vc_nhc[j][i];
      }
    }
  }
}
Barrier(world);
if(num_proc>1){
 if(ip > pi_beads_proc){
  ip_loc = ip - pi_beads_proc*(source_old+1);
  tag=ip;
  Barrier(world);
  if(rank==source*np_states&&rank_state==0){
    if((len_nhc>0)&&(num_nhc>0)){
      ii = 0;
     printf("commd %d\n",ip);fflush(stdout);
      for(j=1;j<=len_nhc;j++){
        for(i=1;i<=num_nhc;i++){
          ii++;
          nhc_temp[ii] = cp->cptherm_pos[ip_loc].vc_nhc[j][i];
        }
      }
      Send(&(nhc_temp[0]),len_nhc*num_nhc+1,MPI_DOUBLE,0,tag,world);
    }
  }
  Barrier(world);
  if(rank==0){
    if((len_nhc>0)&&(num_nhc>0)){
      Recv(&(nhc_temp[0]),len_nhc*num_nhc+1,MPI_DOUBLE,source,tag,world);
    }
  }
  Barrier(world);
 }
}
}

canonical_original_code:
void communicate_coeff_nhc_output(struct cp *cp, double *nhc_temp, int ip, int source, int source_old, struct communicate *communicate, int pi_beads_proc)
   {
  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 ii; int i; int j; int tag; int ip_loc;
  int len_nhc = cp->cptherm_info.len_c_nhc;
  int num_nhc = cp->cptherm_info.num_c_nhc;
  int rank = communicate->myid;
  int rank_state = communicate->myid_state;
  int np_states = communicate->np_states;
  int num_proc = communicate->np;
  int world = communicate->world;
Barrier(world);
if(ip<=pi_beads_proc){
  if(rank==0){
    ii = 0;
    for(j=1;j<=len_nhc;j++){
      for(i=1;i<=num_nhc;i++){
        ii++;
        nhc_temp[ii] = cp->cptherm_pos[ip].vc_nhc[j][i];
      }
    }
  }
}
Barrier(world);
if(num_proc>1){
 if(ip > pi_beads_proc){
  ip_loc = ip - pi_beads_proc*(source_old+1);
  tag=ip;
  Barrier(world);
  if(rank==source*np_states&&rank_state==0){
    if((len_nhc>0)&&(num_nhc>0)){
      ii = 0;
     printf("commd %d\n",ip);fflush(stdout);
      for(j=1;j<=len_nhc;j++){
        for(i=1;i<=num_nhc;i++){
          ii++;
          nhc_temp[ii] = cp->cptherm_pos[ip_loc].vc_nhc[j][i];
        }
      }
      Send(&(nhc_temp[0]),len_nhc*num_nhc+1,MPI_DOUBLE,0,tag,world);
    }
  }
  Barrier(world);
  if(rank==0){
    if((len_nhc>0)&&(num_nhc>0)){
      Recv(&(nhc_temp[0]),len_nhc*num_nhc+1,MPI_DOUBLE,source,tag,world);
    }
  }
  Barrier(world);
 }
}
}

variable_types: i int

variable_types: j int

variable_types: world int

user_defined_types: struct cpopts { int cp_lda; int cp_sic; int cp_gga; int cp_nonint; int cp_norb; int cp_gauss; int cp_ptens_calc; int cp_init_orthog; int cp_gs; int cp_ngrid_skip; int cp_hess_calc; int zero_cp_vel; int iwrite_coef_binary; int iread_coef_binary; int icheck_perd_size; int icheck_dual_size; int cp_para_opt; int cp_becke; int cp_pw91x; int cp_fila_1x; int cp_fila_2x; int cp_pbe_x; int cp_revpbe_x; int cp_rpbe_x; int cp_xpbe_x; int cp_brx89; int cp_brx2k; int cp_lyp; int cp_lypm1; int cp_pw91c; int cp_pbe_c; int cp_xpbe_c; int cp_tau1_c; int cp_debug_xc; int cp_dual_grid_opt; int cp_isok_opt; double te_ext; double tol_edge_dist; double tol_coef; double *occ_up; double *rocc_sum_up; double *rocc_sum_dn; }

user_defined_types: struct cpcoeffs_info { int pi_beads; int nstate_up; int icmass_unif; int ks_rot_on; int n_ks_rot; int cp_ke_dens_on; int cp_tau_functional; int cp_elf_calc_frq; int cp_laplacian_on; int cp_nfree; int cp_nfree_up; int cp_nfree_dn; int pi_beads_proc; int pi_beads_proc_st; int pi_beads_proc_end; int nstate_up_proc; int istate_up_st; int istate_up_end; int cg_reset_flag; int diis_reset_flag; int ncoef; int ncoef_l; int ncoef_l_dens_cp_box; int icoef_start_up; int nstate_ncoef_proc_up; int nstate_ncoef_proc_max_up; int icoef_start_dn; int nstate_ncoef_proc_dn; int nstate_ncoef_proc_max_dn; int *ioff_up; int *ioff_upt; double ecut; double ecut_dens_cp_box; double cp_hess_cut; double pseud_hess_loc; double max_off_diag; double max_diag; double *cmass; double k0_up; }

user_defined_types: struct cptherm_info { int num_c_nhc; int num_c_nhc_proc; int num_c_nhc_norm; int len_c_nhc; int nres_c_nhc; int nyosh_c_nhc; int massiv_flag; int istate_nhc_opt; double cp_therm_heat_fact; double dt_nhc; double c_gkt_massiv; double cmass_nhc_massiv; int *icmapup_nhc; int *icmapdn_nhc; double *wdti; double **c_gkt; double **cmass_nhc; }

user_defined_types: struct electronic_properties { double *cp_elf_up; }

user_defined_types: struct cpewald { int nktot_sm; int nktot_dens_cp_box; int nktot_cp_mall; int nktot_cp_sm_mall; int nktot_dens_cp_box_mall; int box_rat; double dbox_rat; double gw_gmin; double gw_gmin_dens_cp_box; int *kmax_cp; int *kmax_cp_dens_cp_box; int *kastr_sm; int *kastr_dens_cp_box; int *ibrk1_sm; int *ibrk1_dens_cp_box; double *ak2; double *ak2_dens_cp_box; }

user_defined_types: struct cpconstrnt { double c_tolshake; double c_tolratl; double c_tolnorb; }

user_defined_types: struct pseudo { int n_ang_max; int n_ang_max_gh; int n_ang_max_kb; int n_rad_max; int nsplin_g; int nsplin_g_tot; int num_nl_lst; int nl_cut_on; int n_ang_mall; int nsplin_g_mall; int nvpsnorm_mall; int nlist_mall; int n_interp_pme_dual; int natm_typ_nl; int natm_typ_gh; int ngh; double gmin_true; double gmin_spl; double gmax_spl; double dg_spl; double gga_cut; double nlvps_skin; double alpha_conv_dual; int *n_ang; int *nrad_0; int *nrad_max_l; int *loc_opt; int *ivps_label; int *np_nl; int *np_nl_gh; int **np_nl_rad_str; int **np_nl_rad_end; int *ip_nl; int *ip_nl_rev; int *ip_nl_gh; int *ip_nl_rev_gh; int *map_nl; int np_loc_cp_box; int np_nonloc_cp_box; int np_nonloc_cp_box_kb; int np_nonloc_cp_box_gh; int *ip_loc_cp_box; int *ip_nonloc_cp_box; double *vps0; double *dvps0; double *gzvps; double *gzvps0; double *vpsnorm; double *rcut_nl; double *rgh; double *x0w; double *q_pseud; char *vxc_typ; char *ggax_typ; char *ggac_typ; }

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; }


original_code:
void proj_com_out(int natm_tot, double *fx,double *fy, double *fz)
   {
    int i;
    double xcm,ycm,zcm;
   xcm = 0.0;
   ycm = 0.0;
   zcm = 0.0;
   for(i=1;i<=natm_tot;i++){
     xcm += fx[i];
     ycm += fy[i];
     zcm += fz[i];
   }
   xcm /= (double)natm_tot;
   ycm /= (double)natm_tot;
   zcm /= (double)natm_tot;
   for(i=1;i<=natm_tot;i++){
     fx[i] -= xcm;
     fy[i] -= ycm;
     fz[i] -= zcm;
   }
  }

canonical_original_code:
void proj_com_out(int natm_tot, double *fx, double *fy, double *fz)
   {
    int i;
    double xcm; double ycm; double zcm;
   xcm = 0.0;
   ycm = 0.0;
   zcm = 0.0;
   for(i=1;i<=natm_tot;i++){
     xcm += fx[i];
     ycm += fy[i];
     zcm += fz[i];
   }
   xcm /= (double)natm_tot;
   ycm /= (double)natm_tot;
   zcm /= (double)natm_tot;
   for(i=1;i<=natm_tot;i++){
     fx[i] -= xcm;
     fy[i] -= ycm;
     fz[i] -= zcm;
   }
  }

variable_types:
fx
double *

variable_types:
fy
double *

variable_types:
fz
double *

variable_types: xcm double

variable_types: ycm double

variable_types: zcm double