funkalicious 0.1

function_parser.h

Go to the documentation of this file.
00001 /*
00002  *function_parser
00003  *parses the wavefunctions from Craig Pryor's dotcode.
00004  
00005  Copyright (C) 2006 Joseph Pingenot
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 */
00022 
00023 #include <glib-2.0/glib.h>
00024 #include <gio/gio.h>
00025 
00026 #ifndef WAVEFUNCTION_PARSER_H___
00027 #define WAVEFUNCTION_PARSER_H___
00028 
00029 struct wavefunc_header {
00030   /*We include trailing \0 for easy printing.*/
00031   char format[13];
00032   char endian;
00033   /*Easy-to-use flag for IF statements*/
00034   short int little_endian;
00035   char version_string[4];
00036   /*from version_string, but as int*/
00037   int version;
00038   int Nc;
00039   int Nx;
00040   int Ny;
00041   int Nz;
00042   double dx;
00043   double dy;
00044   double dz;
00045   /*Hartree*/
00046   double energy;
00047 };
00048 
00049 /*Reads in a wavefunction from a filename (or GFile)
00050  *ARGS:
00051  *  filename     filename to read in
00052  *  header       pointer to a header we will fill in.
00053  *  matrix       pointer to a pointer of type double.  We will store
00054  *                a pointer to the matrix here.
00055  *  err          pointer to an int in which to store errno, if needed.  If
00056  *                not, is set to 0.
00057  *RETURNS  (E indicates that err is set to errno)
00058  *     0            if successful
00059  *    -1            header pointer was NULL
00060  *    -2            filename was NULL
00061  *  E -3            failed to open file
00062  *  E -4            failed to read in all of a header (NOTE: may return
00063  *                    with err=0, meaning that the file was just too short.
00064  *  E -5            matrix was NULL
00065  *  E -7            error parsing header  err is set to the return value
00066  *                    of parse_header.
00067  *  E -8            failed to allocate matrix storage.
00068  *NOTES
00069  ** matrix format is as follows:
00070  *    [{Re,Im} + N_band*2 + x*Nc*2 + y*Nx*Nc*2 + z*Ny*Nx*Nc*2]
00071  *
00072  *       where
00073  *
00074  *    [1][*][*][*][*] is Re
00075  *    [2][*][*][*][*] is Im
00076  */
00077 int read_wavefunction(char* filename, struct wavefunc_header *header, double **matrix, int *err);
00078 int read_wavefunction_gfile(GFile* f, struct wavefunc_header *header, double **matrix, GError **err);
00079 
00080 double get_binary_double(int le, char *buffer);
00081 int get_binary_int(int le, char *buffer);
00082 int parse_header(struct wavefunc_header *header, char *buff);
00083 int resilient_read(GFileInputStream *infile, char *buffer, int count, GError **err);
00084 
00085 
00086 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines