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

« back to all changes in this revision

Viewing changes to src/lib/libdpd/file2_init.c

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <libpsio/psio.h>
 
4
#include "dpd.h"
 
5
#define EXTERN
 
6
#include "dpd.gbl"
 
7
 
 
8
/* dpd_file2_init(): Initializes a dpd two-index file for reading
 
9
** or writing data.
 
10
**
 
11
** Arguments:
 
12
**   dpdfile2 *File: A pointer to the two-index dpdfile.
 
13
**   int filenum: The PSI unit number for this file.
 
14
**   int irrep: The symmetry of the data (=0 for totally-symmetric)
 
15
**   int pnum: The orbital subspace number for the left index [see
 
16
**             dpd_init()].
 
17
**   int qnum: The orbital subspace number for the right index [see
 
18
**             dpd_init()].
 
19
**   char *label: A string labelling for this buffer.
 
20
**   int print_flag: A boolean for the print routines.
 
21
**   FILE *outfile: The formatted output file stream.
 
22
*/
 
23
 
 
24
int dpd_file2_init(dpdfile2 *File, int filenum, int irrep, int pnum,
 
25
                   int qnum, char *label)
 
26
{
 
27
  int i, q, rs, nirreps;
 
28
  struct dpd_file2_cache_entry *this_entry;
 
29
  int *coltot, *colidx, **colorb, *qpi, *qoff, *qsym;
 
30
 
 
31
  File->dpdnum = dpd_default;
 
32
  File->params = &(dpd_list[dpd_default].params2[pnum][qnum]);
 
33
  strcpy(File->label,label);
 
34
  File->filenum = filenum;
 
35
  File->my_irrep = irrep;
 
36
 
 
37
  nirreps = File->params->nirreps;
 
38
 
 
39
  this_entry = dpd_file2_cache_scan(filenum, irrep, pnum, qnum, label, dpd_default);
 
40
  if(this_entry != NULL) {
 
41
      File->incore = 1;
 
42
      File->matrix = this_entry->matrix;
 
43
    }
 
44
  else {
 
45
      File->incore = 0;
 
46
      File->matrix = (double ***) malloc(File->params->nirreps*sizeof(double **));
 
47
    }
 
48
 
 
49
  /* Construct logical subfile pointers */
 
50
  File->lfiles = (psio_address *) malloc(File->params->nirreps *
 
51
                                         sizeof(psio_address));
 
52
  File->lfiles[0] = PSIO_ZERO;
 
53
  for(i=1; i < File->params->nirreps; i++)
 
54
    File->lfiles[i] = psio_get_address(File->lfiles[i-1],
 
55
                                       (File->params->rowtot[i-1] *
 
56
                                        File->params->coltot[(i-1)^irrep] *
 
57
                                        sizeof(double)));
 
58
 
 
59
  /* Force all two-index files into cache */
 
60
  /*  dpd_file2_cache_add(File); */
 
61
 
 
62
  return 0;
 
63
}