![]() |
ESPResSo 3.2.0-166-g9c4d93d-git
Extensible Simulation Package for Soft Matter Research
|
00001 /* 00002 Copyright (C) 2010,2012,2013 The ESPResSo project 00003 Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 00004 Max-Planck-Institute for Polymer Research, Theory Group 00005 00006 This file is part of ESPResSo. 00007 00008 ESPResSo is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU 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 ESPResSo 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 General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 /** \file parser.c 00022 Implementation of \ref parser.h "parser.h". \ref parse_int_list is too long for inlining. 00023 */ 00024 00025 #include "utils.h" 00026 #include "parser.h" 00027 #include "communication.h" 00028 00029 int parse_int_list(Tcl_Interp *interp, char *list, IntList *il) 00030 { 00031 int i, tmp_argc, res = 1; 00032 char **tmp_argv; 00033 Tcl_SplitList(interp, list, &tmp_argc, &tmp_argv); 00034 realloc_intlist(il, il->n = tmp_argc); 00035 for(i = 0 ; i < tmp_argc; i++) if (Tcl_GetInt(interp, tmp_argv[i], &(il->e[i])) == TCL_ERROR) { res = 0; break; } 00036 Tcl_Free((char *)tmp_argv); 00037 return res; 00038 } 00039 00040 int parse_double_list(Tcl_Interp *interp, char *list, DoubleList *dl) 00041 { 00042 int i, tmp_argc, res = 1; 00043 char **tmp_argv; 00044 Tcl_SplitList(interp, list, &tmp_argc, &tmp_argv); 00045 realloc_doublelist(dl, dl->n = tmp_argc); 00046 for(i = 0 ; i < tmp_argc; i++) if (Tcl_GetDouble(interp, tmp_argv[i], &(dl->e[i])) == TCL_ERROR) { res = 0; break; } 00047 Tcl_Free((char *)tmp_argv); 00048 return res; 00049 } 00050 00051 int gather_runtime_errors(Tcl_Interp *interp, int error_code) 00052 { 00053 char **errors =(char **)malloc(n_nodes*sizeof(char *)); 00054 00055 if (mpi_gather_runtime_errors(errors) == ES_OK) { 00056 free(errors); 00057 return error_code; 00058 } 00059 00060 /* reset any results of the previous command, since we got an error 00061 during evaluation, they are at best bogus. But any normal error 00062 messages should be kept, they might help to track down the 00063 problem. 00064 */ 00065 if (error_code != TCL_ERROR) 00066 Tcl_ResetResult(interp); 00067 else 00068 Tcl_AppendResult(interp, " ", (char *) NULL); 00069 00070 Tcl_AppendResult(interp, "background_errors ", (char *) NULL); 00071 00072 for (int node = 0; node < n_nodes; node++) { 00073 if (errors[node] != NULL) { 00074 char nr_buf[TCL_INTEGER_SPACE + 3]; 00075 sprintf(nr_buf, "%d ", node); 00076 00077 /* check whether it's the same message as from the master, then 00078 just consent */ 00079 if (node > 0 && errors[0] && strcmp(errors[node], errors[0]) == 0) 00080 Tcl_AppendResult(interp, nr_buf, "<consent> ", (char *) NULL); 00081 else 00082 Tcl_AppendResult(interp, nr_buf, errors[node], (char *) NULL); 00083 00084 /* we still need the master nodes error for squashing, see 00085 above */ 00086 if (node > 0) 00087 free(errors[node]); 00088 } 00089 } 00090 00091 free(errors[0]); 00092 free(errors); 00093 00094 return TCL_ERROR; 00095 }
1.7.5.1