|
funkalicious 0.1
|
00001 /* 00002 ** getChainPotential.c 00003 ** 00004 00005 00006 Copyright (C) 2009 Joseph Pingenot 00007 00008 This program is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU Affero General Public License as published by 00010 the Free Software Foundation, either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU Affero General Public License for more details. 00017 00018 You should have received a copy of the GNU Affero General Public License 00019 along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ** Made by (Johnny Q. Hacker) 00022 ** Login <solarion@nathan> 00023 ** 00024 ** Started on Sat Nov 14 17:15:07 2009 Johnny Q. Hacker 00025 ** Last update Sun May 12 01:17:25 2002 Speed Blue 00026 */ 00027 00028 #include <stdlib.h> 00029 #include <stdio.h> 00030 #include <glib-2.0/glib.h> 00031 #include <gio/gio.h> 00032 #include "getChainPotential_args.h" 00033 #include <libpostproc/lp_wavefunction.h> 00034 #include <libpostproc/fftw_wavefunc.h> 00035 #include <libpostproc/unit_conversion.h> 00036 #include <libdotcode/read_binary_data.h> 00037 #include <libdotcode/write_binary_data.h> 00038 #include <libdotcode/matdb-dotcode.h> 00039 #include <libdotcode/grid1.h> 00040 00041 void write_sweeps(struct args* args, struct density* d, char* subdir); 00042 void write_slices(struct args* args, struct density* d, char* subdir, const char* coord_units, const char* density_units); 00043 00044 int main(int argc, char** argv) { 00045 g_type_init(); 00046 GError *e = NULL; 00047 struct args *args = process_args(argc, argv, &e); 00048 if(args == NULL) { 00049 fprintf(stderr, "Failed to process the args: "); 00050 if(e != NULL) { 00051 fprintf(stderr, "%s\n", e->message); 00052 }else{ 00053 fprintf(stderr, "(got no GError, for some reason. This is a problem in the program one way or the other!)\n"); 00054 } 00055 return 1; 00056 } 00057 /*At this point, the wfs haven't been loaded into the 00058 *wavefunction struct. Do that now.*/ 00059 e=NULL; 00060 load_wavefunctions(args->wf_list, &e); 00061 if(e!=NULL){ 00062 fprintf(stderr, "Got error loading the wavefunctions: %s\n", e->message); 00063 return 2; 00064 } 00065 e=NULL; 00066 load_wavefunctions(args->center_wf_list, &e); 00067 if(e!=NULL){ 00068 fprintf(stderr, "Got error loading the center wavefunctions: %s\n", e->message); 00069 return 2; 00070 } 00071 e=NULL; 00072 /*Sum up all of the neighbors in a block*/ 00073 struct density *d = NULL; 00074 if(args->wf_list != NULL) { 00075 d = get_density_for_list_of_wavefunctions(args->wf_list, &e); 00076 if(e != NULL) { 00077 fprintf(stderr, "ERROR: error while getting list of wavefunctions: %s\n", e->message); 00078 return 7; 00079 } 00080 } 00081 struct density *center_d = NULL; 00082 if(args->center_wf_list != NULL) { 00083 center_d = get_density_for_list_of_wavefunctions(args->center_wf_list, &e); 00084 if(e != NULL) { 00085 fprintf(stderr, "ERROR: error while getting list of center wavefunctions: %s\n", e->message); 00086 return 8; 00087 } 00088 } 00089 00090 /*For now, just make a rho=epsilon_0*/ 00091 /*epsilon_0 is 8.854 187 817... x 10-12 F m-1 00092 *Units are in Bohr, and 1 bohr = 0.529 177 208 59 x 10-10 m 00093 *(source: NIST physical constants database 00094 */ 00095 struct density* rhoprime; 00096 /*Read in the density*/ 00097 e=NULL; 00098 struct wavefunction* inwavefunc = (struct wavefunction*)(args->wf_list->data); 00099 if(inwavefunc == NULL) { 00100 inwavefunc = (struct wavefunction*)(args->center_wf_list->data); 00101 if(inwavefunc == NULL) { 00102 fprintf(stderr, "ERROR: Unable to find the first wavefunction!\n"); 00103 return 23; 00104 } 00105 } 00106 GFile* grid1_file = g_file_get_child(inwavefunc->file, ".trun.displ/grid"); 00107 struct dotcode_grid1* g1 = dotcode_grid1_get_from_gfile(grid1_file, &e); 00108 if(e != NULL) { 00109 char* pathstr = g_file_get_uri(grid1_file); 00110 fprintf(stderr, "ERROR: unable to open and process the grid (%s): %s\n", pathstr, e->message); 00111 g_free(pathstr); 00112 g_error_free(e); 00113 return 20; 00114 } 00115 GFile* mdbfile = g_file_get_child(inwavefunc->file, ".matdb"); 00116 struct matdb* mdb = read_matdb_dotcode_gio(mdbfile, &e); 00117 if(e != NULL) { 00118 char* pathstr = g_file_get_uri(mdbfile); 00119 fprintf(stderr, "ERROR: unable to open and process the matdb (%s): %s\n", pathstr, e->message); 00120 g_free(pathstr); 00121 g_error_free(e); 00122 return 21; 00123 } 00124 struct density* epsilon = (struct density*)malloc(sizeof(struct density)); 00125 if(epsilon == NULL) { 00126 fprintf(stderr, "ERROR: unable to allocate memory for epsilon.\n"); 00127 return 23; 00128 } 00129 for(int i=0; i<3; i++) { 00130 epsilon->N[i] = g1->N[i]; 00131 epsilon->dx[i] = g1->dx[i]; 00132 } 00133 epsilon->storage = dotcode_grid1_get_property_grid(g1, mdb, "epsilon_0", &e); 00134 if(e != NULL) { 00135 char* pathstr1 = g_file_get_uri(grid1_file); 00136 char* pathstr2 = g_file_get_uri(mdbfile); 00137 fprintf(stderr, "ERROR: unable to process the grid (%s) and matdb (%s) into a epsilon_0 grid: %s\n", pathstr1, pathstr2, e->message); 00138 g_free(pathstr1); 00139 g_free(pathstr2); 00140 g_error_free(e); 00141 return 22; 00142 } 00143 /*need to multiply epsilon by epsilon_0*/ 00144 density_mul_by_const(epsilon, 8.854187817e-12); 00145 00146 struct density* meta_density; 00147 struct density* meta_epsilon; 00148 /*this algo almost certainly blows our cache and is slow.*/ 00149 if((args->N_neighbors[0] == 0) && (args->N_neighbors[1] == 0) && (args->N_neighbors[2] == 0)) { 00150 meta_density = d; 00151 meta_epsilon = epsilon; 00152 }else{ 00153 int N[3]; 00154 long unsigned int t = 1; 00155 int extra_x = 0; 00156 int extra_y = 0; 00157 int extra_z = 0; 00158 /*If a direction has a non-zero number of neighbors, we need to add an extra neighbor in that direction to get an infinite chain with periodic BCs.*/ 00159 if(args->extra_neighbor[0]) extra_x = 1; 00160 if(args->extra_neighbor[1]) extra_y = 1; 00161 if(args->extra_neighbor[2]) extra_z = 1; 00162 for(int i=0; i<3; i++) { 00163 /*There are 2*N_neighbors[i] blocks (one on each side), plus the center block.*/ 00164 N[i] = (2*(args->N_neighbors[i])+1+args->extra_neighbor[i])*(d->N[i] + args->neighbor_offset[i]); 00165 t *= N[i]; 00166 } 00167 meta_density = new_density(N, d->dx, 0.0); 00168 if(meta_density == NULL) { 00169 fprintf(stderr, "Error: unable to allocate storage for an %dx%dx%d box (%lu total doubles (meta_density))\n", (2*(args->N_neighbors[0])+1)*(d->N[0]), (2*(args->N_neighbors[1])+1)*(d->N[1]), (2*(args->N_neighbors[2])+1)*(d->N[2]), t); 00170 return 3; 00171 } 00172 //Set the meta_epsilon default value from the 0, 0, 0 corner. 00173 /**\todo set this from user-specified value*/ 00174 meta_epsilon = new_density(N, d->dx, *get_density_storage_at_c_(0, 0, 0, epsilon)); 00175 if(meta_epsilon == NULL) { 00176 fprintf(stderr, "Error: unable to allocate storage for an %dx%dx%d box (%lu total doubles (meta epsilon))\n", (2*(args->N_neighbors[0])+1)*(d->N[0]), (2*(args->N_neighbors[1])+1)*(d->N[1]), (2*(args->N_neighbors[2])+1)*(d->N[2]), t); 00177 return 3; 00178 } 00179 int x_counter = 0, y_counter = 0, z_counter=0; 00180 gboolean invert_x, invert_y, invert_z; 00181 /*If we have an even number of neighbors, our first coordinate 00182 is an even neighbor and therefore the even coordinates are even 00183 neighbors and therefore shouldn't be flipped. If we have an odd 00184 number of neighbors, the first coordinate is an odd neighbor, 00185 and therefore the even coordinates are odd neighbors and should 00186 be flipped. 00187 TO CHECK THE LOGIC: the center coordinate is *always* an 00188 even coordinate! 00189 NOTE that the counter will flip before it's checked. 00190 THE ALGORITHM being used here is that 1*-1 = 1; -1*-1 = 1; 0*-1 00191 = 0; So we start at 0 if we're not counting (and we'll never be 00192 flip; we'll flip when the counter is +1, and we'll not flip when 00193 the counter is -1. 00194 UPDATE: the previous algo was crap. We need to flip the 00195 appropriate axes when we're on an "odd" block. 00196 */ 00197 if((args->N_neighbors[0] % 2) == 0) { 00198 x_counter = 1; 00199 }else{ 00200 x_counter = -1; 00201 } 00202 if((args->N_neighbors[1] % 2) == 0) { 00203 y_counter = 1; 00204 }else{ 00205 y_counter = -1; 00206 } 00207 if((args->N_neighbors[2] % 2) == 0) { 00208 z_counter = 1; 00209 }else{ 00210 z_counter = -1; 00211 } 00212 for(int z=0; z<(2*(args->N_neighbors[2])+1+extra_z); z++) { 00213 z_counter *= -1; 00214 for(int y=0; y<(2*(args->N_neighbors[1])+1+extra_y); y++) { 00215 y_counter *= -1; 00216 for(int x=0; x<(2*(args->N_neighbors[0])+1+extra_x); x++) { 00217 x_counter *= -1; 00218 if((x_counter*y_counter*z_counter) > 0) { 00219 invert_x = (args->invert_odd)&1; 00220 invert_y = (args->invert_odd)&2; 00221 invert_z = (args->invert_odd)&4; 00222 }else{ 00223 invert_x = 0; 00224 invert_y = 0; 00225 invert_z = 0; 00226 } 00227 fprintf(stderr, "%d/%d/%d: invert_x: %c invert_y: %c invert_z: %c (x_counter=%d,y_counter=%d,z_counter=%d\n", x, y, z, (invert_x)?'y':'n', (invert_y)?'y':'n', (invert_z)?'y':'n', x_counter, y_counter, z_counter); 00228 /*Check to see if this is the middle block*/ 00229 #ifdef DEBUG 00230 fprintf(stderr, "x=%d(s%d) y=%d(s%d) z=%d(s%d):\n", x, (args->N_neighbors[0]), y, (args->N_neighbors[1]), z, (args->N_neighbors[2])); 00231 #endif 00232 if((z == (args->N_neighbors[2])) 00233 && (y == (args->N_neighbors[1])) 00234 && (x == (args->N_neighbors[0]))) { 00235 #ifdef DEBUG 00236 fprintf(stderr, "center!\n"); 00237 #endif 00238 if(center_d != NULL) { 00239 put_density_into_metadensity(meta_density, center_d, args->N_neighbors, x, y, z, invert_x, invert_y, invert_z, args->neighbor_offset); 00240 } 00241 }else{ 00242 #ifdef DEBUG 00243 fprintf(stderr, "normal.\n"); 00244 #endif 00245 /*We're not; copy in*/ 00246 if(d != NULL) { 00247 put_density_into_metadensity(meta_density, d, args->N_neighbors, x, y, z, invert_x, invert_y, invert_z, args->neighbor_offset); 00248 } 00249 } 00250 /*We always put epsilon into the center, so do it on every loop*/ 00251 put_density_into_metadensity(meta_epsilon, epsilon, args->N_neighbors, x, y, z, invert_x, invert_y, invert_z, args->neighbor_offset); 00252 } 00253 } 00254 } 00255 } 00256 /*if specified, we expand the calculation box here.*/ 00257 if(args->expand_density_boxes != NULL) { 00258 fprintf(stderr, "Expanding meta_density box in %d, %d, %d.\n", args->expand_density_boxes[0], args->expand_density_boxes[1], args->expand_density_boxes[2]); 00259 struct density* t; 00260 t = expand_density_box_with_value(meta_density, args->expand_density_boxes, 0, &e); 00261 if(e != NULL) { 00262 fprintf(stderr, "ERROR: unable to expand meta_density out by %d,%d,%d grid sites: %s\n", args->expand_density_boxes[0], args->expand_density_boxes[1], args->expand_density_boxes[2], e->message); 00263 return 70; 00264 } 00265 free_density(meta_density); 00266 meta_density = t; 00267 fprintf(stderr, "Expanding meta_density box in %d, %d, %d.\n", args->expand_density_boxes[0], args->expand_density_boxes[1], args->expand_density_boxes[2]); 00268 t = expand_density_box(meta_epsilon, args->expand_density_boxes, &e); 00269 if(e != NULL) { 00270 fprintf(stderr, "ERROR: unable to expand meta_epsilon out by %d,%d,%d grid sites: %s\n", args->expand_density_boxes[0], args->expand_density_boxes[1], args->expand_density_boxes[2], e->message); 00271 return 70; 00272 } 00273 free_density(meta_epsilon); 00274 meta_epsilon = t; 00275 } 00276 /*write sweeps and slices for density*/ 00277 write_slices(args, meta_density, "charge_density_slices", "Bohr", "e Bohr^2/Bohr^3"); 00278 write_sweeps(args, meta_density, "charge_density_sweeps"); 00279 write_slices(args, meta_epsilon, "epsilon_slices", "Bohr", "F m"); 00280 write_sweeps(args, meta_epsilon, "epsilon_sweeps"); 00281 00282 /*A check to verify that this works properly.*/ 00283 struct density* dcheck2 = new_density(d->N, d->dx, 0); 00284 get_density_from_metadensity(meta_density, dcheck2, args->expand_density_boxes, args->N_neighbors, 0, 0, 0, args->neighbor_offset); 00285 00286 if(args->center_wf_list == NULL) { 00287 struct density* dcheck = new_density(d->N, d->dx, 0); 00288 get_density_from_metadensity(meta_density, dcheck, args->expand_density_boxes, args->N_neighbors, args->N_neighbors[0], args->N_neighbors[1], args->N_neighbors[2], args->neighbor_offset); 00289 fprintf(stderr, "CHECKING that the center density is zero:"); 00290 for(int k=0; k<dcheck->N[2]; k++) { 00291 for(int j=0; j<dcheck->N[1]; j++) { 00292 for(int i=0; i<dcheck->N[0]; i++) { 00293 if( 00294 dcheck->storage[get_density_storage_index_(i, j, k, dcheck->N[0], dcheck->N[1])] 00295 != 0) { 00296 fprintf(stderr, "ERROR: dcheck[%d,%d,%d] (%g) != 0\n", 00297 i, j, k, 00298 dcheck->storage[get_density_storage_index_(i, j, k, dcheck->N[0], dcheck->N[1])]); 00299 } 00300 } 00301 } 00302 } 00303 free_density(dcheck); 00304 } 00305 fprintf(stderr, "DONE\n"); 00306 00307 /*Density needs to be multiplied by qe and divided by grid spacing 00308 (assuming all are same) in m*/ 00309 if(((meta_density->dx)[0] != (meta_density->dx)[1]) 00310 || ((meta_density->dx)[0] != (meta_density->dx)[2])) { 00311 fprintf(stderr, "ERROR: not all grid spacings are the same! (dx=%g dy=%g dz=%g)\n", (meta_density->dx)[0], (meta_density->dx)[1], (meta_density->dx)[2]); 00312 return 30; 00313 } 00314 printf("grid site distances are the same, and are %g (%gnm)\n", (meta_density->dx)[0], bohr_to_nm((meta_density->dx)[0])); 00315 /*This comes about from the following 00316 * the density is 1/dx[0]^3. The differentiation causes rho to be *multiplied* by dx[0]^2. 00317 * So dx[0]^2/dx[0]^3 = 1/dx[0] 00318 */ 00319 density_mul_by_const(meta_density, mag_q_e_in_C/(bohr_to_m((meta_density->dx)[0]))); 00320 00321 /**\note if we're calling get_potential_for_density directly, we're not using a dielectric term, so it's NULL*/ 00322 struct density *phi; 00323 GError *err5 = NULL; 00324 if(args->use_inhomogeneous_dielectric) { 00325 phi = get_potential_for_density_inhomog_simple(meta_density, meta_epsilon, 1e-4, 0, args->save_inhomog_iterations, &err5); 00326 rhoprime = new_density(meta_density->N, meta_density->dx, 0); 00327 }else{ 00328 phi = get_potential_for_density(meta_density, meta_epsilon, &rhoprime, NULL, NULL, &err5); 00329 } 00330 if(err5 != NULL) { 00331 fprintf(stderr, "ERROR getting potential: %s\n", err5->message); 00332 return 100; 00333 } 00334 if(phi == NULL) { 00335 fprintf(stderr, "Error allocating memory for get_potential_for_density!\n"); 00336 return 5; 00337 } 00338 /*write sweeps and slices for phi*/ 00339 write_slices(args, phi, "potential_slices", "Bohr", "V"); 00340 write_sweeps(args, phi, "potential_sweeps"); 00341 write_slices(args, rhoprime, "rhoprime_slices", "Bohr", "V/Bohr"); 00342 write_sweeps(args, rhoprime, "rhoprime_sweeps"); 00343 00344 struct density* phi_center = new_density(d->N, d->dx, 0); 00345 if(phi_center == NULL) { 00346 fprintf(stderr, "ERROR: failed to get memory for central portion of the density!\n"); 00347 } 00348 get_density_from_metadensity(phi, phi_center, args->expand_density_boxes, args->N_neighbors, args->N_neighbors[0], args->N_neighbors[1], args->N_neighbors[2], args->neighbor_offset); 00349 00350 /*write sweeps and slices for phi*/ 00351 write_slices(args, phi_center, "center_potential_slices", "Bohr", "V"); 00352 write_sweeps(args, phi_center, "center_potential_sweeps"); 00353 00354 /**Convert the output potential to electron interaction energy in Hartree 00355 * per electron. 00356 * Multiplying by -1.0 gets us to eV; then we need to multiply by hartree/eV 00357 */ 00358 density_mul_by_const(phi_center, -ev_in_hartree); 00359 00360 struct dotcode_grid* g = dotcode_grid_from_density(phi_center, &e); 00361 if(e != NULL) { 00362 fprintf(stderr, "ERROR: unable to convert density to a dotcode grid for writing: %s\n", e->message); 00363 return 37; 00364 } 00365 00366 e = dotcode_write_typed_file(DOTCODE_GRID, g, args->outfile); 00367 if(e != NULL) { 00368 char* pathstr = g_file_get_uri(args->outfile); 00369 fprintf(stderr, "ERROR: unable to write out the final potential (%s): %s\n", pathstr, e->message); 00370 g_free(pathstr); 00371 g_error_free(e); 00372 return 21; 00373 } 00374 00375 if(d != meta_density) { 00376 free_density(d); 00377 free_density(meta_density); 00378 }else{ 00379 free_density(d); 00380 } 00381 free_density(epsilon); 00382 free_density(meta_epsilon); 00383 /*free_density(phi);*/ 00384 return 0; 00385 } 00386 00387 void write_sweeps(struct args* args, struct density* d, char* subdir) { 00388 /*Output the sweeps if requested.*/ 00389 if((!(args->sweep_x)) && (!(args->sweep_y)) && (!(args->sweep_z))) return; 00390 GFile* f = g_file_new_for_path(subdir); 00391 GError* e=NULL; 00392 g_file_make_directory_with_parents(f, NULL, &e); 00393 if((e!=NULL) && (e->code != G_IO_ERROR_EXISTS)){ 00394 char* fn = g_file_get_uri(f); 00395 if(e == NULL) { 00396 fprintf(stderr, "ERROR: write_sweeps(%s): unable to make directory for writing sweep (%s)", subdir, fn); 00397 }else{ 00398 fprintf(stderr, "ERROR: write_sweeps(%s): unable to make directory for writing sweep (%s): %s (%d/%d)", subdir, fn, e->message, e->code, G_IO_ERROR_EXISTS); 00399 } 00400 free(fn); 00401 return; 00402 } 00403 char* s; 00404 if(args->sweep_x) { 00405 e=NULL; 00406 s=NULL; 00407 write_density_sweep(X, d, &s, &e, f, args->pixel_strategy); 00408 if(e!=NULL){ 00409 printf("->%s. FAILED: %s.\n", s, e->message); 00410 }else{ 00411 printf("->%s. done.\n", s); 00412 } 00413 if(s!=NULL) { 00414 free(s); 00415 } 00416 } 00417 if(args->sweep_y) { 00418 e=NULL; 00419 s=NULL; 00420 write_density_sweep(Y, d, &s, &e, f, args->pixel_strategy); 00421 if(e!=NULL){ 00422 printf("->%s. FAILED: %s.\n", s, e->message); 00423 }else{ 00424 printf("->%s. done.\n", s); 00425 } 00426 if(s!=NULL) { 00427 free(s); 00428 } 00429 } 00430 if(args->sweep_z) { 00431 e=NULL; 00432 s=NULL; 00433 write_density_sweep(Z, d, &s, &e, f, args->pixel_strategy); 00434 if(e!=NULL){ 00435 printf("->%s. FAILED: %s.\n", s, e->message); 00436 }else{ 00437 printf("->%s. done.\n", s); 00438 } 00439 if(s!=NULL) { 00440 free(s); 00441 } 00442 } 00443 } 00444 00445 void write_slices(struct args* args, struct density* d, char* subdir, const char* coord_units, const char* density_units) { 00446 GError* e=NULL; 00447 /*Output the sweeps if requested.*/ 00448 GFile* f = g_file_new_for_path(subdir); 00449 char* s; 00450 g_file_make_directory_with_parents(f, NULL, &e); 00451 if((e!=NULL) && (e->code != G_IO_ERROR_EXISTS)){ 00452 char* fn = g_file_get_uri(f); 00453 if(e == NULL) { 00454 fprintf(stderr, "ERROR: write_slices(%s): unable to make directory for writing slices (%s)", subdir, fn); 00455 }else{ 00456 fprintf(stderr, "ERROR: write_slices(%s): unable to make directory for writing slices (%s): %s (%d/%d)", subdir, fn, e->message, e->code, G_IO_ERROR_EXISTS); 00457 } 00458 free(fn); 00459 return; 00460 } 00461 if(args->save_ascii_values) { 00462 e=NULL; 00463 GString *ess = g_string_new(""); 00464 g_string_printf(ess, "ascii_%s.pdata", subdir); 00465 fprintf(stderr, "Writing dump to %s: ", ess->str); 00466 GFile* av = g_file_get_child(f, ess->str); 00467 write_density_slice(X, NULL, d, &s, &e, av, args->sepchar, coord_units, density_units); 00468 if(e != NULL) { 00469 fprintf(stderr, "ERROR dumping ascii to file %s: %s\n", s, e->message); 00470 } 00471 fprintf(stderr, "%s\n", s); 00472 g_string_free(ess, TRUE); 00473 g_free(s); 00474 } 00475 if(args->povray) { 00476 e=NULL; 00477 GString *ess = g_string_new(""); 00478 g_string_printf(ess, "ascii_%s.pov", subdir); 00479 fprintf(stderr, "Writing povray scene to %s: ", ess->str); 00480 GFile* av = g_file_get_child(f, ess->str); 00481 write_density_povray(d, av, args->pixel_strategy, &e); 00482 if(e != NULL) { 00483 fprintf(stderr, "ERROR dumping ascii to file %s: %s\n", s, e->message); 00484 } 00485 fprintf(stderr, "%s\n", s); 00486 g_string_free(ess, TRUE); 00487 g_free(s); 00488 } 00489 e=NULL; 00490 if((args->xslices == NULL) && (args->yslices == NULL) && (args->zslices == NULL)) { 00491 fprintf(stderr, "No slices to write. going back to main routine.\n"); 00492 return; 00493 } 00494 GList *l; 00495 for(l=args->xslices; l!=NULL; l=l->next) { 00496 printf("Writing slice x=%d: ", *(int*)(l->data)); 00497 s=NULL; 00498 e=NULL; 00499 write_density_slice(X, (int*)(l->data), d, &s, &e, f, '\t', coord_units, density_units); 00500 if(e!=NULL){ 00501 printf("->%s. FAILED: %s.\n", s, e->message); 00502 }else{ 00503 printf("->%s. done.\n", s); 00504 } 00505 if(s!=NULL) { 00506 g_free(s); 00507 } 00508 } 00509 for(l=args->yslices; l!=NULL; l=l->next) { 00510 printf("Writing slice y=%d: ", *(int*)(l->data)); 00511 s=NULL; 00512 e=NULL; 00513 write_density_slice(Y, (int*)(l->data), d, &s, &e, f, '\t', coord_units, density_units); 00514 if(e!=NULL){ 00515 printf("->%s. FAILED: %s.\n", s, e->message); 00516 }else{ 00517 printf("->%s. done.\n", s); 00518 } 00519 if(s!=NULL) { 00520 g_free(s); 00521 } 00522 } 00523 for(l=args->zslices; l!=NULL; l=l->next) { 00524 printf("Writing slice z=%d: ", *(int*)(l->data)); 00525 s=NULL; 00526 e=NULL; 00527 write_density_slice(Z, (int*)(l->data), d, &s, &e, f, '\t', coord_units, density_units); 00528 if(e!=NULL){ 00529 printf("->%s. FAILED: %s.\n", s, e->message); 00530 }else{ 00531 printf("->%s. done.\n", s); 00532 } 00533 if(s!=NULL) { 00534 g_free(s); 00535 } 00536 } 00537 }