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

« back to all changes in this revision

Viewing changes to src/bin/geom/read11.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
 
** NEW VERSION OF READ_FILE11() TO READ PAST ALL THE OLD ENTRIES ON TOP
3
 
**
4
 
** David Sherrill  -  June 1993
5
 
**
6
 
*/
7
 
 
8
 
/* include's */
9
 
#include <stdio.h>
10
 
#include <stdlib.h>
11
 
 
12
 
/* define's */
13
 
#define MAX_LINE 132
14
 
 
15
 
/* global variables */
16
 
char line1[MAX_LINE] ;
17
 
 
18
 
/*
19
 
** READ_FILE11(): This function reads 'file11.dat' and prints out again
20
 
**      some of the info to an output file.
21
 
**
22
 
** Arguments: 
23
 
**      label   = character string to hold file11 label field
24
 
**      natom   = pointer to variable to hold number of atoms
25
 
**      energy  = pointer to var to hold energy
26
 
**      X, Y, Z = pointers to arrays of cartesian coordinates (assume bohr)
27
 
**                (these are currently allocated in THIS function)
28
 
**      AN      = pointer to atomic number array (allocated here)
29
 
**      fpo     = file pointer for output
30
 
**
31
 
** Returns: success (1) or failure (0) 
32
 
**
33
 
*/
34
 
int read_file11(label, natom, energy, X, Y, Z, AN, fpo) 
35
 
      char *label ;
36
 
      int *natom ;
37
 
      double *energy ;
38
 
      double **X, **Y, **Z, **AN ;
39
 
      FILE *fpo ;
40
 
{
41
 
int i ;                  /* loop variable */
42
 
FILE *fpi ;              /* pointer for input file file11.dat */
43
 
double g1, g2, g3;       /* junk variables for gradients */
44
 
 
45
 
/* open file 11 for reading */
46
 
   if ((fpi = fopen("file11.dat", "r")) == NULL) {
47
 
      printf("(read_file11): Error opening file11.dat\n");
48
 
      exit(0);
49
 
      }
50
 
 
51
 
/* get first file11 label */
52
 
   if (fgets(label, MAX_LINE, fpi) == NULL)
53
 
      prf_abort(fpo, "(read_file11): Trouble reading label\n") ;
54
 
   fflush(fpo) ;
55
 
 
56
 
/* now read the number of atoms and the energy */
57
 
   fgets(line1, MAX_LINE, fpi) ;
58
 
   if (sscanf(line1, "%d %lf", natom, energy) != 2) 
59
 
      prf_abort(fpo, "(read_file11): Trouble reading natoms and energy\n") ;
60
 
   
61
 
/* now make room for the Cartesian coordinates */
62
 
   *X = (double *) malloc (*natom * sizeof(double)) ;
63
 
   malloc_check(*X, "(read_file11): Trouble allocating Cartesian array\n") ;
64
 
   *Y = (double *) malloc (*natom * sizeof(double)) ;
65
 
   malloc_check(*Y, "(read_file11): Trouble allocating Cartesian array\n") ;
66
 
   *Z = (double *) malloc (*natom * sizeof(double)) ;
67
 
   malloc_check(*Z, "(read_file11): Trouble allocating Cartesian array\n") ;
68
 
   *AN = (double *) malloc (*natom * sizeof(double)) ;
69
 
   malloc_check(*AN, "(read_file11): Trouble allocating atomic num array\n") ;
70
 
 
71
 
/* now rewind file11 and read it one chunk at a time */
72
 
   rewind(fpi) ;
73
 
 
74
 
/* loop over each chunk */
75
 
/* read number of atoms and energy */
76
 
   while (fgets(label, MAX_LINE, fpi) != NULL) {
77
 
      fgets(line1, MAX_LINE, fpi) ;
78
 
      if (sscanf(line1, "%d %lf", natom, energy) != 2) 
79
 
         prf_abort(fpo, "(read_file11): Trouble reading natoms and energy\n") ;
80
 
 
81
 
/* read Cartesians */
82
 
      for (i=0; i<(*natom); i++) {
83
 
         if (fscanf(fpi, "%lf %lf %lf %lf", (*AN+i), (*X+i), (*Y+i), 
84
 
            (*Z+i)) != 4)
85
 
            prf_abort(fpo, "(read_file11): Trouble reading Cartesian coords\n");
86
 
            }
87
 
 
88
 
/* read Gradients */
89
 
      for (i=0; i<(*natom); i++) {
90
 
         if (fscanf(fpi, "%lf %lf %lf", &g1, &g2, &g3) != 3)
91
 
            prf_abort(fpo, "(read_file11): Trouble reading gradients\n");
92
 
            }
93
 
      fgets(line1, MAX_LINE, fpi) ;   /* go to end of line */
94
 
      } /* end loop over file11 chunk */
95
 
 
96
 
   fclose(fpi) ;
97
 
   return(1) ;
98
 
}
99
 
 
100
 
 
101
 
 
102
 
/*
103
 
** PRINT_FILE11(): Function prints out the information from file11.dat
104
 
** obtained from the read_file11() function.
105
 
**
106
 
** Arguments: 
107
 
**      label   = character string to hold file11 label field
108
 
**      natom   = number of atoms
109
 
**      energy  = energy from file11
110
 
**      X, Y, Z = arrays of cartesian coordinates (assume bohr)
111
 
**      AN      = atomic number array (allocated here)
112
 
**      fpo     = file pointer for output
113
 
*/
114
 
void print_file11(label, natom, energy, X, Y, Z, AN, fpo) 
115
 
      char *label ;
116
 
      int natom ;
117
 
      double energy ;
118
 
      double *X, *Y, *Z, *AN ;
119
 
      FILE *fpo ;
120
 
{
121
 
int i ;
122
 
 
123
 
   fprintf(fpo, "DATA FROM FILE11.DAT\n") ;
124
 
   fprintf(fpo, "Label :\n%s\n", label) ;
125
 
   fprintf(fpo, "Number of atoms = %d\n", natom) ;
126
 
   fprintf(fpo, "Energy = %.10lf\n", energy) ;
127
 
   fprintf(fpo, "\nCartesian coordinates (bohr) :\n") ;
128
 
   for (i=0; i<natom; i++) {
129
 
      fprintf(fpo, "     %11.6lf    %12.7lf    %12.7lf    %12.7lf\n",
130
 
            AN[i], X[i], Y[i], Z[i]) ;
131
 
      }
132
 
   fprintf(fpo, "\n") ;
133
 
   fflush(fpo) ;
134
 
}
135
 
 
136