next up previous contents
Next: Initialization Up: The Checkpoint File Library Previous: Library Philosophy   Contents

Basic Use Instructions

Following the philosophy that a programmer who wants to read, say, the number of atoms and the irrep labels from the checkpoint file should not have to use fifty lines of code to do so, libchkpt.a was written. Following a call to a single command, chkpt_init(), the programmer can extract many useful bits of info from the checkpoint file relatively painlessly. libchkpt.a is dependent upon libipv1.a and libpsio.a and thus requires that the input parser and I/O system each be initialized so that the proper file name labels may be referenced. An example of a minimal program that sets up the input parser, initilizes a special structure within the libchkpt.a library, and reads the SCF HF energy, eigenvector and eigenvalues is given below. In order to illustrate the writing capability of the library routines, a dummy correlated energy is written to the checkpoint file and then read back again within the code.

#include <stdio.h>
#include <libipv1/ip_lib.h>
#include <libciomr/libciomr.h>
#include <libpsio/psio.h>
#include <libchkpt/chkpt.h>

FILE *infile, *outfile;

void main(void)
{
 
  int nmo;
  double escf, etot;
  double *evals;
  double **scf;

  /*-------------------------------------
    initialize the input parser, read in
    the files information from the
    default section
   -------------------------------------*/
  ffile(&infile,"input.dat",2);
  ffile(&outfile,"output.dat",1);
  tstart(outfile);
  ip_set_uppercase(1);
  ip_initialize(infile,outfile);
  ip_cwk_clear();
  ip_cwk_add(":DEFAULT");
  psio_init();

  /*------------------------------------
    now initialize the checkpoint structure
    and begin reading info
   ------------------------------------*/
  chkpt_init();

  escf = chkpt_rd_escf();
  evals = chkpt_rd_evals();
  scf = chkpt_rd_scf();
  nmo = chkpt_rd_nmo();
 
  chkpt_wt_etot(-1000.0);
  
  etot = chkpt_rd_etot();

  chkpt_close();

  /*--------------------------------------------
    print out info to see what has been read in
   --------------------------------------------*/
  fprintf(outfile,"\n\n\tEscf  = %20.10lf\n",escf);
  fprintf(outfile,"\tEtot = %20.10lf\n",etot);
  fprintf(outfile,"SCF EIGENVECTOR\n");

  eivout(scf,evals,nmo,nmo,outfile); 
  
  psio_done();
  tstop(outfile);
  ip_done();
 }

  /*-------------------------------------------------
    dont forget to add the obligatory gprgid section 
   -------------------------------------------------*/
char *gprgid()
{
   char *prgid = ":TEST";

   return(prgid);
}



psi 2003-01-07