|
funkalicious 0.1
|
#include <errno.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <gio/gio.h>#include <math.h>#include <glib-2.0/glib.h>#include "config.h"#include "dc_sweep_n_slice_args.h"
Include dependency graph for dc_sweep_n_slice_args.c:Go to the source code of this file.
Defines | |
| #define | GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN 1024 |
Functions | |
| void | program_print_version (FILE *f) |
| void | libdotcode_print_version (FILE *f) |
| void | libpostproc_print_version (FILE *f) |
| void | print_version_info () |
| double | double_from_string (const char *s, GError **err) |
| int | int_from_string (const char *s, GError **err) |
| void | get_args (int argc, char **argv, struct args *args, GError **err) |
Variables | |
| const char * | version_info |
| #define GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN 1024 |
Args for dc_sweep_n_slice
Copyright (C) 2011 Joseph Pingenot
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Definition at line 31 of file dc_sweep_n_slice_args.c.
Referenced by double_from_string(), get_args(), and int_from_string().
| double double_from_string | ( | const char * | s, |
| GError ** | err | ||
| ) |
Definition at line 52 of file dc_sweep_n_slice_args.c.
References GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN.
Referenced by get_args().
{
double d;
char *end;
errno = 0;
d = strtod(s, &end);
if(((end == s) && (d == 0)) || (errno != 0)) {
*err = g_error_new(GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN, 2, "dc_sweep_n_slice_args.c::double_from_string: Error occurred converting string (%s) to double: %s", s, strerror(errno));
return nan("NaN");
}
return d;
}
Here is the caller graph for this function:| void get_args | ( | int | argc, |
| char ** | argv, | ||
| struct args * | args, | ||
| GError ** | err | ||
| ) |
Parses the options and sets up the args struct.
| argc | from main |
| argv | from main |
| args | pointer to struct to initialize |
| err | pointer to pointer to GError to return error information (if any) GError code will be set to 1 if the user requested version information. |
set defaults
Definition at line 76 of file dc_sweep_n_slice_args.c.
References args::axes, args::bands, DC_BAND_VOP, double_from_string(), e, wavefunction::file, GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN, args::gridsite, int_from_string(), args::planes, args::point, print_version(), print_version_info(), args::sweeps, args::use_110_coordinates, args::use_gridsite, args::use_max_probability_point, and args::wavefunctions.
Referenced by main().
{
/**set defaults*/
args->use_110_coordinates=FALSE;
args->use_max_probability_point=TRUE;
args->use_gridsite=FALSE;
for(int i=0; i<3; i++) {
args->axes[i]=FALSE;
args->planes[i]=FALSE;
args->point[i]=0;
args->gridsite[i]=0;
args->sweeps[i]=FALSE;
}
args->wavefunctions=NULL;
args->bands=NULL;
gboolean print_version;
gchar* position = NULL;
gchar* gridsite = NULL;
gboolean each_band = FALSE;
GOptionEntry options[] = {
{ "version", 'v', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &print_version, "Print version information about this program", NULL },
//{ "110", '1', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &(args->use_110_coordinates), "Use the (110) coordinate system instead of (100) (i.e. use coordinate system x->(110), y->(-110), z->(001))", NULL},
{ "xaxis", 'x', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &(args->axes[0]), "Save the wavefunction along the x axis", NULL},
{ "yaxis", 'y', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &(args->axes[1]), "Save the wavefunction along the y axis", NULL},
{ "zaxis", 'z', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &(args->axes[2]), "Save the wavefunction along the z axis", NULL},
{ "sweepx", 'X', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &(args->sweeps[0]), "Sweep (plot into a pbm each cooordinate of) the wavefunction along the x axis", NULL},
{ "sweepy", 'Y', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &(args->sweeps[1]), "Sweep (plot into a pbm each cooordinate of) the wavefunction along the y axis", NULL},
{ "sweepz", 'Z', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &(args->sweeps[2]), "Sweep (plot into a pbm each cooordinate of) the wavefunction along the z axis", NULL},
{ "xy", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &(args->planes[0]), "Save the wavefunction in the xy plane", NULL},
{ "xz", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &(args->planes[1]), "Save the wavefunction in the xz plane", NULL},
{ "yz", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &(args->planes[2]), "Save the wavefunction in the yz plane", NULL},
{ "all-bands", 'a', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &each_band, "Print all of the bands separately instead of the total probability density.", NULL},
{ "at", '@', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_STRING, &position, "Position at which to print the wavefunction along the specified directions. Point consists of comma-separted set of floats (will be snapped to gridsite). If no site is given (either with -@ or -g), default is to get the maximum wavefunction prboability density.", NULL},
{ "gridsite", 'g', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_STRING, &gridsite, "Gridsite at which to print the wavefunction along the specified directions. Point consists of comma-separted set of integers. If no site is given (either with -@ or -g), default is to get the maximum wavefunction prboability density.", NULL},
{NULL}
};
GOptionContext *ctx;
ctx = g_option_context_new("- create a dotcode potential for the specified grid of nearest neighbors");
g_option_context_add_main_entries(ctx, options, "Options");
g_option_context_parse(ctx, &argc, &argv, NULL);
g_option_context_free(ctx);
if(print_version) {
print_version_info();
*err = g_error_new(GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN, 1, "No error; user just wanted version information. This shouldn't be printed.\nIf it was printed, then you have encountered a bug that needs fixed.");
return;
}
if((gridsite != NULL) && (position != NULL)) {
*err = g_error_new(GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN, 2, "You must specify *either* --at OR --gridsite; NOT BOTH.");
return;
}
if(gridsite != NULL) {
args->use_max_probability_point=FALSE;
args->use_gridsite=TRUE;
char** gridsite_coords = g_strsplit(gridsite, ",", 3);
for(int i=0; i<3; ++i) {
if(gridsite_coords[i] == NULL) {
*err = g_error_new(GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN, 3, "There were only %d gridsite arguments (received string %s); there should be *three*, comma-separated integer arguments.", i, gridsite);
g_strfreev(gridsite_coords);
return;
}
GError *e = NULL;
args->gridsite[i] = int_from_string(gridsite_coords[i], &e);
if(e != NULL) {
g_propagate_prefixed_error(err, e, "Error converting gridsite coordinate string (%s) (coordinate %d in original string %s) into integer: ", gridsite_coords[i], i, gridsite);
return;
}
}
g_strfreev(gridsite_coords);
}else if(position != NULL) {
args->use_max_probability_point=FALSE;
args->use_gridsite=FALSE;
char** position_coords = g_strsplit(position, ",", 3);
for(int i=0; i<3; ++i) {
if(position_coords[i] == NULL) {
*err = g_error_new(GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN, 3, "There were only %d position arguments (received string %s); there should be *three*, comma-separated integer arguments.", i, position);
g_strfreev(position_coords);
return;
}
GError *e = NULL;
args->point[i] = double_from_string(position_coords[i], &e);
if(e != NULL) {
g_propagate_prefixed_error(err, e, "Error converting position coordinate string (%s) (coordinate %d in original string %s) into double: ", position_coords[i], i, position);
return;
}
}
g_strfreev(position_coords);
}
if(each_band) {
for(int i=0; i<DC_BAND_VOP+1; ++i) {
enum dotcode_band* band = (enum dotcode_band*)malloc(sizeof(enum dotcode_band));
if(band == NULL) {
*err = g_error_new(GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN, 4, "Failed to allocate storage for a dotcode band.");
return;
}
*band = i;
args->bands = g_list_append(args->bands, band);
}
}
for(int i=1; i<argc; ++i) {
struct wavefunction* wf = (struct wavefunction*)malloc(sizeof(struct wavefunction));
if(wf == NULL) {
*err = g_error_new(GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN, 4, "Failed to allocate storage for a dotcode wavefunction struct (file was %s).", argv[i]);
}
wf->file = g_file_new_for_commandline_arg(argv[i]);
args->wavefunctions = g_list_append(args->wavefunctions, wf);
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| int int_from_string | ( | const char * | s, |
| GError ** | err | ||
| ) |
Definition at line 63 of file dc_sweep_n_slice_args.c.
References GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN.
Referenced by get_args().
{
int d;
char *end;
errno = 0;
d = strtod(s, &end);
if(((end == s) && (d == 0)) || (errno != 0)) {
*err = g_error_new(GET_DC_SWEEP_N_SLICE_ARGS_DOMAIN, 2, "dc_sweep_n_slice_args.c::int_from_string: Error occurred converting string (%s) to int: %s", s, strerror(errno));
return nan("NaN");
}
return d;
}
Here is the caller graph for this function:| void libdotcode_print_version | ( | FILE * | f | ) |
| void libpostproc_print_version | ( | FILE * | f | ) |
| void print_version_info | ( | ) |
Definition at line 38 of file dc_sweep_n_slice_args.c.
References libdotcode_print_version(), libpostproc_print_version(), PACKAGE_NAME, program_print_version(), SIZEOF_DOUBLE, SIZEOF_INT, and VERSION.
Referenced by get_args(), and process_args().
{
program_print_version(stdout);
libdotcode_print_version(stdout);
libpostproc_print_version(stdout);
printf("autotools info:\n\tProject: %s\n\tVersion: %s\n", PACKAGE_NAME, VERSION);
printf("Platform information:\n\tSize of int=%d double=%d\n\tEndianness: %s\n", SIZEOF_INT, SIZEOF_DOUBLE,
#ifdef WORDS_BIGENDIAN
"big"
#else
"little"
#endif
);
}
Here is the call graph for this function:
Here is the caller graph for this function:| void program_print_version | ( | FILE * | f | ) |
| const char* version_info |
Referenced by print_version().