~ubuntu-branches/ubuntu/quantal/psicode/quantal

« back to all changes in this revision

Viewing changes to src/bin/input/oldcalc.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2006-09-10 14:01:33 UTC
  • Revision ID: james.westby@ubuntu.com-20060910140133-ib2j86trekykfsfv
Tags: upstream-3.2.3
ImportĀ upstreamĀ versionĀ 3.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <libpsio/psio.h>
 
4
#include <libciomr/libciomr.h>
 
5
#include <libchkpt/chkpt.h>
 
6
#include <psifiles.h>
 
7
 
 
8
#include "input.h"
 
9
#include "defines.h"
 
10
#define EXTERN
 
11
#include "global.h"
 
12
 
 
13
#include "float.h"
 
14
#include "linalg.h"
 
15
 
 
16
void init_oldcalc()
 
17
{
 
18
  int s, ncalcs;
 
19
 
 
20
  /*--- initialize the old checkpoint file ---*/
 
21
  chkpt_init(PSIO_OPEN_OLD);
 
22
 
 
23
  /*--- check if the symmetry is the same ---*/
 
24
  Oldcalc.symmetry = chkpt_rd_sym_label();
 
25
  if (strncmp(Oldcalc.symmetry,symmetry,3)) {
 
26
      fprintf(outfile,"  Old chkpt file uses different point group from the current one\n");
 
27
      fprintf(outfile,"  Will continue without the MO projection\n");
 
28
      fprintf(stderr,"  Old chkpt file uses different point group from the current one\n");
 
29
      fprintf(stderr,"  Will continue without the MO projection\n");
 
30
      chkpt_mos = 0;
 
31
      chkpt_close();
 
32
      return;
 
33
  }
 
34
  Oldcalc.nirreps = chkpt_rd_nirreps();
 
35
 
 
36
  /*--- read the old geometry ---*/
 
37
  Oldcalc.natom = chkpt_rd_natom();
 
38
  Oldcalc.geometry = chkpt_rd_geom();
 
39
  Oldcalc.Rref = chkpt_rd_rref();
 
40
 
 
41
  /*--- read the old basis ---*/
 
42
  Oldcalc.num_ao = chkpt_rd_nao();
 
43
  Oldcalc.num_so = chkpt_rd_nso();
 
44
  Oldcalc.sopi = chkpt_rd_sopi();
 
45
  Oldcalc.num_shells = chkpt_rd_nshell();
 
46
  Oldcalc.num_prims = chkpt_rd_nprim();
 
47
  Oldcalc.exponents = chkpt_rd_exps();
 
48
  Oldcalc.contr_coeff = chkpt_rd_contr_full();
 
49
  Oldcalc.shell_nucleus = chkpt_rd_snuc();
 
50
  Oldcalc.first_prim_shell = chkpt_rd_sprim();
 
51
  Oldcalc.shell_ang_mom = chkpt_rd_stype();
 
52
  Oldcalc.nprim_in_shell = chkpt_rd_snumg();
 
53
  Oldcalc.first_ao_shell = chkpt_rd_sloc();
 
54
  Oldcalc.usotao = chkpt_rd_usotao();
 
55
 
 
56
  /*--- Convert to C-numbering ---*/
 
57
  Oldcalc.max_angmom = 0;
 
58
  for(s=0;s<Oldcalc.num_shells;s++) {
 
59
      Oldcalc.shell_nucleus[s]--;
 
60
      Oldcalc.shell_ang_mom[s]--;
 
61
      Oldcalc.first_ao_shell[s]--;
 
62
      Oldcalc.first_prim_shell[s]--;
 
63
      if (Oldcalc.shell_ang_mom[s] > Oldcalc.max_angmom)
 
64
          Oldcalc.max_angmom = Oldcalc.shell_ang_mom[s];
 
65
  }
 
66
 
 
67
  /*--- read the old SCF eigenvector, RHF case so far ---*/
 
68
  Oldcalc.ref = chkpt_rd_ref();
 
69
  if (Oldcalc.ref == ref_rhf   ||
 
70
      Oldcalc.ref == ref_rohf  ||
 
71
      Oldcalc.ref == ref_tcscf ||
 
72
      Oldcalc.ref == ref_rks)
 
73
      Oldcalc.spinrestr_ref = 1;
 
74
  else if (Oldcalc.ref == ref_uhf   ||
 
75
           Oldcalc.ref == ref_uks)
 
76
      Oldcalc.spinrestr_ref = 0;
 
77
  else {
 
78
      fprintf(outfile,"  Input is not aware of reference type %d\n",Oldcalc.ref);
 
79
      fprintf(outfile,"  Will continue without the MO projection\n");
 
80
      chkpt_mos = 0;
 
81
      chkpt_close();
 
82
      return;
 
83
  }
 
84
 
 
85
  Oldcalc.iopen = chkpt_rd_iopen();
 
86
  Oldcalc.num_mo = chkpt_rd_nmo();
 
87
  Oldcalc.orbspi = chkpt_rd_orbspi();
 
88
  Oldcalc.clsdpi = chkpt_rd_clsdpi();
 
89
  Oldcalc.openpi = chkpt_rd_openpi();
 
90
  Oldcalc.escf = chkpt_rd_escf();
 
91
  if (Oldcalc.spinrestr_ref) { /* Spin-restricted case */
 
92
      Oldcalc.scf_evect_so = chkpt_rd_scf();
 
93
  }
 
94
  else { /* Spin-unrestricted case */
 
95
      Oldcalc.scf_evect_so_alpha = chkpt_rd_alpha_scf();
 
96
      Oldcalc.scf_evect_so_beta = chkpt_rd_beta_scf();
 
97
  }
 
98
 
 
99
  /*--- Done with the checkpoint file ---*/
 
100
  chkpt_close();
 
101
 
 
102
  if (print_lvl >= DEBUGPRINT) {
 
103
    if (Oldcalc.spinrestr_ref) {
 
104
      fprintf(outfile,"  -Old eigenvector (in SO basis):\n");
 
105
      print_mat(Oldcalc.scf_evect_so,Oldcalc.num_so,Oldcalc.num_mo,outfile);
 
106
    }
 
107
    else {
 
108
      fprintf(outfile,"  -Old alpha eigenvector (in SO basis):\n");
 
109
      print_mat(Oldcalc.scf_evect_so_alpha,Oldcalc.num_so,Oldcalc.num_mo,outfile);
 
110
      fprintf(outfile,"  -Old beta eigenvector (in SO basis):\n");
 
111
      print_mat(Oldcalc.scf_evect_so_beta,Oldcalc.num_so,Oldcalc.num_mo,outfile);
 
112
    }
 
113
  }
 
114
  
 
115
  return;
 
116
}
 
117
 
 
118
 
 
119
void cleanup_oldcalc()
 
120
{
 
121
  free_block(Oldcalc.geometry);
 
122
  free_block(Oldcalc.Rref);
 
123
  free(Oldcalc.exponents);
 
124
  free_block(Oldcalc.contr_coeff);
 
125
  free(Oldcalc.shell_nucleus);
 
126
  free(Oldcalc.first_prim_shell);
 
127
  free(Oldcalc.shell_ang_mom);
 
128
  free(Oldcalc.nprim_in_shell);
 
129
  free(Oldcalc.first_ao_shell);
 
130
  free_block(Oldcalc.usotao);
 
131
 
 
132
  free(Oldcalc.orbspi);
 
133
  free(Oldcalc.clsdpi);
 
134
  free(Oldcalc.openpi);
 
135
  if (Oldcalc.spinrestr_ref)
 
136
      free(Oldcalc.scf_evect_so);
 
137
  else {
 
138
      free(Oldcalc.scf_evect_so_alpha);
 
139
      free(Oldcalc.scf_evect_so_beta);
 
140
  }
 
141
 
 
142
  return;
 
143
}
 
144
 
 
145
 
 
146
void store_oldcalc()
 
147
{
 
148
  FLOAT **S12;
 
149
 
 
150
  if (max_angmom > Oldcalc.max_angmom)
 
151
    init_gto(max_angmom);
 
152
  else
 
153
    init_gto(Oldcalc.max_angmom);
 
154
 
 
155
  S12 = overlap_new_old_float();
 
156
  
 
157
  /*--- write things out ---*/
 
158
  psio_open(PSIF_OLD_CHKPT, PSIO_OPEN_NEW);
 
159
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:Num. atoms", (char*) &Oldcalc.natom,
 
160
                   sizeof(int));
 
161
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:Geometry", (char*) Oldcalc.geometry[0],
 
162
                   Oldcalc.natom*3*sizeof(double));
 
163
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:Transmat to reference frame", (char*) Oldcalc.Rref[0],
 
164
                   9*sizeof(double));
 
165
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:Num. irreps", (char*) &Oldcalc.nirreps,
 
166
                   sizeof(int));
 
167
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:SO's per irrep", (char*) Oldcalc.sopi,
 
168
                   Oldcalc.nirreps*sizeof(int));
 
169
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:Reference", (char*) &Oldcalc.ref,
 
170
                   sizeof(reftype));
 
171
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:Num. SO", (char*) &Oldcalc.num_so,
 
172
                   sizeof(int));
 
173
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:Num. MO", (char*) &Oldcalc.num_mo,
 
174
                   sizeof(int));
 
175
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:MO's per irrep", (char*) Oldcalc.orbspi,
 
176
                   Oldcalc.nirreps*sizeof(int));
 
177
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:Closed shells per irrep", (char*) Oldcalc.clsdpi,
 
178
                   Oldcalc.nirreps*sizeof(int));
 
179
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:Open shells per irrep", (char*) Oldcalc.openpi,
 
180
                   Oldcalc.nirreps*sizeof(int));
 
181
  if (Oldcalc.spinrestr_ref) { /* Spin-restricted case */
 
182
    psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:MOs alpha", (char*) Oldcalc.scf_evect_so[0],
 
183
                     Oldcalc.num_so*Oldcalc.num_mo*sizeof(double));
 
184
  }
 
185
  else { /* Spin-unrestricted case */
 
186
    psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:MOs alpha", (char*) Oldcalc.scf_evect_so_alpha[0],
 
187
                     Oldcalc.num_so*Oldcalc.num_mo*sizeof(double));
 
188
    psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:MOs beta", (char*) Oldcalc.scf_evect_so_beta[0],
 
189
                     Oldcalc.num_so*Oldcalc.num_mo*sizeof(double));
 
190
  }
 
191
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:AO->SO", (char *) Oldcalc.usotao[0],
 
192
                   Oldcalc.num_ao*Oldcalc.num_so*sizeof(double));
 
193
  psio_write_entry(PSIF_OLD_CHKPT, ":PrevCalc:New-Old basis overlap", (char*) S12[0],
 
194
                   num_so*Oldcalc.num_so*sizeof(FLOAT));
 
195
  psio_close(PSIF_OLD_CHKPT, 1);
 
196
 
 
197
  delete_matrix(S12);
 
198
}