Skip to content

Commit

Permalink
added funtion for simple output of doubles and integers
Browse files Browse the repository at this point in the history
  • Loading branch information
hannorein committed Apr 30, 2012
1 parent 499031b commit ed9ecf1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/output.c
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions src/output.h
Expand Up @@ -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.
Expand Down

0 comments on commit ed9ecf1

Please sign in to comment.