~ubuntu-branches/ubuntu/karmic/psicode/karmic

« back to all changes in this revision

Viewing changes to src/lib/libiwl/buf_init.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2009-02-23 00:12:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223001202-rutldoy3dimfpesc
Tags: 3.4.0-1
* New upstream release.

[ Michael Banck ]
* debian/patches/01_DESTDIR.dpatch: Refreshed.
* debian/patches/02_FHS.dpatch: Removed, applied upstream.
* debian/patches/03_debian_docdir: Likewise.
* debian/patches/04_man.dpatch: Likewise.
* debian/patches/06_466828_fix_gcc_43_ftbfs.dpatch: Likewise.
* debian/patches/07_464867_move_executables: Fixed and refreshed.
* debian/patches/00list: Adjusted.
* debian/control: Improved description.
* debian/patches-held: Removed.
* debian/rules (install/psi3): Do not ship the ruby bindings for now.

[ Daniel Leidert ]
* debian/rules: Fix txtdir via DEB_MAKE_INSTALL_TARGET.
* debian/patches/01_DESTDIR.dpatch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*!
2
 
  \file buf_init.c
3
 
  \ingroup (IWL)
4
 
*/
5
 
#include <stdio.h>
6
 
#include <stdlib.h>
7
 
#include <libpsio/psio.h>
8
 
#include "iwl.h"
9
 
 
10
 
extern FILE *outfile;
11
 
 
12
 
/*!
13
 
** iwl_buf_init()
14
 
**
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
20
 
**
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.
25
 
**
26
 
** David Sherrill, March 1995
27
 
** Revised 6/26/96 by CDS for new format
28
 
** \ingroup (IWL)
29
 
*/
30
 
void iwl_buf_init(struct iwlbuf *Buf, int itape, double cutoff,
31
 
      int oldfile, int readflag)
32
 
{
33
 
 
34
 
  /*! set up buffer info */
35
 
  Buf->itap = itape;
36
 
  Buf->bufpos = PSIO_ZERO;
37
 
  Buf->ints_per_buf = IWL_INTS_PER_BUF;
38
 
  Buf->cutoff = cutoff;
39
 
  Buf->bufszc = 2 * sizeof(int) + Buf->ints_per_buf * 4 * sizeof(Label) +
40
 
    Buf->ints_per_buf * sizeof(Value);
41
 
  Buf->lastbuf = 0;
42
 
  Buf->inbuf = 0;
43
 
  Buf->idx = 0;
44
 
 
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));
48
 
 
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);
55
 
    return;
56
 
  } 
57
 
 
58
 
  /*! go ahead and read a buffer */
59
 
  if (readflag) iwl_buf_fetch(Buf);
60
 
  
61
 
}
62