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

« back to all changes in this revision

Viewing changes to src/bin/ccenergy/get_params.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 <string.h>
 
4
#include <math.h>
 
5
#include <libipv1/ip_lib.h>
 
6
#include <libciomr/libciomr.h>
 
7
#include <psifiles.h>
 
8
#define EXTERN
 
9
#include "globals.h"
 
10
 
 
11
void get_params()
 
12
{
 
13
  int errcod, iconv, ref, forceit;
 
14
  char *cachetype = NULL;
 
15
  char *junk;
 
16
 
 
17
  errcod = ip_string("WFN", &(params.wfn), 0);
 
18
  if(strcmp(params.wfn, "CCSD") && strcmp(params.wfn, "CCSD_T") &&
 
19
     strcmp(params.wfn, "EOM_CCSD") && strcmp(params.wfn, "LEOM_CCSD") &&
 
20
     strcmp(params.wfn, "BCCD") && strcmp(params.wfn,"BCCD_T")) {
 
21
    fprintf(outfile, "Invalid value of input keyword WFN: %s\n", params.wfn);
 
22
    exit(PSI_RETURN_FAILURE);
 
23
  }
 
24
 
 
25
  if(!strcmp(params.wfn,"BCCD") || !strcmp(params.wfn,"BCCD_T")) 
 
26
    params.brueckner = 1;
 
27
  else params.brueckner = 0;
 
28
 
 
29
  errcod = ip_string("REFERENCE", &(junk),0);
 
30
  /* if no reference is given, assume rhf */
 
31
  if (errcod != IPE_OK) {
 
32
    ref = 0;
 
33
  }
 
34
  else {
 
35
    if(!strcmp(junk, "RHF")) ref = 0;
 
36
    else if(!strcmp(junk, "ROHF")) ref = 1;
 
37
    else if(!strcmp(junk, "UHF")) ref = 2;
 
38
    else { 
 
39
      printf("Invalid value of input keyword REFERENCE: %s\n", junk);
 
40
      exit(PSI_RETURN_FAILURE); 
 
41
    }
 
42
    free(junk);
 
43
  }
 
44
 
 
45
  /* Make sure the value of ref matches that from CC_INFO */
 
46
  if(params.ref != ref) {
 
47
    printf("Value of REFERENCE from input.dat (%1d) and CC_INFO (%1d) do not match!\n", 
 
48
        ref, params.ref);
 
49
    exit(PSI_RETURN_FAILURE);
 
50
  }
 
51
 
 
52
  params.print = 0;
 
53
  errcod = ip_data("PRINT", "%d", &(params.print),0);
 
54
 
 
55
  params.maxiter = 50;
 
56
  errcod = ip_data("MAXITER","%d",&(params.maxiter),0);
 
57
  params.convergence = 1e-7;
 
58
  errcod = ip_data("CONVERGENCE","%d",&(iconv),0);
 
59
  if(errcod == IPE_OK) params.convergence = 1.0*pow(10.0,(double) -iconv);
 
60
  params.restart = 1;
 
61
  errcod = ip_boolean("RESTART", &(params.restart),0);
 
62
  /* If the MO orbital phases are screwed up, don't restart */
 
63
  if(!moinfo.phase) params.restart = 0;
 
64
  /* BUT, the user can force an override of the phase problem */
 
65
  forceit = 0;
 
66
  errcod = ip_boolean("FORCE_RESTART", &forceit,0);
 
67
  if(forceit) params.restart = 1;
 
68
 
 
69
  fndcor(&(params.memory),infile,outfile);
 
70
 
 
71
  if(ip_exist("AO_BASIS",0)) {
 
72
      errcod = ip_string("AO_BASIS", &(params.aobasis),0);
 
73
  }
 
74
  else params.aobasis = strdup("NONE");
 
75
  if(strcmp(params.aobasis,"DISK") && strcmp(params.aobasis,"DIRECT") &&
 
76
     strcmp(params.aobasis,"NONE")) {
 
77
      fprintf(outfile, "Error in input: invalid AO_BASIS = %s\n",
 
78
              params.aobasis);
 
79
      exit(PSI_RETURN_FAILURE);
 
80
  }
 
81
 
 
82
  params.cachelev = 2;
 
83
  errcod = ip_data("CACHELEV", "%d", &(params.cachelev),0);
 
84
 
 
85
  params.cachetype = 1;
 
86
  errcod = ip_string("CACHETYPE", &(cachetype),0);
 
87
  if(cachetype != NULL && strlen(cachetype)) {
 
88
    if(!strcmp(cachetype,"LOW")) params.cachetype = 1;
 
89
    else if(!strcmp(cachetype,"LRU")) params.cachetype = 0;
 
90
    else {
 
91
      fprintf(outfile, "Error in input: invalid CACHETYPE = %s\n",
 
92
          cachetype);
 
93
      exit(PSI_RETURN_FAILURE);
 
94
    }
 
95
    free(cachetype);
 
96
  }
 
97
  if(params.ref == 2) /* No LOW cacheing yet for UHF references */
 
98
    params.cachetype = 0;
 
99
 
 
100
  params.diis = 1;
 
101
  errcod = ip_boolean("DIIS", &(params.diis),0);
 
102
 
 
103
  params.local = 0;
 
104
  errcod = ip_boolean("LOCAL", &(params.local),0);
 
105
  local.cutoff = 0.02;
 
106
  errcod = ip_data("LOCAL_CUTOFF", "%lf", &(local.cutoff), 0);
 
107
 
 
108
  if(ip_exist("LOCAL_METHOD",0)) {
 
109
    errcod = ip_string("LOCAL_METHOD", &(local.method), 0);
 
110
    if(strcmp(local.method,"AOBASIS") && strcmp(local.method,"WERNER")) {
 
111
      fprintf(outfile, "Invalid local correlation method: %s\n", local.method);
 
112
      exit(PSI_RETURN_FAILURE);
 
113
    }
 
114
  }
 
115
  else if(params.local) {
 
116
    local.method = (char *) malloc(7 * sizeof(char));
 
117
    sprintf(local.method, "%s", "WERNER");
 
118
  }
 
119
 
 
120
  if(ip_exist("LOCAL_WEAKP",0)) {
 
121
    errcod = ip_string("LOCAL_WEAKP", &(local.weakp), 0);
 
122
    if(strcmp(local.weakp,"MP2") && strcmp(local.weakp,"NEGLECT") && strcmp(local.weakp,"NONE")) {
 
123
      fprintf(outfile, "Invalid method for treating local pairs: %s\n", local.weakp);
 
124
      exit(PSI_RETURN_FAILURE);
 
125
    }
 
126
  }
 
127
  else if(params.local) {
 
128
    local.weakp = (char *) malloc(4 * sizeof(char));
 
129
    sprintf(local.weakp, "%s", "MP2");
 
130
  }
 
131
 
 
132
  local.filter_singles = 1;
 
133
  ip_boolean("LOCAL_FILTER_SINGLES", &(local.filter_singles), 0);
 
134
 
 
135
  params.num_amps = 10;
 
136
  if(ip_exist("NUM_AMPS",0)) {
 
137
    errcod = ip_data("NUM_AMPS", "%d", &(params.num_amps), 0);
 
138
  }
 
139
 
 
140
  params.bconv = 1e-5;
 
141
  errcod = ip_data("BRUECKNER_CONV", "%d", &(iconv), 0);
 
142
  if(errcod == IPE_OK) params.bconv = 1.0*pow(10.0,(double) -iconv);
 
143
 
 
144
  params.print_mp2_amps = 0;
 
145
  errcod = ip_boolean("PRINT_MP2_AMPS", &(params.print_mp2_amps), 0);
 
146
 
 
147
  params.analyze = 0;
 
148
  errcod = ip_boolean("ANALYZE", &(params.analyze), 0);
 
149
 
 
150
  fprintf(outfile, "\n\tInput parameters:\n");
 
151
  fprintf(outfile, "\t-----------------\n");
 
152
  fprintf(outfile, "\tWave function   =    %6s\n", params.wfn);
 
153
  fprintf(outfile, "\tReference wfn   =    %5s\n",
 
154
           (params.ref == 0) ? "RHF" : ((params.ref == 1) ? "ROHF" : "UHF"));
 
155
  if(params.brueckner) 
 
156
    fprintf(outfile, "\tBrueckner conv. =    %3.1e\n", params.bconv);
 
157
  fprintf(outfile, "\tMemory (Mbytes) =  %5.1f\n",params.memory/1e6);
 
158
  fprintf(outfile, "\tMaxiter         =   %4d\n", params.maxiter);
 
159
  fprintf(outfile, "\tConvergence     = %3.1e\n", params.convergence);
 
160
  fprintf(outfile, "\tRestart         =     %s\n", 
 
161
      params.restart ? "Yes" : "No");
 
162
  fprintf(outfile, "\tDIIS            =     %s\n", params.diis ? "Yes" : "No");
 
163
  fprintf(outfile, "\tLocal CC        =     %s\n", params.local ? "Yes" : "No");
 
164
  if(params.local) {
 
165
    fprintf(outfile, "\tLocal Cutoff    = %3.1e\n", local.cutoff);
 
166
    fprintf(outfile, "\tLocal Method    =    %s\n", local.method);
 
167
    fprintf(outfile, "\tWeak pairs      =    %s\n", local.weakp);
 
168
    fprintf(outfile, "\tFilter singles  =    %s\n", local.filter_singles ? "Yes" : "No");
 
169
  }
 
170
  fprintf(outfile, "\tAO Basis        =     %s\n", params.aobasis);
 
171
  fprintf(outfile, "\tCache Level     =    %1d\n", params.cachelev);
 
172
  fprintf(outfile, "\tCache Type      =    %4s\n", 
 
173
      params.cachetype ? "LOW" : "LRU");
 
174
  fprintf(outfile, "\tPrint Level     =    %1d\n",  params.print);
 
175
  fprintf(outfile, "\t# Amps to Print =    %1d\n",  params.num_amps);
 
176
  fprintf(outfile, "\tPrint MP2 Amps? =    %s\n",  params.print_mp2_amps ?
 
177
      "Yes" : "No" );
 
178
  fprintf(outfile, "\tAnalyze T2 Amps =    %s\n",  params.analyze ? "Yes" : "No" );
 
179
  fprintf(outfile, "\n");
 
180
 
 
181
}
 
182