|
k-dot-p 0.1
|
#include "oneoff_1d_argprocess.h++"#include <stdio.h>#include <glib.h>#include <gio/gio.h>#include <gio/gunixinputstream.h>#include <stdlib.h>#include "kdotp/makestruct_argprocess.h++"#include <libmodelxx/function_specification.h++>#include "config.h"
Include dependency graph for oneoff_1d_argprocess.c++:Go to the source code of this file.
Functions | |
| void | program_print_version (FILE *f) |
| void | libkdotp_print_version (FILE *f) |
| void | libmodelxx_print_version (FILE *f) |
| void | liblapackwrap_print_version (FILE *f) |
| void | print_version_info (void) |
| struct template_parameter_range * | new_template_parameter_range (char *name, double from, double to, double step) |
| int | process_args (int argc, char **argv, struct args *args) |
| void libkdotp_print_version | ( | FILE * | f | ) |
| void liblapackwrap_print_version | ( | FILE * | f | ) |
| void libmodelxx_print_version | ( | FILE * | f | ) |
| struct template_parameter_range* new_template_parameter_range | ( | char * | name, |
| double | from, | ||
| double | to, | ||
| double | step | ||
| ) | [read] |
Definition at line 49 of file oneoff_1d_argprocess.c++.
References kdotp::libmodelxx::postprocessing::template_parameter_range::from, kdotp::libmodelxx::postprocessing::template_parameter_range::stepsize, kdotp::libmodelxx::postprocessing::template_parameter_range::symbol, and kdotp::libmodelxx::postprocessing::template_parameter_range::to.
Referenced by process_args().
{
struct template_parameter_range *tpr = (struct template_parameter_range*)malloc(sizeof(template_parameter_range));
if(tpr == NULL) return NULL;
tpr->symbol = name;
tpr->from = from;
tpr->to = to;
tpr->stepsize = step;
return tpr;
}
Here is the caller graph for this function:| void print_version_info | ( | void | ) |
Definition at line 41 of file oneoff_1d_argprocess.c++.
References libkdotp_print_version(), liblapackwrap_print_version(), libmodelxx_print_version(), PACKAGE_NAME, program_print_version(), and VERSION.
{
program_print_version(stdout);
libmodelxx_print_version(stdout);
libkdotp_print_version(stdout);
liblapackwrap_print_version(stdout);
printf("autotools info:\n\tProject: %s\n\tVersion: %s\n", PACKAGE_NAME, VERSION);
}
Here is the call graph for this function:| int process_args | ( | int | argc, |
| char ** | argv, | ||
| struct args * | args | ||
| ) |
Definition at line 59 of file oneoff_1d_argprocess.c++.
Referenced by main().
{
int errored = 0;
gchar **file_names = NULL;
gboolean print_version = FALSE;
gchar** parameters=NULL;
args->matdb = (char*)"/home/solarion/dist/share/materials-databases/matdb.txt";
GOptionEntry options[] = {
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &file_names,},
{ "version", 'v', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &print_version, "Print version information about this program", NULL },
{ "matdb", 'm', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_STRING, &(args->matdb), "Use an alternate materials database file.", NULL },
{"parameter", 'p', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_STRING_ARRAY, ¶meters, "Provide a template parameter argument, in the form param,value (single value) or param,start,stop,step (sequence)\n"},
{NULL}
};
GOptionContext *ctx;
ctx = g_option_context_new("- sets up a structure for k-dot-p calculations");
g_option_context_add_main_entries(ctx, options, "Options");
g_option_context_parse(ctx, &argc, &argv, NULL);
gchar* htext = g_option_context_get_help(ctx, FALSE, NULL);
g_option_context_free(ctx);
args->filestreams = NULL;
GFileInputStream *instream;
GError *gerr = NULL;
if(file_names != NULL) {
for(int i = 0; file_names[i] != NULL; i++) {
struct file_info *fi = (struct file_info*)malloc(sizeof(struct file_info));
if(fi == NULL) {
fprintf(stderr, "ERROR: unable to allocate input file info struct!\n");
return 500;
}
if((file_names[i][0] == '-') && (file_names[i][1] == '\0')) {
fi->instream = (GInputStream*)g_unix_input_stream_new(0, FALSE);
fi->filename = g_string_new("-");
}else{
GFile *f = g_file_new_for_commandline_arg(file_names[i]);
gerr = NULL;
instream = g_file_read(f, NULL, &gerr);
if(gerr != NULL) {
fprintf(stderr, "makestruct: ERROR reading in structure file (%s): %s", g_file_get_uri(f), gerr->message);
return 100;
}
g_object_unref(f);
fi->instream = (GInputStream*)instream;
fi->filename = g_string_new(file_names[i]);
}
args->filestreams = g_list_append(args->filestreams, fi);
}
}
if(args->filestreams == NULL) {
fprintf(stderr, "ERROR: you MUST give at least one file to process!\n");
errored=1;
}
char** tparam_entry;
args->template_parameters = NULL;
if(parameters != NULL) {
for(unsigned i=0; parameters[i] != NULL; i++) {
tparam_entry = g_strsplit(parameters[i], ",", -1);
int len=g_strv_length(tparam_entry);
struct template_parameter_range* tpr;
if(len == 2) {
/*parameter,value form*/
tpr = new_template_parameter_range(tparam_entry[0], strtod(tparam_entry[1], NULL), strtod(tparam_entry[1], NULL), strtod(tparam_entry[1], NULL));
}else if(len == 4) {
tpr = new_template_parameter_range(tparam_entry[0], strtod(tparam_entry[1], NULL), strtod(tparam_entry[2], NULL), strtod(tparam_entry[3], NULL));
}else{
fprintf(stderr, "ERROR: invalid parameteter entry: incorrect number of parameter range arguments (got %d; expected 2 or 4; should be either parameter,value or parameter,start,stop,step)", len);
return 15;
}
if(tpr == NULL) {
fprintf(stderr, "ERROR: unable to allocate space for new template parameter range (parameter is %s)\n", tparam_entry[0]);
return 16;
}
args->template_parameters = g_list_append(args->template_parameters, tpr);
}
}
if(print_version){
print_version_info();
return 1;
}
if(errored){
printf("%s", htext);
printf("\n\n**For version and compilation information, run with --version***\n");
return 3;
}
return 0;
}
Here is the caller graph for this function:| void program_print_version | ( | FILE * | f | ) |