aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2012-02-20 17:39:00 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:45 +0100
commitbbc99085a2a438bec805d02116326530d361598b (patch)
treef619b052b15661fa11ee5abf37b96e238c64e869 /src
parentd8014c511c73ee561f49517b234a2795ad749de1 (diff)
Fix output logic
Diffstat (limited to 'src')
-rw-r--r--src/partial_sim.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/partial_sim.c b/src/partial_sim.c
index d6b5fb98..da7566d5 100644
--- a/src/partial_sim.c
+++ b/src/partial_sim.c
@@ -515,29 +515,31 @@ int main(int argc, char *argv[])
}
if ( phist_file != NULL ) {
+
fh = fopen(phist_file, "w");
- } else {
- fh = NULL;
- }
- if ( fh != NULL ) {
- for ( i=0; i<NBINS; i++ ) {
+ if ( fh != NULL ) {
- double rcen;
+ for ( i=0; i<NBINS; i++ ) {
- rcen = i/(double)NBINS*qargs.max_q
- + qargs.max_q/(2.0*NBINS);
- fprintf(fh, "%.2f %7li %.3f %.3f\n", rcen/1.0e9,
- qargs.n_ref[i],
- qargs.p_hist[i]/qargs.n_ref[i],
- qargs.p_max[i]);
+ double rcen;
- }
+ rcen = i/(double)NBINS*qargs.max_q
+ + qargs.max_q/(2.0*NBINS);
+ fprintf(fh, "%.2f %7li %.3f %.3f\n", rcen/1.0e9,
+ qargs.n_ref[i],
+ qargs.p_hist[i]/qargs.n_ref[i],
+ qargs.p_max[i]);
+
+ }
- fclose(fh);
+ fclose(fh);
+
+ } else {
+ ERROR("Failed to open file '%s' for writing.\n",
+ phist_file);
+ }
- } else {
- ERROR("Failed to open file '%s' for writing.\n", phist_file);
}
fclose(ofh);