gimme-alpha 0.1

read_nextnano_density.c

Go to the documentation of this file.
00001 /*
00002 ** read_nextnano_density.c
00003 ** 
00004 ** Made by (Johnny Q. Hacker)
00005 ** Login   <solarion@borkborkbork>
00006 
00007     Copyright (C) 2009 Joseph Pingenot
00008 
00009     This program is free software: you can redistribute it and/or modify
00010     it under the terms of the GNU Affero General Public License as published by
00011     the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU Affero General Public License for more details.
00018 
00019     You should have received a copy of the GNU Affero General Public License
00020     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00021 
00022 ** Started on  Tue Mar  3 13:05:05 2009 Johnny Q. Hacker
00023 ** Last update Sun May 12 01:17:25 2002 Speed Blue
00024 */
00025 
00026 #include <stdio.h>
00027 #include <libnextnano/read_nextnano_inputfile.h>
00028 #include <libnextnano/read_nextnano_density.h>
00029 #include <libcommon/textfile_common.h>
00030 
00031 GList *read_nextnano_density_el(GFile* base, GHashTable *input) {
00032   int err;
00033   GError *error = NULL;
00034   GList *titles = g_list_append(NULL, "x");
00035   titles = g_list_append(titles, "total");
00036   titles = g_list_append(titles, "quantum");
00037   titles = g_list_append(titles, "classical");
00038   char *density_dir_str = read_nextnano_extract_item(input, "output-densities", 0, "destination-directory", &err);
00039   if(err != 0) {
00040     fprintf(stderr, "Error extracting output-densities destination-directory from nextnano input.\n");
00041     g_list_free(titles);
00042     return NULL;
00043   }
00044   GFile *density_dir = g_file_get_child(base, density_dir_str);
00045   GFile *densityfile = g_file_get_child(density_dir, "density1Del.dat");
00046   GFileInputStream *density_stream = g_file_read(densityfile, NULL, &error);
00047   if(error != NULL) {
00048     fprintf(stderr, "Error opening the density file for reading (error %s)\n", error->message);
00049     g_list_free(titles);
00050     return NULL;
00051   }
00052   GList *density = read_titled_whitespaced_data(G_INPUT_STREAM(density_stream), &error, &titles, '!', DOUBLE_TYPE);
00053   g_list_free(titles);
00054   return density;
00055 }
 All Classes Files Functions Variables Enumerations Enumerator Defines