Skip to content

Commit d31de82

Browse files
committed
shallow_swap.c writes txt files AND bin files. 16x16 1 Iteration files have been added to ref
1 parent b840d66 commit d31de82

7 files changed

+77
-7
lines changed

shallow_swap.c

+26-7
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,19 @@
3333

3434
#define TRUE 1
3535
#define FALSE 0
36-
#define M 64
37-
#define N 64
36+
#define M 16
37+
#define N 16
3838
#define M_LEN (M + 1)
3939
#define N_LEN (N + 1)
4040
#define SIZE ((M_LEN)*(N_LEN))
41-
#define ITMAX 4000
41+
#define ITMAX 1
4242
#define L_OUT TRUE
4343
#define VAL_OUT TRUE
4444

4545
extern double wtime();
4646
extern void dswap(double **a, double **b);
4747
extern void write_to_file(double *array, int tM, int tN, char *filename);
48+
extern void print_to_file(double *array, int tM, int tN, char *filename);
4849

4950
//! Benchmark weather prediction program for comparing the
5051
//! preformance of current supercomputers. The model is
@@ -363,9 +364,12 @@ int main(int argc, char **argv) {
363364

364365
// Output p, u, v fields and run times.
365366
if(VAL_OUT){
366-
write_to_file(pnew, M_LEN, N_LEN, "p.txt");
367-
write_to_file(unew, M_LEN, N_LEN, "u.txt");
368-
write_to_file(vnew, M_LEN, N_LEN, "v.txt");
367+
write_to_file(pnew, M_LEN, N_LEN, "p.bin");
368+
write_to_file(unew, M_LEN, N_LEN, "u.bin");
369+
write_to_file(vnew, M_LEN, N_LEN, "v.bin");
370+
print_to_file(pnew, M_LEN, N_LEN, "p.txt");
371+
print_to_file(unew, M_LEN, N_LEN, "u.txt");
372+
print_to_file(vnew, M_LEN, N_LEN, "v.txt");
369373
}
370374

371375
if (L_OUT) {
@@ -431,7 +435,7 @@ void dswap(double **pA, double **pB)
431435
*pB = pTemp;
432436
}
433437

434-
void write_to_file(double *array, int tM, int tN, char *filename) {
438+
void print_to_file(double *array, int tM, int tN, char *filename) {
435439
FILE *file = fopen(filename, "w");
436440
if (file == NULL) {
437441
printf("Error opening file %s\n", filename);
@@ -445,3 +449,18 @@ void write_to_file(double *array, int tM, int tN, char *filename) {
445449
}
446450
fclose(file);
447451
}
452+
453+
void write_to_file(double *array, int tM, int tN, char *filename) {
454+
FILE *file = fopen(filename, "wb");
455+
if (file == NULL) {
456+
printf("Error opening file %s\n", filename);
457+
return;
458+
}
459+
for (int i = 0; i < tM; i++) {
460+
for (int j = 0; j < tN; j++) {
461+
fwrite(&array[(i*(tN))+j], sizeof(double), 1, file);
462+
}
463+
fprintf(file, "\n");
464+
}
465+
fclose(file);
466+
}

swm_python/ref/p.16.16.IT1.bin

2.27 KB
Binary file not shown.

swm_python/ref/p.16.16.IT1.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
50007.710629 50006.581433 50003.855314 50001.129195 50000.000000 50001.129196 50003.855315 50006.581434 50007.710629 50006.581433 50003.855314 50001.129195 50000.000000 50001.129196 50003.855316 50006.581434 50007.710629
2+
50006.581433 50005.452238 50002.726119 50000.000000 49998.870804 50000.000000 50002.726119 50005.452238 50006.581433 50005.452237 50002.726118 49999.999999 49998.870804 50000.000001 50002.726120 50005.452239 50006.581433
3+
50003.855314 50002.726119 50000.000000 49997.273881 49996.144685 49997.273881 50000.000000 50002.726119 50003.855314 50002.726118 49999.999999 49997.273880 49996.144685 49997.273882 50000.000001 50002.726120 50003.855314
4+
50001.129195 50000.000000 49997.273881 49994.547762 49993.418566 49994.547762 49997.273881 50000.000000 50001.129195 49999.999999 49997.273880 49994.547761 49993.418566 49994.547763 49997.273882 50000.000001 50001.129195
5+
50000.000000 49998.870804 49996.144685 49993.418566 49992.289371 49993.418567 49996.144686 49998.870805 50000.000000 49998.870804 49996.144685 49993.418566 49992.289371 49993.418567 49996.144687 49998.870805 50000.000000
6+
50001.129196 50000.000000 49997.273881 49994.547762 49993.418567 49994.547763 49997.273882 50000.000001 50001.129196 50000.000000 49997.273880 49994.547762 49993.418567 49994.547763 49997.273882 50000.000001 50001.129196
7+
50003.855315 50002.726119 50000.000000 49997.273881 49996.144686 49997.273882 50000.000001 50002.726120 50003.855315 50002.726119 50000.000000 49997.273881 49996.144686 49997.273882 50000.000002 50002.726120 50003.855315
8+
50006.581434 50005.452238 50002.726119 50000.000000 49998.870805 50000.000001 50002.726120 50005.452239 50006.581434 50005.452238 50002.726119 50000.000000 49998.870805 50000.000001 50002.726121 50005.452239 50006.581434
9+
50007.710629 50006.581433 50003.855314 50001.129195 50000.000000 50001.129196 50003.855315 50006.581434 50007.710629 50006.581433 50003.855314 50001.129195 50000.000000 50001.129196 50003.855316 50006.581434 50007.710629
10+
50006.581433 50005.452237 50002.726118 49999.999999 49998.870804 50000.000000 50002.726119 50005.452238 50006.581433 50005.452237 50002.726118 49999.999999 49998.870804 50000.000000 50002.726120 50005.452238 50006.581433
11+
50003.855314 50002.726118 49999.999999 49997.273880 49996.144685 49997.273880 50000.000000 50002.726119 50003.855314 50002.726118 49999.999998 49997.273880 49996.144685 49997.273881 50000.000000 50002.726119 50003.855314
12+
50001.129195 49999.999999 49997.273880 49994.547761 49993.418566 49994.547762 49997.273881 50000.000000 50001.129195 49999.999999 49997.273880 49994.547761 49993.418566 49994.547762 49997.273882 50000.000000 50001.129195
13+
50000.000000 49998.870804 49996.144685 49993.418566 49992.289371 49993.418567 49996.144686 49998.870805 50000.000000 49998.870804 49996.144685 49993.418566 49992.289371 49993.418567 49996.144687 49998.870805 50000.000000
14+
50001.129196 50000.000001 49997.273882 49994.547763 49993.418567 49994.547763 49997.273882 50000.000001 50001.129196 50000.000000 49997.273881 49994.547762 49993.418567 49994.547764 49997.273883 50000.000002 50001.129196
15+
50003.855316 50002.726120 50000.000001 49997.273882 49996.144687 49997.273882 50000.000002 50002.726121 50003.855316 50002.726120 50000.000000 49997.273882 49996.144687 49997.273883 50000.000002 50002.726121 50003.855316
16+
50006.581434 50005.452239 50002.726120 50000.000001 49998.870805 50000.000001 50002.726120 50005.452239 50006.581434 50005.452238 50002.726119 50000.000000 49998.870805 50000.000002 50002.726121 50005.452240 50006.581434
17+
50007.710629 50006.581433 50003.855314 50001.129195 50000.000000 50001.129196 50003.855315 50006.581434 50007.710629 50006.581433 50003.855314 50001.129195 50000.000000 50001.129196 50003.855316 50006.581434 50007.710629

swm_python/ref/u.16.16.IT1.bin

2.27 KB
Binary file not shown.

swm_python/ref/u.16.16.IT1.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-0.705031 -0.538253 -0.291301 0.000000 0.291301 0.538254 0.703262 0.761205 0.703262 0.538253 0.291301 -0.000000 -0.291301 -0.538254 -0.703262 -0.761205 -0.703262
2+
-2.002719 -1.532815 -0.829553 0.000000 0.829554 1.532815 2.002719 2.167728 2.002719 1.532815 0.829553 -0.000000 -0.829554 -1.532815 -2.002719 -2.167728 -2.002719
3+
-2.997281 -2.294020 -1.241514 0.000000 1.241515 2.294020 2.997281 3.244234 2.997281 2.294019 1.241514 -0.000000 -1.241515 -2.294020 -2.997281 -3.244234 -2.997281
4+
-3.535534 -2.705981 -1.464466 0.000000 1.464466 2.705981 3.535534 3.826834 3.535534 2.705980 1.464466 -0.000001 -1.464467 -2.705981 -3.535534 -3.826834 -3.535534
5+
-3.535534 -2.705980 -1.464466 0.000000 1.464466 2.705981 3.535534 3.826834 3.535534 2.705980 1.464466 -0.000001 -1.464467 -2.705981 -3.535534 -3.826834 -3.535534
6+
-2.997281 -2.294019 -1.241514 0.000000 1.241515 2.294020 2.997281 3.244233 2.997281 2.294019 1.241514 -0.000000 -1.241515 -2.294020 -2.997281 -3.244233 -2.997281
7+
-2.002719 -1.532815 -0.829553 0.000000 0.829553 1.532815 2.002719 2.167727 2.002719 1.532815 0.829553 -0.000000 -0.829554 -1.532815 -2.002719 -2.167727 -2.002719
8+
-0.703261 -0.538253 -0.291300 0.000000 0.291300 0.538253 0.703261 0.761204 0.703261 0.538253 0.291300 -0.000000 -0.291300 -0.538253 -0.703261 -0.761204 -0.703261
9+
0.703262 0.538253 0.291301 -0.000000 -0.291301 -0.538253 -0.703262 -0.761205 -0.703262 -0.538253 -0.291300 0.000000 0.291301 0.538253 0.703262 0.761205 0.703262
10+
2.002719 1.532815 0.829553 -0.000000 -0.829554 -1.532815 -2.002720 -2.167728 -2.002719 -1.532815 -0.829553 0.000000 0.829554 1.532815 2.002720 2.167728 2.002719
11+
2.997281 2.294020 1.241514 -0.000000 -1.241515 -2.294020 -2.997281 -3.244234 -2.997281 -2.294019 -1.241514 0.000000 1.241515 2.294020 2.997281 3.244234 2.997281
12+
3.535534 2.705981 1.464466 -0.000000 -1.464466 -2.705981 -3.535534 -3.826835 -3.535534 -2.705980 -1.464466 0.000001 1.464467 2.705981 3.535534 3.826835 3.535534
13+
3.535534 2.705980 1.464466 -0.000000 -1.464466 -2.705981 -3.535534 -3.826834 -3.535534 -2.705980 -1.464466 0.000001 1.464467 2.705981 3.535534 3.826834 3.535534
14+
2.997281 2.294019 1.241514 -0.000000 -1.241514 -2.294019 -2.997281 -3.244233 -2.997281 -2.294019 -1.241514 0.000000 1.241515 2.294020 2.997281 3.244233 2.997281
15+
2.002719 1.532814 0.829553 -0.000000 -0.829553 -1.532815 -2.002719 -2.167727 -2.002719 -1.532814 -0.829553 0.000000 0.829554 1.532815 2.002719 2.167727 2.002719
16+
0.703261 0.538253 0.291300 -0.000000 -0.291300 -0.538253 -0.703261 -0.761204 -0.703261 -0.538252 -0.291300 0.000000 0.291300 0.538253 0.703261 0.761204 0.703261
17+
-0.703262 -0.538253 -0.291301 0.000000 0.291301 0.538254 0.703262 0.761205 0.703262 0.538253 0.291301 -0.000000 -0.291301 -0.538254 -0.703262 -0.761205 -0.703262

swm_python/ref/v.16.16.IT1.bin

2.27 KB
Binary file not shown.

swm_python/ref/v.16.16.IT1.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
0.701346 2.002719 2.997281 3.535534 3.535534 2.997281 2.002719 0.703261 -0.703262 -2.002719 -2.997281 -3.535534 -3.535534 -2.997281 -2.002719 -0.703261 0.703262
2+
0.538253 1.532815 2.294020 2.705981 2.705980 2.294019 1.532815 0.538253 -0.538253 -1.532815 -2.294020 -2.705981 -2.705980 -2.294019 -1.532814 -0.538253 0.538253
3+
0.291301 0.829553 1.241514 1.464466 1.464466 1.241514 0.829553 0.291300 -0.291301 -0.829553 -1.241514 -1.464466 -1.464466 -1.241514 -0.829553 -0.291300 0.291301
4+
-0.000000 -0.000000 -0.000000 -0.000000 -0.000000 -0.000000 -0.000000 -0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.000000
5+
-0.291301 -0.829554 -1.241515 -1.464466 -1.464466 -1.241515 -0.829553 -0.291300 0.291301 0.829554 1.241515 1.464466 1.464466 1.241514 0.829553 0.291300 -0.291301
6+
-0.538254 -1.532815 -2.294020 -2.705981 -2.705981 -2.294020 -1.532815 -0.538253 0.538253 1.532815 2.294020 2.705981 2.705981 2.294019 1.532815 0.538253 -0.538254
7+
-0.703262 -2.002719 -2.997281 -3.535534 -3.535534 -2.997281 -2.002719 -0.703261 0.703262 2.002720 2.997281 3.535534 3.535534 2.997281 2.002719 0.703261 -0.703262
8+
-0.761205 -2.167728 -3.244234 -3.826834 -3.826834 -3.244233 -2.167727 -0.761204 0.761205 2.167728 3.244234 3.826835 3.826834 3.244233 2.167727 0.761204 -0.761205
9+
-0.703262 -2.002719 -2.997281 -3.535534 -3.535534 -2.997281 -2.002719 -0.703261 0.703262 2.002719 2.997281 3.535534 3.535534 2.997281 2.002719 0.703261 -0.703262
10+
-0.538253 -1.532815 -2.294019 -2.705980 -2.705980 -2.294019 -1.532815 -0.538253 0.538253 1.532815 2.294019 2.705980 2.705980 2.294019 1.532814 0.538252 -0.538253
11+
-0.291301 -0.829553 -1.241514 -1.464466 -1.464466 -1.241514 -0.829553 -0.291300 0.291300 0.829553 1.241514 1.464466 1.464466 1.241514 0.829553 0.291300 -0.291301
12+
0.000000 0.000000 0.000000 0.000001 0.000001 0.000000 0.000000 0.000000 -0.000000 -0.000000 -0.000000 -0.000001 -0.000001 -0.000000 -0.000000 -0.000000 0.000000
13+
0.291301 0.829554 1.241515 1.464467 1.464467 1.241515 0.829554 0.291300 -0.291301 -0.829554 -1.241515 -1.464467 -1.464467 -1.241515 -0.829554 -0.291300 0.291301
14+
0.538254 1.532815 2.294020 2.705981 2.705981 2.294020 1.532815 0.538253 -0.538253 -1.532815 -2.294020 -2.705981 -2.705981 -2.294020 -1.532815 -0.538253 0.538254
15+
0.703262 2.002719 2.997281 3.535534 3.535534 2.997281 2.002719 0.703261 -0.703262 -2.002720 -2.997281 -3.535534 -3.535534 -2.997281 -2.002719 -0.703261 0.703262
16+
0.761205 2.167728 3.244234 3.826834 3.826834 3.244233 2.167727 0.761204 -0.761205 -2.167728 -3.244234 -3.826835 -3.826834 -3.244233 -2.167727 -0.761204 0.761205
17+
0.703262 2.002719 2.997281 3.535534 3.535534 2.997281 2.002719 0.703261 -0.703262 -2.002719 -2.997281 -3.535534 -3.535534 -2.997281 -2.002719 -0.703261 0.703262

0 commit comments

Comments
 (0)