Psi4
Files | Functions
libiwl: I/O Library for Integrals with Labels

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  rdone.cc
 
file  rdtwo.cc
 
file  sortbuf.cc
 
file  wrtone.cc
 
file  wrttwo.cc
 

Functions

void psi::iwl_buf_close (struct iwlbuf *Buf, int keep)
 
void psi::iwl_buf_fetch (struct iwlbuf *Buf)
 
void psi::iwl_buf_flush (struct iwlbuf *Buf, int lastbuf)
 
void psi::iwl_buf_init (struct iwlbuf *Buf, int itape, double cutoff, int oldfile, int readflag)
 
void psi::iwl_buf_put (struct iwlbuf *Buf)
 
int psi::iwl_buf_rd (struct iwlbuf *Buf, int target_pq, double *ints, int *ioff_lt, int *ioff_rt, int mp2, int printflg, std::string out)
 
int psi::iwl_buf_rd_all (struct iwlbuf *Buf, double *ints, int *ioff_lt, int *ioff_rt, int no_pq_perm, int *ioff, int printflg, std::string out)
 
int psi::iwl_buf_rd_all2 (struct iwlbuf *Buf, double **ints, int *ioff_lt, int *ioff_rt, int no_pq_perm, int *, int printflg, std::string out)
 
int psi::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, std::string out)
 
int psi::iwl_buf_rd_all_mp2r12a (struct iwlbuf *Buf, double *ints, int *ioff_lt, int *ioff_rt, int bra_ket_symm, int *, int printflg, std::string out)
 
int psi::iwl_buf_rd_arr (struct iwlbuf *Buf, int target_pq, double *ints, int *rlist, int *slist, int *size, int *ioff, int printflg, std::string out)
 
void psi::iwl_buf_toend (struct iwlbuf *Buf)
 
void psi::iwl_buf_wrt (struct iwlbuf *Buf, int p, int q, int pq, int pqsym, double *arr, int rmax, int *ioff, int *orbsym, int *firsti, int *lasti, int printflag, std::string out)
 
void psi::iwl_buf_wrt_all (struct iwlbuf *Buf, int nbfso, double *ints, int *ioff, int printflg, std::string out)
 
void psi::iwl_buf_wrt_arr (struct iwlbuf *Buf, double *arr, int *p, int *q, int *r, int *s, long int size)
 
void psi::iwl_buf_wrt_arr2 (struct iwlbuf *Buf, double *arr, int p, int q, int *rlist, int *slist, int size, int printflag, std::string out)
 
void psi::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 psi::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 psi::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, std::string out)
 
void psi::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, std::string out)
 
void psi::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, std::string out)
 
void psi::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, std::string out)
 
void psi::iwl_buf_wrt_val (struct iwlbuf *Buf, int p, int q, int r, int s, double value, int printflag, std::string out, int dirac)
 
void psi::iwl_buf_wrt_val_SI (struct iwlbuf *Buf, short int p, short int q, short int r, short int s, double value, int printflag, std::string out, int dirac)
 
int psi::iwl_rdone (int itap, const char *label, double *ints, int ntri, int erase, int printflg, std::string out)
 
void psi::iwl_rdtwo (int itap, double *ints, int *ioff, int norbs, int nfzc, int nfzv, int printflg, std::string out)
 
void psi::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, std::string out)
 
void psi::sortbuf_pk (struct iwlbuf *Inbuf, int out_tape, int is_exch, double *ints, unsigned int fpq, unsigned int lpq, int *so2ind, int *so2sym, int *pksymoff, int printflg, std::string out)
 
void psi::iwl_wrtone (int itap, const char *label, int ntri, double *onel_ints)
 
void psi::iwl_wrttwo (int itap, int nbfso, double *ints, int *ioff, double toler, int printflg, std::string out)
 
static void psi::IWL::sort_buffer_pk (IWL *inbuf, int out_tape, int is_exch, double *ints, unsigned int fpq, unsigned int lpq, int *so2ind, int *so2sym, int *pksymoff, int printflg, std::string out)
 

Detailed Description

Function Documentation

void psi::iwl_buf_close ( struct iwlbuf *  Buf,
int  keep 
)

IWL_BUF_CLOSE()

 \param Buf      Buffer to be closed
 \param keep    Do not delete if keep==1

Close a Integrals With Labels Buffer

void psi::iwl_buf_fetch ( struct iwlbuf *  Buf)

iwl_buf_fetch()

Fetch an IWL buffer from disk David Sherrill, 26 June 1996

void psi::iwl_buf_flush ( struct iwlbuf *  Buf,
int  lastbuf 
)

iwl_buf_flush()

 \param Buf     To be flushed buffer
 \param lastbuf Flag for the last buffer

Flush an Integrals With Labels Buffer All flushing should be done through this routine! David Sherrill, March 1995

void psi::iwl_buf_init ( struct iwlbuf *  Buf,
int  itape,
double  cutoff,
int  oldfile,
int  readflag 
)

iwl_buf_init()

 \param Buf               Buffer to be initialised
 \param itape               Filenumber
 \param cutoff           Cutoff for keeping integral
 \param oldfile             If ==0 create file
 \param readflag            If ==1 fetch buffer

Prepare a PSI Buffer according to the Integrals With Labels format for reading or writing. Important to set readflag=1 if opening for reading, since other IWL buffer read routines anticipate that there is already data in the 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

void psi::iwl_buf_put ( struct iwlbuf *  Buf)

iwl_buf_put(struct iwlbuf *Buf)

Put an IWL buffer to disk David Sherrill, 26 June 1996

int psi::iwl_buf_rd ( struct iwlbuf *  Buf,
int  target_pq,
double *  ints,
int *  ioff_lt,
int *  ioff_rt,
int  mp2,
int  printflg,
std::string  out 
)

iwl_buf_rd(struct iwlbuf *Buf, int target_pq, double *ints, int *ioff_lt, int *ioff_rt, int mp2, int printflg, FILE *out)

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

int psi::iwl_buf_rd_all ( struct iwlbuf *  Buf,
double *  ints,
int *  ioff_lt,
int *  ioff_rt,
int  no_pq_perm,
int *  ioff,
int  printflg,
std::string  out 
)

iwl_buf_rd_all()

Read from an Integrals With Labels formatted buffer. The buffer must have been initialized with iwl_buf_init().

Arguments:

Parameters
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
out= pointer to output file for printing

Returns: 0 if end of file, otherwise 1

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

int psi::iwl_buf_rd_all2 ( struct iwlbuf *  Buf,
double **  ints,
int *  ioff_lt,
int *  ioff_rt,
int  no_pq_perm,
int *  ,
int  printflg,
std::string  out 
)

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

int psi::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,
std::string  out 
)

iwl_buf_rd_all_act()

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.

Parameters
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
out= pointer to output file for printing

Returns: 0 if end of file, otherwise 1

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

int psi::iwl_buf_rd_all_mp2r12a ( struct iwlbuf *  Buf,
double *  ints,
int *  ioff_lt,
int *  ioff_rt,
int  bra_ket_symm,
int *  ,
int  printflg,
std::string  out 
)

iwl_buf_rd_all_mp2r12a()

Read from an Integrals With Labels formatted buffer. The buffer must have been initialized with iwl_buf_init().

Parameters
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.

WARNING - if bra_ket_symm = 0 - ints must be zeroed out!

Parameters
printflg= if 1, print integrals as they are read
out= pointer to output file for printing

Returns: 0 if end of file, otherwise 1

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

int psi::iwl_buf_rd_arr ( struct iwlbuf *  Buf,
int  target_pq,
double *  ints,
int *  rlist,
int *  slist,
int *  size,
int *  ioff,
int  printflg,
std::string  out 
)

iwl_buf_rd_arr()

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

void psi::iwl_buf_toend ( struct iwlbuf *  Buf)

iwl_buf_toend()

Set IWL Buffer's pointer to the end. Useful when want to append to an already existing file

Edward Valeev, January 2001

void psi::iwl_buf_wrt ( struct iwlbuf *  Buf,
int  p,
int  q,
int  pq,
int  pqsym,
double *  arr,
int  rmax,
int *  ioff,
int *  orbsym,
int *  firsti,
int *  lasti,
int  printflag,
std::string  out 
)

iwl_buf_wrt()

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

void psi::iwl_buf_wrt_all ( struct iwlbuf *  Buf,
int  nbfso,
double *  ints,
int *  ioff,
int  printflg,
std::string  out 
)

iwl_buf_wrt_all()

Write out two electron ints to IWL file. Assume that the integrals are in ijkl canonical order (no spatial symmetry).

Parameters
Bufunit to write to
nbfsonumber of basis functions in symmetry orbitals
intstwo electron integrals
ioffthe old ioff array for lexical ordering
printflgprint flag (1 or 0)
outoutput file

David Sherrill, 6/27/96

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

void psi::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

void psi::iwl_buf_wrt_arr2 ( struct iwlbuf *  Buf,
double *  arr,
int  p,
int  q,
int *  rlist,
int *  slist,
int  size,
int  printflag,
std::string  out 
)

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

void psi::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

void psi::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

void psi::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,
std::string  out 
)

iwl_buf_wrt_mat()

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

void psi::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,
std::string  out 
)

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

void psi::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,
std::string  out 
)

iwl_buf_wrt_mp2()

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

void psi::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,
std::string  out 
)

iwl_buf_wrt_mp2r12a()

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

void psi::iwl_buf_wrt_val ( struct iwlbuf *  Buf,
int  p,
int  q,
int  r,
int  s,
double  value,
int  printflag,
std::string  out,
int  dirac 
)

iwl_buf_wrt_val()

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

void psi::iwl_buf_wrt_val_SI ( struct iwlbuf *  Buf,
short int  p,
short int  q,
short int  r,
short int  s,
double  value,
int  printflag,
std::string  out,
int  dirac 
)

iwl_buf_wrt_val_SI()

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

int psi::iwl_rdone ( int  itap,
const char *  label,
double *  ints,
int  ntri,
int  erase,
int  printflg,
std::string  out 
)

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

Parameters
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
out= file pointer for output of ints or error messages
void psi::iwl_rdtwo ( int  itap,
double *  ints,
int *  ioff,
int  norbs,
int  nfzc,
int  nfzv,
int  printflg,
std::string  out 
)

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.

Parameters
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
out= output file pointer

David Sherrill, 1995

void psi::iwl_wrtone ( int  itap,
const 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

void psi::iwl_wrttwo ( int  itap,
int  nbfso,
double *  ints,
int *  ioff,
double  toler,
int  printflg,
std::string  out 
)

iwl_wrttwo()

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.

Parameters
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)
out= output file

Revised 6/27/96 by CDS

void psi::IWL::sort_buffer_pk ( IWL Inbuf,
int  out_tape,
int  is_exch,
double *  ints,
unsigned int  fpq,
unsigned int  lpq,
int *  so2ind,
int *  so2sym,
int *  pksymoff,
int  printflg,
std::string  out 
)
static

sortbuf_pk()

Function reads a file of two-electron integrals into core and writes them back out again in canonical order. Used in Yoshimine PK sort where we have a file containing a few value of pq and all corresponding rs <= pq. We sort to make sure orbitals are directly readable to form Coulomb and exchange matrices, thus with pq >= rs, p >= q and r >= s. In addition, diagonal elements are multiplied by the appropriate factors. The integrals are written to the PK file directly, in the relevant entry, without labels.

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].

Parameters
Inbuf= IWL buffer for input
out_tape= PK file number for output
is_exch= 0 if we are sorting Coulomb, otherwise 1
ints= array to hold integrals in
fpq= first pq for this tape
lpq= last pq for this tape
so2rel= array mapping absolute basis function index to relative basis function index within an irrep, so2rel[abs] = rel
so2sym= array mapping absolute basis function index to irrep number, so2sym[abs] = sym
pksymoff= array containing the offset in each irrep to convert a pq index computed with relative indices to an absolute pq index, pqrel = ioff[prel] + qrel, pqabs = pqrel + pksymoff[psym]
ioff= offset array for the left indices
num_so= number of basis functions per irrep
qdim= dimensions for the q index...nvirt for MP2
printflg= 1 for printing, 0 otherwise
out= output file pointer

Returns: none

N.B. No need to iwl_flush the output buffer...not done in here!!

void psi::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,
std::string  out 
)

sortbuf()

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.

Parameters
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
elbert= integrals obey rs >= pq. Use ioff2 to get offset.
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
out= output file pointer

Returns: none

Revised 6/27/96 by CDS for new IWL format N.B. No need to iwl_flush the output buffer...not done in here!!

void psi::sortbuf_pk ( struct iwlbuf *  Inbuf,
int  out_tape,
int  is_exch,
double *  ints,
unsigned int  fpq,
unsigned int  lpq,
int *  so2ind,
int *  so2sym,
int *  pksymoff,
int  printflg,
std::string  out 
)

sortbuf_pk()

Function reads a file of two-electron integrals into core and writes them back out again in canonical order. Used in Yoshimine PK sort where we have a file containing a few value of pq and all corresponding rs <= pq. We sort to make sure orbitals are directly readable to form Coulomb and exchange matrices, thus with pq >= rs, p >= q and r >= s. In addition, diagonal elements are multiplied by the appropriate factors. The integrals are written to the PK file directly, in the relevant entry, without labels.

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].

Parameters
Inbuf= IWL buffer for input
out_tape= PK file number for output
is_exch= 0 if we are sorting Coulomb, otherwise 1
ints= array to hold integrals in
fpq= first pq for this tape
lpq= last pq for this tape
so2rel= array mapping absolute basis function index to relative basis function index within an irrep, so2rel[abs] = rel
so2sym= array mapping absolute basis function index to irrep number, so2sym[abs] = sym
pksymoff= array containing the offset in each irrep to convert a pq index computed with relative indices to an absolute pq index, pqrel = ioff[prel] + qrel, pqabs = pqrel + pksymoff[psym]
ioff= offset array for the left indices
num_so= number of basis functions per irrep
qdim= dimensions for the q index...nvirt for MP2
printflg= 1 for printing, 0 otherwise
out= output file pointer

Returns: none

N.B. No need to iwl_flush the output buffer...not done in here!!