~ubuntu-branches/ubuntu/vivid/psicode/vivid

« back to all changes in this revision

Viewing changes to src/bin/psi3/psi3.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2008-06-07 16:49:57 UTC
  • mfrom: (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080607164957-8pifvb133yjlkagn
Tags: 3.3.0-3
* debian/rules (DEB_MAKE_CHECK_TARGET): Do not abort test suite on
  failures.
* debian/rules (DEB_CONFIGURE_EXTRA_FLAGS): Set ${bindir} to /usr/lib/psi.
* debian/rules (install/psi3): Move psi3 file to /usr/bin.
* debian/patches/07_464867_move_executables.dpatch: New patch, add
  /usr/lib/psi to the $PATH, so that the moved executables are found.
  (closes: #464867)
* debian/patches/00list: Adjusted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include <psifiles.h>          /* where return values are */
20
20
#include <sys/types.h>
21
21
#include <sys/wait.h>
 
22
#include <libpsio/psio.h>
 
23
#include <psifiles.h>
22
24
 
23
25
#define MXEXEC 100
24
26
#define MAX_EXEC_STR 80
27
29
  extern int setenv(const char *, const char *, int);
28
30
#endif
29
31
 
 
32
int get_ndisp(void);
30
33
FILE *infile, *outfile;
31
 
char **psi_file_prefix;
 
34
/* char **psi_file_prefix; */
 
35
char *psi_file_prefix;
32
36
/* 
33
37
  the following must stay in scope throughout the run, else the 
34
38
  environmental variables will vanish!
65
69
  int nexec_input;
66
70
 
67
71
  enum CalcCode {
68
 
    SP,               /* single-point */
69
 
    OPT,              /* optimization */
70
 
    DISP,             /* displacements */
71
 
    FREQ,             /* frequencies */
72
 
    SYMM_FREQ,        /* frequencies for symmetric modes */
73
 
    OEPROP,           /* one-electron properties */
74
 
    DBOC              /* compute Diagonal Born-Oppenheimer Correction (DBOC) by finite difference */
 
72
    SP,           /* single-point */
 
73
    OPT,          /* optimization */
 
74
    DISP,         /* displacements */
 
75
    FREQ,         /* frequencies */
 
76
    SYMM_FC,      /* force constants in internal coordinates, symmetric modes */
 
77
    FC,           /* force constants in internal coordinates, all modes */
 
78
    OEPROP,       /* one-electron properties */
 
79
    DBOC          /* compute Diagonal Born-Oppenheimer Correction (DBOC) 
 
80
                     by finite difference */
75
81
  } JobType;
76
82
 
 
83
  // Set these to a known value
 
84
  infile = NULL;
 
85
  outfile = NULL;
77
86
 
78
87
  if (!parse_cmdline(argc,argv))
79
88
    psi3_abort();
80
89
 
81
90
  fprintf(outfile, "\n\n The PSI3 Execution Driver \n");
82
91
 
83
 
  /* To find psi.dat first check the environment, then its location after installation */
 
92
  /* To find psi.dat first check the environment, then its location 
 
93
     after installation */
84
94
  psidat_dirname = getenv("PSIDATADIR");
85
95
  if (psidat_dirname != NULL) {
86
96
    char* tmpstr = (char *) malloc(sizeof(char)*(strlen(psidat_dirname)+9));
178
188
    JobType = OPT;
179
189
  else if ((strcmp(calctyp,"DISP")==0) || (strcmp(calctyp,"DISPLACEMENTS")==0))
180
190
    JobType = DISP;
181
 
  else if ((strcmp(calctyp,"FREQ_SYMM")==0)||(strcmp(calctyp,"FREQ-SYMM")==0)||
182
 
           (strcmp(calctyp,"SYMM_FREQ")==0)||(strcmp(calctyp,"SYMM-FREQ")==0)||
183
 
           (strcmp(calctyp,"SYMMETRIC_FREQUENCY")==0)) JobType = SYMM_FREQ;
 
191
  else if ( (strcmp(calctyp,"SYMM_FC")==0)||(strcmp(calctyp,"SYMM-FC")==0))
 
192
    JobType = SYMM_FC;
 
193
  else if ( (strcmp(calctyp,"FC")==0) )
 
194
    JobType = FC;
184
195
  else if ((strcmp(calctyp,"SP")==0) || (strcmp(calctyp,"SINGLE-POINT")==0) ||
185
196
           (strcmp(calctyp,"SINGLE_POINT")==0) ||
186
197
           (strcmp(calctyp,"FORCE")==0)) JobType = SP;
204
215
    if (strcmp(calctyp,"FORCE")==0) 
205
216
      strcpy(dertyp,"FIRST");
206
217
    else if (JobType == OPT) strcpy(dertyp, "FIRST");
207
 
    else if (JobType == FREQ || JobType == SYMM_FREQ) {
 
218
    else if (JobType == FREQ || JobType == SYMM_FC) {
208
219
      if (strcmp(wfn,"SCF")==0) strcpy(dertyp,"SECOND");
209
220
      else strcpy(dertyp,"FIRST"); /* guess analyt grads unless overridden */
210
221
    }
260
271
    else if (strcmp(dertyp,"SECOND")==0)
261
272
      fprintf(outfile, "analytic frequency computation.\n");
262
273
  }
263
 
  else if (JobType == SYMM_FREQ) {
 
274
  else if (JobType == SYMM_FC) {
264
275
    if (strcmp(dertyp,"NONE")==0)
265
276
      fprintf(outfile,"symmetric frequency computation via energies.\n");
266
277
    else if (strcmp(dertyp,"FIRST")==0)
280
291
    fprintf(outfile, "one-electron properties computation.\n");
281
292
  }
282
293
  else if (JobType == DBOC) {
283
 
    fprintf(outfile, "Diagonal Born-Oppenheimer Correction (DBOC) computation.\n");
 
294
    fprintf(outfile, 
 
295
      "Diagonal Born-Oppenheimer Correction (DBOC) computation.\n");
284
296
  }
285
297
  else { 
286
298
    fprintf(outfile, "calculation of unrecognized type.\n");
297
309
    strcpy(proced,"");
298
310
    if (direct == 1)
299
311
      strcat(proced,"DIRECT");
300
 
    strcat(proced,wfn);
 
312
    if (strcmp(wfn,"CASSCF")==0 || strcmp(wfn,"RASSCF")==0)
 
313
      strcat(proced,"DETCAS");
 
314
    else
 
315
      strcat(proced,wfn);
301
316
    strcat(proced,reftyp);
302
317
    /*
303
318
      For some cases do not need to append DERTYPE since it's irrelevant
315
330
        jobtype = strdup("OPT"); break;
316
331
      case FREQ:
317
332
        jobtype = strdup("FREQ"); break;
318
 
      case SYMM_FREQ:
319
 
        jobtype = strdup("SYMM_FREQ"); break;
 
333
      case SYMM_FC:
 
334
        jobtype = strdup("SYMM_FC"); break;
 
335
      case FC:
 
336
        jobtype = strdup("FC"); break;
320
337
      case DISP:
321
338
        jobtype = strdup("DISP"); break;
322
339
      case OEPROP:
335
352
      fprintf(outfile, "Reference               = %s\n", reftyp);
336
353
      fprintf(outfile, "Jobtype                 = %s\n", jobtype);
337
354
      fprintf(outfile, "Dertype                 = %s\n", dertyp);
338
 
      fprintf(outfile, "Direct                  = %s\n", (direct ? "true" : "false"));
 
355
      fprintf(outfile, "Direct                  = %s\n", 
 
356
        (direct ? "true" : "false"));
339
357
    }
340
358
 
341
359
    if (!ip_exist(proced,0)) {
358
376
    fprintf(outfile,"\nThe following programs will be executed:\n\n");
359
377
 
360
378
  if(auto_input) {
361
 
    /* set up the "input" program execution, which should occur before the rest of the procedure */
 
379
    /* set up the "input" program execution, which should occur before the 
 
380
       rest of the procedure */
362
381
    input_exec = parse_var(&nexec_input, MXEXEC, "INPUT");
363
382
    fprintf(outfile, " %s\n", input_exec[0]);
364
383
  }
396
415
 
397
416
void psi3_abort(void)
398
417
{
399
 
  fprintf(outfile,"\nPSI3 exiting.\n");
 
418
  if (outfile)
 
419
    fprintf(outfile,"\nPSI3 exiting.\n");
 
420
  else
 
421
    fprintf(stderr, "\nPSI3 exiting.\n");
 
422
 
400
423
  abort();
401
424
}
402
425
 
430
453
      /* fprintf(stderr,"%serrcod after filter is %d\n",spaces,errcod); */
431
454
 
432
455
      /* if we're getting ndisp from optking */
433
 
      if (strncmp("optking --disp_irrep",exec[i],
434
 
          strlen("optking --disp_irrep"))==0 ||
435
 
          strcmp(exec[i],"optking --disp_nosymm")==0) {
 
456
      if ( !(strncmp("optking --disp_irrep",exec[i],
 
457
           strlen("optking --disp_irrep")))
 
458
        || !(strcmp(exec[i],"optking --disp_nosymm"))
 
459
        || !(strcmp(exec[i],"optking --disp_freq_grad_cart")) 
 
460
        || !(strcmp(exec[i],"optking --disp_freq_energy_cart")) 
 
461
        ) {
436
462
        /* fprintf(outfile, "optking got exit code %d\n", errcod); */
437
463
        for (j=i; j<nexec; j++) {
438
464
          /* fprintf(outfile,"Scanning exec[%d] = %s\n", j, exec[j]);  */
439
465
          if (strcmp(exec[j],"NUM_DISP")==0) {  
440
466
            sprintf(exec[j],"%d",errcod);
 
467
         /*   sprintf(exec[j], "%d", get_ndisp() ); */
441
468
            break;
442
469
          }
443
470
        }
481
508
/* this code is essentially the same as in the psi_start() lib funct */
482
509
int parse_cmdline(int argc, char *argv[])
483
510
{
484
 
  int i;
 
511
  int i,errcod;
485
512
  int found_if_np = 0;          /* found input file name without -i */
486
513
  int found_of_np = 0;          /* found output file name without -o */
487
514
  int found_fp_np = 0;          /* found file prefix name without -p */
577
604
    return(0);
578
605
  }
579
606
 
580
 
  /* if some arguments were not specified on command-line - check the environment */
 
607
  /* if some arguments were not specified on command-line - 
 
608
     check the environment */
581
609
  if (ifname == NULL)
582
610
    ifname = getenv("PSI_INPUT");
583
611
  if (ofname == NULL)
599
627
  }
600
628
  else {
601
629
    infile = fopen("input.dat","r");
 
630
    ifname = "input.dat";
602
631
  }
603
632
  if (infile == NULL) {
604
633
    fprintf(stderr, "Error: could not open input file %s\n",ifname);
605
 
    return(PSI_RETURN_FAILURE);
 
634
    return(0);
606
635
  }
607
636
  if (ofname != NULL) {
608
637
#if HAVE_PUTENV
625
654
#error "Have neither putenv nor setenv. Something must be very broken on this system."
626
655
#endif
627
656
  }
 
657
 
 
658
  /*RAK */
 
659
  /* this hack works but doesn't pick up psi prefixes
 
660
  fclose(infile);
 
661
  psi_start(0,NULL,0);
 
662
  ip_done();
 
663
  fclose(outfile);
 
664
  fclose(infile);
 
665
  if (ifname != NULL)
 
666
    infile = fopen(ifname,"r");
 
667
  else
 
668
    infile = fopen("input.dat","r");
 
669
  outfile = stdout;
 
670
  */
628
671
  return(1);
629
672
}
630
673
 
 
674
int get_ndisp(void) {
 
675
  int ndisp;
 
676
  FILE *outfile_psi3;
 
677
 
 
678
  outfile_psi3 = outfile;
 
679
 
 
680
  /* psi_file_prefix = getenv("PSI_PREFIX");
 
681
  printf("%s\n", psi_file_prefix);
 
682
  psi_start(0,NULL,0); */
 
683
 
 
684
  /* need to remove psi_start */
 
685
  psio_init();
 
686
  psio_open(PSIF_OPTKING, PSIO_OPEN_OLD);
 
687
  psio_read_entry(PSIF_OPTKING, "OPT: Num. of disp.", (char *) &(ndisp), 
 
688
    sizeof(int));
 
689
  psio_close(PSIF_OPTKING,1);
 
690
  psio_done();
 
691
  printf("ndisp: %d\n",ndisp);
 
692
  outfile = outfile_psi3;
 
693
  return ndisp;
 
694
}