7
#include <libpsio/psio.h>
15
** \param Buf Buffer to be initialised
16
** \param itape Filenumber
17
** \param cutoff Cutoff for keeping integral
18
** \param oldfile If ==0 create file
19
** \param readflag If ==1 fetch buffer
21
** Prepare a PSI Buffer according to the Integrals
22
** With Labels format for reading or writing. Important to set
23
** readflag=1 if opening for reading, since other IWL buffer read
24
** routines anticipate that there is already data in the buffer.
26
** David Sherrill, March 1995
27
** Revised 6/26/96 by CDS for new format
30
void iwl_buf_init(struct iwlbuf *Buf, int itape, double cutoff,
31
int oldfile, int readflag)
34
/*! set up buffer info */
36
Buf->bufpos = PSIO_ZERO;
37
Buf->ints_per_buf = IWL_INTS_PER_BUF;
39
Buf->bufszc = 2 * sizeof(int) + Buf->ints_per_buf * 4 * sizeof(Label) +
40
Buf->ints_per_buf * sizeof(Value);
45
/*! make room in the buffer */
46
Buf->labels = (Label *) malloc (4 * Buf->ints_per_buf * sizeof(Label));
47
Buf->values = (Value *) malloc (Buf->ints_per_buf * sizeof(Value));
49
/*! open the output file */
50
/*! Note that we assume that if oldfile isn't set, we O_CREAT the file */
51
psio_open(Buf->itap, oldfile ? PSIO_OPEN_OLD : PSIO_OPEN_NEW);
52
if (oldfile && (psio_tocscan(Buf->itap, IWL_KEY_BUF) == NULL)) {
53
fprintf(outfile,"iwl_buf_init: Can't open file %d\n", Buf->itap);
54
psio_close(Buf->itap,0);
58
/*! go ahead and read a buffer */
59
if (readflag) iwl_buf_fetch(Buf);