forked from dshaver14/usrcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_post.f
More file actions
2144 lines (2007 loc) · 59.9 KB
/
Copy pathmy_post.f
File metadata and controls
2144 lines (2007 loc) · 59.9 KB
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
cc-----------------------------------------------------------------------
c subroutine set_outfld
c
cc Check if we are going to checkpoint at this timestep
cc and set ifoutfld accordingly
c
c include 'SIZE'
c include 'TOTAL'
c include 'CTIMER'
c
c common /rdump/ ntdump
c
c ifoutfld = .false.
c
c if (iostep.le.0 .and. timeio.le.0) return
c
cc if (istep.ge.nsteps) lastep=1
c
c if (iostep.gt.0) then
c if(mod(istep,iostep).eq.0) ifoutfld=.true.
c else if (timeioe.ne.0.0) then
c if (dnekclock_sync()-etimes .ge. (ntdump + 1)*timeio) then
c ntdump=ntdump+1
c ifoutfld=.true.
c endif
c else if (timeio.ne.0.0) then
c if (time.ge.(ntdump + 1)*timeio) then
c ntdump=ntdump+1
c ifoutfld=.true.
c endif
c endif
c
c if (ioinfodmp.ne.0 .or. lastep.eq.1) ifoutfld=.true.
c
c return
c end
cc-----------------------------------------------------------------------
c subroutine check_ioinfo
c
cc Check for io request in file 'ioinfo'
c
c include 'SIZE'
c include 'TSTEP'
c include 'INPUT'
c
c parameter (lxyz=lx1*ly1*lz1)
c parameter (lpsc9=ldimt1+9)
c common /ctmp1/ tdump(lxyz,lpsc9)
c real*4 tdump
c real tdmp(4)
c equivalence (tdump,tdmp)
c
c integer maxstep
c save maxstep
c data maxstep /999999999/
c
c character*132 fname
c character*1 fname1(132)
c equivalence (fname,fname1)
c
c ioinfodmp=0
c if (nid.eq.0 .and. (mod(istep,10).eq.0 .or. istep.lt.200)) then
c call blank(fname1,size(fname1))
c len = ltrunc(path,132)
c call chcopy(fname1,path,len)
c call chcopy(fname1(len+1),'ioinfo',6)
c open(unit=87,file=fname,status='old',err=88)
c read(87,*,end=87,err=87) idummy
c if (ioinfodmp.eq.0) ioinfodmp=idummy
c if (idummy.ne.0) then ! overwrite last i/o request
c rewind(87)
c write(87,86)
c 86 format(' 0')
c endif
c 87 continue
c close(unit=87)
c 88 continue
c if (ioinfodmp.ne.0) write(6,*) 'Output:',ioinfodmp
c endif
c
c tdmp(1)=ioinfodmp
c call gop(tdmp,tdmp(3),'+ ',1)
c ioinfodmp=tdmp(1)
c if (ioinfodmp.lt.0) maxstep=abs(ioinfodmp)
c if (istep.ge.maxstep.or.ioinfodmp.eq.-2) lastep=1
c
c return
c end
cc-----------------------------------------------------------------------
subroutine my_prepost(elist,ifdoin,prefin)
c Store results for later postprocessing
c
c Recent updates:
c
c p65 now indicates the number of parallel i/o files; iff p66 >= 6
c
c we now check whether we are going to checkpoint in set_outfld
c
include 'SIZE'
include 'TOTAL'
include 'CTIMER'
common /scrcg/ pm1 (lx1,ly1,lz1,lelv)
character*3 prefin,prefix
logical ifdoin
integer elist(1)
if (ioinfodmp.eq.-2) return
c#ifdef TIMER
etime1=dnekclock_sync()
c#endif
prefix = prefin
if (prefix.eq.'his') prefix = ' '
if (ifdoin) then
icalld=icalld+1
nprep=icalld
call prepost_map(0) ! map pr and axisymm. arrays
call my_outfld(elist,prefix)
call prepost_map(1) ! map back axisymm. arrays
c#ifdef TIMER
tprep=tprep+dnekclock_sync()-etime1
c#endif
endif
return
end
cc-----------------------------------------------------------------------
c subroutine prepost_map(isave) ! isave=0-->fwd, isave=1-->bkwd
c
cc Store results for later postprocessing
c
c include 'SIZE'
c include 'TOTAL'
cC
cC Work arrays and temporary arrays
cC
c common /scruz/ vxax (lx1,ly1,lelv)
c $ , vyax (lx1,ly1,lelv)
c $ , prax (lx2,ly2,lelv)
c $ , yax (lx1,ly1,lelt)
c common /scrmg/ tax (lx1,ly1,lelt,ldimt)
c common /scrcg/ pm1 (lx1,ly1,lz1,lelv)
cC
cc
c common /prepst/ pa(lx1,ly2,lz2),pb(lx1,ly1,lz2)
c integer e
c
c if (isave.eq.0) then ! map to GLL grid
c
c if (ifaxis) then
c ntotm1 = lx1*ly1*nelt
c call copy (yax,ym1,ntotm1)
c do 5 e=1,nelt
c if (ifrzer(e)) then
c call mxm (ym1(1,1,1,e),lx1,iatjl1,ly1,pb,ly1)
c call copy (ym1(1,1,1,e),pb,lx1*ly1)
c endif
c 5 continue
c if (ifflow) then
c ntotm1 = lx1*ly1*nelt
c ntotm2 = lx2*ly2*nelt
c call copy (vxax,vx,ntotm1)
c call copy (vyax,vy,ntotm1)
c call copy (prax,pr,ntotm2)
c do 10 e=1,nelt
c if (ifrzer(e)) then
c call mxm (vx(1,1,1,e),lx1,iatjl1,ly1,pb,ly1)
c call copy (vx(1,1,1,e),pb,lx1*ly1)
c call mxm (vy(1,1,1,e),lx1,iatjl1,ly1,pb,ly1)
c call copy (vy(1,1,1,e),pb,lx1*ly1)
c call mxm (pr(1,1,1,e),lx2,iatjl2,ly2,pb,ly2)
c call copy (pr(1,1,1,e),pb,lx2*ly2)
c endif
c 10 continue
c endif
c if (ifheat) then
c ntotm1 = lx1*ly1*nelt
c do 15 ifldt=1,npscal+1
c call copy (tax(1,1,1,ifldt),t(1,1,1,1,ifldt),ntotm1)
c 15 continue
c do 30 e=1,nelt
c if (ifrzer(e)) then
c do 25 ifldt=1,npscal+1
c call mxm (t(1,1,1,e,ifldt),lx1,iatjl1,ly1,
c $ pb,ly1)
c call copy (t(1,1,1,e,ifldt),pb,lx1*ly1)
c 25 continue
c endif
c 30 continue
c endif
c endif
cC Map the pressure onto the velocity mesh
cC
c ntott = lx1*ly1*lz1*nelt
c ntot1 = lx1*ly1*lz1*nelt
c nyz2 = ly2*lz2
c nxy1 = lx1*ly1
c nxyz = lx1*ly1*lz1
c nxyz2 = lx2*ly2*lz2
cC
c
c call rzero(pm1,ntott)
c if (ifsplit) then
c call copy(pm1,pr,ntot1)
c elseif (if_full_pres) then
c call rzero(pm1,ntot1)
c do e=1,nelt
c call copy(pm1(1,1,1,e),pr(1,1,1,e),nxyz2)
c enddo
c else
c do 1000 e=1,nelt
c call mxm (ixm21,lx1,pr(1,1,1,e),lx2,pa(1,1,1),nyz2)
c do 100 iz=1,lz2
c call mxm (pa(1,1,iz),lx1,iytm21,ly2,pb(1,1,iz),ly1)
c 100 continue
c call mxm (pb(1,1,1),nxy1,iztm21,lz2,pm1(1,1,1,e),lz1)
c 1000 continue
c endif
c
c else ! map back
c
c if (ifaxis) then
c ntot1 = lx1*ly1*nelt
c call copy (ym1,yax,ntot1)
c if (ifflow) then
c ntot1 = lx1*ly1*nelt
c ntot2 = lx2*ly2*nelt
c call copy (vx,vxax,ntot1)
c call copy (vy,vyax,ntot1)
c call copy (pr,prax,ntot2)
c endif
c if (ifheat) then
c ntot1 = lx1*ly1*nelt
c do 3000 ifldt=1,npscal+1
c call copy (t(1,1,1,1,ifldt),tax(1,1,1,ifldt),ntot1)
c 3000 continue
c endif
c endif
c
c endif
c return
c end
cc-----------------------------------------------------------------------
subroutine my_outfld(elist,prefix)
c output .fld file
include 'SIZE'
include 'TOTAL'
include 'RESTART'
C
C Work arrays and temporary arrays
C
common /scrcg/ pm1 (lx1,ly1,lz1,lelv)
c
c note, this usage of CTMP1 will be less than elsewhere if NELT ~> 3.
parameter (lxyz=lx1*ly1*lz1)
parameter (lpsc9=ldimt1+9)
common /ctmp1/ tdump(lxyz,lpsc9)
real*4 tdump
real tdmp(4)
equivalence (tdump,tdmp)
real*4 test_pattern
character*3 prefix
character*1 fhdfle1(132)
character*132 fhdfle
equivalence (fhdfle,fhdfle1)
character*1 excode(30)
character*10 frmat
common /nopenf/ nopen(99)
common /rdump/ ntdump
data ndumps / 0 /
logical ifxyo_s
integer elist(1)
if(nio.eq.0) then
WRITE(6,1001) istep,time
1001 FORMAT(/,i9,1pe12.4,' Write checkpoint')
endif
call nekgsync()
p66 = param(66)
if (abs(p66).eq.6) then
c call err_chk(ierr,'mfo not supported in my_post$')
call my_mfo_outfld(elist,prefix)
return
endif
ifxyo_s = ifxyo ! Save ifxyo
iprefix = i_find_prefix(prefix,99)
ierr = 0
if (nid.eq.0) then
c Open new file for each dump on /cfs
nopen(iprefix)=nopen(iprefix)+1
if (prefix.eq.' '.and.nopen(iprefix).eq.1) ifxyo = .true. ! 1st file
if (prefix.eq.'rst'.and.max_rst.gt.0)
$ nopen(iprefix) = mod1(nopen(iprefix),max_rst) ! restart
call file2(nopen(iprefix),prefix)
if (p66.lt.1.0) then
open(unit=24,file=fldfle,form='formatted',status='unknown')
else
call byte_open (fldfle,ierr)
c write header as character string
call blank(fhdfle,132)
endif
endif
call bcast(ifxyo,lsize)
if(p66.ge.1.0)
$ call err_chk(ierr,'Error opening file in outfld. Abort. $')
C Figure out what goes in EXCODE
CALL BLANK(EXCODE,30)
NDUMPS=NDUMPS+1
i=1
if (mod(p66,1.0).eq.0.0) then !old header format
IF(IFXYO) then
EXCODE(1)='X'
EXCODE(2)=' '
EXCODE(3)='Y'
EXCODE(4)=' '
i = 5
IF(IF3D) THEN
EXCODE(i) ='Z'
EXCODE(i+1)=' '
i = i + 2
ENDIF
ENDIF
IF(IFVO) then
EXCODE(i) ='U'
EXCODE(i+1)=' '
i = i + 2
ENDIF
IF(IFPO) THEN
EXCODE(i)='P'
EXCODE(i+1)=' '
i = i + 2
ENDIF
IF(IFTO) THEN
EXCODE(i)='T '
EXCODE(i+1)=' '
i = i + 1
ENDIF
do iip=1,ldimt1
if (ifpsco(iip)) then
write(excode(iip+I) ,'(i1)') iip
write(excode(iip+I+1),'(a1)') ' '
i = i + 1
endif
enddo
else
!new header format
IF (IFXYO) THEN
EXCODE(i)='X'
i = i + 1
ENDIF
IF (IFVO) THEN
EXCODE(i)='U'
i = i + 1
ENDIF
IF (IFPO) THEN
EXCODE(i)='P'
i = i + 1
ENDIF
IF (IFTO) THEN
EXCODE(i)='T'
i = i + 1
ENDIF
IF (LDIMT.GT.1) THEN
NPSCALO = 0
do k = 1,ldimt-1
if(ifpsco(k)) NPSCALO = NPSCALO + 1
enddo
IF (NPSCALO.GT.0) THEN
EXCODE(i) = 'S'
WRITE(EXCODE(i+1),'(I1)') NPSCALO/10
WRITE(EXCODE(i+2),'(I1)') NPSCALO-(NPSCALO/10)*10
ENDIF
ENDIF
endif
C Dump header
ierr = 0
nelgt_bak=nelgt
nelgt=iglsum(elist,nelt)
if (nid.eq.0) write(*,*) 'my_outpost,nelgt',nelgt,nelgt_bak
if (nid.eq.0) call dump_header(excode,p66,ierr)
call err_chk(ierr,'Error dumping header in outfld. Abort. $')
nelgt=nelgt_bak
call get_id(id)
nxyz = lx1*ly1*lz1
ierr = 0
do ieg=1,nelgt
jnid = gllnid(ieg)
ie = gllel (ieg)
ifdump=0
if (nid.eq.0) then
if (jnid.eq.0) then
call fill_tmp(tdump,id,ie)
ifdump=elist(ie)
else
mtype=2000+ie
len=4*id*nxyz
dum1=0.
call csend (mtype,dum1,wdsize,jnid,nullpid)
call crecv2 (mtype,tdump,len,jnid)
call crecv2 (mtype,ifdump,4,jnid)
endif
c write(*,*)'ddd',ieg,jnid,ie,ifdump,ierr
if(ifdump.gt.0.AND.ierr.eq.0) call out_tmp(id,p66,ierr)
c if(ierr.eq.0) call out_tmp(id,p66,ierr)
elseif (nid.eq.jnid) then
call fill_tmp(tdump,id,ie)
dum1=0.
mtype=2000+ie
len=4*id*nxyz
call crecv2 (mtype,dum1,wdsize,node0)
call csend (mtype,tdump,len,node0,nullpid)
call csend (mtype,elist(ie),4,node0,nullpid)
endif
enddo
call err_chk(ierr,'Error writing file in outfld. Abort. $')
ifxyo = ifxyo_s ! restore ifxyo
if (nid.eq.0) call close_fld(p66,ierr)
call err_chk(ierr,'Error closing file in outfld. Abort. $')
return
end
cc-----------------------------------------------------------------------
c subroutine file2(nopen,PREFIX)
cC----------------------------------------------------------------------
cC
cC Defines machine specific input and output file names.
cC
cC----------------------------------------------------------------------
c include 'SIZE'
c include 'INPUT'
c include 'TSTEP'
c include 'PARALLEL'
cC
c CHARACTER*132 NAME
c CHARACTER*1 SESS1(132),PATH1(132),NAM1(132)
c EQUIVALENCE (SESSION,SESS1)
c EQUIVALENCE (PATH,PATH1)
c EQUIVALENCE (NAME,NAM1)
c CHARACTER*1 DMP(4),FLD(4),REA(4),HIS(4),SCH(4) ,ORE(4), NRE(4)
c CHARACTER*4 DMP4 ,FLD4 ,REA4 ,HIS4 ,SCH4 ,ORE4 , NRE4
c EQUIVALENCE (DMP,DMP4), (FLD,FLD4), (REA,REA4), (HIS,HIS4)
c $ , (SCH,SCH4), (ORE,ORE4), (NRE,NRE4)
c CHARACTER*1 NUMRL(0:9)
c DATA DMP4,FLD4,REA4 /'.dmp','.fld','.rea'/
c DATA HIS4,SCH4 /'.his','.sch'/
c DATA ORE4,NRE4 /'.ore','.nre'/
c DATA NUMRL /'0','1','2','3','4','5','6','7','8','9'/
c CHARACTER*78 STRING
cc
c character*1 prefix(3)
cC
c call blank(name ,132)
c call blank(fldfle,132)
cC
c LS=LTRUNC(SESSION,132)
c LPP=LTRUNC(PATH,132)
c LSP=LS+LPP
c l = 0
c
cc Construct file names containing full path to host:
cc DO 100 I=1,LPP
cc l = l+1
cc NAM1(l)=PATH1(I)
cc 100 CONTINUE
cC
c if (prefix(1).ne.' '.and.prefix(2).ne.' '.and.
c $ prefix(3).ne.' ') then
c do i=1,3
c l = l+1
c NAM1(l)=prefix(i)
c enddo
c endif
cC
c DO 200 I=1,LS
c l = l+1
c NAM1(l)=SESS1(I)
c 200 CONTINUE
cC
cC .fld file
c DO 300 I=1,4
c l = l+1
c NAM1(l)=FLD(I)
c 300 CONTINUE
c if (nopen.lt.100) then
cC less than 100 dumps....
c ITEN=NOPEN/10
c l = l+1
c NAM1(l)=NUMRL(ITEN)
c IONE=MOD(NOPEN,10)
c l = l+1
c NAM1(l)=NUMRL(IONE)
c elseif (nopen.lt.1000) then
cC less than 1000 dumps....
c IHUN=NOPEN/100
c l = l+1
c NAM1(l)=NUMRL(IHUN)
c ITEN=MOD(NOPEN,100)/10
c l = l+1
c NAM1(l)=NUMRL(ITEN)
c IONE=MOD(NOPEN,10)
c l = l+1
c NAM1(l)=NUMRL(IONE)
c elseif (nopen.lt.10000) then
cC less than 10000 dumps....
c ITHO=NOPEN/1000
c l = l+1
c NAM1(l)=NUMRL(ITHO)
c IHUN=MOD(NOPEN,1000)/100
c l = l+1
c NAM1(l)=NUMRL(IHUN)
c ITEN=MOD(NOPEN,100)/10
c l = l+1
c NAM1(l)=NUMRL(ITEN)
c IONE=MOD(NOPEN,10)
c l = l+1
c NAM1(l)=NUMRL(IONE)
c endif
c FLDFLE=NAME
cC
cC Write the name of the .fld file to the logfile.
cC
c if (nio.eq.0) then
c call chcopy(string,fldfle,78)
c write(6,1000) istep,time,string
c 1000 format(/,i9,1pe12.4,' OPEN: ',a78)
c endif
c
c return
c end
cc=======================================================================
c subroutine rzero4(a,n)
c real*4 A(1)
c DO 100 I = 1, N
c 100 A(I ) = 0.0
c return
c end
cc=======================================================================
c subroutine copyX4(a,b,n)
c REAL*4 A(1)
c REAL B(1)
c DO 100 I = 1, N
c 100 A(I) = B(I)
c return
c end
cc=======================================================================
c subroutine copy4r(a,b,n)
c real a(1)
c real*4 b(1)
c do i = 1, n
c a(i) = b(i)
c enddo
c return
c end
cc=======================================================================
c function i_find_prefix(prefix,imax)
cc
c character*3 prefix
c character*3 prefixes(99)
c save prefixes
c data prefixes /99*'...'/
cc
c integer nprefix
c save nprefix
c data nprefix /0/
cc
cc Scan existing list of prefixes for a match to "prefix"
cc
c do i=1,nprefix
c if (prefix.eq.prefixes(i)) then
c i_find_prefix = i
c return
c endif
c enddo
cc
cc If we're here, we didn't find a match.. bump list and return
cc
c nprefix = nprefix + 1
c prefixes(nprefix) = prefix
c i_find_prefix = nprefix
cc
cc Array bounds check on prefix list
cc
c if (nprefix.gt.99.or.nprefix.gt.imax) then
c write(6,*) 'Hey! nprefix too big! ABORT in i_find_prefix'
c $ ,nprefix,imax
c call exitt
c endif
cc
c return
c end
cc-----------------------------------------------------------------------
c subroutine dump_header(excodein,p66,ierr)
c
c include 'SIZE'
c include 'TOTAL'
c
c character*30 excodein
c
c character*30 excode
c character*1 excode1(30)
c equivalence (excode,excode1)
c
c real*4 test_pattern
c
c character*1 fhdfle1(132)
c character*132 fhdfle
c equivalence (fhdfle,fhdfle1)
c
c write(excode,'(A30)') excodein
c
c ikstep = istep
c do ik=1,10
c if (ikstep.gt.9999) ikstep = ikstep/10
c enddo
c
c call blank(fhdfle,132)
c
cc write(6,111) ! print on screen
cc $ nelgt,lx1,ly1,lz1,time,istep,excode
cc
c if (mod(p66,1.0).eq.0.0) then ! old header format
c if (p66.lt.1.0) then !ASCII
c if(nelgt.lt.10000) then
c WRITE(24,'(4i4,1pe14.7,I5,1X,30A1,1X,A12)')
c $ NELGT,lx1,ly1,lz1,TIME,ikstep,(EXCODE1(I),I=1,30),
c $ 'NELT,NX,NY,N'
c else
c WRITE(24,'(i10,3i4,1pe18.9,I9,1X,30A1,1X,A12)')
c $ NELGT,lx1,ly1,lz1,TIME,ikstep,(EXCODE1(I),I=1,30),
c $ 'NELT,NX,NY,N'
c endif
c else !Binary
c if (nelgt.lt.10000) then
c WRITE(fhdfle,'(4I4,1pe14.7,I5,1X,30A1,1X,A12)')
c $ NELGT,lx1,ly1,lz1,TIME,ikstep,(EXCODE1(I),I=1,30),
c $ ' 4 NELT,NX,NY,N'
c else
c write(fhdfle,'(i10,3i4,1P1e18.9,i9,1x,30a1)')
c $ nelgt,lx1,ly1,lz1,time,istep,(excode1(i),i=1,30)
c endif
c call byte_write(fhdfle,20,ierr)
c endif
c else ! new header format
c if (p66.eq.0.1) then
c write(24,111)
c $ nelgt,lx1,ly1,lz1,time,istep,excode
c else
c write(fhdfle,111)
c $ nelgt,lx1,ly1,lz1,time,istep,excode
c call byte_write(fhdfle,20,ierr)
c endif
c 111 FORMAT(i10,1x,i2,1x,i2,1x,i2,1x,1P1e18.9,1x,i9,1x,a)
c endif
c
c if(ierr.ne.0) return
c
c CDRROR=0.0
c if (p66.LT.1.0) then ! formatted i/o
c WRITE(24,'(6G11.4)')(CDRROR,I=1,NELGT) ! dummy
c else
cC write byte-ordering test pattern to byte file...
c test_pattern = 6.54321
c call byte_write(test_pattern,1,ierr)
c endif
c
c return
c end
cc-----------------------------------------------------------------------
c subroutine fill_tmp(tdump,id,ie)
cC
c include 'SIZE'
c include 'TOTAL'
cc
c common /scrcg/ pm1 (lx1,ly1,lz1,lelv)
cC
cC Fill work array
cC
c parameter (lxyz=lx1*ly1*lz1)
c parameter (lpsc9=ldimt1+9)
c real*4 tdump(lxyz,lpsc9)
cC
c nxyz = lx1*ly1*lz1
cc
c ID=0
c IF(IFXYO)then
c ID=ID+1
c CALL COPYx4(TDUMP(1,ID),XM1(1,1,1,IE),NXYZ)
c ID=ID+1
c CALL COPYx4(TDUMP(1,ID),YM1(1,1,1,IE),NXYZ)
c IF(IF3D) then
c ID=ID+1
c CALL COPYx4(TDUMP(1,ID),ZM1(1,1,1,IE),NXYZ)
c ENDIF
c ENDIF
cc
c IF(IFVO)then
c IF (IE.LE.NELT) then
c ID=ID+1
c CALL COPYx4(TDUMP(1,ID),VX(1,1,1,IE),NXYZ)
c ID=ID+1
c CALL COPYx4(TDUMP(1,ID),VY(1,1,1,IE),NXYZ)
c IF(IF3D)then
c ID=ID+1
c CALL COPYx4(TDUMP(1,ID),VZ(1,1,1,IE),NXYZ)
c ENDIF
c ELSE
c ID=ID+1
c CALL RZERO4(TDUMP(1,ID),NXYZ)
c ID=ID+1
c CALL RZERO4(TDUMP(1,ID),NXYZ)
c IF(IF3D)then
c ID=ID+1
c CALL RZERO4(TDUMP(1,ID),NXYZ)
c ENDIF
c ENDIF
c ENDIF
c IF(IFPO)then
c IF (IE.LE.NELT) then
c ID=ID+1
c CALL COPYx4(TDUMP(1,ID),PM1(1,1,1,IE),NXYZ)
c ELSE
c ID=ID+1
c CALL RZERO4(TDUMP(1,ID),NXYZ)
c ENDIF
c ENDIF
c IF(IFTO)then
c ID=ID+1
c CALL COPYx4(TDUMP(1,ID),T(1,1,1,IE,1),NXYZ)
c ENDIF
cC PASSIVE SCALARS
c do iip=1,ldimt1
c if (ifpsco(iip)) then
c id=id+1
c call copyX4(tdump(1,id),t(1,1,1,ie,iip+1),nxyz)
c endif
c enddo
cc
c return
c end
cc-----------------------------------------------------------------------
c subroutine get_id(id) ! Count amount of data to be shipped
c
c include 'SIZE'
c include 'TOTAL'
c
c id=0
c
c if (ifxyo) id=id+ldim
c if (ifvo) id=id+ldim
c if (ifpo) id=id+1
c if (ifto) id=id+1
c
c do iip=1,ldimt1
c if (ifpsco(iip)) id=id+1 ! Passive scalars
c enddo
c
c return
c end
cc-----------------------------------------------------------------------
c subroutine close_fld(p66,ierr)
c
c include 'SIZE'
c include 'TOTAL'
c
c if (nid.eq.0) then
c if (p66.lt.1) then
c close(unit=24)
c else
c call byte_close(ierr)
c endif
c endif
c
c return
c end
cc-----------------------------------------------------------------------
c subroutine out_tmp(id,p66,ierr)
c
c include 'SIZE'
c include 'TOTAL'
c
c parameter (lxyz=lx1*ly1*lz1)
c parameter (lpsc9=ldimt1+9)
c
c common /ctmp1/ tdump(lxyz,lpsc9)
c real*4 tdump
c
c character*11 frmat
c
c nxyz = lx1*ly1*lz1
c
c call blank(frmat,11)
c if (id.le.9) then
c WRITE(FRMAT,1801) ID
c 1801 FORMAT('(1p',I1,'e14.6)')
c else
c WRITE(FRMAT,1802) ID
c 1802 FORMAT('(1p',I2,'e14.6)')
c endif
c
c if (p66.lt.1.0) then
cC formatted i/o
c WRITE(24,FRMAT)
c $ ((TDUMP(I,II),II=1,ID),I=1,NXYZ)
c else
cC C binary i/o
c do ii=1,id
c call byte_write(tdump(1,ii),nxyz,ierr)
c if(ierr.ne.0) goto 101
c enddo
c endif
c 101 continue
c
c return
c end
c-----------------------------------------------------------------------
subroutine my_mfo_outfld(elist,prefix) ! muti-file output
include 'SIZE'
include 'TOTAL'
include 'RESTART'
common /scrcg/ pm1 (lx1,ly1,lz1,lelv) ! mapped pressure
integer*8 offs0,offs,nbyte,stride,strideB,nxyzo8
integer elist(1)
character*3 prefix
logical ifxyo_s
common /SCRUZ/ ur1(lxo*lxo*lxo*lelt)
& , ur2(lxo*lxo*lxo*lelt)
& , ur3(lxo*lxo*lxo*lelt)
integer lglel_bak(lelt),lglel2(lelt)
tiostart=dnekclock_sync()
call io_init
if(nid.eq.0)write(*,*)'my_mfo_outfld',param(66),ifmpiio
ifxyo_s = ifxyo
ifxyo_ = ifxyo
nout = nelt ! map2reg
c nout = ivlsum(elist,nelt) !nelt
nxo = lx1
nyo = ly1
nzo = lz1
nelgt2= iglsum(elist,nelt)
nout2 = ivlsum(elist,nelt)
nn = nout2
nelB2 = igl_running_sum(nn)
nelB2 = nelB2 - nout2
j=0
call izero(lglel2,lelt)
do ie=1,nelt
ieg=lglel(ie)
if (elist(ie).gt.0) then
j = j + 1
lglel2(j)=ieg
endif
enddo
if (ifreguo) then ! dump on regular (uniform) mesh
if (nrg.gt.lxo) then
if (nid.eq.0) write(6,*)
& 'WARNING: nrg too large, reset to lxo!'
nrg = lxo
endif
nxo = nrg
nyo = nrg
nzo = 1
if(if3d) nzo = nrg
endif
c offs0 = iHeaderSize + 4 + isize*nelgt
offs0 = iHeaderSize + 4 + isize*nelgt2
if(nid.eq.0)write(*,*)'my_mfo_outfld'
$ ,nelB,nelB2,nout,nout2,nelgt,nelgt2
ierr=0
if (nid.eq.pid0) then
call mfo_open_files(prefix,ierr) ! open files on i/o nodes
endif
call err_chk(ierr,'Error opening file in mfo_open_files. $')
call bcast(ifxyo_,lsize)
ifxyo = ifxyo_
nelgt_bak=nelgt
nelt_bak=nelt
nelB_bak=nelB
call icopy(lglel_bak,lglel,lelt)
nelgt=nelgt2
nelt=nout2
nelB=nelB2
call icopy(lglel,lglel2,lelt)
call mfo_write_hdr ! create element mapping +
nelgt=nelgt_bak
nelt=nelt_bak
nelB=nelB_bak
call icopy(lglel,lglel_bak,lelt)
c call exitti('this is wdsizo A:$',wdsizo)
! write hdr
nxyzo8 = nxo*nyo*nzo
c strideB = nelB * nxyzo8*wdsizo
c stride = nelgt* nxyzo8*wdsizo
strideB = nelB2 * nxyzo8*wdsizo
stride = nelgt2* nxyzo8*wdsizo
ioflds = 0
! dump all fields based on the t-mesh to avoid different
! topologies in the post-processor
if (ifxyo) then
offs = offs0 + ldim*strideB
call byte_set_view(offs,ifh_mbyte)
if (ifreguo) then
call map2reg(ur1,nrg,xm1,nout)
call map2reg(ur2,nrg,ym1,nout)
if (if3d) call map2reg(ur3,nrg,zm1,nout)
call my_mfo_outv(elist,ur1,ur2,ur3,nout,nxo,nyo,nzo)
else
call my_mfo_outv(elist,xm1,ym1,zm1,nout,nxo,nyo,nzo)
endif
ioflds = ioflds + ldim
endif
c ierr = 0
c if (nid.eq.pid0) then
c if(ifmpiio) then
c call byte_close_mpi(ifh_mbyte,ierr)
c else
c call byte_close(ierr)
c endif
c endif
c call err_chk(ierr,'Error closing file in mfo_outfld. Abort. $')
c return
if (ifvo ) then
offs = offs0 + ioflds*stride + ldim*strideB
call byte_set_view(offs,ifh_mbyte)
if (ifreguo) then
call map2reg(ur1,nrg,vx,nout)
call map2reg(ur2,nrg,vy,nout)
if (if3d) call map2reg(ur3,nrg,vz,nout)
call my_mfo_outv(elist,ur1,ur2,ur3,nout,nxo,nyo,nzo)
else
call my_mfo_outv(elist,vx,vy,vz,nout,nxo,nyo,nzo) ! B-field handled thru outpost
endif
ioflds = ioflds + ldim
endif
if (ifpo ) then
offs = offs0 + ioflds*stride + strideB
call byte_set_view(offs,ifh_mbyte)
if (ifreguo) then
call map2reg(ur1,nrg,pm1,nout)
call my_mfo_outs(elist,ur1,nout,nxo,nyo,nzo)
else
call my_mfo_outs(elist,pm1,nout,nxo,nyo,nzo)
endif
ioflds = ioflds + 1
endif
if (ifto ) then
offs = offs0 + ioflds*stride + strideB
call byte_set_view(offs,ifh_mbyte)
if (ifreguo) then