Files | |
| file | buf_close.cc |
| file | buf_fetch.cc |
| file | buf_flush.cc |
| file | buf_init.cc |
| file | buf_put.cc |
| file | buf_rd.cc |
| file | buf_rd_all.cc |
| file | buf_rd_all_act.cc |
| file | buf_rd_all_mp2r12a.cc |
| file | buf_rd_arr.cc |
| file | buf_toend.cc |
| file | buf_wrt.cc |
| file | buf_wrt_all.cc |
| file | buf_wrt_arr.cc |
| file | buf_wrt_arr2.cc |
| file | buf_wrt_arr_SI.cc |
| file | buf_wrt_arr_SI_nocut.cc |
| file | buf_wrt_mat.cc |
| file | buf_wrt_mp2.cc |
| file | buf_wrt_mp2r12a.cc |
| file | buf_wrt_val.cc |
| file | buf_wrt_val_SI.cc |
| file | lib/libiwl/rdone.cc |
| file | lib/libiwl/rdtwo.cc |
| file | sortbuf.cc |
| file | wrtone.cc |
| file | wrttwo.cc |
Functions | |
| void | iwl_buf_close (struct iwlbuf *Buf, int keep) |
| void | iwl_buf_fetch (struct iwlbuf *Buf) |
| void | iwl_buf_flush (struct iwlbuf *Buf, int lastbuf) |
| void | iwl_buf_init (struct iwlbuf *Buf, int itape, double cutoff, int oldfile, int readflag) |
| void | iwl_buf_put (struct iwlbuf *Buf) |
| int | iwl_buf_rd (struct iwlbuf *Buf, int target_pq, double *ints, int *ioff_lt, int *ioff_rt, int mp2, int printflg, FILE *outfile) |
| int | iwl_buf_rd_all (struct iwlbuf *Buf, double *ints, int *ioff_lt, int *ioff_rt, int no_pq_perm, int *ioff, int printflg, FILE *outfile) |
| int | iwl_buf_rd_all2 (struct iwlbuf *Buf, double **ints, int *ioff_lt, int *ioff_rt, int no_pq_perm, int *ioff, int printflg, FILE *outfile) |
| int | iwl_buf_rd_all_act (struct iwlbuf *Buf, double *ints, int *ioff_lt, int *ioff_rt, int no_pq_perm, int *ioff, int fstact, int lstact, int printflg, FILE *outfile) |
| int | iwl_buf_rd_all_mp2r12a (struct iwlbuf *Buf, double *ints, int *ioff_lt, int *ioff_rt, int bra_ket_symm, int *ioff, int printflg, FILE *outfile) |
| int | iwl_buf_rd_arr (struct iwlbuf *Buf, int target_pq, double *ints, int *rlist, int *slist, int *size, int *ioff, int printflg, FILE *outfile) |
| void | iwl_buf_toend (struct iwlbuf *Buf) |
| void | iwl_buf_wrt (struct iwlbuf *Buf, int p, int q, int pq, int pqsym, double *arr, int rmax, int *active, int *ioff, int *orbsym, int *firsti, int *lasti, int sortby_rs, int printflag, FILE *outfile) |
| void | iwl_buf_wrt_all (struct iwlbuf *Buf, int nbfso, double *ints, int *ioff, int printflg, FILE *outfile) |
| void | iwl_buf_wrt_arr (struct iwlbuf *Buf, double *arr, int *p, int *q, int *r, int *s, long int size) |
| void | iwl_buf_wrt_arr2 (struct iwlbuf *Buf, double *arr, int p, int q, int *rlist, int *slist, int size, int printflag, FILE *outfile) |
| void | iwl_buf_wrt_arr_SI (struct iwlbuf *Buf, double *arr, short int *p, short int *q, short int *r, short int *s, int size) |
| void | iwl_buf_wrt_arr_SI_nocut (struct iwlbuf *Buf, double *arr, short int *p, short int *q, short int *r, short int *s, int size) |
| void | iwl_buf_wrt_mat (struct iwlbuf *Buf, int ptr, int qtr, double **mat, int rfirst, int rlast, int sfirst, int slast, int *reorder, int reorder_offset, int printflag, int *ioff, FILE *outfile) |
| void | iwl_buf_wrt_mat2 (struct iwlbuf *Buf, int ptr, int qtr, double **mat, int rfirst, int rlast, int sfirst, int slast, int *reorder, int reorder_offset, int printflag, int *ioff, FILE *outfile) |
| void | iwl_buf_wrt_mp2 (struct iwlbuf *Buf, int p, int q, int pq, int pqsym, double **arr, int rsym, int *firstr, int *lastr, int *firsts, int *lasts, int *occ, int *vir, int *ioff, int printflag, FILE *outfile) |
| void | iwl_buf_wrt_mp2r12a (struct iwlbuf *Buf, int p, int q, int pq, int pqsym, double **arr, int rsym, int *firstr, int *lastr, int *firsts, int *lasts, int *occ, int bra_ket_symm, int *ioff, int printflag, FILE *outfile) |
| void | iwl_buf_wrt_val (struct iwlbuf *Buf, int p, int q, int r, int s, double value, int printflag, FILE *outfile, int dirac) |
| void | iwl_buf_wrt_val_SI (struct iwlbuf *Buf, short int p, short int q, short int r, short int s, double value, int printflag, FILE *outfile, int dirac) |
| int | iwl_rdone (int itap, char *label, double *ints, int ntri, int erase, int printflg, FILE *outfile) |
| void | iwl_rdtwo (int itap, double *ints, int *ioff, int norbs, int nfzc, int nfzv, int printflg, FILE *outfile) |
| void | sortbuf (struct iwlbuf *Inbuf, struct iwlbuf *Outbuf, double *ints, int fpq, int lpq, int *ioff, int *ioff2, int nbfso, int elbert, int intermediate, int no_pq_perm, int qdim, int add, int printflg, FILE *outfile) |
| void | iwl_wrtone (int itap, char *label, int ntri, double *onel_ints) |
| void | iwl_wrttwo (int itap, int nbfso, double *ints, int *ioff, double toler, int printflg, FILE *outfile) |
| void iwl_buf_close | ( | struct iwlbuf * | Buf, | |
| int | keep | |||
| ) |
IWL_BUF_CLOSE()
| Buf | Buffer to be closed | |
| keep | Do not delete if keep==1 |
Definition at line 23 of file buf_close.cc.
Referenced by iwl_buf_toend(), iwl_rdtwo(), iwl_wrttwo(), main(), and psi::psimrcc::CCTransform::read_tei_mo_integrals_block().
00024 { 00025 00026 psio_close(Buf->itap, keep ? 1 : 0); 00027 free(Buf->labels); 00028 free(Buf->values); 00029 }
| void iwl_buf_fetch | ( | struct iwlbuf * | Buf | ) |
Fetch an IWL buffer from disk David Sherrill, 26 June 1996
Definition at line 18 of file buf_fetch.cc.
References psio_read().
Referenced by iwl_buf_init(), iwl_buf_rd(), iwl_buf_rd_all(), iwl_buf_rd_all2(), iwl_buf_rd_all_act(), iwl_buf_rd_arr(), iwl_buf_rd_arr2(), psi::psimrcc::CCTransform::read_tei_mo_integrals_block(), and sortbuf().
00019 { 00020 psio_read(Buf->itap, IWL_KEY_BUF, (char *) &(Buf->lastbuf), sizeof(int), 00021 Buf->bufpos, &Buf->bufpos); 00022 psio_read(Buf->itap, IWL_KEY_BUF, (char *) &(Buf->inbuf), sizeof(int), 00023 Buf->bufpos, &Buf->bufpos); 00024 psio_read(Buf->itap, IWL_KEY_BUF, (char *) Buf->labels, Buf->ints_per_buf * 00025 4 * sizeof(Label), Buf->bufpos, &Buf->bufpos); 00026 psio_read(Buf->itap, IWL_KEY_BUF, (char *) Buf->values, Buf->ints_per_buf * 00027 sizeof(Value), Buf->bufpos, &Buf->bufpos); 00028 Buf->idx = 0; 00029 }
| void iwl_buf_flush | ( | struct iwlbuf * | Buf, | |
| int | lastbuf | |||
| ) |
| Buf | To be flushed buffer | |
| lastbuf | Flag for the last buffer |
Definition at line 22 of file buf_flush.cc.
References iwl_buf_put().
Referenced by iwl_wrttwo(), and main().
00023 { 00024 int idx; 00025 Label *lblptr; 00026 Value *valptr; 00027 00028 Buf->inbuf = Buf->idx; 00029 lblptr = Buf->labels; 00030 valptr = Buf->values; 00031 00032 idx = 4 * Buf->idx; 00033 00034 while (Buf->idx < Buf->ints_per_buf) { 00035 lblptr[idx++] = 0; 00036 lblptr[idx++] = 0; 00037 lblptr[idx++] = 0; 00038 lblptr[idx++] = 0; 00039 valptr[Buf->idx] = 0.0; 00040 Buf->idx++; 00041 } 00042 00043 if (lastbuf) Buf->lastbuf = 1; 00044 else Buf->lastbuf = 0; 00045 00046 iwl_buf_put(Buf); 00047 Buf->idx = 0; 00048 }
| void iwl_buf_init | ( | struct iwlbuf * | Buf, | |
| int | itape, | |||
| double | cutoff, | |||
| int | oldfile, | |||
| int | readflag | |||
| ) |
| Buf | Buffer to be initialised | |
| itape | Filenumber | |
| cutoff | Cutoff for keeping integral | |
| oldfile | If ==0 create file | |
| readflag | If ==1 fetch buffer |
David Sherrill, March 1995 Revised 6/26/96 by CDS for new format
set up buffer info
make room in the buffer
open the output file
Note that we assume that if oldfile isn't set, we O_CREAT the file
go ahead and read a buffer
Definition at line 32 of file buf_init.cc.
References iwl_buf_fetch(), psio_open(), psio_tocscan(), and PSIO_ZERO.
Referenced by iwl_rdtwo(), iwl_wrttwo(), main(), and psi::psimrcc::CCTransform::read_tei_mo_integrals_block().
00034 { 00035 00037 Buf->itap = itape; 00038 Buf->bufpos = PSIO_ZERO; 00039 Buf->ints_per_buf = IWL_INTS_PER_BUF; 00040 Buf->cutoff = cutoff; 00041 Buf->bufszc = 2 * sizeof(int) + Buf->ints_per_buf * 4 * sizeof(Label) + 00042 Buf->ints_per_buf * sizeof(Value); 00043 Buf->lastbuf = 0; 00044 Buf->inbuf = 0; 00045 Buf->idx = 0; 00046 00048 Buf->labels = (Label *) malloc (4 * Buf->ints_per_buf * sizeof(Label)); 00049 Buf->values = (Value *) malloc (Buf->ints_per_buf * sizeof(Value)); 00050 00053 psio_open(Buf->itap, oldfile ? PSIO_OPEN_OLD : PSIO_OPEN_NEW); 00054 if (oldfile && (psio_tocscan(Buf->itap, IWL_KEY_BUF) == NULL)) { 00055 fprintf(outfile,"iwl_buf_init: Can't open file %d\n", Buf->itap); 00056 psio_close(Buf->itap,0); 00057 return; 00058 } 00059 00061 if (readflag) iwl_buf_fetch(Buf); 00062 00063 }
| void iwl_buf_put | ( | struct iwlbuf * | Buf | ) |
iwl_buf_put(struct iwlbuf *Buf)
Put an IWL buffer to disk David Sherrill, 26 June 1996
Definition at line 18 of file buf_put.cc.
References psio_write().
Referenced by iwl_buf_flush(), iwl_buf_wrt(), iwl_buf_wrt_all(), iwl_buf_wrt_arr(), iwl_buf_wrt_arr2(), iwl_buf_wrt_arr_SI(), iwl_buf_wrt_arr_SI_nocut(), iwl_buf_wrt_mat(), iwl_buf_wrt_mat2(), iwl_buf_wrt_mp2(), iwl_buf_wrt_mp2r12a(), iwl_buf_wrt_val(), iwl_buf_wrt_val_SI(), and sortbuf().
00019 { 00020 psio_write(Buf->itap, IWL_KEY_BUF, (char *) &(Buf->lastbuf), sizeof(int), 00021 Buf->bufpos, &(Buf->bufpos)); 00022 psio_write(Buf->itap, IWL_KEY_BUF, (char *) &(Buf->inbuf), sizeof(int), 00023 Buf->bufpos, &(Buf->bufpos)); 00024 psio_write(Buf->itap, IWL_KEY_BUF, (char *) Buf->labels, Buf->ints_per_buf * 00025 4 * sizeof(Label), Buf->bufpos, &(Buf->bufpos)); 00026 psio_write(Buf->itap, IWL_KEY_BUF, (char *) Buf->values, Buf->ints_per_buf * 00027 sizeof(Value), Buf->bufpos, &(Buf->bufpos)); 00028 }
| int iwl_buf_rd | ( | struct iwlbuf * | Buf, | |
| int | target_pq, | |||
| double * | ints, | |||
| int * | ioff_lt, | |||
| int * | ioff_rt, | |||
| int | mp2, | |||
| int | printflg, | |||
| FILE * | outfile | |||
| ) |
iwl_buf_rd(struct iwlbuf *Buf, int target_pq, double *ints, int *ioff_lt, int *ioff_rt, int mp2, int printflg, FILE *outfile)
Read from an Integrals With Labels formatted PSI buffer. The buffer must have been initialized with iwl_buf_init(). David Sherrill, March 1995
Returns: 0 if end of file, otherwise 1
Altered such that if the current pq value does not equal the target_pq then routine returns. This may be dangerous in that if you don't know the order of pq's in the iwl_buf, you may skip integrals! -Daniel, November 9, 1995
Revised 6/26/96 by CDS for new format
I _think_ this will work
if (pq < target_pq) continue;
end loop through current buffer
read new buffers
I _think_ this will work
end loop through current buffer
end loop over reading buffers
we must have reached the last buffer at this point
Definition at line 35 of file buf_rd.cc.
References iwl_buf_fetch().
00038 { 00039 int lastbuf; 00040 Value *valptr; 00041 Label *lblptr; 00042 int idx, p, q, r, s, pq, rs; 00043 00044 lblptr = Buf->labels; 00045 valptr = Buf->values; 00046 00047 lastbuf = Buf->lastbuf; 00048 00049 for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) { 00050 p = (int) lblptr[idx++]; 00051 q = (int) lblptr[idx++]; 00052 r = (int) lblptr[idx++]; 00053 s = (int) lblptr[idx++]; 00054 00055 if(mp2) { 00056 pq = ioff_lt[p] + q; 00057 rs = ioff_rt[r] + s; 00058 } 00059 else { 00060 pq = ioff_lt[MAX0(p,q)] + MIN0(p,q); 00061 rs = ioff_rt[MAX0(r,s)] + MIN0(r,s); 00062 } 00063 00065 if (pq != target_pq) return(1); 00066 00067 ints[rs] = (double) valptr[Buf->idx]; 00068 00069 if (printflg) 00070 fprintf(outfile, "<%d %d %d %d [%d][%d] = %20.10lf\n", 00071 p, q, r, s, pq, rs, ints[rs]) ; 00072 00073 } 00076 while (!lastbuf) { 00077 iwl_buf_fetch(Buf); 00078 lastbuf = Buf->lastbuf; 00079 00080 for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) { 00081 p = (int) lblptr[idx++]; 00082 q = (int) lblptr[idx++]; 00083 r = (int) lblptr[idx++]; 00084 s = (int) lblptr[idx++]; 00085 00086 if(mp2) { 00087 pq = ioff_lt[p] + q; 00088 rs = ioff_rt[r] + s; 00089 } 00090 else { 00091 pq = ioff_lt[MAX0(p,q)] + MIN0(p,q); 00092 rs = ioff_rt[MAX0(r,s)] + MIN0(r,s); 00093 } 00094 00095 if (pq < target_pq) continue; 00096 if (pq > target_pq) return(1); 00097 00098 ints[rs] = (double) valptr[Buf->idx]; 00099 00100 if (printflg) 00101 fprintf(outfile, "<%d %d %d %d [%d][%d] = %20.10lf\n", 00102 p, q, r, s, pq, rs, ints[rs]) ; 00103 00104 } 00106 } 00108 return(0); 00109 }
| int iwl_buf_rd_all | ( | struct iwlbuf * | Buf, | |
| double * | ints, | |||
| int * | ioff_lt, | |||
| int * | ioff_rt, | |||
| int | no_pq_perm, | |||
| int * | ioff, | |||
| int | printflg, | |||
| FILE * | outfile | |||
| ) |
Read from an Integrals With Labels formatted buffer. The buffer must have been initialized with iwl_buf_init().
Arguments:
| Buf | = IWL Buffer to read from (already initialized) | |
| ints | = memory buffer to put integrals into | |
| ioff_lt | = ioff array for the left pair of indices (p and q) | |
| ioff_rt | = ioff array for the right pair of indices (r and s) | |
| no_pq_perm | = if 1, do not use p/q or r/s permutational symmetry | |
| ioff | = the ioff array to figure the total index pqrs from the pair indices pq and rs | |
| printflg | = if 1, print integrals as they are read | |
| outfile | = pointer to output file for printing |
I _think_ this will work
end loop through current buffer
read new PSI buffers
I _think_ this will work
end loop through current buffer
end loop over reading buffers
we must have reached the last buffer at this point
Definition at line 36 of file buf_rd_all.cc.
References iwl_buf_fetch().
Referenced by iwl_rdtwo().
00039 { 00040 int lastbuf; 00041 Label *lblptr; 00042 Value *valptr; 00043 int idx, p, q, r, s, pq, rs, pqrs; 00044 00045 lblptr = Buf->labels; 00046 valptr = Buf->values; 00047 00048 lastbuf = Buf->lastbuf; 00049 00050 for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) { 00051 p = fabs((int) lblptr[idx++]); 00052 q = (int) lblptr[idx++]; 00053 r = (int) lblptr[idx++]; 00054 s = (int) lblptr[idx++]; 00055 00056 if(no_pq_perm) { 00057 pq = ioff_lt[p] + q; 00058 rs = ioff_rt[r] + s; 00059 } 00060 else { 00061 pq = ioff_lt[MAX0(p,q)] + MIN0(p,q); 00062 rs = ioff_rt[MAX0(r,s)] + MIN0(r,s); 00063 } 00064 00065 pqrs = INDEX(pq,rs); 00066 00067 ints[pqrs] = (double) valptr[Buf->idx]; 00068 00069 if (printflg) 00070 fprintf(outfile, "<%2d %2d %2d %2d [%2d][%2d] [[%3d]] = %20.10lf\n", 00071 p, q, r, s, pq, rs, pqrs, ints[pqrs]) ; 00072 00073 } 00076 while (!lastbuf) { 00077 iwl_buf_fetch(Buf); 00078 lastbuf = Buf->lastbuf; 00079 00080 for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) { 00081 p = fabs((int) lblptr[idx++]); 00082 q = (int) lblptr[idx++]; 00083 r = (int) lblptr[idx++]; 00084 s = (int) lblptr[idx++]; 00085 00086 if(no_pq_perm) { 00087 pq = ioff_lt[p] + q; 00088 rs = ioff_rt[r] + s; 00089 } 00090 else { 00091 pq = ioff_lt[MAX0(p,q)] + MIN0(p,q); 00092 rs = ioff_rt[MAX0(r,s)] + MIN0(r,s); 00093 } 00094 00095 pqrs = INDEX(pq,rs); 00096 00097 ints[pqrs] = (double) valptr[Buf->idx]; 00098 00099 if (printflg) 00100 fprintf(outfile, "<%d %d %d %d [%d][%d] [[%d]] = %20.10lf\n", 00101 p, q, r, s, pq, rs, pqrs, ints[pqrs]) ; 00102 00103 } 00105 } 00107 return(0); 00108 }
| int iwl_buf_rd_all2 | ( | struct iwlbuf * | Buf, | |
| double ** | ints, | |||
| int * | ioff_lt, | |||
| int * | ioff_rt, | |||
| int | no_pq_perm, | |||
| int * | ioff, | |||
| int | printflg, | |||
| FILE * | outfile | |||
| ) |
IWL_BUF_RD_ALL2(): This routine works exactly like iwl_buf_rd_all(), except that the integral list is not assumed to have bra-ket permutational symmetry. The list is still required to have permutational symmetry WITHIN bra and ket, however, unless no_pq_perm is set. This function requires that the input array be (double **) rather than (double *). This routine is necessary, for example, for reading the alpha-beta two-electron integrals from the UHF transqt code.
TDC, 6/01
I _think_ this will work
end loop through current buffer
read new PSI buffers
I _think_ this will work
end loop through current buffer
end loop over reading buffers
we must have reached the last buffer at this point
Definition at line 124 of file buf_rd_all.cc.
References iwl_buf_fetch().
00127 { 00128 int lastbuf; 00129 Label *lblptr; 00130 Value *valptr; 00131 int idx, p, q, r, s, pq, rs; 00132 00133 lblptr = Buf->labels; 00134 valptr = Buf->values; 00135 00136 lastbuf = Buf->lastbuf; 00137 00138 for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) { 00139 p = fabs((int) lblptr[idx++]); 00140 q = (int) lblptr[idx++]; 00141 r = (int) lblptr[idx++]; 00142 s = (int) lblptr[idx++]; 00143 00144 if(no_pq_perm) { 00145 pq = ioff_lt[p] + q; 00146 rs = ioff_rt[r] + s; 00147 } 00148 else { 00149 pq = ioff_lt[MAX0(p,q)] + MIN0(p,q); 00150 rs = ioff_rt[MAX0(r,s)] + MIN0(r,s); 00151 } 00152 00153 ints[pq][rs] = (double) valptr[Buf->idx]; 00154 00155 if (printflg) 00156 fprintf(outfile, "<%2d %2d %2d %2d [%2d][%2d] = %20.10lf\n", 00157 p, q, r, s, pq, rs, ints[pq][rs]) ; 00158 00159 } 00162 while (!lastbuf) { 00163 iwl_buf_fetch(Buf); 00164 lastbuf = Buf->lastbuf; 00165 00166 for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) { 00167 p = fabs((int) lblptr[idx++]); 00168 q = (int) lblptr[idx++]; 00169 r = (int) lblptr[idx++]; 00170 s = (int) lblptr[idx++]; 00171 00172 if(no_pq_perm) { 00173 pq = ioff_lt[p] + q; 00174 rs = ioff_rt[r] + s; 00175 } 00176 else { 00177 pq = ioff_lt[MAX0(p,q)] + MIN0(p,q); 00178 rs = ioff_rt[MAX0(r,s)] + MIN0(r,s); 00179 } 00180 00181 ints[pq][rs] = (double) valptr[Buf->idx]; 00182 00183 if (printflg) 00184 fprintf(outfile, "<%d %d %d %d [%d][%d] = %20.10lf\n", 00185 p, q, r, s, pq, rs, ints[pq][rs]) ; 00186 00187 } 00189 } 00191 return(0); 00192 }
| int iwl_buf_rd_all_act | ( | struct iwlbuf * | Buf, | |
| double * | ints, | |||
| int * | ioff_lt, | |||
| int * | ioff_rt, | |||
| int | no_pq_perm, | |||
| int * | ioff, | |||
| int | fstact, | |||
| int | lstact, | |||
| int | printflg, | |||
| FILE * | outfile | |||
| ) |
Read from an Integrals With Labels formatted buffer. The buffer must have been initialized with iwl_buf_init(). Same as function iwl_buf_rd_all() except that we only keep the integrals with all-active labels.
| Buf | = IWL Buffer to read from (already initialized) | |
| ints | = memory buffer to put integrals into | |
| ioff_lt | = ioff array for the left pair of indices (p and q) | |
| ioff_rt | = ioff array for the right pair of indices (r and s) | |
| no_pq_perm | = if 1, do not use p/q or r/s permutational symmetry | |
| ioff | = the ioff array to figure the total index pqrs from the pair indices pq and rs | |
| fstact | = index of first active orbital | |
| lstact | = index of last active orbital | |
| printflg | = if 1, print integrals as they are read | |
| outfile | = pointer to output file for printing |
I _think_ this will work
end loop through current buffer
read new PSI buffers
I _think_ this will work
end loop through current buffer
end loop over reading buffers
we must have reached the last buffer at this point
Definition at line 39 of file buf_rd_all_act.cc.
References iwl_buf_fetch().
Referenced by iwl_rdtwo().
00042 { 00043 int lastbuf; 00044 Label *lblptr; 00045 Value *valptr; 00046 int idx, p, q, r, s, pq, rs, pqrs; 00047 00048 lblptr = Buf->labels; 00049 valptr = Buf->values; 00050 00051 lastbuf = Buf->lastbuf; 00052 00053 for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) { 00054 p = (int) lblptr[idx++]; 00055 q = (int) lblptr[idx++]; 00056 r = (int) lblptr[idx++]; 00057 s = (int) lblptr[idx++]; 00058 00059 if (p > lstact || q > lstact || r > lstact || s > lstact) continue; 00060 if (p < fstact || q < fstact || r < fstact || s < fstact) continue; 00061 p -= fstact; 00062 q -= fstact; 00063 r -= fstact; 00064 s -= fstact; 00065 00066 if(no_pq_perm) { 00067 pq = ioff_lt[p] + q; 00068 rs = ioff_rt[r] + s; 00069 } 00070 else { 00071 pq = ioff_lt[MAX0(p,q)] + MIN0(p,q); 00072 rs = ioff_rt[MAX0(r,s)] + MIN0(r,s); 00073 } 00074 00075 pqrs = INDEX(pq,rs); 00076 00077 ints[pqrs] = (double) valptr[Buf->idx]; 00078 00079 if (printflg) 00080 fprintf(outfile, "<%2d %2d %2d %2d [%2d][%2d] [[%3d]] = %20.10lf\n", 00081 p, q, r, s, pq, rs, pqrs, ints[pqrs]) ; 00082 00083 } 00086 while (!lastbuf) { 00087 iwl_buf_fetch(Buf); 00088 lastbuf = Buf->lastbuf; 00089 00090 for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) { 00091 p = (int) lblptr[idx++]; 00092 q = (int) lblptr[idx++]; 00093 r = (int) lblptr[idx++]; 00094 s = (int) lblptr[idx++]; 00095 00096 if (p > lstact || q > lstact || r > lstact || s > lstact) continue; 00097 if (p < fstact || q < fstact || r < fstact || s < fstact) continue; 00098 p -= fstact; 00099 q -= fstact; 00100 r -= fstact; 00101 s -= fstact; 00102 00103 if(no_pq_perm) { 00104 pq = ioff_lt[p] + q; 00105 rs = ioff_rt[r] + s; 00106 } 00107 else { 00108 pq = ioff_lt[MAX0(p,q)] + MIN0(p,q); 00109 rs = ioff_rt[MAX0(r,s)] + MIN0(r,s); 00110 } 00111 00112 pqrs = INDEX(pq,rs); 00113 00114 ints[pqrs] = (double) valptr[Buf->idx]; 00115 00116 if (printflg) 00117 fprintf(outfile, "<%d %d %d %d [%d][%d] [[%d]] = %20.10lf\n", 00118 p, q, r, s, pq, rs, pqrs, ints[pqrs]) ; 00119 00120 } 00122 } 00124 return(0); 00125 }
| int iwl_buf_rd_all_mp2r12a | ( | struct iwlbuf * | Buf, | |
| double * | ints, | |||
| int * | ioff_lt, | |||
| int * | ioff_rt, | |||
| int | bra_ket_symm, | |||
| int * | ioff, | |||
| int | printflg, | |||
| FILE * | outfile | |||
| ) |
Read from an Integrals With Labels formatted buffer. The buffer must have been initialized with iwl_buf_init().
| Buf | = IWL Buffer to read from (already initialized) | |
| ints | = memory buffer to put integrals into | |
| ioff_lt | = ioff array for the left pair of indices (p and q) | |
| ioff_rt | = ioff array for the right pair of indices (r and s) | |
| bra_ket_symm | = if 1, then these are ERI or R12 integrals, read them in as usual, else these are [r12,T2] integrals - form [T1+T2,r12] out of these. |
| ioff | = the ioff array to figure the total index pqrs from the pair indices pq and rs | |
| printflg | = if 1, print integrals as they are read | |
| outfile | = pointer to output file for printing |
ERIs or R12-integrals
(ip|[T1+T2,r12]|jq) = -[(ip|[r12,T1]|jq) + (jq|[r12,T2]|ip)]
end loop through current buffer
read new PSI buffers
ERIs or R12-integrals
(ip|[T1+T2,r12]|jq) = -[(ip|[r12,T2]|jq)+(jq|[r12,T2]|ip)]
end loop through current buffer
end loop over reading buffers
we must have reached the last buffer at this point
Definition at line 40 of file buf_rd_all_mp2r12a.cc.
00043 { 00044 int lastbuf; 00045 Label *lblptr; 00046 Value *valptr; 00047 int idx, p, q, r, s; 00048 long int pq, rs, pqrs; 00049 00050 lblptr = Buf->labels; 00051 valptr = Buf->values; 00052 00053 lastbuf = Buf->lastbuf; 00054 00055 for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) { 00056 p = (int) lblptr[idx++]; 00057 q = (int) lblptr[idx++]; 00058 r = (int) lblptr[idx++]; 00059 s = (int) lblptr[idx++]; 00060 00061 pq = ioff_lt[p] + q; 00062 rs = ioff_rt[r] + s; 00063 00064 pqrs = INDEX(pq,rs); 00065 00066 if (bra_ket_symm) 00067 ints[pqrs] = (double) valptr[Buf->idx]; 00068 else { 00069 if (pq != rs) 00070 ints[pqrs] -= (double) valptr[Buf->idx]; 00071 else 00072 ints[pqrs] -= (double) 2.0*valptr[Buf->idx]; 00073 } 00074 00075 if (printflg) 00076 fprintf(outfile, "<%2d %2d %2d %2d [%2ld][%2ld] [[%3ld]] = %20.10lf\n", 00077 p, q, r, s, pq, rs, pqrs, ints[pqrs]) ; 00078 00079 } 00082 while (!lastbuf) { 00083 iwl_buf_fetch(Buf); 00084 lastbuf = Buf->lastbuf; 00085 00086 for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) { 00087 p = (int) lblptr[idx++]; 00088 q = (int) lblptr[idx++]; 00089 r = (int) lblptr[idx++]; 00090 s = (int) lblptr[idx++]; 00091 00092 pq = ioff_lt[p] + q; 00093 rs = ioff_rt[r] + s; 00094 00095 pqrs = INDEX(pq,rs); 00096 00097 if (bra_ket_symm) 00098 ints[pqrs] = (double) valptr[Buf->idx]; 00099 else { 00100 if (pq != rs) 00101 ints[pqrs] -= (double) valptr[Buf->idx]; 00102 else 00103 ints[pqrs] -= (double) 2.0*valptr[Buf->idx]; 00104 } 00105 00106 if (printflg) 00107 fprintf(outfile, "<%d %d %d %d [%ld][%ld] [[%ld]] = %20.10lf\n", 00108 p, q, r, s, pq, rs, pqrs, ints[pqrs]) ; 00109 00110 } 00112 } 00114 return(0); 00115 }
| int iwl_buf_rd_arr | ( | struct iwlbuf * | Buf, | |
| int | target_pq, | |||
| double * | ints, | |||
| int * | rlist, | |||
| int * | slist, | |||
| int * | size, | |||
| int * | ioff, | |||
| int | printflg, | |||
| FILE * | outfile | |||
| ) |
Read from an Integrals With Labels formatted PSI buffer. The buffer must have been initialized with iwl_buf_init(). The integrals and their labels are returned in the arrays ints, rlist, and slist, and the size of these arrays is returned in 'size.' David Sherrill, March 1995
Returns: 0 if end of file, otherwise 1
Revised 6/27/96 by CDS for new format
end loop through current buffer
read new buffers
end loop through current buffer
end loop over reading buffers
we must have reached the last buffer at this point
Definition at line 30 of file buf_rd_arr.cc.
References iwl_buf_fetch().
00033 { 00034 int lastbuf; 00035 int idx, p, q, r, s, pq; 00036 double value; 00037 Value *valptr; 00038 Label *lblptr; 00039 00040 lblptr = Buf->labels; 00041 valptr = Buf->values; 00042 00043 lastbuf = Buf->lastbuf; 00044 00045 *size = 0; 00046 00047 for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) { 00048 p = (int) lblptr[idx++]; 00049 q = (int) lblptr[idx++]; 00050 r = (int) lblptr[idx++]; 00051 s = (int) lblptr[idx++]; 00052 00053 pq = INDEX(p,q); 00054 00055 if (pq < target_pq) continue; 00056 if (pq > target_pq) return(1); 00057 00058 value = (double) valptr[Buf->idx]; 00059 *ints++ = value; 00060 *rlist++ = r; 00061 *slist++ = s; 00062 *size = *size + 1; 00063 00064 if (printflg) 00065 fprintf(outfile, "<%d %d %d %d [%d] = %20.10lf\n", p, q, r, s, 00066 pq, value); 00067 00068 } 00071 while (!lastbuf) { 00072 iwl_buf_fetch(Buf); 00073 lastbuf = Buf->lastbuf; 00074 00075 for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) { 00076 p = (int) lblptr[idx++]; 00077 q = (int) lblptr[idx++]; 00078 r = (int) lblptr[idx++]; 00079 s = (int) lblptr[idx++]; 00080 00081 pq = INDEX(p,q); 00082 00083 if (pq < target_pq) continue; 00084 if (pq > target_pq) return(1); 00085 00086 value = (double) valptr[Buf->idx]; 00087 *ints++ = value; 00088 *rlist++ = r; 00089 *slist++ = s; 00090 *size = *size + 1; 00091 00092 if (printflg) 00093 fprintf(outfile, "<%d %d %d %d [%d] = %20.10lf\n", p, q, r, s, 00094 pq, value); 00095 00096 } 00098 } 00100 return(0); 00101 }
| void iwl_buf_toend | ( | struct iwlbuf * | Buf | ) |
Set IWL Buffer's pointer to the end. Useful when want to append to an already existing file
Edward Valeev, January 2001
Definition at line 23 of file buf_toend.cc.
References iwl_buf_close(), psio_get_address(), psio_get_length(), psio_tocscan(), and PSIO_ZERO.
00024 { 00025 psio_tocentry *this_entry; 00026 ULI entry_length; 00027 00028 this_entry = psio_tocscan(Buf->itap, IWL_KEY_BUF); 00029 if (this_entry == NULL) { 00030 fprintf(outfile, 00031 "iwl_buf_toend: Can't find IWL buffer entry in file %d\n", Buf->itap); 00032 iwl_buf_close(Buf,1); 00033 return; 00034 } 00035 00036 /* set up buffer pointer */ 00037 entry_length = psio_get_length(this_entry->sadd,this_entry->eadd); 00038 Buf->bufpos = psio_get_address(PSIO_ZERO,entry_length); 00039 00040 return; 00041 }
| void iwl_buf_wrt | ( | struct iwlbuf * | Buf, | |
| int | p, | |||
| int | q, | |||
| int | pq, | |||
| int | pqsym, | |||
| double * | arr, | |||
| int | rmax, | |||
| int * | active, | |||
| int * | ioff, | |||
| int * | orbsym, | |||
| int * | firsti, | |||
| int * | lasti, | |||
| int | sortby_rs, | |||
| int | printflag, | |||
| FILE * | outfile | |||
| ) |
Write to an Integrals With Labels formatted buffer. The buffer must have been initialized with iwl_buf_init(). Don't forget to call iwl_buf_flush() when finished with all writes to the buffer to ensure that all contents are written to disk. David Sherrill, March 1995
Revised 6/27/96 by CDS for new format
Definition at line 24 of file buf_wrt.cc.
References iwl_buf_put().
00027 { 00028 int r, s, rs, rsym, ssym, smax, idx; 00029 double value; 00030 Label *lblptr; 00031 Value *valptr; 00032 00033 lblptr = Buf->labels; 00034 valptr = Buf->values; 00035 00036 for (r=0; r<rmax; r++) { 00037 rsym = orbsym[r]; 00038 ssym = pqsym ^ rsym; 00039 smax = (rsym == ssym) ? r : lasti[ssym]; 00040 00041 for (s=firsti[ssym]; s<=smax; s++) { 00042 rs = ioff[r] + s; 00043 value = arr[rs]; 00044 00045 if (fabs(value) > Buf->cutoff) { 00046 idx = 4 * Buf->idx; 00047 lblptr[idx] = (Label) p; 00048 lblptr[idx+1] = (Label) q; 00049 lblptr[idx+2] = (Label) r; 00050 lblptr[idx+3] = (Label) s; 00051 valptr[Buf->idx] = (Value) value; 00052 00053 Buf->idx++; 00054 00055 if (Buf->idx == Buf->ints_per_buf) { 00056 Buf->inbuf = Buf->idx; 00057 Buf->lastbuf = 0; 00058 iwl_buf_put(Buf); 00059 Buf->idx = 0; 00060 } 00061 00062 if(printflag) 00063 fprintf(outfile, "<%d %d %d %d [%d] [%d] = %20.10lf\n", 00064 p, q, r, s, pq, rs, value); 00065 00066 } /* end if (fabs(value) > Buf->cutoff) ... */ 00067 } /* end loop over s */ 00068 } /* end loop over r */ 00069 00070 }
| void iwl_buf_wrt_all | ( | struct iwlbuf * | Buf, | |
| int | nbfso, | |||
| double * | ints, | |||
| int * | ioff, | |||
| int | printflg, | |||
| FILE * | outfile | |||
| ) |
Write out two electron ints to IWL file. Assume that the integrals are in ijkl canonical order (no spatial symmetry).
| itap | = unit to write to | |
| nbfso | = number of basis functions in symmetry orbitals | |
| ints | = two electron integrals | |
| ioff | = the old ioff array for lexical ordering | |
| printflg | = print flag (1 or 0) | |
| outfile | = output file |
NB: This routine will only write "standard" (pq|rs) indices to disk. The cints integral program marks certain integrals with negative index values to indicate the end of PK-matrix blocks. This marking is used by the cscf code (only?). Therefore, is this routine is used to write integrals to disk, the SCF code will most likely give incorrect data if it uses the resulting integrals. TDC 12/24/01
Definition at line 36 of file buf_wrt_all.cc.
References iwl_buf_put().
Referenced by iwl_wrttwo().
00038 { 00039 int idx, p, q, r, s, smax, pq, rs, pqrs; 00040 Label *lblptr; 00041 Value *valptr; 00042 00043 lblptr = Buf->labels; 00044 valptr = Buf->values; 00045 00046 /* go through the lexical order and print to the output file */ 00047 for (p=0; p<nbfso; p++) { 00048 for (q=0; q<=p; q++) { 00049 pq = ioff[p] + q; 00050 for (r=0; r<=p; r++) { 00051 smax = (p==r) ? (q+1) : (r+1); 00052 for (s=0; s < smax; s++) { 00053 rs = ioff[r] + s; 00054 pqrs = ioff[pq] + rs; 00055 if (fabs(ints[pqrs]) > Buf->cutoff) { 00056 idx = 4 * Buf->idx; 00057 lblptr[idx++] = (Label) p; 00058 lblptr[idx++] = (Label) q; 00059 lblptr[idx++] = (Label) r; 00060 lblptr[idx++] = (Label) s; 00061 valptr[Buf->idx] = (Value) ints[pqrs]; 00062 Buf->idx++; 00063 if (printflg) fprintf(outfile, "%d %d %d %d [%d] = %10.6lf\n", 00064 p, q, r, s, pqrs, ints[pqrs]) ; 00065 00066 if (Buf->idx == Buf->ints_per_buf) { 00067 Buf->lastbuf = 0; 00068 Buf->inbuf = Buf->idx; 00069 iwl_buf_put(Buf); 00070 Buf->idx = 0; 00071 } 00072 } 00073 } 00074 } 00075 } 00076 } 00077 }
| void iwl_buf_wrt_arr | ( | struct iwlbuf * | Buf, | |
| double * | arr, | |||
| int * | p, | |||
| int * | q, | |||
| int * | r, | |||
| int * | s, | |||
| long int | size | |||
| ) |
IWL_BUF_WRT_ARR()
This function writes out an array of two-electron integrals using the Integrals With Labels file format. David Sherrill, March 1995
Revised 6/27/96 by CDS for new format
Definition at line 22 of file buf_wrt_arr.cc.
References iwl_buf_put().
00024 { 00025 00026 long int i; 00027 int idx; 00028 double value; 00029 Label *lblptr; 00030 Value *valptr; 00031 00032 if (size < 0) { 00033 printf("(iwl_buf_wrt_arr): Called with size = %ld\n", size); 00034 return; 00035 } 00036 00037 if (Buf == NULL || arr == NULL || p == NULL || q == NULL || r == NULL 00038 || s == NULL) { 00039 printf("(iwl_buf_wrt_arr): Called with null pointer argument\n"); 00040 return; 00041 } 00042 00043 lblptr = Buf->labels; 00044 valptr = Buf->values; 00045 00046 for (i=0; i<size; i++) { 00047 value = *arr++; 00048 00049 if (fabs(value) > Buf->cutoff) { 00050 idx = 4 * Buf->idx; 00051 lblptr[idx++] = (Label) p[i]; 00052 lblptr[idx++] = (Label) q[i]; 00053 lblptr[idx++] = (Label) r[i]; 00054 lblptr[idx++] = (Label) s[i]; 00055 valptr[Buf->idx] = (Value) value; 00056 00057 Buf->idx++; 00058 00059 if (Buf->idx == Buf->ints_per_buf) { 00060 Buf->lastbuf = 0; 00061 Buf->inbuf = Buf->idx; 00062 iwl_buf_put(Buf); 00063 Buf->idx = 0; 00064 } 00065 00066 } /* end if cutoff */ 00067 } /* end loop over i */ 00068 00069 }
| void iwl_buf_wrt_arr2 | ( | struct iwlbuf * | Buf, | |
| double * | arr, | |||
| int | p, | |||
| int | q, | |||
| int * | rlist, | |||
| int * | slist, | |||
| int | size, | |||
| int | printflag, | |||
| FILE * | outfile | |||
| ) |
IWL_BUF_WRT_ARR2()
This function writes out an array of two-electron integrals using the Integrals With Labels file format. All integrals in the input arr have common indices p and q. r and s indices are given in the lists plist and qlist. David Sherrill, March 1995
Revised 6/27/96 by CDS for new format
Definition at line 24 of file buf_wrt_arr2.cc.
References iwl_buf_put().
00026 { 00027 int i,idx; 00028 double value; 00029 Label *lblptr; 00030 Value *valptr; 00031 00032 if (size < 0) { 00033 printf("(iwl_buf_wrt_arr2): Called with size = %d\n", 00034 size); 00035 return; 00036 } 00037 00038 if (Buf == NULL || arr == NULL || rlist == NULL || slist == NULL) { 00039 printf("(iwl_buf_wrt_arr2): Called with null pointer argument\n"); 00040 return; 00041 } 00042 00043 lblptr = Buf->labels; 00044 valptr = Buf->values; 00045 00046 for (i=0; i<size; i++) { 00047 value = *arr++; 00048 if (fabs(value) > Buf->cutoff) { 00049 idx = 4 * Buf->idx; 00050 lblptr[idx++] = (Label) p; 00051 lblptr[idx++] = (Label) q; 00052 lblptr[idx++] = (Label) rlist[i]; 00053 lblptr[idx++] = (Label) slist[i]; 00054 valptr[Buf->idx] = (Value) value; 00055 00056 if(printflag) 00057 fprintf(outfile, "%d %d %d %d %20.10f\n", p, q, 00058 rlist[i], slist[i], value); 00059 00060 Buf->idx++; 00061 00062 if (Buf->idx == Buf->ints_per_buf) { 00063 Buf->lastbuf = 0; 00064 Buf->inbuf = Buf->idx; 00065 iwl_buf_put(Buf); 00066 Buf->idx = 0; 00067 } 00068 00069 } /* end if (fabs(value) > Buf->cutoff) ... */ 00070 } /* end loop over i */ 00071 00072 }
| void iwl_buf_wrt_arr_SI | ( | struct iwlbuf * | Buf, | |
| double * | arr, | |||
| short int * | p, | |||
| short int * | q, | |||
| short int * | r, | |||
| short int * | s, | |||
| int | size | |||
| ) |
IWL_BUF_WRT_ARR_SI()
This function writes out an array of two-electron integrals using the Integrals With Labels file format with indices stored in arrays of short int's Ed Valeev, February 1999
Definition at line 21 of file buf_wrt_arr_SI.cc.
References iwl_buf_put().
00023 { 00024 00025 int i,idx; 00026 double value; 00027 Label *lblptr; 00028 Value *valptr; 00029 00030 if (size < 0) { 00031 printf("(iwl_buf_wrt_arr_SI): Called with size = %d\n", 00032 size); 00033 return; 00034 } 00035 00036 if (Buf == NULL || arr == NULL || p == NULL || q == NULL || r == NULL 00037 || s == NULL) { 00038 printf("(iwl_buf_wrt_arr_SI): Called with null pointer argument\n"); 00039 return; 00040 } 00041 00042 lblptr = Buf->labels; 00043 valptr = Buf->values; 00044 00045 for (i=0; i<size; i++) { 00046 value = *arr++; 00047 if (fabs(value) > Buf->cutoff) { 00048 idx = 4 * Buf->idx; 00049 lblptr[idx++] = (Label) p[i]; 00050 lblptr[idx++] = (Label) q[i]; 00051 lblptr[idx++] = (Label) r[i]; 00052 lblptr[idx++] = (Label) s[i]; 00053 valptr[Buf->idx] = (Value) value; 00054 00055 Buf->idx++; 00056 00057 if (Buf->idx == Buf->ints_per_buf) { 00058 Buf->lastbuf = 0; 00059 Buf->inbuf = Buf->idx; 00060 iwl_buf_put(Buf); 00061 Buf->idx = 0; 00062 } 00063 00064 } /* end if cutoff */ 00065 } /* end loop over i */ 00066 00067 }
| void iwl_buf_wrt_arr_SI_nocut | ( | struct iwlbuf * | Buf, | |
| double * | arr, | |||
| short int * | p, | |||
| short int * | q, | |||
| short int * | r, | |||
| short int * | s, | |||
| int | size | |||
| ) |
IWL_BUF_WRT_ARR_SI_nocut()
This function writes out an array of two-electron integrals using the Integrals With Labels file format with indices stored in arrays of short int's. It DOES NOT use Buf->Cutoff when writing. Ed Valeev, February 1999
Definition at line 22 of file buf_wrt_arr_SI_nocut.cc.
References iwl_buf_put().
00024 { 00025 00026 int i,idx; 00027 double value; 00028 Label *lblptr; 00029 Value *valptr; 00030 00031 if (size < 0) { 00032 printf("(iwl_buf_wrt_arr_SI_nocut): Called with size = %d\n", 00033 size); 00034 return; 00035 } 00036 00037 if (Buf == NULL || arr == NULL || p == NULL || q == NULL || r == NULL 00038 || s == NULL) { 00039 printf("(iwl_buf_wrt_arr_SI_nocut): Called with null pointer argument\n"); 00040 return; 00041 } 00042 00043 lblptr = Buf->labels; 00044 valptr = Buf->values; 00045 00046 for (i=0; i<size; i++) { 00047 value = *arr++; 00048 idx = 4 * Buf->idx; 00049 lblptr[idx++] = (Label) p[i]; 00050 lblptr[idx++] = (Label) q[i]; 00051 lblptr[idx++] = (Label) r[i]; 00052 lblptr[idx++] = (Label) s[i]; 00053 valptr[Buf->idx] = (Value) value; 00054 00055 Buf->idx++; 00056 00057 if (Buf->idx == Buf->ints_per_buf) { 00058 Buf->lastbuf = 0; 00059 Buf->inbuf = Buf->idx; 00060 iwl_buf_put(Buf); 00061 Buf->idx = 0; 00062 } 00063 } /* end loop over i */ 00064 00065 }
| void iwl_buf_wrt_mat | ( | struct iwlbuf * | Buf, | |
| int | ptr, | |||
| int | qtr, | |||
| double ** | mat, | |||
| int | rfirst, | |||
| int | rlast, | |||
| int | sfirst, | |||
| int | slast, | |||
| int * | reorder, | |||
| int | reorder_offset, | |||
| int | printflag, | |||
| int * | ioff, | |||
| FILE * | outfile | |||
| ) |
Write to an Integrals With Labels formatted buffer. The buffer must have been initialized with iwl_buf_init(). Don't forget to call iwl_buf_flush() when finished with all writes to the buffer to ensure that all contents are written to disk.
This version takes as input a matrix, as might be handy for a matrix formulation of an integral transformation. It assumes that all rs are available for a given pq. r and s are allowed to range from rfirst/sfirst to rlast/slast (with s<=r), and this maps to a matrix addressing of 0 to (rlast-rfirst) and 0 to (slast-sfirst).
This routine is also compatible with a reordering of the orbitals before output. We assume that p and q are already reordered, but r and s are not (yet). The reordered address of an orbital is computed according to rtr = reorder[r] - reorder_offset.
I have further modified the routine to spit out integrals whose reordered indices are canonical ij >= kl. The routine does not care whether ptr >= qtr, but it insists that the transformed pq and kl indices (called ij and kl in the routine) satisfy ij >= kl. David Sherrill, October 1995
Revised 6/27/96 by CDS for new format
Definition at line 44 of file buf_wrt_mat.cc.
References iwl_buf_put().
00048 { 00049 int idx, r, s, R, S, rtr, str; 00050 int ij, kl; 00051 double value; 00052 Label *lblptr; 00053 Value *valptr; 00054 00055 lblptr = Buf->labels; 00056 valptr = Buf->values; 00057 00058 ij = INDEX(ptr,qtr); 00059 00060 for (r=rfirst,R=0; r <= rlast; r++,R++) { 00061 rtr = reorder[r] - reorder_offset; 00062 00063 for (s=sfirst,S=0; s <= slast && s <= r; s++,S++) { 00064 str = reorder[s] - reorder_offset; 00065 00066 kl = INDEX(rtr,str); 00067 00068 value = mat[R][S]; 00069 00070 if (ij >= kl && fabs(value) > Buf->cutoff) { 00071 idx = 4 * Buf->idx; 00072 lblptr[idx++] = (Label) MAX0(ptr,qtr); 00073 lblptr[idx++] = (Label) MIN0(ptr,qtr); 00074 lblptr[idx++] = (Label) MAX0(rtr,str); 00075 lblptr[idx++] = (Label) MIN0(rtr,str); 00076 valptr[Buf->idx] = (Value) value; 00077 00078 Buf->idx++; 00079 00080 if (Buf->idx == Buf->ints_per_buf) { 00081 Buf->lastbuf = 0; 00082 Buf->inbuf = Buf->idx; 00083 iwl_buf_put(Buf); 00084 Buf->idx = 0; 00085 } 00086 00087 if (printflag) 00088 fprintf(outfile, ">%d %d %d %d [%d] [%d] = %20.10lf\n", 00089 ptr, qtr, rtr, str, ij, kl, value); 00090 00091 } /* end if (fabs(value) > Buf->cutoff) ... */ 00092 } /* end loop over s */ 00093 } /* end loop over r */ 00094 00095 }
| void iwl_buf_wrt_mat2 | ( | struct iwlbuf * | Buf, | |
| int | ptr, | |||
| int | qtr, | |||
| double ** | mat, | |||
| int | rfirst, | |||
| int | rlast, | |||
| int | sfirst, | |||
| int | slast, | |||
| int * | reorder, | |||
| int | reorder_offset, | |||
| int | printflag, | |||
| int * | ioff, | |||
| FILE * | outfile | |||
| ) |
IWL_BUF_WRT_MAT2(): This routine is exactly like iwl_buf_wrt_mat() except that the requirement that ij >= kl has been lifted. This is necessary for the UHF alpha-beta transformation of the two-electron integrals.
TDC, 6/01
Definition at line 106 of file buf_wrt_mat.cc.
References iwl_buf_put().
00110 { 00111 int idx, r, s, R, S, rtr, str; 00112 int ij, kl; 00113 double value; 00114 Label *lblptr; 00115 Value *valptr; 00116 00117 lblptr = Buf->labels; 00118 valptr = Buf->values; 00119 00120 ij = INDEX(ptr,qtr); 00121 00122 for (r=rfirst,R=0; r <= rlast; r++,R++) { 00123 rtr = reorder[r] - reorder_offset; 00124 00125 for (s=sfirst,S=0; s <= slast && s <= r; s++,S++) { 00126 str = reorder[s] - reorder_offset; 00127 00128 kl = INDEX(rtr,str); 00129 00130 value = mat[R][S]; 00131 00132 if (fabs(value) > Buf->cutoff) { 00133 idx = 4 * Buf->idx; 00134 lblptr[idx++] = (Label) MAX0(ptr,qtr); 00135 lblptr[idx++] = (Label) MIN0(ptr,qtr); 00136 lblptr[idx++] = (Label) MAX0(rtr,str); 00137 lblptr[idx++] = (Label) MIN0(rtr,str); 00138 valptr[Buf->idx] = (Value) value; 00139 00140 Buf->idx++; 00141 00142 if (Buf->idx == Buf->ints_per_buf) { 00143 Buf->lastbuf = 0; 00144 Buf->inbuf = Buf->idx; 00145 iwl_buf_put(Buf); 00146 Buf->idx = 0; 00147 } 00148 00149 if (printflag) 00150 fprintf(outfile, ">%d %d %d %d [%d] [%d] = %20.10lf\n", 00151 ptr, qtr, rtr, str, ij, kl, value); 00152 00153 } /* end if (fabs(value) > Buf->cutoff) ... */ 00154 } /* end loop over s */ 00155 } /* end loop over r */ 00156 00157 }
| void iwl_buf_wrt_mp2 | ( | struct iwlbuf * | Buf, | |
| int | p, | |||
| int | q, | |||
| int | pq, | |||
| int | pqsym, | |||
| double ** | arr, | |||
| int | rsym, | |||
| int * | firstr, | |||
| int * | lastr, | |||
| int * | firsts, | |||
| int * | lasts, | |||
| int * | occ, | |||
| int * | vir, | |||
| int * | ioff, | |||
| int | printflag, | |||
| FILE * | outfile | |||
| ) |
Write to an Integrals With Labels formatted PSI buffer. The buffer must have been initialized with iwl_buf_init(). Don't forget to call iwl_buf_flush() when finished with all writes to the buffer to ensure that all contents are written to disk. David Sherrill, March, 1995
This routine is a modified form of iwl_buf_wrt() specific to mp2-type restricted transforms. It's not general, but it should work. Daniel, 9/25/95
Definition at line 26 of file buf_wrt_mp2.cc.
References iwl_buf_put().
00029 { 00030 int idx, r, s, rs, ssym; 00031 int R,S,rnew,snew; 00032 double value; 00033 Label *lblptr; 00034 Value *valptr; 00035 00036 lblptr = Buf->labels; 00037 valptr = Buf->values; 00038 00039 ssym = pqsym ^ rsym; 00040 for (r=firstr[rsym],R=0; r <= lastr[rsym]; r++,R++) { 00041 rnew = occ[r]; 00042 for (s=firsts[ssym],S=0; s <=lasts[ssym]; s++,S++) { 00043 snew = vir[s]; 00044 rs = ioff[rnew] + snew; 00045 /*------------------------------------------ 00046 We do not need integrals with rs > pq 00047 rs can only increase, hence if rs > pq - 00048 it is time to leave 00049 ------------------------------------------*/ 00050 if (rs > pq) 00051 return; 00052 value = arr[R][S]; 00053 00054 if (fabs(value) > Buf->cutoff) { 00055 idx = 4 * Buf->idx; 00056 lblptr[idx++] = (Label) p; 00057 lblptr[idx++] = (Label) q; 00058 lblptr[idx++] = (Label) rnew; 00059 lblptr[idx++] = (Label) snew; 00060 valptr[Buf->idx] = (Value) value; 00061 00062 Buf->idx++; 00063 00064 if (Buf->idx == Buf->ints_per_buf) { 00065 Buf->lastbuf = 0; 00066 Buf->inbuf = Buf->idx; 00067 iwl_buf_put(Buf); 00068 Buf->idx = 0; 00069 } 00070 00071 if(printflag) 00072 fprintf(outfile, "<%d %d %d %d [%d] [%d] = %20.10lf\n", 00073 p, q, rnew, snew, pq, rs, value); 00074 00075 } /* end if (fabs(value) > Buf->cutoff) ... */ 00076 } /* end loop over s */ 00077 } /* end loop over r */ 00078 00079 }
| void iwl_buf_wrt_mp2r12a | ( | struct iwlbuf * | Buf, | |
| int | p, | |||
| int | q, | |||
| int | pq, | |||
| int | pqsym, | |||
| double ** | arr, | |||
| int | rsym, | |||
| int * | firstr, | |||
| int * | lastr, | |||
| int * | firsts, | |||
| int * | lasts, | |||
| int * | occ, | |||
| int | bra_ket_symm, | |||
| int * | ioff, | |||
| int | printflag, | |||
| FILE * | outfile | |||
| ) |
Write to an Integrals With Labels formatted PSI buffer. The buffer must have been initialized with iwl_buf_init(). Don't forget to call iwl_buf_flush() when finished with all writes to the buffer to ensure that all contents are written to disk. David Sherrill, March, 1995
This routine is a modified form of iwl_buf_wrt() specific to mp2-type restricted transforms. It's not general, but it should work. Daniel, 9/25/95
This routine is a modified form of iwl_buf_wrt_mp2() specific to mp2r12a-type restricted transforms. Edward, 8/04/99
Definition at line 30 of file buf_wrt_mp2r12a.cc.
References iwl_buf_put().
00033 { 00034 int idx, r, s, rs, ssym; 00035 int R,S,rnew,snew; 00036 double value; 00037 Label *lblptr; 00038 Value *valptr; 00039 00040 lblptr = Buf->labels; 00041 valptr = Buf->values; 00042 00043 ssym = pqsym ^ rsym; 00044 for (r=firstr[rsym],R=0; r <= lastr[rsym]; r++,R++) { 00045 rnew = occ[r]; /* r-index is in QTS-ordering, not Pitzer */ 00046 for (s=firsts[ssym],S=0; s <=lasts[ssym]; s++,S++) { 00047 snew = s; /* s-index is in Pitzer ordering */ 00048 rs = ioff[rnew] + snew; 00049 /*--------------------------------------- 00050 If bra_ket_symm != 0 -> we do not need 00051 integrals with rs > pq. rs can only 00052 increase here 00053 ---------------------------------------*/ 00054 if (bra_ket_symm && rs > pq) 00055 return; 00056 value = arr[R][S]; 00057 00058 if (fabs(value) > Buf->cutoff) { 00059 idx = 4 * Buf->idx; 00060 lblptr[idx++] = (Label) p; 00061 lblptr[idx++] = (Label) q; 00062 lblptr[idx++] = (Label) rnew; 00063 lblptr[idx++] = (Label) snew; 00064 valptr[Buf->idx] = (Value) value; 00065 00066 Buf->idx++; 00067 00068 if (Buf->idx == Buf->ints_per_buf) { 00069 Buf->lastbuf = 0; 00070 Buf->inbuf = Buf->idx; 00071 iwl_buf_put(Buf); 00072 Buf->idx = 0; 00073 } 00074 00075 if(printflag) 00076 fprintf(outfile, "<%d %d %d %d [%d] [%d] = %20.10lf\n", 00077 p, q, rnew, snew, pq, rs, value); 00078 00079 } /* end if (fabs(value) > Buf->cutoff) ... */ 00080 } /* end loop over s */ 00081 } /* end loop over r */ 00082 00083 }
| void iwl_buf_wrt_val | ( | struct iwlbuf * | Buf, | |
| int | p, | |||
| int | q, | |||
| int | r, | |||
| int | s, | |||
| double | value, | |||
| int | printflag, | |||
| FILE * | outfile, | |||
| int | dirac | |||
| ) |
Write to an Integrals With Labels formatted buffer. The buffer must have been initialized with iwl_buf_init(). Don't forget to call iwl_buf_flush() when finished with all writes to the buffer to ensure that all contents are written to disk.
This function writes only a particular value and its indices to the given iwl buffer. This is useful when index rearragements are necessary (e.g. conversion from Mulliken to Dirac notation). This is not as nice as being able to write entire arrays of values to the buffer, but may be necessary at times. Daniel Crawford, Novemeber 1995
Definition at line 28 of file buf_wrt_val.cc.
References iwl_buf_put().
00030 { 00031 int idx; 00032 Label *lblptr; 00033 Value *valptr; 00034 00035 lblptr = Buf->labels; 00036 valptr = Buf->values; 00037 00038 if (fabs(value) > Buf->cutoff) { 00039 idx = 4 * Buf->idx; 00040 if(dirac) { 00041 lblptr[idx++] = (Label) p; 00042 lblptr[idx++] = (Label) r; 00043 lblptr[idx++] = (Label) q; 00044 lblptr[idx++] = (Label) s; 00045 } 00046 else { 00047 lblptr[idx++] = (Label) p; 00048 lblptr[idx++] = (Label) q; 00049 lblptr[idx++] = (Label) r; 00050 lblptr[idx++] = (Label) s; 00051 } 00052 valptr[Buf->idx] = (Value) value; 00053 00054 Buf->idx++; 00055 00056 if (Buf->idx == Buf->ints_per_buf) { 00057 Buf->lastbuf = 0; 00058 Buf->inbuf = Buf->idx; 00059 iwl_buf_put(Buf); 00060 Buf->idx = 0; 00061 } 00062 00063 if (printflag) { 00064 if(dirac) { 00065 fprintf(outfile, ">%d %d %d %d = %20.10lf\n", 00066 p, r, q, s, value); 00067 } 00068 else { 00069 fprintf(outfile, ">%d %d %d %d = %20.10lf\n", 00070 p, q, r, s, value); 00071 } 00072 } 00073 } 00074 }
| void iwl_buf_wrt_val_SI | ( | struct iwlbuf * | Buf, | |
| short int | p, | |||
| short int | q, | |||
| short int | r, | |||
| short int | s, | |||
| double | value, | |||
| int | printflag, | |||
| FILE * | outfile, | |||
| int | dirac | |||
| ) |
Write to an Integrals With Labels formatted buffer. The buffer must have been initialized with iwl_buf_init(). Don't forget to call iwl_buf_flush() when finished with all writes to the buffer to ensure that all contents are written to disk.
This function writes only a particular value and its indices to the given iwl buffer. This is useful when index rearragements are necessary (e.g. conversion from Mulliken to Dirac notation). This is not as nice as being able to write entire arrays of values to the buffer, but may be necessary at times. Daniel Crawford, Novemeber 1995
Uses short int's as indices. May be useful. Ed Valeev, February 1999
Definition at line 31 of file buf_wrt_val_SI.cc.
References iwl_buf_put().
00034 { 00035 int idx; 00036 Label *lblptr; 00037 Value *valptr; 00038 00039 lblptr = Buf->labels; 00040 valptr = Buf->values; 00041 00042 if (fabs(value) > Buf->cutoff) { 00043 idx = 4 * Buf->idx; 00044 if(dirac) { 00045 lblptr[idx++] = (Label) p; 00046 lblptr[idx++] = (Label) r; 00047 lblptr[idx++] = (Label) q; 00048 lblptr[idx++] = (Label) s; 00049 } 00050 else { 00051 lblptr[idx++] = (Label) p; 00052 lblptr[idx++] = (Label) q; 00053 lblptr[idx++] = (Label) r; 00054 lblptr[idx++] = (Label) s; 00055 } 00056 valptr[Buf->idx] = (Value) value; 00057 00058 Buf->idx++; 00059 00060 if (Buf->idx == Buf->ints_per_buf) { 00061 Buf->lastbuf = 0; 00062 Buf->inbuf = Buf->idx; 00063 iwl_buf_put(Buf); 00064 Buf->idx = 0; 00065 } 00066 00067 if (printflag) { 00068 if(dirac) { 00069 fprintf(outfile, ">%d %d %d %d = %20.10lf\n", 00070 p, r, q, s, value); 00071 } 00072 else { 00073 fprintf(outfile, ">%d %d %d %d = %20.10lf\n", 00074 p, q, r, s, value); 00075 } 00076 } 00077 } 00078 }
| int iwl_rdone | ( | int | itap, | |
| char * | label, | |||
| double * | ints, | |||
| int | ntri, | |||
| int | erase, | |||
| int | printflg, | |||
| FILE * | outfile | |||
| ) |
IWL_RDONE()
This function reads the one-electron integrals in the MO basis from disk and stores them in core. Substantially revised on 29 April 1998 to filter out frozen orbitals if requested. This change requires a very different argument list from the previous version of this code.
David Sherrill, January 1994 Revised by David Sherrill, April 1998 Revised by TDC, June 2001
| itap | = tape to read ints from | |
| label | = the PSIO label | |
| ints | = buffer (already allocated) to store the integrals | |
| ntri | = number of packed integrals | |
| erase | = erase itap (1=yes, 0=no) | |
| printflg | = printing flag. Set to 1 to print ints; otherwise, set to 0 | |
| outfile | = file pointer for output of ints or error messages |
Definition at line 36 of file lib/libiwl/rdone.cc.
References print_array(), psio_open(), and psio_read_entry().
00038 { 00039 00040 int nmo; 00041 00042 psio_open(itap, PSIO_OPEN_OLD); 00043 psio_read_entry(itap, label, (char *) ints, ntri*sizeof(double)); 00044 psio_close(itap, !erase); 00045 00046 if (printflg) { 00047 nmo = (sqrt((double) (1 + 8 * ntri)) - 1)/2; 00048 print_array(ints, nmo, outfile); 00049 } 00050 00051 return(1); 00052 }
| void iwl_rdtwo | ( | int | itap, | |
| double * | ints, | |||
| int * | ioff, | |||
| int | norbs, | |||
| int | nfzc, | |||
| int | nfzv, | |||
| int | printflg, | |||
| FILE * | outfile | |||
| ) |
iwl_rdtwo(): read two electron ints from the given file. The "iwl" stands for "integrals with labels," and this is the proposed new standard for storing two-electron integrals and their (absolute) orbital labels.
| itap | = unit to read from | |
| ints | = two electron integrals (already allocated) | |
| ioff | = the old ioff array for lexical ordering | |
| norbs | = number of orbitals | |
| nfzc | = number of frozen core orbitals | |
| nfzv | = number of frozen virtual orbitals | |
| printflg | = print integrals as they're read | |
| outfile | = output file pointer |
Definition at line 33 of file lib/libiwl/rdtwo.cc.
References iwl_buf_close(), iwl_buf_init(), iwl_buf_rd_all(), and iwl_buf_rd_all_act().
00035 { 00036 struct iwlbuf Buf; 00037 00038 iwl_buf_init(&Buf, itap, 0.0, 1, 1); 00039 if ((nfzc == 0) && (nfzv == 0)) 00040 iwl_buf_rd_all(&Buf, ints, ioff, ioff, 0, ioff, printflg, outfile); 00041 else 00042 iwl_buf_rd_all_act(&Buf, ints, ioff, ioff, 0, ioff, nfzc, norbs-nfzv-1, 00043 printflg, outfile); 00044 iwl_buf_close(&Buf, 1); 00045 }
| void iwl_wrtone | ( | int | itap, | |
| char * | label, | |||
| int | ntri, | |||
| double * | onel_ints | |||
| ) |
IWL_WRTONE()
This function writes one-electron integrals.
itap = tape to read ints from label = the PSIO label ntri = the size of the array (lower triangle) onel_ints = array to hold the one-electron integrals.
David Sherrill, March 1995 Revised by TDC, June 2001
Definition at line 25 of file wrtone.cc.
References psio_open(), and psio_write_entry().
00026 { 00027 psio_open(itap, PSIO_OPEN_OLD); 00028 psio_write_entry(itap, label, (char *) onel_ints, ntri*sizeof(double)); 00029 psio_close(itap,1); 00030 }
| void iwl_wrttwo | ( | int | itap, | |
| int | nbfso, | |||
| double * | ints, | |||
| int * | ioff, | |||
| double | toler, | |||
| int | printflg, | |||
| FILE * | outfile | |||
| ) |
Write two electron ints to output in lexical order The "iwl" stands for "integrals with labels," and this is the proposed new standard for storing two-electron integrals and their (absolute) orbital labels. This function closes the output file when finished.
| itap | = unit to write to | |
| nbfso | = number of basis functions in symmetry orbitals | |
| ints | = two electron integrals | |
| ioff | = the old ioff array for lexical ordering | |
| printflg | = print flag (1 or 0) | |
| outfile | = output file |
Definition at line 30 of file wrttwo.cc.
References iwl_buf_close(), iwl_buf_flush(), iwl_buf_init(), and iwl_buf_wrt_all().
00032 { 00033 struct iwlbuf Buf; 00034 00035 iwl_buf_init(&Buf, itap, toler, 0, 0); 00036 iwl_buf_wrt_all(&Buf, nbfso, ints, ioff, printflg, outfile); 00037 iwl_buf_flush(&Buf, 1); 00038 iwl_buf_close(&Buf, 1); 00039 00040 }
| void sortbuf | ( | struct iwlbuf * | Inbuf, | |
| struct iwlbuf * | Outbuf, | |||
| double * | ints, | |||
| int | fpq, | |||
| int | lpq, | |||
| int * | ioff, | |||
| int * | ioff2, | |||
| int | nbfso, | |||
| int | elbert, | |||
| int | intermediate, | |||
| int | no_pq_perm, | |||
| int | qdim, | |||
| int | add, | |||
| int | printflg, | |||
| FILE * | outfile | |||
| ) |
Function reads a file of two-electron integrals into core and writes them back out again in canonical order. Used in Yoshimine sorts where we have a file containing all rs for a few values of pq, but the ints are not in canonical order. At the very least, we need to sort to make sure that all (pq|rs) for a given pq are grouped together, since the transformation program wants to work with all rs for a single pq value at one time. We may or may not use the restriction pq >= rs (not used if intermediate = 1, which is how this routine is always called right now).
One interesting issue here is that the intermediate array ('ints') must be big enough to hold the integrals in the current buffer, but we don't generally want it to be much larger than necessary! Thus we calculate an 'offset' which is the canonical index of the first integral in the buffer, and we use this so that the first integral in the buffer is stored in ints[0]. What's different for the Elbert ordering is that we have all rs for a given pq but rs >= pq! If we want our canonical indices to be consecutive WITHIN THE CURRENT BUFFER, we MUST use upper triangle ordering rather than lower triangle! That's what ioff2 is used for. Obviously the offset must also be calculated with ioff2 for the Elbert order. Formula for ioff2: ioff2[0] = 0; ioff2[i] = ioff2[i-1] + n - i; Note that this is not the case when this routine is used for MP2 sorts. The definitions of the ioff arrays can be confusing, so care should be taken when using this routine.
| Inbuf | = IWL buffer for input | |
| Outbuf | = IWL buffer for output | |
| ints | = array to hold integrals in | |
| fpq | = first pq for this tape | |
| lpq | = last pq for this tape | |
| ioff | = offset array for the left indices | |
| ioff2 | = offset array for Elbert sorts or for the right indices when no_pq_perm=1 | |
| nbfso | = number of basis functions in SO's | |
| lastsort | = 1 if this is the last intape, 0 otherwise | |
| elbert | = integrals obey rs >= pq. Use ioff2 to get offset. | |
| intermediate= | 1 if sorting a intermediate in the transformation which is indexed as X[ij][kl] where ij runs from fpq to lpq and kl runs from 0 to nbstri | |
| no_pq_perm | = don't use permutational symmetry to swap p and q (appropriate for MP2 where one is occ and one is virt) | |
| qdim | = dimensions for the q index...nvirt for MP2 | |
| add | = add contributions to the same integral during sort | |
| printflg | = 1 for printing, 0 otherwise | |
| outfile | = output file pointer |
Revised 6/27/96 by CDS for new IWL format N.B. Now need to iwl_flush the output buffer...not done in here!!
Definition at line 74 of file sortbuf.cc.
References iwl_buf_fetch(), and iwl_buf_put().
00078 { 00079 int i; 00080 Value *valptr; /* array of integral values */ 00081 Label *lblptr; /* array of integral labels */ 00082 int idx; /* index for curr integral (0..ints_per_buf) */ 00083 int lastbuf; /* last buffer flag */ 00084 int p, q, qmax, qmin, r, rmin, rmax, s, smin, smax, pq, rs; 00085 long int pqrs, offset; 00086 int first_p, first_q, first_pq, last_p, last_q; 00087 int nbstri; 00088 00089 if (printflg) { 00090 fprintf(outfile, "\nsortbuf for pq=%d to %d\n", fpq, lpq); 00091 } 00092 00093 if (no_pq_perm && !intermediate) { 00094 fprintf(outfile,"(sortbuf): illegal parameter combination.\n"); 00095 fprintf(stderr, "(sortbuf): illegal parameter combination.\n"); 00096 } 00097 00098 nbstri = nbfso * (nbfso + 1) / 2; 00099 00100 /* figure out ranges on things */ 00101 /* I believe this section works fine, even with different ioff arrays */ 00102 i = 0; 00103 while (fpq >= ioff[i] && i < BIGNUM) i++; 00104 if (i == BIGNUM) { 00105 fprintf(outfile, "(sortbuf): parameter error\n") ; 00106 return; 00107 } 00108 first_p = i-1 ; first_q = fpq - ioff[i-1]; 00109 first_pq = ioff[first_p] + first_q; 00110 if (first_pq != fpq) { 00111 fprintf(outfile, "(sortbuf): fpq != first_pq.\n"); 00112 fprintf(stderr, "(sortbuf): fpq != first_pq.\n"); 00113 } 00114 00115 if (!intermediate) { 00116 if (elbert) offset = ioff2[first_pq] + first_pq ; 00117 else offset = ioff[first_pq] ; 00118 } 00119 else offset = 0; 00120 00121 i=0; 00122 while (lpq >= ioff[i] && i < BIGNUM) i++ ; 00123 if (i == BIGNUM) { 00124 fprintf(outfile, "(sortbuf): parameter error\n") ; 00125 return ; 00126 } 00127 last_p = i-1 ; last_q = lpq - ioff[i-1] ; 00128 00129 00130 lblptr = Inbuf->labels; 00131 valptr = Inbuf->values; 00132 00133 /* read a buffer at a time until we're done */ 00134 00135 do { 00136 iwl_buf_fetch(Inbuf); 00137 lastbuf = Inbuf->lastbuf; 00138 for (idx=4*Inbuf->idx; Inbuf->idx<Inbuf->inbuf; Inbuf->idx++) { 00139 p = (int) lblptr[idx++]; 00140 q = (int) lblptr[idx++]; 00141 r = (int) lblptr[idx++]; 00142 s = (int) lblptr[idx++]; 00143 00144 /* if (no_pq_perm) ioff is the appropriate offset array for the left 00145 indices (ioff[p] = nvirt * p for MP2); ioff2 is then the usual 00146 ioff offset array, used for the right indices */ 00147 if (no_pq_perm) { 00148 pq = ioff[p] + q; 00149 rs = ioff2[MAX0(r,s)] + MIN0(r,s); 00150 } 00151 else { 00152 pq = ioff[MAX0(p,q)] + MIN0(p,q); 00153 rs = ioff[MAX0(r,s)] + MIN0(r,s); 00154 } 00155 00156 if (!intermediate) { 00157 if (elbert) 00158 pqrs = ioff2[pq] + rs; 00159 else { 00160 pqrs = ioff[MAX0(pq,rs)]; 00161 pqrs += MIN0(pq,rs); 00162 } 00163 } 00164 else { 00165 pqrs = (pq - first_pq); 00166 pqrs *= nbstri; 00167 pqrs += rs; 00168 } 00169 00170 if (printflg && ints[pqrs-offset] != 0.0) 00171 fprintf(outfile, "Adding %10.6lf to el %d %d %d %d = %10.6lf\n", 00172 valptr[Inbuf->idx], p, q, r, s, ints[pqrs-offset]); 00173 00174 if (add) ints[pqrs-offset] += valptr[Inbuf->idx]; 00175 else ints[pqrs-offset] += valptr[Inbuf->idx]; 00176 00177 if (printflg) 00178 fprintf(outfile, "<%d %d %d %d | %d %d [%ld] = %10.6lf\n", 00179 p, q, r, s, pq, rs, pqrs, ints[pqrs-offset]) ; 00180 } 00181 } while (!lastbuf); 00182 00183 /* now write them out again, in order */ 00184 lblptr = Outbuf->labels; 00185 valptr = Outbuf->values; 00186 00187 idx = 0; 00188 00189 for (p=first_p; p<=last_p; p++) { 00190 qmax = (p==last_p) ? last_q : p ; 00191 qmin = (p==first_p) ? first_q : 0 ; 00192 if(no_pq_perm) { 00193 qmax = (p==last_p) ? last_q : (qdim-1); 00194 qmin = (p==first_p) ? first_q: 0; 00195 } 00196 for (q=qmin; q<=qmax; q++) { 00197 pq = ioff[p] + q ; /* This should be fine even with MP2 */ 00198 00199 if (!intermediate) { 00200 rmin = (elbert) ? p : 0 ; 00201 rmax = (elbert) ? nbfso : p+1 ; 00202 } 00203 else { /* This should be fine with MP2, also */ 00204 rmin = 0; 00205 rmax = nbfso; 00206 } 00207 00208 for (r=rmin; r<rmax; r++) { 00209 00210 if (!intermediate) { 00211 if (elbert) { 00212 smax = r+1 ; 00213 smin = (p==r) ? q : 0 ; 00214 } 00215 else { 00216 smax = (p==r) ? (q+1) : (r+1) ; 00217 smin = 0 ; 00218 } 00219 } 00220 else { /* This should be fine with MP2, also */ 00221 smax = r + 1; 00222 smin = 0; 00223 } 00224 00225 for (s=smin; s < smax; s++) { 00226 if(no_pq_perm) rs = ioff2[r] + s; 00227 else rs = ioff[r] + s; 00228 00229 /* Again, this should be fine with MP2 */ 00230 if (elbert) pqrs = ioff2[pq] + rs ; 00231 else if (intermediate) { 00232 pqrs = (pq - first_pq); 00233 pqrs *= nbstri; 00234 pqrs += rs; 00235 } 00236 else pqrs = ioff[pq] + rs ; 00237 00238 if (fabs(ints[pqrs-offset]) > Outbuf->cutoff) { 00239 idx = 4*Outbuf->idx; 00240 lblptr[idx++] = p; 00241 lblptr[idx++] = q; 00242 lblptr[idx++] = r; 00243 lblptr[idx++] = s; 00244 valptr[Outbuf->idx] = ints[pqrs-offset]; 00245 if (printflg) 00246 fprintf(outfile, ">%d %d %d %d | %d %d [%ld] = %10.6lf\n", 00247 p, q, r, s, pq, rs, pqrs, ints[pqrs-offset]) ; 00248 00249 Outbuf->idx++; 00250 if (Outbuf->idx == Outbuf->ints_per_buf) { 00251 Outbuf->lastbuf = 0; 00252 Outbuf->inbuf = Outbuf->idx; 00253 iwl_buf_put(Outbuf); 00254 Outbuf->idx = 0; 00255 } 00256 } 00257 } 00258 } 00259 } 00260 } 00261 00262 }
1.5.4