The FARGO_THORIN code developer's guide
 All Data Structures Files Functions Variables Typedefs Macros
merge.c
Go to the documentation of this file.
1 /** \file merge.c
2 
3 Contains the function that merges the output of different processors.
4 The resulting merged file is undistinguishable from the file that
5 would have been produced by a sequential run.
6 
7 @author THORIN modifications by
8 Ondřej Chrenko <chrenko@sirrah.troja.mff.cuni.cz>, Copyright (C) 2017;
9 original code by Frédéric Masset
10 
11 */
12 
13 #include "fargo.h"
14 
15 void merge (nb) /* #THORIN: new outputs */
16  int nb;
17 {
18  int i,j;
19  char radix[512];
20  char command[1024];
21  boolean gotonext;
22  if (!CPU_Master) return;
23  message ("Merging output files...");
24  for (j = 0; j < 3+(AdvecteLabel == YES); j++) {
25  switch (j) {
26  case 0: strcpy (radix, "dens");
27  break;
28  case 1: strcpy (radix, "vrad");
29  break;
30  case 2: strcpy (radix, "vtheta");
31  break;
32  case 3: strcpy (radix, "label");
33  break;
34  }
35  for (i = 1; i < CPU_Number; i++) {
36  sprintf (command, "cd %s; cat gas%s%d.dat.%05d >> gas%s%d.dat",\
37  OUTPUTDIR, radix, nb, i, radix, nb);
38  system (command);
39  }
40  sprintf (command, "cd %s; rm -f gas%s%d.dat.0*",\
41  OUTPUTDIR, radix, nb);
42  system (command);
43  }
44  gotonext = NO;
45  for (j = 0; j < 9; j++) {
46  switch (j) {
47  case 0:
48  if (Write_Energy) {
49  strcpy (radix, "energy");
50  } else {
51  gotonext = YES;
52  }
53  break;
54  case 1:
55  if (Write_Temperature) {
56  strcpy (radix, "temper");
57  } else {
58  gotonext = YES;
59  }
60  break;
61  case 2:
62  if (Write_Divergence) {
63  strcpy (radix, "divv");
64  } else {
65  gotonext = YES;
66  }
67  break;
68  case 3:
69  if (Write_Qplus) {
70  strcpy (radix, "qplus");
71  } else {
72  gotonext = YES;
73  }
74  break;
75  case 4:
76  if (Write_Qbalance) {
77  strcpy (radix, "qbalance");
78  } else {
79  gotonext = YES;
80  }
81  break;
82  case 5:
83  if (Pebbles) {
84  strcpy (radix, "pebbledens");
85  } else {
86  gotonext = YES;
87  }
88  break;
89  case 6:
90  if (Pebbles) {
91  strcpy (radix, "pebblevrad");
92  } else {
93  gotonext = YES;
94  }
95  break;
96  case 7:
97  if (Pebbles) {
98  strcpy (radix, "pebblevtheta");
99  } else {
100  gotonext = YES;
101  }
102  break;
103  case 8:
104  if (Write_Eta) {
105  strcpy (radix, "eta");
106  } else {
107  gotonext = YES;
108  }
109  break;
110  }
111  if (gotonext) {
112  gotonext = NO;
113  continue;
114  }
115  for (i = 1; i < CPU_Number; i++) {
116  sprintf (command, "cd %s; cat gas%s%d.dat.%05d >> gas%s%d.dat",\
117  OUTPUTDIR, radix, nb, i, radix, nb);
118  system (command);
119  }
120  sprintf (command, "cd %s; rm -f gas%s%d.dat.0*",\
121  OUTPUTDIR, radix, nb);
122  system (command);
123  }
124  message ("done\n");
125  fflush (stdout);
126 }
int CPU_Number
Definition: global.h:2
#define YES
Definition: types.h:46
void message(char *msg)
Definition: LowTasks.c:66
char OUTPUTDIR[512]
Definition: param_noex.h:11
boolean Write_Qplus
Definition: global.h:25
boolean Write_Energy
Definition: global.h:25
void merge(int nb)
Definition: merge.c:15
boolean AdvecteLabel
Definition: global.h:29
#define NO
Definition: types.h:47
boolean Write_Qbalance
Definition: global.h:25
Contains all the include directives requested by the code.
boolean Write_Eta
Definition: global.h:27
boolean Write_Temperature
Definition: global.h:25
boolean CPU_Master
Definition: global.h:3
boolean Write_Divergence
Definition: global.h:25
boolean Pebbles
Definition: global.h:27