-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump.f90
7173 lines (6136 loc) · 252 KB
/
dump.f90
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
MODULE DUMP
! Create and write ("dump") to various output files
USE PRECISION_PARAMETERS
USE COMP_FUNCTIONS
USE MESH_VARIABLES
USE GLOBAL_CONSTANTS
USE TRAN
USE ISODEFS
USE COMPRESSDEFS
USE MESH_POINTERS
USE DEVICE_VARIABLES
USE CONTROL_VARIABLES
USE OUTPUT_DATA
USE TYPES
IMPLICIT NONE
PRIVATE
CHARACTER(50), DIMENSION(:), ALLOCATABLE :: FNDUMP
INTEGER, PARAMETER :: ONE_INTEGER=1,ZERO_INTEGER=0
INTEGER, DIMENSION(:), ALLOCATABLE :: LUDUMP
REAL(EB), POINTER, DIMENSION(:,:,:) :: WFX,WFY,WFZ
INTEGER :: N_DEVC_FILES
CHARACTER(80) :: TCFORM
LOGICAL :: EX,DRY
CHARACTER(255), PARAMETER :: dumpid='$Id: dump.f90 9974 2012-02-03 18:41:26Z mcgratta $'
CHARACTER(255), PARAMETER :: dumprev='$Revision: 9974 $'
CHARACTER(255), PARAMETER :: dumpdate='$Date: 2012-02-03 10:41:26 -0800 (Fri, 03 Feb 2012) $'
TYPE (MESH_TYPE), POINTER :: M=>NULL()
TYPE (PARTICLE_TYPE), POINTER :: LP=>NULL()
TYPE (OBSTRUCTION_TYPE), POINTER :: OB=>NULL()
TYPE (VENTS_TYPE), POINTER :: VT=>NULL()
TYPE (PARTICLE_CLASS_TYPE), POINTER :: PC=>NULL()
TYPE (SPECIES_TYPE), POINTER :: SS=>NULL()
TYPE (REACTION_TYPE), POINTER :: RN=>NULL()
TYPE (SURFACE_TYPE),POINTER :: SF=>NULL()
TYPE (MATERIAL_TYPE),POINTER :: ML=>NULL()
TYPE (PROPERTY_TYPE), POINTER :: PY=>NULL()
TYPE (DEVICE_TYPE), POINTER :: DV=>NULL(), DV2=>NULL()
TYPE (SLICE_TYPE), POINTER :: SL=>NULL()
TYPE (WALL_TYPE), POINTER :: WC=>NULL()
TYPE (BOUNDARY_ELEMENT_FILE_TYPE), POINTER :: BE=>NULL()
TYPE (BOUNDARY_FILE_TYPE), POINTER :: BF=>NULL()
TYPE (ISOSURFACE_FILE_TYPE), POINTER :: IS=>NULL()
TYPE (INITIALIZATION_TYPE), POINTER :: IN=>NULL()
PUBLIC ASSIGN_FILE_NAMES,INITIALIZE_GLOBAL_DUMPS,INITIALIZE_MESH_DUMPS,WRITE_STATUS_FILES, &
TIMINGS,FLUSH_GLOBAL_BUFFERS,FLUSH_EVACUATION_BUFFERS,FLUSH_LOCAL_BUFFERS,READ_RESTART,WRITE_DIAGNOSTICS, &
WRITE_SMOKEVIEW_FILE,DUMP_MESH_OUTPUTS,UPDATE_GLOBAL_OUTPUTS,DUMP_DEVICES,DUMP_HRR,DUMP_MASS, DUMP_CONTROLS,&
GET_REV_dump, INITIALIZE_DIAGNOSTIC_FILE,&
DUMP_VEG,DUMP_UVW,DUMP_BNDE,DUMP_GEOM
CONTAINS
SUBROUTINE UPDATE_GLOBAL_OUTPUTS(T,NM)
USE COMP_FUNCTIONS, ONLY : SECOND
REAL(EB) :: TNOW
INTEGER, INTENT(IN) :: NM
REAL(EB),INTENT(IN) :: T
TNOW = SECOND()
CALL UPDATE_HRR(NM)
CALL UPDATE_MASS(NM)
CALL UPDATE_DEVICES(T,NM)
TUSED(7,NM) = TUSED(7,NM) + SECOND() - TNOW
END SUBROUTINE UPDATE_GLOBAL_OUTPUTS
SUBROUTINE DUMP_MESH_OUTPUTS(T,NM)
USE COMP_FUNCTIONS, ONLY : SECOND
USE EVAC, ONLY : EMESH_NFIELDS, EVAC_FDS6, EMESH_EXITS, EVAC_EMESH_EXITS_TYPE, N_EXITS, N_CO_EXITS, N_DOORS, EMESH_INDEX
IMPLICIT NONE
REAL(EB) :: TNOW, TTMP
REAL(EB), INTENT(IN) :: T
INTEGER, INTENT(IN) :: NM
CHARACTER(80) :: FN_UVW
LOGICAL :: L_READ_EFF
INTEGER :: NFIELDS, I1, I2, I2_NOW, K, N_END
TNOW = SECOND()
EVACUATION_DUMP: IF (ANY(EVACUATION_GRID) .AND. EVACUATION_ONLY(NM)) THEN
! Dump the EVAC flowfieds for all EVAC meshes
L_READ_EFF = BTEST(I_EVAC,2) ! Is the EFF file read in or (re)calculated?
IF (EVAC_FDS6 .AND. EVACUATION_GRID(NM) .AND. ABS(ICYC)==EVAC_TIME_ITERATIONS) THEN
TTMP = EVAC_DT_FLOWFIELD*EMESH_NFIELDS(EMESH_INDEX(NM))*EVAC_TIME_ITERATIONS/&
MAX(1,MAXVAL(EMESH_NFIELDS))
ELSE
TTMP = EVAC_DT_FLOWFIELD*EVAC_TIME_ITERATIONS
END IF
IF (EVAC_FDS6 .AND. EVACUATION_GRID(NM)) THEN
IF (L_READ_EFF) THEN
NFIELDS = EMESH_NFIELDS(EMESH_INDEX(NM))
K = MESHES(NM)%KBAR
N_END = N_EXITS - N_CO_EXITS + N_DOORS
DO I1 = 1, NFIELDS
LOOP_EXITS: DO I2 = 1, N_END
IF (EMESH_EXITS(I2)%MAINMESH == NM .AND. EMESH_EXITS(I2)%I_DOORS_EMESH == I1) THEN
I2_NOW = I2
EXIT LOOP_EXITS
END IF
END DO LOOP_EXITS
MESHES(NM)%U(:,:,K) = EMESH_EXITS(I2_NOW)%U_EVAC(:,:)
MESHES(NM)%V(:,:,K) = EMESH_EXITS(I2_NOW)%V_EVAC(:,:)
MESHES(NM)%U(:,:,0) = MESHES(NM)%U(:,:,K)
MESHES(NM)%V(:,:,0) = MESHES(NM)%V(:,:,K)
MESHES(NM)%U(:,:,K+1) = MESHES(NM)%U(:,:,K)
MESHES(NM)%V(:,:,K+1) = MESHES(NM)%V(:,:,K)
MESHES(NM)%KRES(:,:,:) = 0.5_EB*SQRT(MESHES(NM)%U(:,:,:)**2 + MESHES(NM)%V(:,:,:)**2)
MESHES(NM)%W(:,:,:) = 0.0_EB
TTMP = (NFIELDS - I1 + 1)*EVAC_DT_FLOWFIELD
CALL DUMP_SLCF(T-TTMP,NM,0)
END DO
ELSE
CALL DUMP_SLCF(T-TTMP,NM,0)
END IF
END IF
IF (.NOT.EVAC_FDS6) CALL DUMP_SLCF(T-TTMP,NM,0)
ELSE
IF (T>=PART_CLOCK(NM).AND.PARTICLE_FILE) THEN
IF (SYNCHRONIZE) THEN
IF (.NOT.EB_PART_FILE) CALL DUMP_PART(T,NM)
IF ( EB_PART_FILE) CALL DUMP_PART_EB(T,NM)
ELSE
IF (.NOT.EB_PART_FILE) CALL DUMP_PART(PART_CLOCK(NM),NM)
IF ( EB_PART_FILE) CALL DUMP_PART_EB(PART_CLOCK(NM),NM)
ENDIF
DO
PART_CLOCK(NM) = PART_CLOCK(NM) + DT_PART
IF (PART_CLOCK(NM)>=T) EXIT
ENDDO
ENDIF
IF (T>=ISOF_CLOCK(NM)) THEN
IF (SYNCHRONIZE) THEN
CALL DUMP_ISOF(T,NM)
ELSE
CALL DUMP_ISOF(ISOF_CLOCK(NM),NM)
ENDIF
DO
ISOF_CLOCK(NM) = ISOF_CLOCK(NM) + DT_ISOF
IF (ISOF_CLOCK(NM)>=T) EXIT
ENDDO
ENDIF
IF (T>=SLCF_CLOCK(NM)) THEN
IF (SYNCHRONIZE) THEN
CALL DUMP_SLCF(T,NM,0)
IF (SMOKE3D) CALL DUMP_SMOKE3D(T,NM)
ELSE
CALL DUMP_SLCF(SLCF_CLOCK(NM),NM,0)
IF (SMOKE3D) CALL DUMP_SMOKE3D(SLCF_CLOCK(NM),NM)
ENDIF
DO
SLCF_CLOCK(NM) = SLCF_CLOCK(NM) + DT_SLCF
IF (SLCF_CLOCK(NM)>=T) EXIT
ENDDO
ENDIF
IF (T>=SL3D_CLOCK(NM) .OR. PROCESS_STOP_STATUS/=NO_STOP) THEN
CALL DUMP_SLCF(T,NM,2)
DO
SL3D_CLOCK(NM) = SL3D_CLOCK(NM) + DT_SL3D
IF (SL3D_CLOCK(NM)>=T) EXIT
ENDDO
ENDIF
IF (T>=BNDF_CLOCK(NM)) THEN
IF (SYNCHRONIZE) THEN
CALL DUMP_BNDF(T,NM)
ELSE
CALL DUMP_BNDF(BNDF_CLOCK(NM),NM)
ENDIF
IF(TERRAIN_CASE)THEN
IF (SYNCHRONIZE) THEN
CALL DUMP_BNDF_TO_SLCF(T,NM)
ELSE
CALL DUMP_BNDF_TO_SLCF(BNDF_CLOCK(NM),NM)
ENDIF
ENDIF
DO
BNDF_CLOCK(NM) = BNDF_CLOCK(NM) + DT_BNDF
IF (BNDF_CLOCK(NM)>=T) EXIT
ENDDO
ENDIF
IF (T>=PL3D_CLOCK(NM) .OR. PROCESS_STOP_STATUS/=NO_STOP) THEN
CALL DUMP_SLCF(T,NM,1)
DO
PL3D_CLOCK(NM) = PL3D_CLOCK(NM) + DT_PL3D
IF (PL3D_CLOCK(NM)>=T) EXIT
ENDDO
ENDIF
IF (T>=PROF_CLOCK(NM)) THEN
IF (SYNCHRONIZE) THEN
CALL DUMP_PROF(T,NM)
ELSE
CALL DUMP_PROF(PROF_CLOCK(NM),NM)
ENDIF
DO
PROF_CLOCK(NM) = PROF_CLOCK(NM) + DT_PROF
IF (PROF_CLOCK(NM)>=T) EXIT
ENDDO
ENDIF
IF (T>=CORE_CLOCK(NM) .OR. PROCESS_STOP_STATUS==USER_STOP) THEN
CALL DUMP_CORE(T,NM)
CORE_CLOCK(NM) = CORE_CLOCK(NM) + DT_RESTART
ENDIF
PT2_IF: IF (PERIODIC_TEST==2) THEN
IF (T>=UVW_CLOCK_CBC(IUVW)) THEN
WRITE(FN_UVW,'(A,A,I3.3,A)') TRIM(CHID),'_uvw_',IUVW,'.csv'
CALL DUMP_UVW(NM,FN_UVW)
! IUVW = IUVW + 1
MESHES(NM)%IUVW = MESHES(NM)%IUVW + 1
ENDIF
ENDIF PT2_IF
IF (T>=UVW_TIMER(MESHES(NM)%IUVW)) THEN
IF (NMESHES>1) THEN
WRITE(FN_UVW,'(A,A,I3.3,A,I3.3,A)') TRIM(CHID),'_uvw_t',MESHES(NM)%IUVW,'_m',NM,'.csv'
ELSE
WRITE(FN_UVW,'(A,A,I3.3,A)') TRIM(CHID),'_uvw_',MESHES(NM)%IUVW,'.csv'
ENDIF
CALL DUMP_UVW(NM,FN_UVW)
MESHES(NM)%IUVW = MESHES(NM)%IUVW + 1
ENDIF
ENDIF EVACUATION_DUMP
TUSED(7,NM) = TUSED(7,NM) + SECOND() - TNOW
END SUBROUTINE DUMP_MESH_OUTPUTS
SUBROUTINE ASSIGN_FILE_NAMES
! Assign names and logical units for all output files
USE COMP_FUNCTIONS
INTEGER :: NM,I,N
INTEGER :: N_TREE
CHARACTER(30) :: CFORM
!CHARACTER(100) :: MESSAGE
! Set up file number counter
ALLOCATE(FILE_COUNTER(0:NUMPROCS))
FILE_COUNTER = 10
! Endian File
FN_END = TRIM(CHID)//'.end'
! SVN ID file
FN_SVN = TRIM(CHID)//'_svn.txt'
! Smokeview File
FN_SMV = TRIM(CHID)//'.smv'
! Diagnostic Output File
FN_OUTPUT = TRIM(CHID)//'.out'
IF (.NOT. OVERWRITE) THEN
INQUIRE(FILE=FN_OUTPUT,EXIST=EX)
IF (EX) THEN
WRITE(LU_ERR,'(A,A,A)') 'ERROR: OVERWRITE=.FALSE. and the file ',TRIM(FN_OUTPUT),' exists.'
STOP
ENDIF
ENDIF
! Mass and HRR Files
IF (MASS_FILE) THEN
LU_MASS = GET_FILE_NUMBER()
FN_MASS = TRIM(CHID)//'_mass.csv'
ENDIF
LU_HRR = GET_FILE_NUMBER()
FN_HRR = TRIM(CHID)//'_hrr.csv'
! Device and Control Files
IF(HISTOGRAM_FILE) THEN
LU_HISTOGRAM=GET_FILE_NUMBER()
FN_HISTOGRAM=TRIM(CHID)//'_hist.csv'
ENDIF
IF (COLUMN_DUMP_LIMIT) THEN
N_DEVC_FILES = N_DEVC_TIME / DEVC_COLUMN_LIMIT
IF (N_DEVC_FILES * DEVC_COLUMN_LIMIT < N_DEVC_TIME) N_DEVC_FILES = N_DEVC_FILES + 1
N_CTRL_FILES = N_CTRL / CTRL_COLUMN_LIMIT
IF (N_CTRL_FILES * CTRL_COLUMN_LIMIT < N_CTRL) N_CTRL_FILES = N_CTRL_FILES + 1
ELSE
IF (N_DEVC_TIME >= 1) THEN
N_DEVC_FILES = 1
DEVC_COLUMN_LIMIT = N_DEVC_TIME
ENDIF
IF (N_CTRL >= 1) THEN
N_CTRL_FILES = 1
CTRL_COLUMN_LIMIT = N_CTRL
ENDIF
ENDIF
ALLOCATE(LU_DEVC(N_DEVC_FILES))
ALLOCATE(FN_DEVC(N_DEVC_FILES))
ALLOCATE(LU_CTRL(N_CTRL_FILES))
ALLOCATE(FN_CTRL(N_CTRL_FILES))
DO I=1,N_DEVC_FILES
LU_DEVC(I) = GET_FILE_NUMBER()
WRITE(FN_DEVC(I),'(A,A,I0,A)') TRIM(CHID),'_',I,'_devc.csv'
ENDDO
IF (N_DEVC_FILES==1) FN_DEVC(1) = TRIM(CHID)//'_devc.csv'
DO I=1,N_CTRL_FILES
LU_CTRL(I) = GET_FILE_NUMBER()
WRITE(FN_CTRL(I),'(A,A,I0,A)') TRIM(CHID),'_',I,'_ctrl.csv'
ENDDO
IF (N_CTRL_FILES==1) FN_CTRL(1) = TRIM(CHID)//'_ctrl.csv'
! Line files
IF (N_DEVC_LINE>0) THEN
LU_LINE = GET_FILE_NUMBER()
FN_LINE = TRIM(CHID)//'_line.csv'
ENDIF
! Profile Files
ALLOCATE(LU_PROF(N_PROF))
ALLOCATE(FN_PROF(N_PROF))
DO N=1,N_PROF
LU_PROF(N) = GET_FILE_NUMBER()
IF (N_PROF <100) CFORM = '(A,A,I2.2,A)'
IF (N_PROF>=100) CFORM = '(A,A,I3.3,A)'
WRITE(FN_PROF(N),CFORM) TRIM(CHID),'_prof_',N,'.csv'
ENDDO
! Vegetation File(s) for Fuel Element model
IF (N_TREES_OUT > 0) THEN
N_TREE = 0
ALLOCATE(LU_VEG_OUT(N_TREES_OUT))
ALLOCATE(FN_VEG_OUT(N_TREES_OUT))
DO N = 1,N_TREES
N_TREE = N_TREE_OUT(N)
IF (N_TREE /= 0) THEN
LU_VEG_OUT(N_TREE) = GET_FILE_NUMBER()
WRITE(FN_VEG_OUT(N_TREE),'(A,A,A,A)') TRIM(CHID),'_',TRIM(VEG_LABELS(N)), &
'_vegout.csv'
ENDIF
ENDDO
ENDIF
! Plot3D
ALLOCATE(FN_XYZ(NMESHES))
ALLOCATE(LU_XYZ(NMESHES))
ALLOCATE(FN_PL3D(NMESHES))
ALLOCATE(LU_PL3D(NMESHES))
ALLOCATE(FN_ISOF(N_ISOF,NMESHES))
ALLOCATE(LU_ISOF(N_ISOF,NMESHES))
ALLOCATE(FN_SLCF(N_SLCF_MAX,NMESHES))
ALLOCATE(LU_SLCF(N_SLCF_MAX,NMESHES))
ALLOCATE(FN_GEOM(1)) ! later each geometry group may have a serparate file
ALLOCATE(LU_GEOM(1))
ALLOCATE(FN_BNDE(N_BNDE))
ALLOCATE(LU_BNDE(N_BNDE))
ALLOCATE(FN_BNDF(N_BNDF,NMESHES))
ALLOCATE(LU_BNDF(N_BNDF,NMESHES))
IF(TERRAIN_CASE)THEN
ALLOCATE(FN_BNDF_SLCF(N_BNDF,NMESHES))
ALLOCATE(LU_BNDF_SLCF(N_BNDF,NMESHES))
ENDIF
ALLOCATE(FN_SMOKE3D(2,NMESHES))
ALLOCATE(LU_SMOKE3D(2,NMESHES))
ALLOCATE(FN_PART(NMESHES))
ALLOCATE(LU_PART(NMESHES))
ALLOCATE(FN_CORE(NMESHES))
ALLOCATE(LU_CORE(NMESHES))
ALLOCATE(FN_RESTART(NMESHES))
ALLOCATE(LU_RESTART(NMESHES))
MESH_LOOP: DO NM=1,NMESHES
IF (PROCESS(NM)/=MYID) CYCLE MESH_LOOP
M => MESHES(NM)
! Plot3D Files
LU_XYZ(NM) = GET_FILE_NUMBER()
LU_PL3D(NM) = GET_FILE_NUMBER()
IF (NMESHES >1) WRITE(FN_XYZ(NM),'(A,A,I4.4,A)') TRIM(CHID),'_',NM,'.xyz'
IF (NMESHES==1) WRITE(FN_XYZ(NM),'(A,A)') TRIM(CHID), '.xyz'
DO N=1,N_ISOF
IF (NMESHES >1) WRITE(FN_ISOF(N,NM),'(A,A,I4.4,A,I2.2,A)') TRIM(CHID),'_',NM,'_',N,'.iso'
IF (NMESHES==1) WRITE(FN_ISOF(N,NM),'(A,A,I2.2,A)') TRIM(CHID),'_',N,'.iso'
ENDDO
IF (NMESHES >1) WRITE(FN_SMOKE3D(1,NM),'(A,A,I4.4,A)') TRIM(CHID),'_',NM,'_01.s3d'
IF (NMESHES==1) WRITE(FN_SMOKE3D(1,NM),'(A,A)') TRIM(CHID), '_01.s3d'
IF (NMESHES >1) WRITE(FN_SMOKE3D(2,NM),'(A,A,I4.4,A)') TRIM(CHID),'_',NM,'_02.s3d'
IF (NMESHES==1) WRITE(FN_SMOKE3D(2,NM),'(A,A)') TRIM(CHID), '_02.s3d'
! Slice Files
DO N=1,M%N_SLCF
LU_SLCF(N,NM) = GET_FILE_NUMBER()
IF (NMESHES>1) THEN
IF (M%N_SLCF <100) CFORM = '(A,A,I4.4,A,I2.2,A)'
IF (M%N_SLCF>=100) CFORM = '(A,A,I4.4,A,I3.3,A)'
WRITE(FN_SLCF(N,NM),CFORM) TRIM(CHID),'_',NM,'_',N,'.sf'
ELSE
IF (M%N_SLCF <100) CFORM = '(A,A,I2.2,A)'
IF (M%N_SLCF>=100) CFORM = '(A,A,I3.3,A)'
WRITE(FN_SLCF(N,NM),CFORM) TRIM(CHID),'_',N,'.sf'
ENDIF
ENDDO
! Boundary Files
DO N=1,N_BNDF
LU_BNDF(N,NM) = GET_FILE_NUMBER()
IF (NMESHES>1) THEN
WRITE(FN_BNDF(N,NM),'(A,A,I4.4,A,I2.2,A)') TRIM(CHID),'_',NM,'_',N,'.bf'
ELSE
WRITE(FN_BNDF(N,NM),'(A,A,I2.2,A)') TRIM(CHID),'_',N,'.bf'
ENDIF
ENDDO
! Boundary Files mapped to slice files for terrain cases
IF(TERRAIN_CASE) THEN
DO N=1,N_BNDF
LU_BNDF_SLCF(N,NM) = GET_FILE_NUMBER()
IF (NMESHES>1) THEN
WRITE(FN_BNDF_SLCF(N,NM),'(A,A,I4.4,A,I2.2,A)') TRIM(CHID),'_',NM,'_',N,'_bf.sf'
ELSE
WRITE(FN_BNDF_SLCF(N,NM),'(A,A,I2.2,A)') TRIM(CHID),'_',N,'_bf.sf'
ENDIF
ENDDO
ENDIF
! Particle Files
IF (PARTICLE_FILE .AND. .NOT.EVACUATION_ONLY(NM)) THEN
LU_PART(NM) = GET_FILE_NUMBER()
IF (NMESHES>1) THEN
WRITE(FN_PART(NM),'(A,I4.4,A)') TRIM(CHID)//'_',NM,'.prt5'
ELSE
WRITE(FN_PART(NM),'(A,A)') TRIM(CHID),'.prt5'
ENDIF
ENDIF
! Particle Files for Evacuation
IF (EVACUATION_GRID(NM)) THEN
LU_PART(NM) = GET_FILE_NUMBER()
IF (NMESHES>1) THEN
WRITE(FN_PART(NM),'(A,I4.4,A)') TRIM(CHID)//'_',NM,'.prt5'
ELSE
WRITE(FN_PART(NM),'(A,A)') TRIM(CHID),'.prt5'
ENDIF
ENDIF
! Restart Files
LU_RESTART(NM) = GET_FILE_NUMBER()
WRITE(FN_RESTART(NM),'(A,A,I4.4,A)') TRIM(RESTART_CHID),'_',NM,'.restart'
LU_CORE(NM) = GET_FILE_NUMBER()
WRITE(FN_CORE(NM), '(A,A,I4.4,A)') TRIM(CHID),'_',NM,'.restart'
ENDDO MESH_LOOP
! Boundary Element Files
DO N=1,N_BNDE
LU_BNDE(N) = GET_FILE_NUMBER()
WRITE(FN_BNDE(N),'(A,A,I2.2,A)') TRIM(CHID),'_',N,'.be'
ENDDO
! Unstructured Geometry Files
IF (N_FACE>0) THEN
DO N=1,1
LU_GEOM(N) = GET_FILE_NUMBER()
WRITE(FN_GEOM(N),'(A,A,I2.2,A)') TRIM(CHID),'_',N,'.ge'
ENDDO
ENDIF
! Status File
IF (STATUS_FILES) THEN
LU_NOTREADY = GET_FILE_NUMBER()
FN_NOTREADY = TRIM(CHID)//'.notready'
ENDIF
IF (VELOCITY_ERROR_FILE) THEN
LU_VELOCITY_ERROR = GET_FILE_NUMBER()
FN_VELOCITY_ERROR = TRIM(CHID)//'_pressit.csv'
ENDIF
IF (N_INIT>0) THEN
DO N=1,N_INIT
INITIALIZATION(N)%LU_PARTICLE = GET_FILE_NUMBER()
ENDDO
ENDIF
END SUBROUTINE ASSIGN_FILE_NAMES
SUBROUTINE INITIALIZE_GLOBAL_DUMPS
! Open and initialize all files that are not tied to a particular mesh
USE COMP_FUNCTIONS, ONLY: SECOND
USE PHYSICAL_FUNCTIONS, ONLY: GET_MASS_FRACTION_ALL,GET_MOLECULAR_WEIGHT
USE CONTROL_VARIABLES
REAL(EB) :: TNOW
INTEGER :: NN,I,N,N_OUT
CHARACTER(30), DIMENSION(42) :: LABEL='null'
TNOW=SECOND()
CALL INITIALIZE_DIAGNOSTIC_FILE
! Initialize device output file (CHID_devc.csv)
IF (N_DEVC_TIME>0) THEN
ALLOCATE(TIME_DEVC_LABEL(N_DEVC_TIME))
ALLOCATE(TIME_DEVC_UNITS(N_DEVC_TIME))
ALLOCATE(TIME_DEVC_VALUE(N_DEVC_TIME))
NN = 0
DO N=1,N_DEVC
DV => DEVICE(N)
IF (DV%LINE==0 .AND. DV%OUTPUT) THEN
NN = NN + 1
TIME_DEVC_LABEL(NN) = DV%ID
TIME_DEVC_UNITS(NN) = DV%UNITS
ENDIF
ENDDO
DO I = 1,N_DEVC_FILES
IF (APPEND) THEN
OPEN(LU_DEVC(I),FILE=FN_DEVC(I),FORM='FORMATTED',STATUS='OLD',POSITION='APPEND')
ELSE
N_OUT = MIN(DEVC_COLUMN_LIMIT , N_DEVC_TIME-DEVC_COLUMN_LIMIT*(I-1))
OPEN(LU_DEVC(I),FILE=FN_DEVC(I),FORM='FORMATTED',STATUS='REPLACE')
WRITE(TCFORM,'(A,I4.4,A)') "(",N_OUT,"(A,','),A)"
WRITE(LU_DEVC(I),TCFORM) 's',(TRIM(TIME_DEVC_UNITS(N)),N=DEVC_COLUMN_LIMIT*(I-1)+1,MIN(N_DEVC_TIME,I*DEVC_COLUMN_LIMIT))
WRITE(TCFORM,'(A,I4.4,A)') "(A,",N_OUT,"(',',3A))"
WRITE(LU_DEVC(I),TCFORM) 'Time',('"',TRIM(TIME_DEVC_LABEL(N)),'"', &
N=DEVC_COLUMN_LIMIT * (I - 1) + 1,MIN(N_DEVC_TIME, I * DEVC_COLUMN_LIMIT))
ENDIF
ENDDO
ENDIF
! Define labels for line devices
IF (N_DEVC_LINE>0) THEN
ALLOCATE(LINE_DEVC_LABEL(N_DEVC_LINE))
ALLOCATE(LINE_DEVC_UNITS(N_DEVC_LINE))
ALLOCATE(LINE_DEVC_VALUE(N_DEVC_LINE,MAX_DEVC_LINE_POINTS))
NN = 0
DO N=1,N_DEVC
DV => DEVICE(N)
IF (DV%LINE>0 .AND. DV%POINT==1) THEN
NN = NN+1
SELECT CASE(DV%LINE_COORD_CODE)
CASE(0)
LINE_DEVC_LABEL(NN) = TRIM(DV%ID)
LINE_DEVC_UNITS(NN) = TRIM(DV%UNITS)
CASE(1)
LINE_DEVC_LABEL(NN) = TRIM(DV%X_ID)//','//TRIM(DV%ID)
LINE_DEVC_UNITS(NN) = 'm,'//TRIM(DV%UNITS)
CASE(2)
LINE_DEVC_LABEL(NN) = TRIM(DV%Y_ID)//','//TRIM(DV%ID)
LINE_DEVC_UNITS(NN) = 'm,'//TRIM(DV%UNITS)
CASE(3)
LINE_DEVC_LABEL(NN) = TRIM(DV%Z_ID)//','//TRIM(DV%ID)
LINE_DEVC_UNITS(NN) = 'm,'//TRIM(DV%UNITS)
CASE(12)
LINE_DEVC_LABEL(NN) = TRIM(DV%X_ID)//','//TRIM(DV%Y_ID)//','//TRIM(DV%ID)
LINE_DEVC_UNITS(NN) = 'm,m,'//TRIM(DV%UNITS)
CASE(13)
LINE_DEVC_LABEL(NN) = TRIM(DV%X_ID)//','//TRIM(DV%Z_ID)//','//TRIM(DV%ID)
LINE_DEVC_UNITS(NN) = 'm,m,'//TRIM(DV%UNITS)
CASE(23)
LINE_DEVC_LABEL(NN) = TRIM(DV%Y_ID)//','//TRIM(DV%Z_ID)//','//TRIM(DV%ID)
LINE_DEVC_UNITS(NN) = 'm,m,'//TRIM(DV%UNITS)
CASE(123)
LINE_DEVC_LABEL(NN) = TRIM(DV%X_ID)//','//TRIM(DV%Y_ID)//','//TRIM(DV%Z_ID)//','//TRIM(DV%ID)
LINE_DEVC_UNITS(NN) = 'm,m,m,'//TRIM(DV%UNITS)
END SELECT
ENDIF
ENDDO
ENDIF
! Initialize control output file (CHID_ctrl.csv)
IF (N_CTRL>0) THEN
DO I = 1,N_CTRL_FILES
IF (APPEND) THEN
OPEN(LU_CTRL(I),FILE=FN_CTRL(I),FORM='FORMATTED',STATUS='OLD',POSITION='APPEND')
ELSE
OPEN(LU_CTRL(I),FILE=FN_CTRL(I),FORM='FORMATTED',STATUS='REPLACE')
N_OUT = MIN(CTRL_COLUMN_LIMIT, N_CTRL - CTRL_COLUMN_LIMIT * (I - 1))
WRITE(TCFORM,'(A,I4.4,A)') "(",N_OUT,"(A,','),A)"
WRITE(LU_CTRL(I),TCFORM) 's',('status',N=CTRL_COLUMN_LIMIT * (I - 1) + 1,MIN(N_CTRL, I * CTRL_COLUMN_LIMIT))
WRITE(TCFORM,'(A,I4.4,A)') "(A,",N_OUT,"(',',3A))"
WRITE(LU_CTRL(I),TCFORM) 'Time',('"',TRIM(CONTROL(N)%ID),'"', &
N=CTRL_COLUMN_LIMIT * (I - 1) + 1,MIN(N_CTRL, I * CTRL_COLUMN_LIMIT))
ENDIF
ENDDO
ENDIF
! Open heat release rate file (CHID_hrr.csv)
IF (APPEND) THEN
OPEN(LU_HRR,FILE=FN_HRR,FORM='FORMATTED',STATUS='OLD',POSITION='APPEND')
ELSE
OPEN(LU_HRR,FILE=FN_HRR,FORM='FORMATTED',STATUS='REPLACE')
WRITE(TCFORM,'(A,I4.4,A)') "(",6+N_ZONE,"(A,','),A)"
WRITE(LU_HRR,TCFORM) 's','kW','kW','kW','kW','kW','kg/s',('Pa',N=1,N_ZONE)
WRITE(LU_HRR,TCFORM) 'Time','HRR','Q_RADI','Q_OPEN','Q_WALL','Q_TOTAL','BURN_RATE',(TRIM(P_ZONE(N)%ID),N=1,N_ZONE)
ENDIF
! Open vegetation ouput files(s) for Fuel Element model
DO N=1,N_TREES_OUT
IF (APPEND) THEN
OPEN(LU_VEG_OUT(N),FILE=FN_VEG_OUT(N),FORM='FORMATTED',STATUS='OLD',POSITION='APPEND')
ELSE
OPEN(LU_VEG_OUT(N),FILE=FN_VEG_OUT(N),FORM='FORMATTED',STATUS='REPLACE')
WRITE(LU_VEG_OUT(N),'(A,A,A,A,A,A,A,A,A,A,A)')'s, ','C, ','C, ','kg, ','kg, ','kg, ','kg ','kW, ','kW','kg','kW'
WRITE(LU_VEG_OUT(N),'(A,A,A,A,A,A,A,A,A,A,A)')'Time, ','TreeAvgTempVeg, ','TreeAvgTempGas, ', &
'Total_Tree_Dry_Mass, ', 'Total_Tree_Moist_Mass, ', &
'Total_Tree_Char_Mass, ','Total_Tree_Ash_Mass, ', &
'TreeAvg_int_div(qveg_conv)dVe, ','TreeAvg_int_div(qveg_rad)dVe, ', &
'Total Char Loss, ','Total CharOx HRR'
ENDIF
ENDDO
! Open species mass file
IF_DUMP_SPECIES_INFO: IF (MASS_FILE) THEN
IF (APPEND) THEN
OPEN(LU_MASS,FILE=FN_MASS,FORM='FORMATTED',STATUS='OLD',POSITION='APPEND')
ELSE
OPEN(LU_MASS,FILE=FN_MASS,FORM='FORMATTED',STATUS='REPLACE')
LABEL(1) = 'Time'
LABEL(2) = 'Total'
NN=2
LABEL(3:3+N_SPECIES-1) = SPECIES(1:N_SPECIES)%ID
WRITE(TCFORM,'(A,I4.4,A)') "(",N_SPECIES+1,"(A,','),A)"
WRITE(LU_MASS,TCFORM) 's',('kg',N=1,N_SPECIES+1)
WRITE(LU_MASS,TCFORM) (TRIM(LABEL(N)),N=1,N_SPECIES+2)
ENDIF
ENDIF IF_DUMP_SPECIES_INFO
! Special output for pressure iteration scheme
IF (VELOCITY_ERROR_FILE) THEN
OPEN(UNIT=LU_VELOCITY_ERROR,FILE=FN_VELOCITY_ERROR,FORM='FORMATTED',STATUS='UNKNOWN',POSITION='REWIND')
WRITE(LU_VELOCITY_ERROR,'(A)') 'ICYC, PRESS IT, VELOCITY_ERROR_MAX'
ENDIF
BOUNDARY_ELEMENT_FILES: DO N=1,N_BNDE
RESTART_BE: IF (APPEND) THEN
OPEN(LU_BNDE(N),FILE=FN_BNDE(N),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND')
ELSE RESTART_BE
OPEN(LU_BNDE(N),FILE=FN_BNDE(N),FORM='UNFORMATTED',STATUS='REPLACE')
WRITE(LU_BNDE(N)) ONE_INTEGER
WRITE(LU_BNDE(N)) NINT(VERSION_NUMBER*100.)
ENDIF RESTART_BE
ENDDO BOUNDARY_ELEMENT_FILES
UNSTRUCTURED_GEOMETRY: IF (N_FACE>0) THEN
DO N=1,1 ! loop over number of geometry groups
RESTART_GE: IF (APPEND) THEN
OPEN(LU_GEOM(N),FILE=FN_GEOM(N),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND')
ELSE RESTART_GE
OPEN(LU_GEOM(N),FILE=FN_GEOM(N),FORM='UNFORMATTED',STATUS='REPLACE')
WRITE(LU_GEOM(N)) ONE_INTEGER
WRITE(LU_GEOM(N)) NINT(VERSION_NUMBER*100.)
ENDIF RESTART_GE
ENDDO
ENDIF UNSTRUCTURED_GEOMETRY
TUSED(7,:) = TUSED(7,:) + SECOND() - TNOW
END SUBROUTINE INITIALIZE_GLOBAL_DUMPS
SUBROUTINE INITIALIZE_MESH_DUMPS(NM)
USE COMP_FUNCTIONS, ONLY : SECOND
USE MEMORY_FUNCTIONS, ONLY:RE_ALLOCATE_STRINGS,CHKMEMERR
USE EVAC, ONLY : EVAC_FDS6
INTEGER, INTENT(IN) :: NM
INTEGER :: IOR,IZERO,I,J,K,N,ERROR,I1,I2,J1,J2,K1,K2,I1B,I2B,IW,NN,NF
INTEGER :: NTSL
CHARACTER(30) :: LABEL1,LABEL2,LABEL3
REAL(EB) :: TNOW
TNOW=SECOND()
M => MESHES(NM)
IBAR=>M%IBAR
JBAR=>M%JBAR
KBAR=>M%KBAR
IBP1=>M%IBP1
JBP1=>M%JBP1
KBP1=>M%KBP1
! Compute grid coords in single precision for output
ALLOCATE(M%XPLT(0:IBAR),STAT=IZERO)
CALL ChkMemErr('DUMP','XPLT',IZERO)
ALLOCATE(M%YPLT(0:JBAR),STAT=IZERO)
CALL ChkMemErr('DUMP','YPLT',IZERO)
ALLOCATE(M%ZPLT(0:KBAR),STAT=IZERO)
CALL ChkMemErr('DUMP','ZPLT',IZERO)
DO I=0,IBAR
M%XPLT(I) = M%X(I)
ENDDO
DO J=0,JBAR
M%YPLT(J) = M%Y(J)
ENDDO
DO K=0,KBAR
M%ZPLT(K) = M%Z(K)
ENDDO
! Initialize PLOT3D grid file (CHID.xyz)
IF (.NOT.EVACUATION_ONLY(NM)) THEN
ALLOCATE(M%IBLK(0:IBAR,0:JBAR,0:KBAR),STAT=IZERO)
CALL ChkMemErr('DUMP','IBLK',IZERO)
ENDIF
ALLOCATE(M%QQ(0:IBP1,0:JBP1,0:KBP1,5),STAT=IZERO)
CALL ChkMemErr('DUMP','QQ',IZERO)
M%QQ=0._FB
WRITE_XYZ_FILE: IF (WRITE_XYZ .AND..NOT.EVACUATION_ONLY(NM)) THEN
OPEN(LU_XYZ(NM),FILE=FN_XYZ(NM),FORM='UNFORMATTED',STATUS='REPLACE')
DO K=0,KBAR
DO J=0,JBAR
DO I=0,IBAR
IF (M%SOLID(M%CELL_INDEX(I,J,K)) .AND. M%SOLID(M%CELL_INDEX(I+1,J,K)) .AND. &
M%SOLID(M%CELL_INDEX(I,J+1,K)) .AND. M%SOLID(M%CELL_INDEX(I,J,K+1)) .AND. &
M%SOLID(M%CELL_INDEX(I+1,J+1,K)).AND. M%SOLID(M%CELL_INDEX(I+1,J,K+1)) .AND. &
M%SOLID(M%CELL_INDEX(I,J+1,K+1)).AND. M%SOLID(M%CELL_INDEX(I+1,J+1,K+1)) ) THEN
M%IBLK(I,J,K) = 0
ELSE
M%IBLK(I,J,K) = 1
ENDIF
ENDDO
ENDDO
ENDDO
WRITE(LU_XYZ(NM)) IBP1,JBP1,KBP1
WRITE(LU_XYZ(NM)) (((M%XPLT(I),I=0,IBAR),J=0,JBAR),K=0,KBAR),(((M%YPLT(J),I=0,IBAR),J=0,JBAR),K=0,KBAR), &
(((M%ZPLT(K),I=0,IBAR),J=0,JBAR),K=0,KBAR),(((M%IBLK(I,J,K),I=0,IBAR),J=0,JBAR),K=0,KBAR)
CLOSE(LU_XYZ(NM))
IF (M%N_STRINGS+2>M%N_STRINGS_MAX) THEN
CALL RE_ALLOCATE_STRINGS(NM)
ENDIF
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(A)') 'XYZ'
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(FN_XYZ(NM))
ENDIF WRITE_XYZ_FILE
! Re-allocate IBLK array for use with isosurface generation
IF (.NOT.EVACUATION_ONLY(NM)) THEN
DEALLOCATE(M%IBLK)
ALLOCATE(M%IBLK(1:IBAR,1:JBAR,1:KBAR),STAT=IZERO)
CALL ChkMemErr('DUMP','IBLK',IZERO)
ENDIF
! Initialize isosurface file
IF (.NOT.APPEND .AND. .NOT.EVACUATION_ONLY(NM)) THEN
DO N=1,N_ISOF
IS => ISOSURFACE_FILE(N)
IF (M%N_STRINGS+5>M%N_STRINGS_MAX) CALL RE_ALLOCATE_STRINGS(NM)
M%N_STRINGS = M%N_STRINGS + 1
IF (IS%INDEX2==0) THEN
WRITE(M%STRING(M%N_STRINGS),'(A,I6)') 'ISOF',NM
ELSE
WRITE(M%STRING(M%N_STRINGS),'(A,I6)') 'TISOF',NM
ENDIF
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(FN_ISOF(N,NM))
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(IS%SMOKEVIEW_LABEL)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(IS%SMOKEVIEW_BAR_LABEL)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(OUTPUT_QUANTITY(IS%INDEX)%UNITS)
IF (IS%INDEX2/=0) THEN
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(IS%SMOKEVIEW_LABEL2)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(IS%SMOKEVIEW_BAR_LABEL2)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(OUTPUT_QUANTITY(IS%INDEX2)%UNITS)
ENDIF
LABEL1 = TRIM(IS%SMOKEVIEW_LABEL)//CHAR(0)
LABEL2 = TRIM(IS%SMOKEVIEW_BAR_LABEL)//CHAR(0)
LABEL3 = TRIM(OUTPUT_QUANTITY(IS%INDEX)%UNITS)//CHAR(0)
ERROR = 0
IF (IS%INDEX2==0) CALL ISOHEADER(TRIM(FN_ISOF(N,NM))//CHAR(0),LABEL1,LABEL2,LABEL3, &
IS%VALUE(1:IS%N_VALUES),IS%N_VALUES,ERROR)
IF (IS%INDEX2/=0) CALL TISOHEADER(TRIM(FN_ISOF(N,NM))//CHAR(0),LABEL1,LABEL2,LABEL3, &
IS%VALUE(1:IS%N_VALUES),IS%N_VALUES,ERROR)
ENDDO
ENDIF
! Initialize Smoke3d file
SMOKE3D_INITIALIZATION: IF (SMOKE3D .AND..NOT.EVACUATION_ONLY(NM)) THEN
IF (.NOT.APPEND) THEN
IF (M%N_STRINGS+5>M%N_STRINGS_MAX) CALL RE_ALLOCATE_STRINGS(NM)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(A,I6)') 'SMOKE3D',NM
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(FN_SMOKE3D(1,NM))
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(SMOKE3D_SMOKEVIEW_LABEL)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(SMOKE3D_SMOKEVIEW_BAR_LABEL)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(OUTPUT_QUANTITY(SMOKE3D_QUANTITY_INDEX)%UNITS)
CALL SMOKE3DHEADER(TRIM(FN_SMOKE3D(1,NM))//CHAR(0),0,M%IBAR,0,M%JBAR,0,M%KBAR)
ENDIF
IF (.NOT.APPEND .AND. SMOKE3D_QUANTITY_INDEX/=11) THEN
IF (M%N_STRINGS+5>M%N_STRINGS_MAX) CALL RE_ALLOCATE_STRINGS(NM)
M%N_STRINGS = M%N_STRINGS + 1
IF(USE_HRRPUV_MAX_SMV==1)THEN
WRITE(M%STRING(M%N_STRINGS),'(A,I6,1X,E13.6)') 'VSMOKE3D',NM,HRRPUV_MAX_SMV
ELSE
WRITE(M%STRING(M%N_STRINGS),'(A,I6)') 'SMOKE3D',NM
ENDIF
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(FN_SMOKE3D(2,NM))
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(OUTPUT_QUANTITY(11)%NAME)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(OUTPUT_QUANTITY(11)%SHORT_NAME)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(OUTPUT_QUANTITY(11)%UNITS)
CALL SMOKE3DHEADER(TRIM(FN_SMOKE3D(2,NM))//CHAR(0),0,M%IBAR,0,M%JBAR,0,M%KBAR)
ENDIF
ENDIF SMOKE3D_INITIALIZATION
! Initialize Slice Files
NTSL = 0
DO N=1,M%N_SLCF
SL => M%SLICE(N)
IF (APPEND) THEN
OPEN(LU_SLCF(N,NM),FILE=FN_SLCF(N,NM),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND')
ELSE
IF (M%N_STRINGS+5>M%N_STRINGS_MAX) CALL RE_ALLOCATE_STRINGS(NM)
M%N_STRINGS = M%N_STRINGS + 1
IF (SL%ID/='null') THEN
IF (.NOT.SL%TERRAIN_SLICE.AND..NOT.SL%CELL_CENTERED) WRITE(M%STRING(M%N_STRINGS),'(A,I6,A,A)') 'SLCF',NM,' %',TRIM(SL%ID)
IF (SL%CELL_CENTERED) WRITE(M%STRING(M%N_STRINGS),'(A,I6,A,A)') 'SLCC',NM,' %',TRIM(SL%ID)
ELSE
IF (.NOT.SL%TERRAIN_SLICE.AND..NOT.SL%CELL_CENTERED) WRITE(M%STRING(M%N_STRINGS),'(A,I6)') 'SLCF',NM
IF (SL%CELL_CENTERED) WRITE(M%STRING(M%N_STRINGS),'(A,I6)') 'SLCC',NM
ENDIF
IF (SL%TERRAIN_SLICE)THEN
IF (SL%FIRE_LINE) THEN
WRITE(M%STRING(M%N_STRINGS),'(A,I6,F10.4)') 'SLFL',NM,SL%SLICE_AGL
ELSE
WRITE(M%STRING(M%N_STRINGS),'(A,I6,F10.4)') 'SLCT',NM,SL%SLICE_AGL
ENDIF
ENDIF
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(FN_SLCF(N,NM))
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(SL%SMOKEVIEW_LABEL)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(SL%SMOKEVIEW_BAR_LABEL)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(OUTPUT_QUANTITY(SL%INDEX)%UNITS)
OPEN(LU_SLCF(N,NM),FILE=FN_SLCF(N,NM),FORM='UNFORMATTED',STATUS='REPLACE')
WRITE(LU_SLCF(N,NM)) SL%SMOKEVIEW_LABEL(1:30)
WRITE(LU_SLCF(N,NM)) SL%SMOKEVIEW_BAR_LABEL(1:30)
WRITE(LU_SLCF(N,NM)) OUTPUT_QUANTITY(SL%INDEX)%UNITS(1:30)
IF (.NOT. SL%TERRAIN_SLICE) THEN
WRITE(LU_SLCF(N,NM)) SL%I1,SL%I2,SL%J1,SL%J2,SL%K1,SL%K2
ELSE
NTSL = NTSL + 1
IF (SL%I1 == 0) M%K_AGL_SLICE(0,SL%J1:SL%J2,NTSL) = M%K_AGL_SLICE(1,SL%J1:SL%J2,NTSL)
IF (SL%I2 == IBP1) M%K_AGL_SLICE(IBP1,SL%J1:SL%J2,NTSL) = M%K_AGL_SLICE(IBP1-1,SL%J1:SL%J2,NTSL)
IF (SL%J1 == 0) M%K_AGL_SLICE(SL%I1:SL%I2,0,NTSL) = M%K_AGL_SLICE(SL%I1:SL%I2,1,NTSL)
IF (SL%J2 == JBP1) M%K_AGL_SLICE(SL%I1:SL%I2,JBP1,NTSL) = M%K_AGL_SLICE(SL%I1:SL%I2,JBP1-1,NTSL)
WRITE(LU_SLCF(N,NM)) SL%I1,SL%I2,SL%J1,SL%J2,M%K_AGL_SLICE(SL%I1,SL%J1,NTSL),M%K_AGL_SLICE(SL%I1,SL%J1,NTSL)
ENDIF
ENDIF
ENDDO
! Initialize Boundary Files
IF_BOUNDARY_FILES: IF (N_BNDF>0 .AND. .NOT.EVACUATION_ONLY(NM)) THEN
I1B = MAX(IBP1,JBP1)
I2B = MAX(JBP1,KBP1)
ALLOCATE(M%PP(0:I1B,0:I2B),STAT=IZERO)
CALL ChkMemErr('DUMP','PP',IZERO)
M%PP = 0._EB
ALLOCATE(M%PPN(0:I1B,0:I2B),STAT=IZERO)
CALL ChkMemErr('DUMP','PPN',IZERO)
ALLOCATE(M%IBK(0:I1B,0:I2B),STAT=IZERO)
CALL ChkMemErr('DUMP','IBK',IZERO)
IF_NOT_APPEND: IF (.NOT.APPEND) THEN
M%INC = 0
DO IW=1,M%N_EXTERNAL_WALL_CELLS+M%N_INTERNAL_WALL_CELLS
IOR = M%WALL(IW)%IOR
IF (M%WALL(IW)%BOUNDARY_TYPE==SOLID_BOUNDARY .OR. M%WALL(IW)%BOUNDARY_TYPE==NULL_BOUNDARY) &
M%INC(IOR,M%WALL(IW)%OBST_INDEX) = 1
IF (.NOT.BNDF_DEFAULT .AND. M%WALL(IW)%OBST_INDEX==0) M%INC(IOR,M%WALL(IW)%OBST_INDEX) = 0
ENDDO
M%NPATCH = 0
DO N=0,M%N_OBST
OB=>M%OBSTRUCTION(N)
DO I=-3,3
IF (.NOT.OB%SHOW_BNDF(I)) M%INC(I,N) = 0
IF (M%INC(I,N)==1) M%NPATCH = M%NPATCH + 1
ENDDO
ENDDO
ENDIF IF_NOT_APPEND
ENDIF IF_BOUNDARY_FILES
BOUNDARY_FILES: DO NF=1,N_BNDF
BF => BOUNDARY_FILE(NF)
IF (M%NPATCH==0) EXIT BOUNDARY_FILES
IF (EVACUATION_ONLY(NM)) EXIT BOUNDARY_FILES
RESTART: IF (APPEND) THEN
OPEN(LU_BNDF(NF,NM),FILE=FN_BNDF(NF,NM),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND')
IF(TERRAIN_CASE)THEN
OPEN(LU_BNDF_SLCF(NF,NM),FILE=FN_BNDF_SLCF(NF,NM),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND')
ENDIF
ELSE RESTART
IF (M%N_STRINGS+5>M%N_STRINGS_MAX) CALL RE_ALLOCATE_STRINGS(NM)
M%N_STRINGS = M%N_STRINGS + 1
IF (BF%CELL_CENTERED) THEN
WRITE(M%STRING(M%N_STRINGS),'(A,2I6)') 'BNDC',NM,1
ELSE
WRITE(M%STRING(M%N_STRINGS),'(A,2I6)') 'BNDF',NM,1
ENDIF
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(FN_BNDF(NF,NM))
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(BF%SMOKEVIEW_LABEL)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(BF%SMOKEVIEW_BAR_LABEL)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(OUTPUT_QUANTITY(BF%INDEX)%UNITS)
OPEN(LU_BNDF(NF,NM),FILE=FN_BNDF(NF,NM),FORM='UNFORMATTED',STATUS='REPLACE')
WRITE(LU_BNDF(NF,NM)) BF%SMOKEVIEW_LABEL(1:30)
WRITE(LU_BNDF(NF,NM)) BF%SMOKEVIEW_BAR_LABEL(1:30)
WRITE(LU_BNDF(NF,NM)) OUTPUT_QUANTITY(BF%INDEX)%UNITS(1:30)
WRITE(LU_BNDF(NF,NM)) M%NPATCH
IF (M%INC(-3,0)==1) WRITE(LU_BNDF(NF,NM)) 0,IBAR,0,JBAR,KBAR,KBAR,-3,0,NM
IF (M%INC(-2,0)==1) WRITE(LU_BNDF(NF,NM)) 0,IBAR,JBAR,JBAR,0,KBAR,-2,0,NM
IF (M%INC(-1,0)==1) WRITE(LU_BNDF(NF,NM)) IBAR,IBAR,0,JBAR,0,KBAR,-1,0,NM
IF (M%INC( 1,0)==1) WRITE(LU_BNDF(NF,NM)) 0, 0,0,JBAR,0,KBAR, 1,0,NM
IF (M%INC( 2,0)==1) WRITE(LU_BNDF(NF,NM)) 0,IBAR, 0,0,0,KBAR, 2,0,NM