-
Notifications
You must be signed in to change notification settings - Fork 7
/
dump.c
1741 lines (1207 loc) · 45.8 KB
/
dump.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "decs.h"
// mpi.h has following datatypes corresponding to the C types
// pick one per dump file. (no per column types yet)
// same for image.c
// same for restart.c
/*
#define MPI_CHAR ((MPI_Datatype)1)
#define MPI_UNSIGNED_CHAR ((MPI_Datatype)2)
#define MPI_BYTE ((MPI_Datatype)3)
#define MPI_SHORT ((MPI_Datatype)4)
#define MPI_UNSIGNED_SHORT ((MPI_Datatype)5)
#define MPI_INT ((MPI_Datatype)6)
#define MPI_UNSIGNED ((MPI_Datatype)7)
#define MPI_LONG ((MPI_Datatype)8)
#define MPI_UNSIGNED_LONG ((MPI_Datatype)9)
#define MPI_FLOAT ((MPI_Datatype)10)
#define MPI_DOUBLE ((MPI_Datatype)11)
#define MPI_LONG_DOUBLE ((MPI_Datatype)12)
#define MPI_LONG_LONG_INT ((MPI_Datatype)13)
*/
/* Follow these steps to create a new dump file
1) defs.???.h: create the storage variable if needed
2) set_array???.c : shift variable if necessary (follow examples)
3) global.nondepmnemonics.h : change NUMDUMPTYPES and add label and add to MYDUMPNAMELIST
4) global.???.h change NUMDUMPTYPES and add another entry if want separate timing of output
5) dump.c : add dnumcolumns[LABEL]=NUMCOLUMNS where NUMCOLUMNS is number of entries in dump file
6) dump.c : follow examples from here (dump() uses dump_header() and dump_content()). One must define the header and content function and the wrapper (3 functions) or use an existing header function
7) diag.c : follow example of "dump", dumpc, tlastdump, etc.
8) init.c : DTdumpgen, dumpcntgen, and other things.
9) global.dump.h : add global prototypes
*/
int init_dumps(void)
{
trifprintf("begin: init_dumps\n");
///////////////////////////
//
// Output nprlist information to SM-readable file
//
///////////////////////////
output_nprlist_info();
///////////////////////////
//
// setup number of columns per dump file
// (see dumpgen.c or dump.c for how used)
//
///////////////////////////
init_dnumcolumns_dnumversion();
if(mpicombine==1 && mpicombinetype==MPICOMBINEMINMEM){
///////////////////////////
//
// setup link list (only used for MINMEM method)
//
///////////////////////////
init_linklists();
}
trifprintf("end: init_dumps\n");
return(0);
}
void output_nprlist_info(void)
{
int pliter,pl;
int numversion;
int numlines;
FILE *out;
// only CPU=0
if(myid==0){
out=fopen("nprlistinfo.dat","wt");
if(out==NULL){
dualfprintf(fail_file,"Couldn't open nprlistinfo.dat\n");
myexit(12358235);
}
numlines=7;
numversion=0; // version number of this file
myfprintf(out,"%d %d\n",numlines,numversion);
// NPR: (conserved quantities: U0-U? in SM)
PLOOP(pliter,pl){
myfprintf(out,"%d ",pl);
}
if(pliter==0) myfprintf(out,"-1"); // nothing in this list
myfprintf(out,"\n");
// NPR2INTERP:
PINTERPLOOP(pliter,pl){
myfprintf(out,"%d ",pl);
}
if(pliter==0) myfprintf(out,"-1"); // nothing in this list
myfprintf(out,"\n");
// NPR2NOTINTERP:
PNOTINTERPLOOP(pliter,pl){
myfprintf(out,"%d ",pl);
}
if(pliter==0) myfprintf(out,"-1"); // nothing in this list
myfprintf(out,"\n");
// NPRBOUND:
PBOUNDLOOP(pliter,pl){
myfprintf(out,"%d ",pl);
}
if(pliter==0) myfprintf(out,"-1"); // nothing in this list
myfprintf(out,"\n");
// NPRFLUXBOUND:
PFLUXBOUNDLOOP(pliter,pl){
myfprintf(out,"%d ",pl);
}
if(pliter==0) myfprintf(out,"-1"); // nothing in this list
myfprintf(out,"\n");
// NPRDUMP:
PDUMPLOOP(pliter,pl){
myfprintf(out,"%d ",pl);
}
if(pliter==0) myfprintf(out,"-1"); // nothing in this list
myfprintf(out,"\n");
// NPRINVERT:
PINVERTLOOP(pliter,pl){
myfprintf(out,"%d ",pl);
}
if(pliter==0) myfprintf(out,"-1"); // nothing in this list
myfprintf(out,"\n");
fclose(out);
}// end if CPU==0
}
// setup number of columns per dump file (see dumpgen.c or dump.c for how used)
void init_dnumcolumns_dnumversion(void)
{
char tempdumpnamelist[NUMDUMPTYPES][MAXFILENAME]=MYDUMPNAMELIST;
int i;
extern void set_image_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_dump_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_gdump_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_avg_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_avg2_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_debug_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_enodebug_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_fieldline_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_dissdump_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_dumpother_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_fluxdump_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_eosdump_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_vpotdump_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_failfloordudump_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_rupperpoledump_read_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_rupperpoledump_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_rdump_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_rmetricdump_read_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
extern void set_rmetricdump_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion);
// assign local to global -- do this since global not easily assigned to value with defs and decs approach
int dumpiter;
for(dumpiter=0;dumpiter<NUMDUMPTYPES;dumpiter++){
strcpy(dumpnamelist[dumpiter],tempdumpnamelist[dumpiter]);
}
// always numcolumns=0 for fake dump
// version=0 shouldn't matter for fake dump
dnumcolumns[FAKEDUMPTYPE]=0; dnumversion[FAKEDUMPTYPE]=0;
// image
set_image_content_dnumcolumns_dnumversion(&dnumcolumns[IMAGEDUMPTYPE],&dnumversion[IMAGEDUMPTYPE]);
// dump
set_dump_content_dnumcolumns_dnumversion(&dnumcolumns[MAINDUMPTYPE],&dnumversion[MAINDUMPTYPE]);
// gdump
set_gdump_content_dnumcolumns_dnumversion(&dnumcolumns[GRIDDUMPTYPE],&dnumversion[GRIDDUMPTYPE]);
// avg
set_avg_content_dnumcolumns_dnumversion(&dnumcolumns[AVG1DUMPTYPE],&dnumversion[AVG1DUMPTYPE]);
// avg2
set_avg2_content_dnumcolumns_dnumversion(&dnumcolumns[AVG2DUMPTYPE],&dnumversion[AVG2DUMPTYPE]);
// debug
set_debug_content_dnumcolumns_dnumversion(&dnumcolumns[DEBUGDUMPTYPE],&dnumversion[DEBUGDUMPTYPE]);
// enodebug
set_enodebug_content_dnumcolumns_dnumversion(&dnumcolumns[ENODEBUGDUMPTYPE],&dnumversion[ENODEBUGDUMPTYPE]);
// fieldline
set_fieldline_content_dnumcolumns_dnumversion(&dnumcolumns[FIELDLINEDUMPTYPE],&dnumversion[FIELDLINEDUMPTYPE]);
// dissdump
set_dissdump_content_dnumcolumns_dnumversion(&dnumcolumns[DISSDUMPTYPE],&dnumversion[DISSDUMPTYPE]);
// dumpother
set_dumpother_content_dnumcolumns_dnumversion(&dnumcolumns[OTHERDUMPTYPE],&dnumversion[OTHERDUMPTYPE]);
// fluxdump
set_fluxdump_content_dnumcolumns_dnumversion(&dnumcolumns[FLUXDUMPTYPE],&dnumversion[FLUXDUMPTYPE]);
// eosdump
set_eosdump_content_dnumcolumns_dnumversion(&dnumcolumns[EOSDUMPTYPE],&dnumversion[EOSDUMPTYPE]);
// vpotdump
set_vpotdump_content_dnumcolumns_dnumversion(&dnumcolumns[VPOTDUMPTYPE],&dnumversion[VPOTDUMPTYPE]);
// failfloordudump
set_failfloordudump_content_dnumcolumns_dnumversion(&dnumcolumns[FAILFLOORDUDUMPTYPE],&dnumversion[FAILFLOORDUDUMPTYPE]);
// rdump (must come after all normal dumps since dnumcolumns used by restart to store other things needed up restart that are dealt with also above)
// rupperpoledump
set_rupperpoledump_content_dnumcolumns_dnumversion(&dnumcolumns[RESTARTUPPERPOLEDUMPTYPE],&dnumversion[RESTARTUPPERPOLEDUMPTYPE]);
set_rdump_content_dnumcolumns_dnumversion(&dnumcolumns[RESTARTDUMPTYPE],&dnumversion[RESTARTDUMPTYPE]);
// rmetricdump
set_rmetricdump_content_dnumcolumns_dnumversion(&dnumcolumns[RESTARTMETRICDUMPTYPE],&dnumversion[RESTARTMETRICDUMPTYPE]);
trifprintf("dump number of columns(see global.nondepmnemonics.h)\n");
for(i=0;i<NUMDUMPTYPES;i++){
trifprintf("%s dnumcolumns[%d]=%d\n",dumpnamelist[i],i,dnumcolumns[i]);
}
trifprintf("\n");
}
int dump(long dump_cnt)
{
MPI_Datatype datatype;
int whichdump;
char fileprefix[MAXFILENAME];
char filesuffix[MAXFILENAME];
char fileformat[MAXFILENAME];
trifprintf("begin dumping dump# %ld ... ",dump_cnt);
whichdump=MAINDUMPTYPE;
datatype=MPI_FTYPE;
strcpy(fileprefix,"dumps/dump");
strcpy(fileformat,"%04ld"); //atch adjust dump every substep
strcpy(filesuffix,"");
if(dump_gen(WRITEFILE,dump_cnt,binaryoutput,whichdump,datatype,fileprefix,fileformat,filesuffix,dump_header,dump_content)>=1) return(1);
/////// output the symmetry information to the fail file
//writesyminfo();
///////
trifprintf("end dumping dump# %ld ... ",dump_cnt);
return(0);
}
/////// output the symmetry information to the fail file; symmetrizes w.r.t. i == j
void writesyminfo( void )
{
int i, j;
for( i = 0; i < N1; i++ ) {
}
}
int dump_header(int whichdump, int whichdumpversion, int numcolumns, int bintxt, FILE *headerptr)
{
int dump_header_general(int whichdump, int whichdumpversion, int numcolumns, long localrealnstep, SFTYPE localdt, int bintxt, FILE *headerptr);
int retval;
retval=dump_header_general(whichdump, whichdumpversion, numcolumns, realnstep,dt, bintxt, headerptr);
return(retval);
}
int fluxdump_header(int whichdump, int whichdumpversion, int numcolumns, int bintxt, FILE *headerptr)
{
int dump_header_general(int whichdump, int whichdumpversion, int numcolumns, long localrealnstep, SFTYPE localdt, int bintxt, FILE *headerptr);
int retval;
retval=dump_header_general(whichdump, whichdumpversion, numcolumns, fluxdumprealnstep,fluxdumpdt, bintxt, headerptr);
return(retval);
}
int dump_header_general(int whichdump, int whichdumpversion, int numcolumns, long localrealnstep, SFTYPE localdt, int bintxt, FILE *headerptr)
{
int realtotalsize[NDIM];
FTYPE realstartx[NDIM];
FTYPE X[NDIM];
int is,ie,js,je,ks,ke;
// set computational domain for output header
is=Uconsevolveloop[FIS]+SHIFTX1DN;
ie=Uconsevolveloop[FIE]+SHIFTX1UP;
js=Uconsevolveloop[FJS]+SHIFTX2DN;
je=Uconsevolveloop[FJE]+SHIFTX2UP;
ks=Uconsevolveloop[FKS]+SHIFTX3DN;
ke=Uconsevolveloop[FKE]+SHIFTX3UP;
// get real startx's (assumes rectangular grid)
realtotalsize[1]=totalsize[1]+2*EXTRADUMP1;
if(EXTRADUMP1!=0){
coord(0-EXTRADUMP1,0,0,FACE1,X);
realstartx[1]=X[1];
}
else realstartx[1]=startx[1];
realtotalsize[2]=totalsize[2]+2*EXTRADUMP2;
if(EXTRADUMP2!=0){
coord(0,0-EXTRADUMP2,0,FACE2,X);
realstartx[2]=X[2];
}
else realstartx[2]=startx[2];
realtotalsize[3]=totalsize[3]+2*EXTRADUMP3;
if(EXTRADUMP3!=0){
coord(0,0,0-EXTRADUMP3,FACE3,X);
realstartx[3]=X[3];
}
else realstartx[3]=startx[3];
// dx is the same (constant)
// 15+3=18 elements total
if(bintxt==BINARYOUTPUT){
fwrite(&tsteppartf,sizeof(FTYPE),1,headerptr);
fwrite(&realtotalsize[1],sizeof(int),1,headerptr);
fwrite(&realtotalsize[2],sizeof(int),1,headerptr);
fwrite(&realtotalsize[3],sizeof(int),1,headerptr);
fwrite(&realstartx[1],sizeof(FTYPE),1,headerptr);
fwrite(&realstartx[2],sizeof(FTYPE),1,headerptr);
fwrite(&realstartx[3],sizeof(FTYPE),1,headerptr);
fwrite(&dx[1],sizeof(FTYPE),1,headerptr);
fwrite(&dx[2],sizeof(FTYPE),1,headerptr);
fwrite(&dx[3],sizeof(FTYPE),1,headerptr);
fwrite(&localrealnstep,sizeof(long),1,headerptr);
fwrite(&gam,sizeof(FTYPE),1,headerptr);
fwrite(&a,sizeof(FTYPE),1,headerptr);
fwrite(&R0,sizeof(FTYPE),1,headerptr);
fwrite(&Rin,sizeof(FTYPE),1,headerptr);
fwrite(&Rout,sizeof(FTYPE),1,headerptr);
fwrite(&hslope,sizeof(FTYPE),1,headerptr);
fwrite(&localdt,sizeof(FTYPE),1,headerptr);
fwrite(&defcoord,sizeof(int),1,headerptr);
fwrite(&MBH,sizeof(FTYPE),1,headerptr);
fwrite(&QBH,sizeof(FTYPE),1,headerptr);
fwrite(&EP3,sizeof(FTYPE),1,headerptr);
fwrite(&THETAROT,sizeof(FTYPE),1,headerptr);
fwrite(&is,sizeof(int),1,headerptr);
fwrite(&ie,sizeof(int),1,headerptr);
fwrite(&js,sizeof(int),1,headerptr);
fwrite(&je,sizeof(int),1,headerptr);
fwrite(&ks,sizeof(int),1,headerptr);
fwrite(&ke,sizeof(int),1,headerptr);
fwrite(&whichdump,sizeof(int),1,headerptr);
fwrite(&whichdumpversion,sizeof(int),1,headerptr);
fwrite(&numcolumns,sizeof(int),1,headerptr);
}
else{
#if(REALTYPE==DOUBLETYPE)
fprintf(headerptr, "%21.15g %d %d %d %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %ld %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %d %21.15g %21.15g %21.15g %21.15g %d %d %d %d %d %d %d %d %d\n", tsteppartf, realtotalsize[1], realtotalsize[2], realtotalsize[3], realstartx[1], realstartx[2], realstartx[3], dx[1], dx[2], dx[3], localrealnstep,gam,a,R0,Rin,Rout,hslope,localdt,defcoord,MBH,QBH,EP3,THETAROT,is,ie,js,je,ks,ke,whichdump,whichdumpversion,numcolumns);
#elif(REALTYPE==LONGDOUBLETYPE)
fprintf(headerptr, "%31.25Lg %d %d %d %31.25Lg %31.25Lg %31.25Lg %31.25Lg %31.25Lg %31.25Lg %ld %31.25Lg %31.25Lg %31.25Lg %31.25Lg %31.25Lg %31.25Lg %31.25Lg %d %31.25Lg %31.25Lg %31.25Lg %31.25Lg %d %d %d %d %d %d %d %d %d\n", tsteppartf, realtotalsize[1], realtotalsize[2], realtotalsize[3], realstartx[1], realstartx[2], realstartx[3], dx[1], dx[2],dx[3],localrealnstep,gam,a,R0,Rin,Rout,hslope,localdt,defcoord,MBH,QBH,EP3,THETAROT,is,ie,js,je,ks,ke,whichdump,whichdumpversion,numcolumns);
#endif
}
fflush(headerptr);
return(0);
}
// number of columns for dump file
void set_dump_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion)
{
// always NPRDUMP
if(GAMMIEDUMP) *numcolumns=2*3 + NPRDUMP+NPR + 3 + 1 + NDIM * NDIM + 6 + 1
#if(CALCFARADAYANDCURRENTS)
+ NDIM*2
+ 2*6
#endif
;
else{
*numcolumns=3*3 + NPRDUMP + 3 + (nprend+1) + 1 + NDIM * NDIM + 6 + 1 //replace NPR -> (nprend+1) since nprend, not NPR, controls dumping. Fixes: DOEXTRAINTERP=1 case
#if(CALCFARADAYANDCURRENTS)
+ NDIM*2
+ 2*6
#endif
; // 61 total if also doing currents and faraday, 41 otherwise
if(FLUXB==FLUXCTSTAG && 0){ // DEBUG (change corresponding code in dump.c)
*numcolumns+= NPR2INTERP*COMPDIM*2 + NPR + COMPDIM*3*2 + COMPDIM*3*2*2;
}
}
// Version number:
*numversion=0;
}
int dump_content(int i, int j, int k, MPI_Datatype datatype,void *writebuf)
{
int pl,pliter;
FTYPE r, th, vmin[NDIM], vmax[NDIM];
int ignorecourant;
struct of_state qdontuse;
struct of_state *qptr=&qdontuse;
FTYPE X[NDIM],V[NDIM];
FTYPE divb;
FTYPE b[NDIM],ucon[NDIM];
FTYPE U[NPR];
FTYPE ftemp;
FTYPE jcov[NDIM];
FTYPE fcov[NUMFARADAY];
FTYPE rho,u,pressure,cs2,Sden;
int dir,l,m,n,o;
struct of_geom geomdontuse;
struct of_geom *ptrgeom=&geomdontuse;
int loc=CENT;
//////////////
//
// some calculations
//
bl_coord_ijk_2(i, j, k, loc, X,V);
// if failed, then data output for below invalid, but columns still must exist
get_geometry(i, j, k, loc, ptrgeom);
if (!failed) {
if (get_state(GLOBALMAC(pdump,i,j,k), ptrgeom, qptr) >= 1)
FAILSTATEMENT("dump.c:dump()", "get_state() dir=0", 1);
if (vchar(GLOBALMAC(pdump,i,j,k), qptr, 1, ptrgeom, &vmax[1], &vmin[1],&ignorecourant) >= 1)
FAILSTATEMENT("dump.c:dump()", "vchar() dir=1or2", 1);
if (vchar(GLOBALMAC(pdump,i,j,k), qptr, 2, ptrgeom, &vmax[2], &vmin[2],&ignorecourant) >= 1)
FAILSTATEMENT("dump.c:dump()", "vchar() dir=1or2", 2);
if (vchar(GLOBALMAC(pdump,i,j,k), qptr, 3, ptrgeom, &vmax[3], &vmin[3],&ignorecourant) >= 1)
FAILSTATEMENT("dump.c:dump()", "vchar() dir=1or2", 3);
}
else {// do a per zone check, otherwise set to 0
whocalleducon=1; // force no failure mode, just return like failure, and don't return if failure, just set to 0 and continue
if (get_state(GLOBALMAC(pdump,i,j,k), ptrgeom, qptr) >= 1){
for (pl = 0; pl < NDIM; pl++)
qptr->ucon[pl]=0;
for (pl = 0; pl < NDIM; pl++)
qptr->ucov[pl]=0;
for (pl = 0; pl < NDIM; pl++)
qptr->bcon[pl]=0;
for (pl = 0; pl < NDIM; pl++)
qptr->bcov[pl]=0;
}
if (vchar(GLOBALMAC(pdump,i,j,k), qptr, 1, ptrgeom, &vmax[1], &vmin[1],&ignorecourant) >= 1){
vmax[1]=vmin[1]=0;
}
if (vchar(GLOBALMAC(pdump,i,j,k), qptr, 2, ptrgeom, &vmax[2], &vmin[2],&ignorecourant) >= 1){
vmax[2]=vmin[2]=0;
}
if (vchar(GLOBALMAC(pdump,i,j,k), qptr, 3, ptrgeom, &vmax[3], &vmin[3],&ignorecourant) >= 1){
vmax[3]=vmin[3]=0;
}
whocalleducon=0; // return to normal state
}
// GODMARK: use of globals: Ok for dumps since probably always globally dumped, not dumped per section computed or something similar
setfdivb(&divb, GLOBALPOINT(pdump), GLOBALPOINT(pstagdump), GLOBALPOINT(udump), GLOBALPOINT(Bhatdump), i, j, k); // udump also set externally GODMARK
//////////////////////////
//
// do the assignments
//
// if you change # of outputted vars, remember to change numcolumns
//static
if(!GAMMIEDUMP){
ftemp=(FTYPE)(i+startpos[1]);
myset(datatype,&ftemp,0,1,writebuf); //ti
ftemp=(FTYPE)(j+startpos[2]);
myset(datatype,&ftemp,0,1,writebuf); //tj
ftemp=(FTYPE)(k+startpos[3]);
myset(datatype,&ftemp,0,1,writebuf); //tk
}
myset(datatype,X,1,3,writebuf); //x1, x2, x3
myset(datatype,V,1,3,writebuf); //r, h, ph
// 9
////////////////////////
//
// rest dynamic
// primitives
// must use PDUMPLOOP() since may be any order unlike NPR loop
PDUMPLOOP(pliter,pl) myset(datatype,&(GLOBALMACP0A1(pdump,i,j,k,pl)),0,1,writebuf); // NPRDUMP //rho u v1 v2 v3 B1 B2 B3 ??
////////////
//
// output some EOS stuff since in general not simple function of rho0,u
rho = GLOBALMACP0A1(pdump,i,j,k,RHO);
u = GLOBALMACP0A1(pdump,i,j,k,UU);
pressure = pressure_rho0_u_simple(i,j,k,loc,rho,u);
cs2 = cs2_compute_simple(i,j,k,loc,rho,u);
Sden = compute_entropy_simple(i,j,k,loc,rho,u);
myset(datatype,&pressure,0,1,writebuf); // 1 //p
myset(datatype,&cs2,0,1,writebuf); // 1 //cs2
myset(datatype,&Sden,0,1,writebuf); // 1 //Sden
//////////////////////
//
// output the conserved quantities since not easily inverted and at higher order aren't invertable from point primitives
// PLOOP() used since conserved quantities always fill full PLOOP, while PDUMPLOOP is for primitives that may be duplicate among conserved quantities
PLOOP(pliter,pl) myset(datatype,&(GLOBALMACP0A1(udump,i,j,k,pl)),0,1,writebuf); // NPR //U0 U1 U2 U3 U4 U5 U6 U7 ??
myset(datatype,&divb,0,1,writebuf); // 1 //divb
for (pl = 0; pl < NDIM; pl++)
myset(datatype,&(qptr->ucon[pl]),0,1,writebuf); //uu0 uu1 uu2 uu3
for (pl = 0; pl < NDIM; pl++)
myset(datatype,&(qptr->ucov[pl]),0,1,writebuf); //ud0 ud1 ud2 ud3
for (pl = 0; pl < NDIM; pl++)
myset(datatype,&(qptr->bcon[pl]),0,1,writebuf); //bu0 bu1 bu2 bu3
for (pl = 0; pl < NDIM; pl++)
myset(datatype,&(qptr->bcov[pl]),0,1,writebuf); //bd0 bd1 bd2 bd3
// 4*4
myset(datatype,&vmin[1],0,1,writebuf); //v1m v1p v2m v2p v3m v3p
myset(datatype,&vmax[1],0,1,writebuf);
myset(datatype,&vmin[2],0,1,writebuf);
myset(datatype,&vmax[2],0,1,writebuf);
myset(datatype,&vmin[3],0,1,writebuf);
myset(datatype,&vmax[3],0,1,writebuf);
// 6
// one static term
myset(datatype,&(ptrgeom->gdet),0,1,writebuf); // 1 //gdet //end of default read
if(CALCFARADAYANDCURRENTS){ // NIM*2+6*2 = 8+12=20
// updated 11/16/2003
// new 10/23/2003
// current density
lower_vec(GLOBALMAC(jcon,i,j,k),ptrgeom,jcov);
myset(datatype,GLOBALMAC(jcon,i,j,k),0,NDIM,writebuf); // (NDIM)
myset(datatype,jcov,0,NDIM,writebuf);// (NDIM)
// faraday (2*6)
lowerf(GLOBALMAC(fcon,i,j,k),ptrgeom,fcov);
myset(datatype,GLOBALMAC(fcon,i,j,k),0,NUMFARADAY,writebuf); // (6)
myset(datatype,fcov,0,NUMFARADAY,writebuf); // (6)
}
// DEBUG: Also add +3 to numcolumns for this to work
if(0){
if(FLUXB==FLUXCTSTAG) myset(datatype,GLOBALMAC(pstagdump,i,j,k),B1,3,writebuf);
else{
FTYPE plblob[NPR]={0};
myset(datatype,plblob,B1,3,writebuf);
}
}
if(FLUXB==FLUXCTSTAG && 0){ // DEBUG (change corresponding code in dump.c)
// uses jrdp3dudebug in gtwod.m that assumes CALCFARADAYANDCURRENTS==0
for(l=1;l<=COMPDIM;l++) myset(datatype,GLOBALMACP1A0(pl_ctdump,l,i,j,k),0,NPR2INTERP,writebuf); // 3*8 = 24
for(l=1;l<=COMPDIM;l++) myset(datatype,GLOBALMACP1A0(pr_ctdump,l,i,j,k),0,NPR2INTERP,writebuf); // 3*8 = 24
myset(datatype,GLOBALMAC(pstagdump,i,j,k),0,NPR,writebuf); // 8 // GODMARK: use of globals
// for(dir=1;dir<=COMPDIM;dir++) for(pl=B1;pl<=B3;pl++) for(n=0;n<=1;n++) myset(datatype,&GLOBALMACP3A0(pbcorninterp,dir,pl,n,i,j,k),0,1,writebuf); // 3*3*2 = 18
for(dir=1;dir<=COMPDIM;dir++) for(pl=1;pl<=COMPDIM;pl++) for(n=0;n<NUMCS+1;n++) for(o=0;o<NUMCS;o++) myset(datatype,&GLOBALMACP1A3(pvbcorninterp,dir,i,j,k,pl,n,o),0,1,writebuf); // 3*3*(2+1)*2 = 54 (was 36)
}
return (0);
}
int debugdump(long dump_cnt)
{
MPI_Datatype datatype;
int whichdump;
char fileprefix[MAXFILENAME];
char filesuffix[MAXFILENAME];
char fileformat[MAXFILENAME];
trifprintf("begin dumping debug dump# %ld ... ",dump_cnt);
whichdump=DEBUGDUMPTYPE;
datatype=MPI_CTYPE;
strcpy(fileprefix,"dumps/debug");
strcpy(fileformat,"%04ld");
strcpy(filesuffix,"");
// same header as dump
if(dump_gen(WRITEFILE,dump_cnt,binaryoutput,whichdump,datatype,fileprefix,fileformat,filesuffix,dump_header,debug_content)>=1) return(1);
trifprintf("end dumping debug# %ld ... ",dump_cnt);
return(0);
}
extern void set_debug_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion)
{
if(DODEBUG){
*numcolumns=2*NUMFAILFLOORFLAGS*NUMTSCALES;
}
else *numcolumns=0;
// Version number:
*numversion=0;
}
int debug_content(int i, int j, int k, MPI_Datatype datatype,void *writebuf)
{
// could also make everything FTYPE and convert like for normal i,j dump file
// NOTEMARK: see also restart.c since this is added to restart
myset(datatype,GLOBALMAC(failfloorcount,i,j,k),0,2*NUMTSCALES*NUMFAILFLOORFLAGS,writebuf);
return(0);
}
int enodebugdump(long dump_cnt)
{
MPI_Datatype datatype;
int whichdump;
char fileprefix[MAXFILENAME];
char filesuffix[MAXFILENAME];
char fileformat[MAXFILENAME];
trifprintf("begin dumping enodebug dump# %ld ... ",dump_cnt);
whichdump=ENODEBUGDUMPTYPE;
// datatype=MPI_FTYPE;
datatype=MPI_CTYPE;
strcpy(fileprefix,"dumps/enodebug");
strcpy(fileformat,"%04ld");
strcpy(filesuffix,"");
// same header as dump
if(dump_gen(WRITEFILE,dump_cnt,binaryoutput,whichdump,datatype,fileprefix,fileformat,filesuffix,eno_dump_header,enodebug_content)>=1) return(1);
trifprintf("end dumping enodebug# %ld ... ",dump_cnt);
return(0);
}
void set_enodebug_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion)
{
if(DOENODEBUG){
//*numcolumns=NUMENODEBUGS;
*numcolumns=(3-1)* NUMENOINTERPTYPES * (NPR-4) * NUMENODEBUGS; //SASMARK2
}
else *numcolumns=0;
// Version number:
*numversion=0;
}
int enodebug_content(int i, int j, int k, MPI_Datatype datatype,void *writebuf)
{
// could also make everything FTYPE and convert like for normal i,j dump file
//myset(datatype,GLOBALMAC(enodebugarray,i,j,k),0,3*NUMENOINTERPTYPES*NPR*NUMENODEBUGS,writebuf);
myset(datatype,GLOBALMAC(enodebugarray,i,j,k),0,(3-1)*NUMENOINTERPTYPES*(NPR-4)*NUMENODEBUGS,writebuf); //atch corrected
return(0);
}
int eno_dump_header(int whichdump, int whichdumpversion, int numcolumns, int bintxt, FILE *headerptr)
{
int dump_header_general(int whichdump, int whichdumpversion, int numcolumns, long localrealnstep, SFTYPE localdt, int bintxt, FILE *headerptr);
int retval;
retval=dump_header_general(whichdump, whichdumpversion, numcolumns, realnstep,dt, bintxt, headerptr);
return(retval);
}
int avgdump(long dump_cnt)
{
MPI_Datatype datatype;
int whichdump;
char fileprefix[MAXFILENAME];
char filesuffix[MAXFILENAME];
char fileformat[MAXFILENAME];
trifprintf("begin dumping avgdump# %ld ... ",dump_cnt);
whichdump=AVG1DUMPTYPE;
datatype=MPI_FTYPE;
strcpy(fileprefix,"dumps/avg");
strcpy(fileformat,"%04ld");
strcpy(filesuffix,"");
if(dump_gen(WRITEFILE,dump_cnt,binaryoutput,whichdump,datatype,fileprefix,fileformat,filesuffix,dump_header,avg_content)>=1) return(1);
trifprintf("end dumping avgdump# %ld ... ",dump_cnt);
return(0);
}
void set_avg_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion)
{
// 36+29+8*2+4*2+2+12*2+96*2=339
*numcolumns=3*3 + 1 + NUMNORMDUMP // (6+1+29=36)
+ NUMNORMDUMP // |normal terms| (29)
#if(CALCFARADAYANDCURRENTS)
+ NDIM*2 // jcon/jcov (8)
+ NDIM*2 // |jcon|/|jcov| (8)
#endif
+ NDIM*2 // massflux/|massflux|
+ NUMOTHER*2 // other stuff and fabs of each
#if(CALCFARADAYANDCURRENTS)
+6*2 // fcon/fcov (12)
+6*2 // |fcon|,|fcov| (12)
#endif
+7*16 // Tud all 7 parts, all 4x4 terms (112)
+7*16 // |Tud| all 7 parts, all 4x4 terms (112)
;
if(DOAVG2){
*numcolumns-=224;
}
// Version number:
*numversion=0;
}
int avg_content(int i, int j, int k, MPI_Datatype datatype,void *writebuf)
{
int pl = 0, l = 0, col = 0;
FTYPE X[NDIM],V[NDIM];
FTYPE ftemp;
struct of_geom geomdontuse;
struct of_geom *ptrgeom=&geomdontuse;
int loc=CENT;
bl_coord_ijk_2(i, j, k, loc, X,V);
get_geometry(i, j, k, loc, ptrgeom);
if(!GAMMIEDUMP){
ftemp=(FTYPE)(i+startpos[1]);
myset(datatype,&ftemp,0,1,writebuf);
ftemp=(FTYPE)(j+startpos[2]);
myset(datatype,&ftemp,0,1,writebuf);
ftemp=(FTYPE)(k+startpos[3]);
myset(datatype,&ftemp,0,1,writebuf);
}
myset(datatype,X,1,3,writebuf);
myset(datatype,V,1,3,writebuf);
myset(datatype,&(ptrgeom->gdet),0,1,writebuf);
// now do time average stuff
myset(datatype,GLOBALMAC(normalvarstavg,i,j,k),0,NUMNORMDUMP,writebuf);
myset(datatype,GLOBALMAC(anormalvarstavg,i,j,k),0,NUMNORMDUMP,writebuf);
#if(CALCFARADAYANDCURRENTS)
myset(datatype,GLOBALMAC(jcontavg,i,j,k),0,NDIM,writebuf);
myset(datatype,GLOBALMAC(jcovtavg,i,j,k),0,NDIM,writebuf);
myset(datatype,GLOBALMAC(ajcontavg,i,j,k),0,NDIM,writebuf);
myset(datatype,GLOBALMAC(ajcovtavg,i,j,k),0,NDIM,writebuf);
#endif
myset(datatype,GLOBALMAC(massfluxtavg,i,j,k),0,NDIM,writebuf);
myset(datatype,GLOBALMAC(amassfluxtavg,i,j,k),0,NDIM,writebuf);
myset(datatype,GLOBALMAC(othertavg,i,j,k),0,NUMOTHER,writebuf);
myset(datatype,GLOBALMAC(aothertavg,i,j,k),0,NUMOTHER,writebuf);
#if(CALCFARADAYANDCURRENTS)
myset(datatype,GLOBALMAC(fcontavg,i,j,k),0,NUMFARADAY,writebuf);
myset(datatype,GLOBALMAC(fcovtavg,i,j,k),0,NUMFARADAY,writebuf);
myset(datatype,GLOBALMAC(afcontavg,i,j,k),0,NUMFARADAY,writebuf);
myset(datatype,GLOBALMAC(afcovtavg,i,j,k),0,NUMFARADAY,writebuf);
#endif
#if(DOAVG2==0)
myset(datatype,GLOBALMAC(tudtavg,i,j,k),0,NUMSTRESSTERMS,writebuf);
myset(datatype,GLOBALMAC(atudtavg,i,j,k),0,NUMSTRESSTERMS,writebuf);
#endif
return(0);
}
int avg2dump(long dump_cnt)
{
MPI_Datatype datatype;
int whichdump;
char fileprefix[MAXFILENAME];
char filesuffix[MAXFILENAME];
char fileformat[MAXFILENAME];
trifprintf("begin dumping avg2dump# %ld ... ",dump_cnt);
whichdump=AVG2DUMPTYPE;
datatype=MPI_FTYPE;
strcpy(fileprefix,"dumps/avg2");
strcpy(fileformat,"%04ld");
strcpy(filesuffix,"");
if(dump_gen(WRITEFILE,dump_cnt,binaryoutput,whichdump,datatype,fileprefix,fileformat,filesuffix,dump_header,avg2_content)>=1) return(1);
trifprintf("end dumping avg2dump# %ld ... ",dump_cnt);
return(0);
}
void set_avg2_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion)
{
if(DOAVG2){
*numcolumns=10 + 224; // otherwise doesn't exist so don't need to set
}
else *numcolumns=0;
// Version number:
*numversion=0;
}
int avg2_content(int i, int j, int k, MPI_Datatype datatype,void *writebuf)
{
int pl = 0, l = 0, col = 0;
FTYPE X[NDIM],V[NDIM];
FTYPE ftemp;
struct of_geom geomdontuse;
struct of_geom *ptrgeom=&geomdontuse;
int loc=CENT;
bl_coord_ijk_2(i, j, k, loc, X,V);
get_geometry(i, j, k, loc, ptrgeom);
// if you change # of outputted vars, remember to change numcolumns above
if(!GAMMIEDUMP){
ftemp=(FTYPE)(i+startpos[1]);
myset(datatype,&ftemp,0,1,writebuf);
ftemp=(FTYPE)(j+startpos[2]);
myset(datatype,&ftemp,0,1,writebuf);
ftemp=(FTYPE)(k+startpos[3]);
myset(datatype,&ftemp,0,1,writebuf);
}
myset(datatype,X,1,3,writebuf);
myset(datatype,V,1,3,writebuf);
myset(datatype,&(ptrgeom->gdet),0,1,writebuf);
// 10
myset(datatype,GLOBALMAC(tudtavg,i,j,k),0,NUMSTRESSTERMS,writebuf);
myset(datatype,GLOBALMAC(atudtavg,i,j,k),0,NUMSTRESSTERMS,writebuf);
// 112*2
// total=10+112*2=234
return(0);
}
int gdump(long dump_cnt)
{
MPI_Datatype datatype;
int whichdump;
char fileprefix[MAXFILENAME];
char filesuffix[MAXFILENAME];
char fileformat[MAXFILENAME];
trifprintf("begin dumping gdump# %ld ... ",dump_cnt);
whichdump=GRIDDUMPTYPE;
datatype=MPI_FTYPE;
strcpy(fileprefix,"dumps/gdump");
strcpy(fileformat,"%04ld");
strcpy(filesuffix,"");
// dump_cnt==-1 means no file number
if(dump_gen(WRITEFILE,dump_cnt,binaryoutput,whichdump,datatype,fileprefix,fileformat,filesuffix,dump_header,gdump_content)>=1) return(1);
trifprintf("end dumping gdump# %ld ... ",dump_cnt);
return(0);
}
extern void set_gdump_content_dnumcolumns_dnumversion(int *numcolumns, int *numversion)
{
// 205+4+4*4 currently
//*numcolumns=3*3+NDIM*NDIM*NDIM+NPG*NDIM*NDIM*2+NPG+4+4*4;
//NPG was replaced with unity in order to avoid excessive dumping of info (only center info now available)