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

« back to all changes in this revision

Viewing changes to src/bin/cints/Tools/small_fns.cc

  • 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
/*! \file small_fns.cc
 
2
    \ingroup CINTS
 
3
    \brief Enter brief description of file here 
 
4
*/
 
5
#include<cstdio>
 
6
#include<cstdlib>
 
7
#include <cstring>
 
8
#include<libipv1/ip_lib.h>
 
9
#include<cmath>
 
10
#include<libciomr/libciomr.h>
 
11
#include<libchkpt/chkpt.h>
 
12
#include <psifiles.h>
 
13
 
 
14
#include"defines.h"
 
15
#define EXTERN
 
16
#include"global.h"
 
17
#include <stdexcept>
 
18
 
 
19
namespace psi { namespace CINTS {
 
20
 
 
21
void setup()
 
22
{
 
23
   register int i, j;
 
24
 
 
25
   ioff[0] = 0;
 
26
   for (i=1; i<IOFFMAX; i++){
 
27
      ioff[i] = ioff[i-1] + i;
 
28
      }
 
29
 
 
30
/* Factorials */
 
31
   fac[0] = 1;
 
32
   fac[1] = 1;
 
33
   for(i=2;i<CINTS_MAX_AM*2;i++)
 
34
     fac[i] = fac[i-1]*i;
 
35
 
 
36
/* Binomial coefficients */
 
37
   for(i=0;i<=CINTS_MAX_AM;i++)
 
38
     for(j=0;j<=i;j++)
 
39
       bc[i][j] = (int)(fac[i]/(fac[i-j]*fac[j]));
 
40
 
 
41
/* df[i] gives (i-1)!!, so that (-1)!! is defined... */
 
42
/* we shouldn't need both this and lci with the range needed on df[] */
 
43
  df[0] = 1.0;
 
44
  df[1] = 1.0;
 
45
  df[2] = 1.0;
 
46
  for(i=3; i<MAXFACT*2; i++){
 
47
    df[i] = (i-1)*df[i-2];
 
48
    }
 
49
 
 
50
  /* (2i-1)!! a useful thing, num_ser in the integral expansion */
 
51
   num_ser[0] = 1;
 
52
   for (i=1; i<CINTS_MAX_AM+1; i++)
 
53
      num_ser[i] = (2*i-1)*num_ser[i-1];
 
54
 
 
55
}
 
56
 
 
57
void start_io(int argc, char *argv[])
 
58
{
 
59
  int i, errcod;
 
60
  int num_extra_args = 0;
 
61
  char **extra_args;
 
62
  extra_args = (char **) malloc(argc*sizeof(char *));
 
63
 
 
64
  /* Filter out known options */
 
65
  for (i=1; i<argc; i++) {
 
66
    if ( strcmp(argv[i], "--fock") &&
 
67
         strcmp(argv[i], "--oeints") &&
 
68
         strcmp(argv[i], "--teints") &&
 
69
         strcmp(argv[i], "--deriv1") &&
 
70
         strcmp(argv[i], "--deriv1_ints") &&
 
71
         strcmp(argv[i], "--deriv2") &&
 
72
         strcmp(argv[i], "--oeprop") &&
 
73
         strcmp(argv[i], "--mp2") &&
 
74
         strcmp(argv[i], "--mkpt2") &&
 
75
         strcmp(argv[i], "--r12ints") &&
 
76
         strcmp(argv[i], "--cc_bt2") &&
 
77
         strcmp(argv[i], "--giao_deriv") &&
 
78
         strcmp(argv[i], "--mp2r12") )
 
79
      extra_args[num_extra_args++] = argv[i];
 
80
  }
 
81
  
 
82
  errcod = psi_start(&infile,&outfile,&psi_file_prefix,num_extra_args, extra_args, 0);
 
83
  if (errcod != PSI_RETURN_SUCCESS)
 
84
    abort();
 
85
  ip_cwk_add(":CINTS");
 
86
  psio_init(); psio_ipv1_config();
 
87
  chkpt_init(PSIO_OPEN_OLD);
 
88
 
 
89
  free(extra_args);
 
90
  return;
 
91
}
 
92
 
 
93
void stop_io()
 
94
{
 
95
  chkpt_close();
 
96
  if(UserOptions.print_lvl)
 
97
    tstop(outfile);
 
98
  psio_done();
 
99
  psi_stop(infile,outfile,psi_file_prefix);
 
100
}
 
101
 
 
102
void punt(char *mess)
 
103
{
 
104
  fprintf(outfile, "  error: %s\n", mess);
 
105
  fprintf(stderr, "  CINTS error: %s\n", mess);
 
106
  stop_io();
 
107
  //  abort();
 
108
}
 
109
 
 
110
double distance_calc(struct coordinates g1, struct coordinates g2)
 
111
{
 
112
  return sqrt((g1.x-g2.x)*(g1.x-g2.x) +
 
113
              (g1.y-g2.y)*(g1.y-g2.y) +
 
114
              (g1.z-g2.z)*(g1.z-g2.z));
 
115
}
 
116
 
 
117
double ***init_box(int a, int b, int c)
 
118
{
 
119
  int i,j,k;
 
120
  double ***box;
 
121
 
 
122
  box = (double ***) malloc(sizeof(double **)*a);
 
123
  for(i=0;i<a;i++)
 
124
    box[i] = (double **) malloc(sizeof(double *)*b);
 
125
  for(i=0;i<a;i++)
 
126
    for(j=0;j<b;j++) {
 
127
        box[i][j] = (double *) malloc(sizeof(double)*c);
 
128
        //bzero((char *) box[i][j],sizeof(double)*c);
 
129
        memset(box[i][j], '\0', sizeof(double)*c);
 
130
    }
 
131
 
 
132
  return box;
 
133
 
 
134
}
 
135
 
 
136
 
 
137
void free_box(double ***box, int a, int b)
 
138
{
 
139
  int i,j;
 
140
 
 
141
  for(i=0;i<a;i++)
 
142
    for(j=0;j<b;j++)
 
143
      free(box[i][j]);
 
144
 
 
145
  for(i=0;i<a;i++)
 
146
    free(box[i]); 
 
147
 
 
148
  free(box);
 
149
 
 
150
}
 
151
};};