Permalink
Browse files

added funtion for simple output of doubles and integers

  • Loading branch information...
1 parent 499031b commit ed9ecf160855af4d95cc81806d193039b96f05d8 @hannorein committed Apr 30, 2012
Showing with 44 additions and 0 deletions.
  1. +30 −0 src/output.c
  2. +14 −0 src/output.h
View
@@ -336,6 +336,36 @@ void output_append_velocity_dispersion(char* filename){
fclose(of);
}
+int output_logfile_first = 1;
+void output_logfile(char* data){
+ if (output_logfile_first){
+ output_logfile_first = 0;
+ system("rm -fv config.log");
+ }
+ FILE* file = fopen("config.log","a+");
+ fputs(data,file);
+ fclose(file);
+}
+
+void output_double(char* name, double value){
+ char data[2048];
+ if (value>1e7){
+ sprintf(data,"%-35s = %10e\n",name,value);
+ }else{
+ if (fabs(fmod(value,1.))>1e-9){
+ sprintf(data,"%-35s = %20.10f\n",name,value);
+ }else{
+ sprintf(data,"%-35s = %11.1f\n",name,value);
+ }
+ }
+ output_logfile(data);
+}
+void output_int(char* name, int value){
+ char data[2048];
+ sprintf(data,"%-35s = %9d\n",name,value);
+ output_logfile(data);
+}
+
#ifdef OPENGL
#ifdef LIBPNG
unsigned char* imgdata = NULL;
View
@@ -95,6 +95,20 @@ void output_binary_positions(char* filename);
*/
void output_append_velocity_dispersion(char* filename);
+/**
+ * Output a string to the default log file 'config.log'
+ * @param name Description of value
+ * @param value Value to be outputted
+ */
+void output_double(char* name, double value);
+
+/**
+ * Output a string to the default log file 'config.log'
+ * @param name Description of value
+ * @param value Value to be outputted
+ */
+void output_int(char* name, int value);
+
#if defined(OPENGL) && defined(LIBPNG)
/**
* Outputs a screenshot of the current OpenGL view.

0 comments on commit ed9ecf1

Please sign in to comment.