-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoutput_common.orig
1563 lines (1235 loc) · 51.5 KB
/
output_common.orig
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
!! output_common_original.f90
integer function bad_outputtype()
use ModInputs, only : OutputType, nOutputTypes
implicit none
integer :: iOutputType
logical :: IsFound
do iOutputType = 1, nOutputTypes
IsFound = .false.
if (OutputType(iOutputType) == '3DALL') IsFound = .true.
if (OutputType(iOutputType) == '3DNEU') IsFound = .true.
if (OutputType(iOutputType) == '3DION') IsFound = .true.
if (OutputType(iOutputType) == '3DTHM') IsFound = .true.
if (OutputType(iOutputType) == '3DCHM') IsFound = .true.
if (OutputType(iOutputType) == '3DUSR') IsFound = .true.
if (OutputType(iOutputType) == '3DGLO') IsFound = .true.
if (OutputType(iOutputType) == '2DGEL') IsFound = .true.
if (OutputType(iOutputType) == '2DMEL') IsFound = .true.
if (OutputType(iOutputType) == '2DUSR') IsFound = .true.
if (OutputType(iOutputType) == '1DALL') IsFound = .true.
if (OutputType(iOutputType) == '1DGLO') IsFound = .true.
if (OutputType(iOutputType) == '1DTHM') IsFound = .true.
if (OutputType(iOutputType) == '1DNEW') IsFound = .true.
if (OutputType(iOutputType) == '1DCHM') IsFound = .true.
if (OutputType(iOutputType) == '1DCMS') IsFound = .true.
if (OutputType(iOutputType) == '1DUSR') IsFound = .true.
if (.not. IsFound) then
bad_outputtype = iOutputType
return
endif
enddo
bad_outputtype = 0
return
end function bad_outputtype
!----------------------------------------------------------------
!
!----------------------------------------------------------------
subroutine output(dir, iBlock, iOutputType)
use ModSphereInterface, only:iStartBlk
use ModSatellites, only : CurrentSatellitePosition, CurrentSatelliteName
use ModGITM
use ModEUV
use ModTime
use ModInputs
use ModSources
use ModUserGITM, only: nVarsUser2d, nVarsUser3d, nVarsUser1d
implicit none
character (len=*), intent(in) :: dir
integer, intent(in) :: iBlock
integer, intent(in) :: iOutputType
character (len=5) :: proc_str,cBlock, cType
character (len=24) :: cTime='', cTimeSave=''
integer :: iiLat, iiLon, nGCs, cL=0
integer :: iLon,iLat,iAlt, nVars_to_Write, nlines, iBLK,iSpecies
logical :: done, IsFirstTime = .true., IsThere
real :: LatFind, LonFind
real :: rLon, rLat
character (len=2) :: cYear, cMonth, cDay, cHour, cMinute, cSecond
character (len=4) :: cYearL
!! construct naming strings
if (iOutputType == -1) then
cType = "1DALL"
else
cType = OutputType(iOutputType)
if (cType(1:2) == "3D" .and. Is1D) then
cType(1:2) = "1D"
endif
endif
if (Is1D) then
iiLat = 1
iiLon = 1
rLon = 1.0
rLat = 1.0
endif
if (iOutputType == -1) then
LatFind = CurrentSatellitePosition(iNorth_)
LonFind = CurrentSatellitePosition(iEast_)
if ((Longitude(0,iBlock)+Longitude(1,iBlock))/2 <=LonFind .and. &
(Longitude(nLons,iBlock)+Longitude(nLons+1,iBlock))/2 >LonFind) then
if ((Latitude(0,iBlock)+Latitude(1,iBlock))/2 <=LatFind .and. &
(Latitude(nLats,iBlock)+Latitude(nLats+1,iBlock))/2 >LatFind) then
iiLat = -1
iiLon = -1
do iLon = 0,nLons
if (Longitude(iLon,iBlock) <= LonFind .and. &
Longitude(iLon+1,iBlock) > LonFind) then
iiLon = iLon
rLon = 1.0 - (LonFind - Longitude(iLon,iBlock)) / &
(Longitude(iLon+1,iBlock) - Longitude(iLon,iBlock))
endif
enddo
do iLat = 0,nLats
if (Latitude(iLat,iBlock) <= LatFind .and. &
Latitude(iLat+1,iBlock) > LatFind) then
iiLat = iLat
rLat = 1.0 - (LatFind - Latitude(iLat,iBlock)) / &
(Latitude(iLat+1,iBlock) - Latitude(iLat,iBlock))
endif
enddo
else
return
endif
else
return
endif
endif
if ((iProc == 0.and.iBlock == 1).and.(iOutputType /= -1)) &
write(*,'(a,i7,i5,5i3)') &
"Writing Output files ("//cType//") at iStep : ",&
iStep, iTimeArray(1:6)
if (iOutputType == -1) &
write(*,'(a,i7,i5,5i3)') &
"Writing satellite file ("//CurrentSatelliteName//") at iStep : ",&
iStep, iTimeArray(1:6)
call calc_physics(iBlock)
call calc_rates(iBlock)
call calc_collisions(iBlock)
call chapman_integrals(iBlock)
call set_horizontal_bcs(iBlock)
if (.not. Is1D) call calc_efield(iBlock)
iBLK = iStartBLK + iBlock
write(cBlock,'(a1,i4.4)') "b",iBLK
call i2s(mod(iTimeArray(1),100), cYear, 2)
call i2s(iTimeArray(1), cYearL, 4)
call i2s(iTimeArray(2), cMonth, 2)
call i2s(iTimeArray(3), cDay, 2)
call i2s(iTimeArray(4), cHour, 2)
call i2s(iTimeArray(5), cMinute, 2)
call i2s(iTimeArray(6), cSecond, 2)
!-----------
! New feature - we want to be able to write to the same file over and
! over and over again, so we don't get 100,000,000 satellite files.
! So, here we are going to name the file the first time, then open
! that same file over and over again with an append.
!-----------
if ( IsFirstTime .or. &
.not. DoAppendFiles .or. &
(iOutputType /= -1 .and. .not. Is1D)) then
cTime = "t"//cYear//cMonth//cDay//"_"//cHour//cMinute//cSecond
cL = 14
if (IsFirstTime) cTimeSave = cTime
else
cTime = cTimeSave
endif
!! ---------------------------------------------
!! Write the binary data files
!! ---------------------------------------------
if (iOutputType == -1) then
inquire(file=dir//"/"//CurrentSatelliteName//"_"//cTime(1:cL)//".sat", &
EXIST=IsThere)
if (.not. DoAppendFiles .or. tSimulation < 0.1 .or. .not. IsThere) then
open(unit=iOutputUnit_, form="unformatted", &
file=dir//"/"//CurrentSatelliteName//"_"//cTime(1:cL)//".sat",&
status="unknown")
else
open(unit=iOutputUnit_, form="unformatted", &
file=dir//"/"//CurrentSatelliteName//"_"//cTime(1:cL)//".sat",&
status="unknown",position='append')
endif
else
if (cType /= '2DMEL' .or. iBLK == 1) then
inquire(file=dir//"/"//cType//"_"//cTime(1:cL)//"."//cBlock,&
EXIST=IsThere)
if (.not. DoAppendFiles .or. tSimulation < 0.1 .or. .not. IsThere) then
open(unit=iOutputUnit_, form="unformatted", &
file=dir//"/"//cType//"_"//cTime(1:cL)//"."//cBlock,&
status="unknown")
else
open(unit=iOutputUnit_, form="unformatted", &
file=dir//"/"//cType//"_"//cTime(1:cL)//"."//cBlock,&
status="unknown",position='append')
endif
endif
endif
nGCs = 2
select case (cType)
case ('3DALL')
!nvars_to_write = 13+nSpeciesTotal+nSpecies+nIons+nIons-1+1
nvars_to_write = 13+nSpeciesTotal+nSpecies+nIons+nIons-1+1 + &
1 + & ! Add LocalTime
1 + & ! Add Solar-Mars Distance
1 ! NO emissions
call output_3dall(iBlock)
case ('3DNEU')
nvars_to_write = 8+nSpeciesTotal+nSpecies
call output_3dneu(iBlock)
case ('3DION')
nvars_to_write = 8+nIons+6+4+4+1
call output_3dion(iBlock)
case ('3DTHM')
nvars_to_write = 14
call output_3dthm(iBlock)
case ('1DCHM')
nGCs = 0
nvars_to_write = 30
call output_1dchm(iBlock)
case ('3DCHM')
nvars_to_write = 30
call output_3dchm(iBlock)
case ('3DGLO')
nvars_to_write = 3 + 3
call output_3dglo(iBlock)
case ('3DUSR')
if (iBlock == 1) call set_nVarsUser3d
nvars_to_write = nVarsUser3d
call output_3duser(iBlock, iOutputUnit_)
case ('2DGEL')
nvars_to_write = 13
call output_2dgel(iBlock)
case ('2DMEL')
nvars_to_write = 29
if (iBLK == 1) call output_2dmel(iBlock)
case ('2DUSR')
if (iBlock == 1) call set_nVarsUser2d
nvars_to_write = nVarsUser2d
call output_2duser(iBlock, iOutputUnit_)
case ('1DALL')
nGCs = 0
nvars_to_write = nSpeciesTotal+nSpecies+nIons+nSpecies+5+nIons-2+1
call output_1dall(iiLon, iiLat, iBlock, rLon, rLat, iOutputUnit_)
case ('1DGLO')
nGCs = 0
nvars_to_write = 6
call output_1dglo
case ('1DTHM')
nGCs = 0
nvars_to_write = 14 + (nspeciestotal*2)
call output_1dthm
case ('1DNEW')
nGCs = 0
nvars_to_write = 15 + nSpeciesTotal + nSpecies + nIons + nSpecies
call output_1dnew(iiLon, iiLat, iBlock, rLon, rLat, iOutputUnit_)
end select
close(unit=iOutputUnit_)
!! Now write the header file
if ((iProc == 0 .and. iBlock == nBlocks) .or. iOutputType == -1) then
if (iOutputType == -1) then
inquire(file=dir//"/"//CurrentSatelliteName//"_"//cTime(1:cL)//".header", &
EXIST=IsThere)
if (.not. DoAppendFiles .or. tSimulation < 0.1 .or. .not. IsThere) then
open(unit=iOutputUnit_, &
file=dir//"/"//CurrentSatelliteName//"_"//cTime(1:cL)//".header",&
status="unknown")
else
open(unit=iOutputUnit_, &
file=dir//"/"//CurrentSatelliteName//"_"//cTime(1:cL)//".header",&
status="unknown",position='append')
endif
else
inquire(file=dir//"/"//cType//"_"//cTime(1:cL)//".header",&
EXIST=IsThere)
if (.not. DoAppendFiles .or. tSimulation < 0.1 .or. .not. IsThere) then
open(unit=iOutputUnit_, &
file=dir//"/"//cType//"_"//cTime(1:cL)//".header",&
status="unknown")
else
open(unit=iOutputUnit_, &
file=dir//"/"//cType//"_"//cTime(1:cL)//".header",&
status="unknown",position='append')
endif
endif
call write_head_blocks
call write_head_time
call write_head_version
if (cType(3:5) == 'USR') then
call output_header_user(cType, iOutputUnit_)
elseif (cType(3:5) == 'NEW') then
call output_header_new
else
call output_header
endif
write(iOutputUnit_,*) ""
write(iOutputUnit_,*) "END"
write(iOutputUnit_,*) ""
close(unit=iOutputUnit_)
endif
IsFirstTime = .false.
contains
!----------------------------------------------------------------
!
!----------------------------------------------------------------
subroutine output_header
use ModElectrodynamics, only : nMagLats, nMagLons
integer :: iOff, iSpecies, iIon
write(iOutputUnit_,*) "NUMERICAL VALUES"
write(iOutputUnit_,"(I7,6A)") nvars_to_write, " nvars"
if (cType(1:2) /= "2D") then
write(iOutputUnit_,"(I7,7A)") nAlts+4, " nAltitudes"
else
write(iOutputUnit_,"(I7,7A)") 1, " nAltitudes"
endif
if (cType(1:2) == "1D") then
write(iOutputUnit_,"(I7,7A)") 1, " nLatitudes"
write(iOutputUnit_,"(I7,7A)") 1, " nLongitudes"
else
if (cType(3:5) =="MEL") then
write(iOutputUnit_,"(I7,A)") nMagLats, " nLatitude"
write(iOutputUnit_,"(I7,A)") nMagLons+1, " nLongitudes"
write(iOutputUnit_,*) " "
write(iOutputUnit_,*) "NO GHOSTCELLS"
elseif (cType(3:5) =="GEL") then
write(iOutputUnit_,"(I7,A)") nLats, " nLatitude"
write(iOutputUnit_,"(I7,A)") nLons, " nLongitudes"
write(iOutputUnit_,*) " "
write(iOutputUnit_,*) "NO GHOSTCELLS"
else
write(iOutputUnit_,"(I7,7A)") nLats+nGCs*2, " nLatitudes"
write(iOutputUnit_,"(I7,7A)") nLons+nGCs*2, " nLongitudes"
endif
endif
write(iOutputUnit_,*) ""
write(iOutputUnit_,*) "VARIABLE LIST"
write(iOutputUnit_,"(I7,A1,a)") 1, " ", "Longitude"
write(iOutputUnit_,"(I7,A1,a)") 2, " ", "Latitude"
write(iOutputUnit_,"(I7,A1,a)") 3, " ", "Altitude"
if (cType(3:5) == "GEL") then
write(iOutputUnit_,"(I7,A1,a)") 4, " ", "Potential"
write(iOutputUnit_,"(I7,A1,a)") 5, " ", "Pedersen Conductance"
write(iOutputUnit_,"(I7,A1,a)") 6, " ", "Hall Conductance"
write(iOutputUnit_,"(I7,A1,a)") 7, " ", "Electron_Average_Energy"
write(iOutputUnit_,"(I7,A1,a)") 8, " ", "Electron_Energy_Flux"
write(iOutputUnit_,"(I7,A1,a)") 9, " ", "DivJuAlt"
write(iOutputUnit_,"(I7,A1,a)") 10, " ", "Pedersen FL Conductance"
write(iOutputUnit_,"(I7,A1,a)") 11, " ", "Hall FL Conductance"
write(iOutputUnit_,"(I7,A1,a)") 12, " ", "DivJu FL"
write(iOutputUnit_,"(I7,A1,a)") 13, " ", "FL Length"
endif
if (cType(3:5) == "THM") then
write(iOutputUnit_,"(I7,A1,a)") 4, " ", "EUV Heating"
write(iOutputUnit_,"(I7,A1,a)") 5, " ", "Conduction"
write(iOutputUnit_,"(I7,A1,a)") 6, " ", "Molecular Conduction"
write(iOutputUnit_,"(I7,A1,a)") 7, " ", "Eddy Conduction"
write(iOutputUnit_,"(I7,A1,a)") 8, " ", "Eddy Adiabatic Conduction"
write(iOutputUnit_,"(I7,A1,a)") 9, " ", "Chemical Heating"
write(iOutputUnit_,"(I7,A1,a)") 10, " ", "Auroral Heating"
write(iOutputUnit_,"(I7,A1,a)") 11, " ", "Joule Heating"
write(iOutputUnit_,"(I7,A1,a)") 12, " ", "NO Cooling"
write(iOutputUnit_,"(I7,A1,a)") 13, " ", "O Cooling"
write(iOutputUnit_,"(I7,A1,a)") 14, " ", "Total Abs EUV"
if (cType(1:2) == "1D") then
do iSpecies = 1, nSpeciesTotal
write(iOutputUnit_,"(I7,A1,a,a)") 11 + iSpecies, " ", &
"Production Rate ",cSpecies(iSpecies)
enddo
do iSpecies = 1, nSpeciesTotal
write(iOutputUnit_,"(I7,A1,a,a)") 11 + nSpeciesTotal + iSpecies, " ", &
"Loss Rate ",cSpecies(iSpecies)
enddo
endif
endif
if (cType(3:5) == "CHM") then
write(iOutputUnit_,"(I7,A1,a)") 4, " ", "N!D2!U+!N + e"
write(iOutputUnit_,"(I7,A1,a)") 5, " ", "O!D2!U+!N + e"
write(iOutputUnit_,"(I7,A1,a)") 6, " ", "N!D2!U+!N + O"
write(iOutputUnit_,"(I7,A1,a)") 7, " ", "NO!U+!N + e"
write(iOutputUnit_,"(I7,A1,a)") 8, " ", "N!U+!N + O!D2!N"
write(iOutputUnit_,"(I7,A1,a)") 9, " ", "NO + N"
write(iOutputUnit_,"(I7,A1,a)") 10, " ","O!U+!N + O!D2!N"
write(iOutputUnit_,"(I7,A1,a)") 11, " ", "N + O!D2!N"
write(iOutputUnit_,"(I7,A1,a)") 12, " ", "O!D2!U+!N + N"
write(iOutputUnit_,"(I7,A1,a)") 13, " ", "O!D2!U+!N + NO"
write(iOutputUnit_,"(I7,A1,a)") 14, " ", "O!D2!U+!N + N2"
write(iOutputUnit_,"(I7,A1,a)") 15, " ", "N!D2!U+!N + O!D2!N"
write(iOutputUnit_,"(I7,A1,a)") 16, " ", "N!U+!N + O"
write(iOutputUnit_,"(I7,A1,a)") 17, " ", "O!+!N + N!D2!N"
write(iOutputUnit_,"(I7,A1,a)") 18, " ", "O(1D) + N!D2!N"
write(iOutputUnit_,"(I7,A1,a)") 19, " ", "O(1D) + O!D2!N"
write(iOutputUnit_,"(I7,A1,a)") 20, " ", "O(1D) + O"
write(iOutputUnit_,"(I7,A1,a)") 21, " ", "O(1D) + e"
write(iOutputUnit_,"(I7,A1,a)") 22, " ", "N(2D) + O!D2!N"
write(iOutputUnit_,"(I7,A1,a)") 23, " ", "O!U+!N(2D)+e"
write(iOutputUnit_,"(I7,A1,a)") 24, " ", "N(2D) + O"
write(iOutputUnit_,"(I7,A1,a)") 25, " ", "N(2D) + e"
write(iOutputUnit_,"(I7,A1,a)") 26, " ", "O!U+!N(2D + N!D2!N"
write(iOutputUnit_,"(I7,A1,a)") 27, " ", "O!U+!N(2P) + e"
write(iOutputUnit_,"(I7,A1,a)") 28, " ", "O!U+!N(2P) + O"
write(iOutputUnit_,"(I7,A1,a)") 29, " ", "O!U+!N(2P) + N!D2!N"
write(iOutputUnit_,"(I7,A1,a)") 30, " ", "Chemical Heating Rate"
endif
if (cType(3:5) == "GLO") then
write(iOutputUnit_,"(I7,A1,a)") 4, " ", "6300 A Emission"
write(iOutputUnit_,"(I7,A1,a)") 5, " ", "PhotoElectronUp"
write(iOutputUnit_,"(I7,A1,a)") 6, " ", "PhotoElectronDown"
endif
if (cType(3:5) == "MEL") then
write(iOutputUnit_,"(I7,A1,a)") 4, " ", "MLT"
write(iOutputUnit_,"(I7,A1,a)") 5, " ", "GeoLat"
write(iOutputUnit_,"(I7,A1,a)") 6, " ", "GeoLon"
write(iOutputUnit_,"(I7,A1,a)") 7, " ", "Pedersen Conductance"
write(iOutputUnit_,"(I7,A1,a)") 8, " ", "Hall Conductance"
write(iOutputUnit_,"(I7,A1,a)") 9, " ", "DivJuAlt"
write(iOutputUnit_,"(I7,A1,a)") 10, " ", "Field Line Length"
write(iOutputUnit_,"(I7,A1,a)") 11, " ", "Sigma PP"
write(iOutputUnit_,"(I7,A1,a)") 12, " ", "Sigma LL"
write(iOutputUnit_,"(I7,A1,a)") 13, " ", "Sigma H"
write(iOutputUnit_,"(I7,A1,a)") 14, " ", "Sigma C"
write(iOutputUnit_,"(I7,A1,a)") 15, " ", "Sigma PL"
write(iOutputUnit_,"(I7,A1,a)") 16, " ", "Sigma LP"
write(iOutputUnit_,"(I7,A1,a)") 17, " ", "K^D_{m\phi}"
write(iOutputUnit_,"(I7,A1,a)") 18, " ", "K^D_{m\lamda}"
write(iOutputUnit_,"(I7,A1,a)") 19, " ", "Solver A"
write(iOutputUnit_,"(I7,A1,a)") 20, " ", "Solver B"
write(iOutputUnit_,"(I7,A1,a)") 21, " ", "Solver C"
write(iOutputUnit_,"(I7,A1,a)") 22, " ", "Solver D"
write(iOutputUnit_,"(I7,A1,a)") 23, " ", "Solver E"
write(iOutputUnit_,"(I7,A1,a)") 24, " ", "Solver S"
write(iOutputUnit_,"(I7,A1,a)") 25, " ", "DynamoPotential"
write(iOutputUnit_,"(I7,A1,a)") 26, " ", "Ed1new"
write(iOutputUnit_,"(I7,A1,a)") 27, " ", "Ed2new"
write(iOutputUnit_,"(I7,A1,a)") 28, " ", "Kphi"
write(iOutputUnit_,"(I7,A1,a)") 29, " ", "Klamda"
endif
if (cType(3:5) == "ALL" .or. cType(3:5) == "NEU") then
write(iOutputUnit_,"(I7,A1,a)") 4, " ", "Rho"
iOff = 4
do iSpecies = 1, nSpeciesTotal
write(iOutputUnit_,"(I7,A1,a)") iOff+iSpecies, " ", &
"["//cSpecies(iSpecies)//"]"
enddo
iOff = 4+nSpeciesTotal
write(iOutputUnit_,"(I7,A1,a)") iOff+1, " ", "Temperature"
write(iOutputUnit_,"(I7,A1,a)") iOff+2, " ", "V!Dn!N (east)"
write(iOutputUnit_,"(I7,A1,a)") iOff+3, " ", "V!Dn!N (north)"
write(iOutputUnit_,"(I7,A1,a)") iOff+4, " ", "V!Dn!N (up)"
iOff = 8+nSpeciesTotal
do iSpecies = 1, nSpecies
write(iOutputUnit_,"(I7,A1,a)") iOff+iSpecies, " ",&
"V!Dn!N (up,"//cSpecies(iSpecies)//")"
enddo
endif
if (cType(3:5) == "ALL" .or. cType(3:5) == "ION") then
iOff = 3
if (cType(3:5) == "ALL") iOff = 8+nSpeciesTotal+nSpecies
do iIon = 1, nIons
write(iOutputUnit_,"(I7,A1,a)") iOff+iIon, " ", "["//cIons(iIon)//"]"
enddo
iOff = iOff+nIons
write(iOutputUnit_,"(I7,A1,a)") iOff+1, " ", "eTemperature"
write(iOutputUnit_,"(I7,A1,a)") iOff+2, " ", "iTemperature"
write(iOutputUnit_,"(I7,A1,a)") iOff+3, " ", "V!Di!N (east)"
write(iOutputUnit_,"(I7,A1,a)") iOff+4, " ", "V!Di!N (north)"
write(iOutputUnit_,"(I7,A1,a)") iOff+5, " ", "V!Di!N (up)"
iOff = iOff + 5
do iIon = 1, nIons-1
write(iOutputUnit_,"(I7,A1,a)") iOff+iIon, " ", "EUV Ionization Rate("//cIons(iIon)//&
")"
enddo
iOff = iOff + nIons-1
write(iOutputUnit_,"(I7,A1,a)") iOff+1, " ", "Solar Zenith Angle"
iOff = iOff + 1
write(iOutputUnit_,"(I7,A1,a)") iOff+1, " ", "Local Time (hr)"
iOff = iOff + 1
write(iOutputUnit_,"(I7,A1,a)") iOff+1, " ", "Mars-Solar Distance (AU)"
iOff = iOff + 1
write(iOutputUnit_,"(I7,A1,a)") iOff+1, " ", "NO Emissions (ph/cm^3/s)"
iOff = iOff + 1
if (cType(3:5) == "ALL") then
! write(iOutputUnit_,"(I7,A1,a)") iOff+1, " ", "N2 Mixing Ratio"
! write(iOutputUnit_,"(I7,A1,a)") iOff+2, " ", "CH4 Mixing Ratio"
! write(iOutputUnit_,"(I7,A1,a)") iOff+3, " ", "Ar Mixing Ratio"
! write(iOutputUnit_,"(I7,A1,a)") iOff+4, " ", "HCN Mixing Ratio"
! write(iOutputUnit_,"(I7,A1,a)") iOff+5, " ", "H2 Mixing Ratio"
!
!! write(iOutputUnit_,"(I7,A1,a)") iOff+6, " ", "15N2 Mixing Ratio"
!! write(iOutputUnit_,"(I7,A1,a)") iOff+7, " ", "13CH4 Mixing Ratio"
!
! iOff = iOff + nSpecies
! write(iOutputUnit_,"(I7,A1,a)") iOff+1, " ", "RadCooling"
! write(iOutputUnit_,"(I7,A1,a)") iOff+2, " ", "EuvHeating"
! write(iOutputUnit_,"(I7,A1,a)") iOff+3, " ", "Conduction"
! write(iOutputUnit_,"(I7,A1,a)") iOff+4, " ", "Heat Balance Total"
! write(iOutputUnit_,"(I7,A1,a)") iOff+5, " ", "Heaing Efficiency"
else
write(iOutputUnit_,"(I7,A1,a)") iOff+1, " ", "Ed1"
write(iOutputUnit_,"(I7,A1,a)") iOff+2, " ", "Ed2"
write(iOutputUnit_,"(I7,A1,a)") iOff+3, " ", "Je1"
write(iOutputUnit_,"(I7,A1,a)") iOff+4, " ", "Je2"
write(iOutputUnit_,"(I7,A1,a)") iOff+5, " ", "Magnetic Latitude"
write(iOutputUnit_,"(I7,A1,a)") iOff+6, " ", "Magnetic Longitude"
write(iOutputUnit_,"(I7,A1,a)") iOff+8, " ", "B.F. East"
write(iOutputUnit_,"(I7,A1,a)") iOff+9, " ", "B.F. North"
write(iOutputUnit_,"(I7,A1,a)") iOff+10, " ", "B.F. Vertical"
write(iOutputUnit_,"(I7,A1,a)") iOff+11, " ", "B.F. Magnitude"
write(iOutputUnit_,"(I7,A1,a)") iOff+7, " ", "Potential"
write(iOutputUnit_,"(I7,A1,a)") iOff+8, " ", "E.F. East"
write(iOutputUnit_,"(I7,A1,a)") iOff+9, " ", "E.F. North"
write(iOutputUnit_,"(I7,A1,a)") iOff+10, " ", "E.F. Vertical"
write(iOutputUnit_,"(I7,A1,a)") iOff+11, " ", "E.F. Magnitude"
endif
endif
write(iOutputUnit_,*) ""
end subroutine output_header
subroutine output_header_new
use ModElectrodynamics, only : nMagLats, nMagLons
integer :: iOff, iSpecies, iIon
write(iOutputUnit_,*) "NUMERICAL VALUES"
write(iOutputUnit_,"(I7,6A)") nvars_to_write, " nvars"
write(iOutputUnit_,"(I7,7A)") nAlts, " nAltitudes"
write(iOutputUnit_,"(I7,7A)") 1, " nLatitudes"
write(iOutputUnit_,"(I7,7A)") 1, " nLongitudes"
write(iOutputUnit_,*) ""
write(iOutputUnit_,*) "VARIABLE LIST"
write(iOutputUnit_,"(I7,A1,a)") 1, " ", "Longitude"
write(iOutputUnit_,"(I7,A1,a)") 2, " ", "Local Time"
write(iOutputUnit_,"(I7,A1,a)") 3, " ", "Latitude"
write(iOutputUnit_,"(I7,A1,a)") 4, " ", "Altitude"
write(iOutputUnit_,"(I7,A1,a)") 5, " ", "Solar Zenith Angle"
write(iOutputUnit_,"(I7,A1,a)") 6, " ", "Rho"
iOff = 6
do iSpecies = 1, nSpeciesTotal
write(iOutputUnit_,"(I7,A1,a)") iOff+iSpecies, " ", &
"["//cSpecies(iSpecies)//"]"
enddo
iOff = iOff + nSpeciesTotal
write(iOutputUnit_,"(I7,A1,a)") iOff+1, " ", "Temperature"
write(iOutputUnit_,"(I7,A1,a)") iOff+2, " ", "V!Dn!N (east)"
write(iOutputUnit_,"(I7,A1,a)") iOff+3, " ", "V!Dn!N (north)"
write(iOutputUnit_,"(I7,A1,a)") iOff+4, " ", "V!Dn!N (up)"
iOff = iOff + 4
do iSpecies = 1, nSpecies
write(iOutputUnit_,"(I7,A1,a)") iOff+iSpecies, " ",&
"V!Dn!N (up,"//cSpecies(iSpecies)//")"
enddo
iOff = iOff + nSpecies
do iIon = 1, nIons
write(iOutputUnit_,"(I7,A1,a)") iOff+iIon, " ", "["//cIons(iIon)//"]"
enddo
iOff = iOff+nIons
write(iOutputUnit_,"(I7,A1,a)") iOff+1, " ", "eTemperature"
write(iOutputUnit_,"(I7,A1,a)") iOff+2, " ", "iTemperature"
write(iOutputUnit_,"(I7,A1,a)") iOff+3, " ", "V!Di!N (east)"
write(iOutputUnit_,"(I7,A1,a)") iOff+4, " ", "V!Di!N (north)"
write(iOutputUnit_,"(I7,A1,a)") iOff+5, " ", "V!Di!N (up)"
iOff = iOff + 5
do iSpecies = 1, nSpecies
write(iOutputUnit_,"(I7,A1,a)") iOff+iSpecies, " ", &
" "//cSpecies(iSpecies)//"Mixing Ratio"
enddo
write(iOutputUnit_,*) ""
end subroutine output_header_new
!----------------------------------------------------------------
subroutine write_head_blocks
if (cType(1:2) == "1D") return
write(iOutputUnit_,*) "BLOCKS"
write(iOutputUnit_,"(I7,A)") 1, " nBlocksAlt"
if (cType /= "2DMEL") then
write(iOutputUnit_,"(I7,A)") nBlocksLat, " nBlocksLat"
write(iOutputUnit_,"(I7,A)") nBlocksLon, " nBlocksLon"
else
write(iOutputUnit_,"(I7,A)") 1, " nBlocksLat"
write(iOutputUnit_,"(I7,A)") 1, " nBlocksLon"
endif
write(iOutputUnit_,*) ""
end subroutine write_head_blocks
!----------------------------------------------------------------
!
!----------------------------------------------------------------
subroutine write_head_time
write(iOutputUnit_,*) "TIME"
write(iOutputUnit_,"(I7,A)") iTimeArray(1), " Year"
write(iOutputUnit_,"(I7,A)") iTimeArray(2), " Month"
write(iOutputUnit_,"(I7,A)") iTimeArray(3), " Day"
write(iOutputUnit_,"(I7,A)") iTimeArray(4), " Hour"
write(iOutputUnit_,"(I7,A)") iTimeArray(5), " Minute"
write(iOutputUnit_,"(I7,A)") iTimeArray(6), " Second"
write(iOutputUnit_,"(I7,A)") iTimeArray(7), " Millisecond"
write(iOutputUnit_,*) ""
end subroutine write_head_time
!----------------------------------------------------------------
!
!----------------------------------------------------------------
subroutine write_head_version
write(iOutputUnit_,*) "VERSION"
write(iOutputUnit_,*) 3.1+PlanetNum
write(iOutputUnit_,*) ""
end subroutine write_head_version
end subroutine output
!! !----------------------------------------------------------------
!! !
!! !----------------------------------------------------------------
!!
!! subroutine output_1d(dir, cName, iBlock, Position)
!!
!! use ModGITM
!! use ModEUV
!! use ModTime
!! use ModInputs
!! use ModSources
!! use ModConstants
!!
!! implicit none
!!
!! character (len=*), intent(in) :: dir
!! character (len=*), intent(in) :: cName
!! integer, intent(in) :: iBlock
!! real, intent(in) :: Position(3)
!!
!! character (len=14) :: cTime
!! integer :: iLon,iLat,iAlt, nvars_to_write, nlines, iBLK, i
!! integer :: iiLon, iiLat, iiAlt
!! logical :: done
!!
!! real :: LatFind, LonFind
!! real :: rLon, rLat
!!
!! character (len=2) :: cYear, cMonth, cDay, cHour, cMinute, cSecond
!!
!! LatFind = Position(iNorth_)
!! LonFind = Position(iEast_)
!!
!! if ((Longitude(0,iBlock)+Longitude(1,iBlock))/2 <=LonFind .and. &
!! (Longitude(nLons,iBlock)+Longitude(nLons+1,iBlock))/2 >LonFind) then
!! if ((Latitude(0,iBlock)+Latitude(1,iBlock))/2 <=LatFind .and. &
!! (Latitude(nLats,iBlock)+Latitude(nLats+1,iBlock))/2 >LatFind) then
!!
!! iiLat = -1
!! iiLon = -1
!! do iLon = 0,nLons
!! if (Longitude(iLon,iBlock) <= LonFind .and. &
!! Longitude(iLon+1,iBlock) > LonFind) then
!! iiLon = iLon
!! rLon = 1.0 - (LonFind - Longitude(iLon,iBlock)) / &
!! (Longitude(iLon+1,iBlock) - Longitude(iLon,iBlock))
!! endif
!! enddo
!!
!! do iLat = 0,nLats
!! if (Latitude(iLat,iBlock) <= LatFind .and. &
!! Latitude(iLat+1,iBlock) > LatFind) then
!! iiLat = iLat
!! rLat = 1.0 - (LatFind - Latitude(iLat,iBlock)) / &
!! (Latitude(iLat+1,iBlock) - Latitude(iLat,iBlock))
!! endif
!! enddo
!!
!! else
!! return
!! endif
!! else
!! return
!! endif
!!
!! if (iProc == 0 .and. iBlock == 1) &
!! write(*,'(a,i7,i5,5i3)') &
!! "Writing Output files at iStep : ",iStep, iTimeArray(1:6)
!!
!! call calc_physics(iBlock)
!! call chapman_integrals(iBlock)
!! call calc_rates(iBlock)
!! if (.not. Is1D) call calc_efield(iBlock)
!!
!! !! construct naming strings
!!
!! call i2s(mod(iTimeArray(1),100), cYear, 2)
!! call i2s(iTimeArray(2), cMonth, 2)
!! call i2s(iTimeArray(3), cDay, 2)
!! call i2s(iTimeArray(4), cHour, 2)
!! call i2s(iTimeArray(5), cMinute, 2)
!! call i2s(iTimeArray(6), cSecond, 2)
!!
!! cTime = "t"//cYear//cMonth//cDay//"_"//cHour//cMinute//cSecond
!!
!! !! open file
!! open(unit=iOutputUnit_, &
!! file=dir//"/"//cName//"_"//cTime(1:cL)//"."//"dat",&
!! status="unknown")
!!
!! write(iOutputUnit_,*) ""
!! write(iOutputUnit_,*) "TIME"
!! do i=1,7
!! write(iOutputUnit_,*) iTimeArray(i)
!! enddo
!! write(iOutputUnit_,*) ""
!!
!! call output_header(.true., nVars_to_Write)
!!
!! call output_1dall(iiLon, iiLat, iBlock, rLon, rLat, iOutputUnit_)
!!
!! close(unit=iOutputUnit_)
!!
!! end subroutine output_1d
!----------------------------------------------------------------
!
!----------------------------------------------------------------
subroutine output_3dall(iBlock)
use ModGITM
use ModInputs
use ModEUV, only: EUVIonRates,SZA
implicit none
integer, intent(in) :: iBlock
integer :: iAlt, iLat, iLon, iiAlt, iiLat, iiLon, i
do iAlt=-1,nAlts+2
!!! Why ???
iiAlt = max(min(iAlt,nAlts),1)
do iLat=-1,nLats+2
!!! Why ???
iiLat = min(max(iLat,1),nLats)
do iLon=-1,nLons+2
!!! Why ???
iiLon = min(max(iLon,1),nLons)
write(iOutputUnit_) &
Longitude(iLon,iBlock), &
Latitude(iLat,iBlock), &
Altitude_GB(iLon,iLat,iAlt,iBlock),&
Rho(iLon,iLat,iAlt,iBlock),&
(NDensityS(iLon,iLat,iAlt,i,iBlock),i=1,nSpeciesTotal), &
Temperature(iLon,iLat,iAlt,iBlock)*TempUnit(iLon,iLat,iAlt),&
(Velocity(iLon,iLat,iAlt,i,iBlock),i=1,3), &
(VerticalVelocity(iLon,iLat,iAlt,i,iBlock),i=1,nSpecies), &
(IDensityS(iLon,iLat,iAlt,i,iBlock),i=1,nIons), &
eTemperature(iLon,iLat,iAlt,iBlock) ,&
ITemperature(iLon,iLat,iAlt,iBlock) ,&
(Ivelocity(iLon,iLat,iAlt,i,iBlock),i=1,3),&
EUVIonRateS(iLon,iLat,iAlt,1,iBlock),&
EUVIonRateS(iLon,iLat,iAlt,2,iBlock),&
EUVIonRateS(iLon,iLat,iAlt,3,iBlock),&
EUVIonRateS(iLon,iLat,iAlt,4,iBlock),&
EUVIonRateS(iLon,iLat,iAlt,5,iBlock),&
SZA(iiLon,iiLat,iBlock)*180/Pi, &
LocalTime(iiLon), &
MarsOrbitalDistance(iiLon,iiLat,iiAlt),&
Emissions(iiLon,iiLat,iiAlt,iENOUV_,iBlock)
enddo
enddo
enddo
end subroutine output_3dall
!----------------------------------------------------------------
!
!----------------------------------------------------------------
subroutine output_3dneu(iBlock)
use ModGITM
use ModInputs
implicit none
integer, intent(in) :: iBlock
integer :: iAlt, iLat, iLon, iiAlt, iiLat, iiLon
do iAlt=-1,nAlts+2
iiAlt = max(min(iAlt,nAlts),1)
do iLat=-1,nLats+2
iiLat = min(max(iLat,1),nLats)
do iLon=-1,nLons+2
iiLon = min(max(iLon,1),nLons)
write(iOutputUnit_) &
Longitude(iLon,iBlock), &
Latitude(iLat,iBlock), &
Altitude_GB(iLon,iLat,iAlt,iBlock),&
Rho(iLon,iLat,iAlt,iBlock),&
NDensityS(iLon,iLat,iAlt,:,iBlock), &
Temperature(iLon,iLat,iAlt,iBlock)*TempUnit(iLon,iLat,iAlt),&
velocity(iLon,iLat,iAlt,:,iBlock) , &
VerticalVelocity(iLon,iLat,iAlt,:,iBlock)
enddo
enddo
enddo
end subroutine output_3dneu
!----------------------------------------------------------------
!
!----------------------------------------------------------------
subroutine output_3dion(iBlock)
use ModGITM
use ModInputs
use ModElectrodynamics
implicit none
integer, intent(in) :: iBlock
integer :: iAlt, iLat, iLon, iiAlt, iiLat, iiLon
do iAlt=-1,nAlts+2
do iLat=-1,nLats+2
do iLon=-1,nLons+2
write(iOutputUnit_) &
Longitude(iLon,iBlock), &
Latitude(iLat,iBlock), &
Altitude_GB(iLon,iLat,iAlt,iBlock), &
IDensityS(iLon,iLat,iAlt,:,iBlock), &
eTemperature(iLon,iLat,iAlt,iBlock), &
ITemperature(iLon,iLat,iAlt,iBlock), &
Ivelocity(iLon,iLat,iAlt,:,iBlock), &
ed1(iLon,iLat,iAlt), &
ed2(iLon,iLat,iAlt), &
je1(iLon,iLat,iAlt), &
je2(iLon,iLat,iAlt), &
mLatitude(iLon,iLat,iAlt,iBlock), &
mLongitude(iLon,iLat,iAlt,iBlock), &
B0(iLon,iLat,iAlt,:,iBlock), & !Geomagnetic B0(nLons,nLats,nAlts,4[iEast_,iNorth_,iUp_,iMag_],nBlocks)
potential(iLon,iLat,iAlt,iBlock), &
EField(iLon,iLat,iAlt,:), & ! EField(Lon,lat,alt,3)
sqrt(sum(EField(iLon,iLat,iAlt,:)**2)) ! magnitude of E.F.
enddo
enddo
enddo
end subroutine output_3dion
!----------------------------------------------------------------
!
!----------------------------------------------------------------
subroutine output_3dthm(iBlock)
use ModGITM
use ModInputs
use ModSources
use ModEuv, only : EuvTotal
implicit none
integer, intent(in) :: iBlock
integer :: iAlt, iLat, iLon, iiAlt, iiLat, iiLon
do iAlt=-1,nAlts+2
iiAlt = max(min(iAlt,nAlts),1)
do iLat=-1,nLats+2
iiLat = min(max(iLat,1),nLats)
do iLon=-1,nLons+2
iiLon = min(max(iLon,1),nLons)