Index: pcp/src/parsetest.c
===================================================================
--- pcp/src/parsetest.c	(revision a0bcf15381c41adb281e0a5d9293f02515ba70c0)
+++ pcp/src/parsetest.c	(revision a0bcf15381c41adb281e0a5d9293f02515ba70c0)
@@ -0,0 +1,147 @@
+//#include "init.h"
+#include <stdio.h>
+
+enum value_type { string_type, double_type, int_type, grid, lower_trigrid, upper_trigrid};	//!< Specifying the type to be read of a parameter
+
+
+/** Reads parameter from a parsed file.
+ * \warning value is modified (both in contents and position)!
+ * \param file file to be parsed
+ * \param name Name of value in file (at least 3 chars!)
+ * \param xth Which among a number of parameters it is (in grid case it's row number as grid is read as a whole!)
+ * \param yth Only needed in grid case, specifying column number
+ * \param type Type of the Parameter to be read
+ * \param value address of the value to be read (must have been allocated)
+ * \sa ReadMainParameterFile Calling routine
+ */
+int ParseForParameter(FILE *file, const char *const name, int const xth, int const yth, enum value_type type, void *value) {
+	int i,j;	// loop variables
+	int me;
+	long file_position = ftell(file);	// mark current position
+	char *dummy1, *dummy, *free_dummy;		// pointers in the line that is read in per step
+	char *free_parameter, *parameter;	// parameter dummy
+	dummy1 = free_dummy = (char *) malloc(256 * sizeof(char)); //,"ParseForParameter: MemAlloc for dummy1 failed");
+  //MPI_Comm_rank(MPI_COMM_WORLD, &me);
+
+	//fprintf(stderr,"(%i) Parsing for %s\n",me,name);	
+
+	int line = 0;	// marks line where parameter was found
+	int found = 0;	// marks if parameter name was found
+	while((!feof(file)) && (!found)) {
+		dummy1 = dummy = free_dummy;
+		do {
+			fgets(dummy1, 256, file);	// Read the whole line, skips commentary and empty ones
+			line++;
+		} while ((dummy1[0] == '#') || (dummy1[0] == '\n'));
+		if (dummy1 == NULL)
+			fprintf(stderr,"(%i) Error reading line %i\n",me,line);
+		else 
+			//fprintf(stderr,"(%i) Reading next line %i: %s\n",me, line, dummy1);
+		dummy = strchr(dummy1,'\t');	// set dummy on first tab
+		if (dummy == NULL) {
+			dummy = strchr(dummy1, '\n');	// set on line end then (whole line = keyword)
+			//fprintf(stderr,"(%i)Error: Cannot find tabs on line %i in search for %s\n", me, line, name);
+	    //Error(FileOpenParams, NULL);			
+		} else {
+			//fprintf(stderr,"(%i) found tab at %i\n",me,(int)dummy-(int)dummy1);
+		}
+		if ((dummy-dummy1 >= 3) && (strncmp(dummy1, name, strlen(name)) == 0)) {
+			found = 1; // found the parameter!
+			//fprintf(stderr,"(%i) found %s at line %i\n",me, name, line);		
+			
+			for (i=0;i<xth;i++) {	// i = rows
+				if (type >= 3) {
+					// grid structure means, grid begins in the next line, not after keyword
+					dummy1 = dummy = free_dummy;
+					do {
+						fgets(dummy1, 256, file);	// Read the whole line, skips commentary and empty ones
+						line++;
+					} while ((dummy1[0] == '#') || (dummy1[0] == '\n'));
+					if (dummy1 == NULL){
+						fprintf(stderr,"(%i) Error reading line %i\n", me, line);
+					} else {
+						//fprintf(stderr,"(%i) Reading next line %i: %s\n", me, line, dummy1);
+					}
+				} else {
+					while (*dummy == '\t')
+						dummy++;
+				}
+
+				for (j=0;j<yth;j++) { // j = columns
+					// check for lower triangular area and upper triangular area
+					if ( ((i > j) && (type == upper_trigrid)) || ((j > i) && (type == lower_trigrid))) {
+						*((double *)value) = 0.0;
+						fprintf(stderr,"%f\t",*((double *)value));
+						value += sizeof(double);
+					} else {
+						dummy1 = dummy;
+						dummy = strchr(dummy1, '\t');	// seek for tab
+						if (dummy == NULL) {
+							dummy = strchr(dummy1, '\n');	 // at line end then
+							if ((j < yth-1) && (type < 4)) {	// check if xth value or not yet
+								fprintf(stderr,"(%i)Error: EoL at %i and still missing %i values %d for parameter %s\n", me, line, yth-j, name);
+						    //Error(FileOpenParams, NULL);			
+							}
+						} else {
+							//fprintf(stderr,"(%i) found tab at %i\n",me,(int)dummy-(int)free_dummy);
+						}
+						//fprintf(stderr,"(%i) value from %i to %i\n",me,(int)dummy1-(int)free_dummy,(int)dummy-(int)free_dummy);
+						switch(type) { 
+							case(grid):
+							case(lower_trigrid):
+							case(upper_trigrid):
+								*((double *)value) = atof(dummy1);
+								if ((i==0) && (j==0))	fprintf(stderr,"(%i)%s = ",me, name);
+								fprintf(stderr,"%f\t",*((double *)value));
+								value += sizeof(double);
+								break;
+							case(double_type):
+								*((double *)value) = atof(dummy1);
+							  if (i == xth-1) fprintf(stderr,"(%i)%s = %f\n",me, name, *((double *) value));
+								//value += sizeof(double);
+								break;
+							case(int_type):
+								*((int *)value) = atoi(dummy1);
+							  if (i == xth-1) fprintf(stderr,"(%i)%s = %i\n",me, name, *((int *) value));
+								//value += sizeof(int);
+								break;
+							default:
+							case(string_type):
+								strncpy((char *)value, dummy1, dummy-dummy1);
+								fprintf(stderr,"(%i)%s is '%s'\n",me,name,((char *) value));
+								//value += sizeof(char);
+							break;
+						}
+					}
+					while (*dummy == '\t')
+						dummy++;
+				}
+				//fprintf(stderr,"\n");
+			}
+		}
+	}	
+	free(free_dummy);
+	fseek(file, file_position, SEEK_SET);	// rewind to start position
+	//fprintf(stderr, "(%i) End of Parsing\n\n",me);
+	
+	return (found);	// true if found, false if not
+}
+
+int main(int argc, char **argv) {
+
+	FILE *cpiInputFile;
+	if (argc < 1) {
+      printf("Cant't find pseudopot path or file\n");
+      return 255;
+	}
+    cpiInputFile = fopen(argv[1],"r");
+    if (cpiInputFile == NULL) {
+      printf("Cant't find pseudopot path or file\n");
+      return 255;
+    }
+    double test;
+	ParseForParameter(cpiInputFile, NULL, 1, 1, double_type, &test);
+	printf("Parsed Value: %f", test);
+
+	return 1;	
+}
