-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMars.asc
9542 lines (7508 loc) · 298 KB
/
Mars.asc
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
subroutine fill_photo(photoion, photoabs, photodis)
! CVS_new_code: Dec. 19, 2011 (DP additions)
! -- Timing Fix, photoabs(58,iCO2_) = 0.0
! -- E(EUV) = 0.21 (off) or 0.18 (on)
! -- TOTAL(1) = 0.0; TOTAL(2) = 0.0
! -- populate 1-D and 3-D fields for diagnostics from RT code
! (RadCoolingRate,LowAtmosRadRate subroutines)
! -- ALS = constant for Amanda Brech = 0.2 (for Comparison Studies Studes Only!)
! CVS_new_code: Dec. 20, 2011 (DP additions)
! -- ALS = array from 2-D table (standard input for all cases)
! Adjustment: May 2012
! -- KMAX = 1000., KMIN = 500.
! Adjustments: November 2012 (standard)
! -- ALS = array from 2-D table (standard input for all cases)
! Adjustment: June 2017
! -- KMAX = 1500., KMIN = 500.
! -- KMAX = 2000., KMIN = 500.
! Adjustment: June-July 2017
! O-CO2 cooling coefficient enhancement
! -- k20xc = 4.e-12 * rfvto3p
! -- k20xc = 3.e-12 * rfvto3p
! New nlte_tcool code from FGG and MLV: November 2017
! Modified by S. W. Bougher : November 2017
! -- nlte_setup routine (1)
! -- nlte_tcool.F (major code)
! -- supporting subroutines (5)
! -- supporting parameters and inputs (1)
! -- supporting array declarations (real, integer) (1)
use ModPlanet
use ModEUV
implicit none
real, intent(out) :: photoion(Num_WaveLengths_High, nIons-1)
real, intent(out) :: photoabs(Num_WaveLengths_High, nSpeciesTotal)
real, intent(out) :: photodis(Num_WaveLengths_High, nSpeciesTotal)
integer :: i, iSpecies, iIon, NWH
! --------------------------------------------------------------------
! Secondary PE enhancement factors (simplified; check against Fox & Sung)
real,parameter :: sfn2p = 1.40, sfop = 1.60, sfco2p = 1.50
! --------------------------------------------------------------------
photoabs = 0.0
photoion = 0.0
photodis = 0.0
NWH = Num_WaveLengths_High
photoabs = 0.0
photoabs(:,iCO2_) = PhotoAbs_CO2
photoabs(:,iCO_) = PhotoAbs_CO
photoabs(:,iO_) = PhotoAbs_O
photoabs(:,iN2_) = PhotoAbs_N2
photoabs(:,iO2_) = PhotoAbs_O2
photoabs(58,iCO2_) = 0.0! timing fix (DP: Nov. 2011)
! ---------------------------------------------------------------------
! Specific Photoionization Cross Sections (nIons-1)
! Total Ionization Cross Sections * Specific Branching Ratios
! Need: O+, O2+, CO2+, N2+ Productions
! ---------------------------------------------------------------------
photoion(1:NWH,iOP_) = PhotoIon_OPlus4S(1:NWH)*sfop
photoion(1:NWH,iO2P_) = PhotoIon_O2(1:NWH)
photoion(1:NWH,iCO2P_) = PhotoIon_CO2(1:NWH)* &
BranchingRatio_CO2_to_CO2Plus(1:NWH)*sfco2p
photoion(1:NWH,iN2P_) = PhotoIon_N2(1:NWH)* &
BranchingRatio_N2_to_N2Plus(1:NWH)*sfn2p
photoion(1:NWH,iNOP_) = PhotoIon_CO2(1:NWH)* &
BranchingRatio_CO2_to_OPlus(1:NWH)*sfco2p
! ---------------------------------------------------------------------
! Specific PhotoiDissociations (Absorption-Total_Ionization) (nSpecies)
! Need: CO2, O2, and N2 dissociations (only)
! ---------------------------------------------------------------------
photodis(1:NWH,iCO2_) = PhotoAbs_CO2(1:NWH)-PhotoIon_CO2(1:NWH)
photodis(1:NWH,iN2_) = PhotoAbs_N2(1:NWH)-PhotoIon_N2(1:NWH)
photodis(1:NWH,iO2_) = PhotoAbs_O2(1:NWH)-PhotoIon_O2(1:NWH)
end subroutine fill_photo
!---------------------------------------------------------------------
! Initialize Heating Rates
!---------------------------------------------------------------------
subroutine init_heating_efficiency
use ModEUV, only: HeatingEfficiency_CB, eHeatingEfficiency_CB
implicit none
! HeatingEfficiency_CB = 0.21
HeatingEfficiency_CB = 0.18
eHeatingEfficiency_CB = 0.0
! call init_radcool
call init_nlte_setup
end subroutine init_heating_efficiency
!---------------------------------------------------------+
!
!---------------------------------------------------------+
subroutine calc_planet_sources(iBlock)
! All new source code in here
use ModInputs
use ModSources
use ModGITM
use ModPlanet
use ModEUV, only:SunOrbitEccentricity,AveCosSza
use ModTime
implicit none
integer, intent(in) :: iBlock
integer :: nw, iLat, iLon, iAlt
integer :: L_LAYERS, L_LEVELS, L_NLAYRAD,L_NLEVRAD
real :: tmp2(nLons, nLats, nAlts)
real :: tmp3(nLons, nLats, nAlts)
! Ls Variables
real :: deltat
real :: em
real :: alpha_pms
real :: pbs
real :: deltat_h
integer :: i
call start_timing("calc_planet_sources")
! New sources specificly for Mars include:
! (1) calc_radcooling(iBlock): added 1/31/07 (BOUGHER)
! (2) calc_radcode(iBlock) : to be added later (NELLI)
! (3) OCooling code : added 4/14/12 (BOUGHER)
if (useGravityWave) call calc_GW(iBlock)
!\ -------------------------------------------------------------------
! CO2 NLTE Cooling Formulation from Miguel Lopez-Valverde (2017)
!/
!/ Cooling ON
call nlte_tcool(iBlock)
!\
! RadCoolingRate is in K/s (from nlte_tcool.F routine)
! --------------------------------------------------
! RadCoolingRate = K/s
! RadCoolingRate/TempUnit = <T>/s
! TempUnit = MeanMajorMass/kb = K*kg/J = K/(m/s)^2
! --------------------------------------------------
! cp is in J/kg/K
! rho is in kg/m^3
! cp*rho is in J/K/m^3
! 1.0/(cp*rho) is in (K*m^3)/J
! --------------------------------------------------
!/ Cooling ON
RadCooling(1:nLons,1:nLats,1:nAlts,iBlock) = &
RadCoolingRate(1:nLons,1:nLats,1:nAlts,iBlock)/&
(TempUnit(1:nLons,1:nLats,1:nAlts))
!/ Cooling OFF (zeroed out)
! RadCooling = 0.0
! RadCoolingRate = 0.0
!\ -------------------------------------------------------------------
! O(63 micron) Cooling Formulation from Kockarts (1970)
!/
if (UseOCooling) then
! [O] cooling
! Initial Reference: Kockarts, G., P. Sp.Sci., Vol. 18, pp. 271-285, 1970
! Exact LTE (opt. thin) equations found in Banks and Kockarts [1973] pg. 22.
! a. Where does tau = 1.0, above which optically thin approx is valid?
! b. We reduce the LTE 63-um cooling rate by a factor of 2 for
! the non-LTE effects.[Roble et.al,1987, JGR, 92, 8745]
tmp2 = exp(-228./(Temperature(1:nLons,1:nLats,1:nAlts,iBlock)*&
TempUnit(1:nLons,1:nLats,1:nAlts)))
tmp3 = exp(-326./(Temperature(1:nLons,1:nLats,1:nAlts,iBlock)*&
TempUnit(1:nLons,1:nLats,1:nAlts)))
! In erg/cm3/s
! Factor of two applied:
! ---------------------------------------------------------------------
OCooling = 0.5* (1.69e-18*tmp2 + 4.59e-20*tmp3) * &
(NDensityS(1:nLons,1:nLats,1:nAlts,iO_,iBlock)/1.0e6) / &
(1.0 + 0.6*tmp2 + 0.2*tmp3)
! Utilized without factor of two in Earth GITM:
! ---------------------------------------------------------------------
! OCooling = (1.69e-18*tmp2 + 4.59e-20*tmp3) * &
! (NDensityS(1:nLons,1:nLats,1:nAlts,iO_,iBlock)/1.0e6) / &
! (1.0 + 0.6*tmp2 + 0.2*tmp3)
! In w/m3/3
OCooling = OCooling/10.0
! In our special units:
OCooling = OCooling/ TempUnit(1:nLons,1:nLats,1:nAlts) / &
(Rho(1:nLons,1:nLats,1:nAlts,iBlock)*cp(:,:,1:nAlts,iBlock))
else
OCooling = 0.0
endif
RadCooling(1:nLons,1:nLats,1:nAlts,iBlock) = &
RadCooling(1:nLons,1:nLats,1:nAlts,iBlock) + OCooling
!\
! ---------------------------------------------------------------
! This calls the lower atmosphere radiation code
! Steven Nelli May 7, 2007
! ---------------------------------------------------------------
!/
! --------------------------------------------------
! xLowAtmosRadRate = K/s
! xLowAtmosRadRate/TempUnit = <T>/s
! TempUnit = MeanMajorMass/kb = K*kg/J = K/(m/s)^2
! --------------------------------------------------
!
! Mars GITM ground temperature (on its grid) -------------------
! grtemp(1:nLons,1:nLats,iBlock)=280.0 !240.0
! Calculating the solar flux at Mars
! SunOrbitEccentricity = sqrt(2.64236)
do NW=1,L_NSPECTV
SOL(nw) = SOLARF(NW)/(SunOrbitEccentricity**2)
!SOL(nw) = SOLARF(NW)/(2.64236)
end do
!##############################################################
! MAIN LOOP, for MarsGITM horizontal grid (Latitude,Longitude)
if( floor((tSimulation - dT)/DtLTERadiation) == &
floor(tSimulation/DtLTERadiation)) then
! Do nothing
else
! Calculate Ls
deltat_h = iTimeArray(4)+iTimeArray(5)/60.0+iTimeArray(6)/3600.0
deltat = 367*iTimeArray(1)-7*(iTimeArray(1)+(iTimeArray(2)+9)/12)/4 &
+275*iTimeArray(2)/9+iTimeArray(3)-730531.5+deltat_h/24.0
em = (19.3870+0.52402075*deltat)*pi/180.0
alpha_pms = 270.3863+0.52403840*deltat
ell_s = alpha_pms+(10.691+3.d-7*deltat)*dsin(em)+ &
0.623*dsin(2.0*em)+0.050*dsin(3.0*em)+ &
0.005*dsin(4.0*em)+0.0005*dsin(5.0*em)
pbs = 0.0
do i=1,7
pbs = pbs+Ls_a(i)*dcos(pi/180.0*(0.985626*deltat/ &
Ls_tau(i)+Ls_phi(i)))
enddo
ell_s = ell_s+pbs
if (ell_s > 0.0) then
ell_s = 360.0*(ell_s/360.0-floor(ell_s/360.0))
else
ell_s = 360.0+360.0*(ell_s/360.0-ceiling(ell_s/360.0))
endif
! print*, ell_s
LowAtmosRadRate(1:nLons,1:nLats,1:nAlts,iBlock)=0.0
SurfaceTemp(1:nLons,1:nLats,iBlock) = SurfaceTemp(1:nLons,1:nLats,iBlock)+&
dSurfaceTemp(1:nLons,1:nLats,iBlock)*DtLTERadiation
SubsurfaceTemp(1:nLons,1:nLats,iBlock) = SubsurfaceTemp(1:nLons,1:nLats,iBlock)+&
dSubsurfaceTemp(1:nLons,1:nLats,iBlock)*DtLTERadiation
do iLat = 1, nLats
do iLon = 1, nLons
! Mars GITM ground temperature (on its grid) -------------------
if (minval(Altitude_GB(:,:,0,iBlock)) .lt. 0 .or. UseTopography) then
Temperature(iLon,iLat,0,iBlock)=SurfaceTemp(iLon,iLat,iBlock)/&
TempUnit(iLon,iLat,0)
Temperature(iLon,iLat,-1,iBlock)=SurfaceTemp(iLon,iLat,iBlock)/&
TempUnit(iLon,iLat,-1)
endif
! Determining the top of the lower atmosphere radiative zone
do iAlt=1,nAlts
if(pressure(iLon,iLat,iAlt,iBlock)*0.01.gt.prad) L_LAYERS = iAlt
end do
! L_LAYERS = 20
! setting up the vertical fields
L_LEVELS = 2*L_LAYERS+3
L_NLAYRAD = L_LAYERS+1
L_NLEVRAD = L_LAYERS+2
call calc_lowatmosrad(iblock,iLat,iLon,L_LAYERS,L_LEVELS,&
L_NLAYRAD,L_NLEVRAD)
end do !Latitude Loop
end do !Longitude Loop
!!$ xLowAtmosRadRate(1:nLons,1:nLats,1:nAlts,iBlock) = &
!!$ xLowAtmosRadRate(1:nLons,1:nLats,1:nAlts,iBlock)/&
!!$ (TempUnit(1:nLons,1:nLats,1:nAlts))
endif
!################# END MAIN COMPUTATIONAL LOOP#################
call end_timing("calc_planet_sources")
end subroutine calc_planet_sources
!---------------------------------------------------------+
!
!---------------------------------------------------------+
subroutine init_topography
use ModGITM
use ModInputs
implicit None
! real, intent(out) :: altzero2(nLons,nLats,nBlocks)
integer, parameter :: nMOLALons = 1440 , nMOLALats = 720 !1/4 degree resolution
real, dimension(nMolaLons,nMOLALats, 3) :: SurfaceAltitude
integer :: ilon, ilat, iilon, iilat, jlon, jlat, iBlock
real :: rlat, rlon,latfind,lonfind
open(unit=iInputUnit_, file='DataIn/Mars_MOLA_topo.dat', action='read', status="old")
if (iDebugLevel > 4) write(*,*) "=====> Reading Topography"
do iLat = 1, nMOLALats
do iLon = 1, nMOLALons
read(iInputUnit_,*) SurfaceAltitude(iLon,iLat,iNorth_), &
SurfaceAltitude(iLon,iLat,iEast_), &
SurfaceAltitude(iLon,iLat,iUp_)
enddo
enddo
close(iInputUnit_)
do iBlock = 1, nBlocks
do iLon = 1, nLons
do iLat = 1, nLats
LonFind = Longitude(iLon,iBlock)*180/pi
LatFind = latitude(iLat,iBlock)*180/pi
do jLon = 1, nMOLALons-1
if (SurfaceAltitude(jLon,1,iEast_) <= LonFind .and. &
SurfaceAltitude(jLon+1,1,iEast_) >= LonFind) then
iiLon = jLon
rLon = 1.0 - (LonFind - SurfaceAltitude(jLon,1,iEast_))/ &
(SurfaceAltitude(jLon+1,1,iEast_)-SurfaceAltitude(jLon,1,iEast_))
endif
enddo
do jLat = 1, nMOLALats-1
if (SurfaceAltitude(1,jLat,iNorth_) <= LatFind .and. &
SurfaceAltitude(1,jLat+1,iNorth_) >= LatFind) then
iiLat = jLat
rLat = 1.0 - (LatFind - SurfaceAltitude(1,jLat,iNorth_))/ &
(SurfaceAltitude(1,jLat+1,iNorth_)-SurfaceAltitude(1,jLat,iNorth_))
endif
enddo
altzero(iLon,iLat,iBlock) = (rLon)*(rLat)*SurfaceAltitude(iiLon,iiLat,iUp_) + &
(1-rLon)*( rLat)*SurfaceAltitude(iiLon +1,iiLat,iUp_) + &
(rLon)*(1-rLat)*SurfaceAltitude(iiLon,iiLat+1,iUp_) + &
(1-rLon)*(1-rLat)*SurfaceAltitude(iiLon+1,iiLat+1,iUp_)
enddo
enddo
enddo
end subroutine init_topography
!---------------------------------------------------------+
!
!---------------------------------------------------------+
!------------------------------------------------------------------
subroutine nlte_tcool(iBlock)
! ---------------------------------------------------------------------
! Purpose: to calculate NLTE CO2 15-micron cooling in Mars upper atmosphere
! (above 80 km, where NLTE physics becomes important)
! Source: nltecool.F from mtgcm16
! Coders: M. Lopez-Valverde (2012)
! S. W. Bougher (2017-MGITM)
! Inputs: from MarsGITM (Pressure, Temperature, VMRCO2, VMRO, VMRN2, VMRCO)
! all on MarsGITM grid (nLons,nLats,nAlts)
! Output: COOLTOT (K/sec) and RadCoolingRate(1:nLons,1:nLats,1:nAlts,iBlock)
! =======================================================================
! From Miguel Lopez-Valverde: Main code for modification and calling
!
! subroutine nlte_tcool(ngridgcm,n_gcm,
! $ p_gcm, t_gcm, z_gcm,
! $ co2vmr_gcm, n2vmr_gcm, covmr_gcm, o3pvmr_gcm,
! $ q15umco2_gcm , ierr, varerr)
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Fast scheme for NLTE cooling rates at 15um by CO2 in a Martian GCM !
! Version dlvr11_03. 2012. !
! Software written and provided by IAA/CSIC, Granada, Spain, !
! under ESA contract "Mars Climate Database and Physical Models" !
! Person of contact: Miguel Angel Lopez Valverde [email protected] !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! November 2017 Adapt to the MGITM model (3D version); S. Bougher
! & F. G.Galindo
! -----------------------------------------------------------------
use ModInputs
use ModSources, only: RadCoolingRate
use ModPlanet
use ModGITM
use ModUserGITM
use ModConstants, only: Boltzmanns_Constant, Speed_Light, &
Planck_Constant
use ModIndicesInterfaces
implicit none
! Common Blocks (from LMD-MGCM) ! Added to ModPlanet.f90
! include 'nlte_paramdef.h'
! include 'nlte_commons.h'
! INPUTS:----------------------------------------------------------
integer,intent(in):: iBlock
! -----------------------------------------------------------------
! Input variables
integer, parameter :: n_gcm = nAlts ! no. of atmospheric layers
integer, parameter :: nlon = nLons ! no. of long gridpoints
integer, parameter :: nlat = nLats ! no. of latitude gridpoints
integer, parameter :: ngridgcm = nlat*nlon ! no. of horizontal gridpoints
!logical :: found
! -----------------------------------------------------------------
! Local Variables and Constants
integer :: iLat, iLon, iAlt
integer :: i,ig, l, indice, nl_cts_real, nzy_cts_real
real*8 :: q15umco2_nltot(nltot), zld(nltot)
real*8 :: hr110CTS(nl_cts)
real :: xx,factor
real :: auxgcm(n_gcm)
real*8 :: auxgcmd(n_gcm), aux2gcmd(n_gcm)
real :: zmin_gcm
integer :: ierr
real*8 :: varerr
! -----------------------------------------------------------------
! Repository for MGITM fields into 2-D arrays (not needed)
! real,dimension(ngridgcm,n_gcm) :: p_gcm, t_gcm, z_gcm, co2vmr_gcm, &
! n2vmr_gcm, covmr_gcm, o3pvmr_gcm, q15umco2_gcm
!
! -----------------------------------------------------------------
! Repository for MGITM fields into 1-D arrays
real,dimension(n_gcm) :: p_ig,z_ig,t_ig, &
co2_ig,n2_ig,co_ig,o3p_ig,mmean_ig, cpnew_ig
! -----------------------------------------------------------------
! Internal fields recast from MarsGITM
real,dimension(1:nLons,1:nLats,1:nAlts) :: &
TN2,P,vmrco2,vmro,vmrn2,vmrco,q15umco2_gcm,mnd,mmean,cpm,zht
! Mars GITM real temperature (on its grid) ----------------------
TN2(1:nLons,1:nLats,1:nAlts) = &
Temperature(1:nLons,1:nLats,1:nAlts,iBlock)* &
TempUnit(1:nLons,1:nLats,1:nAlts)
! Mars GITM pressure in pascals (on its grid) -------------------
! (convert to ATM units for nlte_tcool subroutine)
! (1.0 mb = 100.0 Pa; 1013.25 mb = 1.01325e+05 Pa = 1.0 ATM)
! (1.0 Pa = 9.869e-6 ATM)
P(1:nLons,1:nLats,1:nAlts) = &
Pressure(1:nLons,1:nLats,1:nAlts,iBlock)*9.869e-06
! Mars GITM heights in meters (on its grid) -------------------
zht(1:nLons,1:nLats,1:nAlts) = &
Altitude_GB(1:nLons,1:nLats,1:nAlts,iBlock)
! Mars GITM cp in J/kg/K (on its grid) -------------------
! (same units as LMD-MGCM cooling code, and will vary with altitude)
! (cpco2 = 8.4e+06 erg/gm/K = 0.84 J/gm/K = 8.4e-04 J/kg/K)
cpm(1:nLons,1:nLats,1:nAlts) = &
cp(1:nLons,1:nLats,1:nAlts,iBlock)
! Volume Mixing Ratio amd MWT Calculations
mnd(1:nLons,1:nLats,1:nAlts) = &
NDensity(1:nLons,1:nLats,1:nAlts,iBlock)+1.0
vmro(1:nLons,1:nLats,1:nAlts) = &
NdensityS(1:nLons,1:nLats,1:nAlts,iO_,iBlock)&
/mnd(1:nLons,1:nLats,1:nAlts)
vmrco(1:nLons,1:nLats,1:nAlts) = &
NdensityS(1:nLons,1:nLats,1:nAlts,iCO_,iBlock)&
/mnd(1:nLons,1:nLats,1:nAlts)
vmrn2(1:nLons,1:nLats,1:nAlts) = &
NdensityS(1:nLons,1:nLats,1:nAlts,iN2_,iBlock)&
/mnd(1:nLons,1:nLats,1:nAlts)
vmrco2(1:nLons,1:nLats,1:nAlts) = &
NdensityS(1:nLons,1:nLats,1:nAlts,iCO2_,iBlock)&
/mnd(1:nLons,1:nLats,1:nAlts)
mmean(1:nLons,1:nLats,1:nAlts) = &
vmro(1:nLons,1:nLats,1:nAlts)*16.+ &
(vmrco(1:nLons,1:nLats,1:nAlts)+vmrn2(1:nLons,1:nLats,1:nAlts))&
*28. + vmrco2(1:nLons,1:nLats,1:nAlts)*44.
! -----------------------------------------------------------------
!
! **** Initialize to zero
q15umco2_gcm(1:nLons,1:nLats,1:nAlts) = 0.0
!-------------------------------------------------------------
! MAIN LOOP, for MarsGITM horizontal grid (Latitude,Longitude)
! (Corresponds to the ig = 1,ngridgcm loop from MLV)
do iLat = 1, nlat
do iLon = 1, nlon
ierr = 0
nl_cts_real = 0
nzy_cts_real = 0
! ***** populate 1-D arrays(n_gcm) for calc_radcooling for MarsGITM
do iAlt=1,n_gcm
p_ig(iALT)= P(iLon,iLat,iAlt)
t_ig(iALT)= TN2(iLon,iLat,iAlt)
co2_ig(iALT)=vmrco2(iLon,iLat,iAlt)
n2_ig(iALT)=vmrn2(iLon,iLat,iAlt)
o3p_ig(iALT)=vmro(iLon,iLat,iAlt)
co_ig(iALT)=vmrco(iLon,iLat,iAlt)
z_ig(iALT)=zht(iLon,iLat,iAlt)/1000.
mmean_ig(iALT)=mmean(iLon,iLat,iAlt)
cpnew_ig(iALT)=cpm(iLon,iLat,iAlt)
enddo
! ****** From GCM's grid to NLTE's grid
call NLTEdlvr11_ZGRID (n_gcm, &
p_ig, t_ig, z_ig, &
co2_ig, n2_ig, co_ig, o3p_ig, &
mmean_ig,cpnew_ig, &
nl_cts_real, nzy_cts_real )
! ***** Isotopic Tstar & VC at the NLTE grid
call interdp_ESCTVCISO
! ***** Tstar para NLTE-CTS
! call MZESC110 ( ig,nl_cts_real, nzy_cts_real,ierr,varerr )
call MZESC110 (nl_cts_real, nzy_cts_real,ierr,varerr )
if (ierr .gt. 0) call ERRORS (ierr,varerr)
! 626FB C.M.
call leetvt
c110(1:nl,1:nl)=0.d0
! call zerom (c110, nl)
call zero2v (vc110,taustar11, nl)
call MZTUD110 ( ierr, varerr )
if (ierr .gt. 0) call ERRORS (ierr,varerr)
input_cza = 0
call NLTEdlvr11_CZALU(ierr,varerr)
if (ierr .gt. 0) call ERRORS (ierr,varerr)
input_cza = 1
call NLTEdlvr11_CZALU(ierr,varerr)
if (ierr .gt. 0) call ERRORS (ierr,varerr)
! call NLTEdlvr11_FB626CTS
! Falta un merging del hr110CTS con el HR110
! NLTE-CTS
call NLTEdlvr11_FB626CTS ( hr110CTS , nl_cts_real )
! total TCR
do i = 1, nl
q15umco2_nltot(i) =hr110(i) + hr210(i) + hr310(i) + hr410(i) &
+ hr121(i)
enddo
! Merging con / actualizacion del HR_total
! Eliminamos el ultimo pto de hrTotal, y en el penultimo
! (que coincide con i=1 en el grid nl_cts)
! hacemos la media entre hrTotal y hr110CTS :
i=nl-1
q15umco2_nltot(i) = 0.5d0*( q15umco2_nltot(i) + hr110CTS(1) )
do i=2,nl_cts_real
indice = (nl-2) + i
q15umco2_nltot(indice) = hr110CTS(i)
enddo
do i=nl_cts_real+1,nl_cts
indice = (nl-2) + i
q15umco2_nltot(indice) = 0.0d0
enddo
! Interpol to original Pgrid
!
! Primero, la parte conocida ([1,nl_cts_real])
do i=1,nl
zld(i) = - dble ( alog(pl(i)) )
!write (*,*) i, zld(i), q15umco2_nltot(i)
enddo
do i=3,nl_cts_real
indice = (nl-2) + i
zld(indice) = - dble ( alog(pl_cts(i)) )
!write (*,*) indice, zld(indice), q15umco2_nltot(indice)
enddo
! En caso que nl_cts_real < nl_cts , extrapolo el grid alegremente
factor = pl_cts(nl_cts_real)/pl_cts(nl_cts_real-1)
xx = pl_cts(nl_cts_real)
do i=nl_cts_real+1,nl_cts
indice = (nl-2) + i
xx = xx * factor
zld(indice) = - dble ( alog(xx) )
enddo
do i=1,n_gcm
auxgcmd(i) = - dble( alog(p_ig(i)))
enddo
! call zerov( aux2gcmd, n_gcm )
aux2gcmd(1:n_gcm)=0.d0
call interdp_limits (aux2gcmd, auxgcmd, n_gcm, &
jlowerboundary,jtopCTS, &
q15umco2_nltot, zld, nltot, 1, nltot, 1)
! Smoothing
call suaviza ( aux2gcmd, n_gcm, 1, auxgcmd )
do i=1,n_gcm
q15umco2_gcm(iLon,iLat,i) = sngl( aux2gcmd(i) )
enddo
enddo !-------- END OF MAIN LONGITUDE LOOP
enddo !-------- END OF MAIN LATITUDE LOOP
!-------------------------------------------------------------
! CO2 Cooling Rate (K/Earth_day): Use Positive sign from Loop above
! Retain dynamical and radiative heat balance terms in K/Earth_day
RadCoolingRate(1:nLons,1:nLats,1:nAlts,iBlock) = &
q15umco2_gcm(1:nLons,1:nLats,1:nAlts)
! -q15umco2_gcm(1:nLons,1:nLats,1:nAlts)
! Diagnostics
!-----------------------------------------------------------------
! S. W. BOUGHER defined: 11-11-01 UserData1D
! S. W. BOUGHER defined: 11-11-01 UserData3D
! Pressure (ubar units for MTGCM compatibility)
!-----------------------------------------------------------------
UserData3D(:,:,:,4,iBlock) = 0.0
UserData3D(1:nLons, 1:nLats, 1:nAlts, 4, iBlock) = &
RadCoolingRate(1:nLons,1:nLats,1:nAlts,iBlock)
UserData3D(:,:,:,8,iBlock) = 0.0
UserData3D(1:nLons, 1:nLats, 1:nAlts, 8, iBlock) = &
Pressure(1:nLons, 1:nLats, 1:nAlts, iBlock)*10.0
UserData3D(:,:,:,9,iBlock) = 0.0
UserData3D(1:nLons, 1:nLats, 1:nAlts, 9, iBlock) = &
Temperature(1:nLons,1:nLats,1:nAlts,iBlock)* &
TempUnit(1:nLons,1:nLats,1:nAlts)
UserData3D(:,:,:,10,iBlock) = 0.0
UserData3D(1:nLons, 1:nLats, 1:nAlts, 10, iBlock) = &
vmro(1:nLons,1:nLats,1:nAlts)
UserData3D(:,:,:,11,iBlock) = 0.0
UserData3D(1:nLons, 1:nLats, 1:nAlts, 11, iBlock) = &
vmrco2(1:nLons,1:nLats,1:nAlts)
!
UserData1D(1,1,:,4) = 0.0
UserData1D(1, 1, 1:nAlts, 4) = &
RadCoolingRate(1,1,1:nAlts,iBlock)
UserData1D(1,1,:,8) = 0.0
UserData1D(1, 1, 1:nAlts, 8) = Pressure(1, 1, 1:nAlts, iBlock)*10.0
UserData1D(1,1,:,9) = 0.0
UserData1D(1, 1, 1:nAlts, 9) = &
Temperature(1,1,1:nAlts,iBlock)* &
TempUnit(1,1,1:nAlts)
UserData1D(1,1,:,10) = 0.0
UserData1D(1, 1, 1:nAlts, 10) = vmro(1,1,1:nAlts)
UserData1D(1,1,:,11) = 0.0
UserData1D(1, 1, 1:nAlts, 11) = vmrco2(1,1,1:nAlts)
!-------------------------------------------------------------
!-------------------------------------------------------------
end subroutine nlte_tcool
!---------------------------------------------------------+
subroutine init_isochem
use ModPlanet, only: ialtminiono
use ModInputs, only: altminiono
use ModGITM, only: Altitude_GB
use ModSizeGITM
implicit none
integer :: iBlock, iLon, iLat, iAlt
iAltMinIono = 1
do iBlock = 1, nBlocks
do iLon = 1, nLons
do iLat = 1, nLats
do ialt = 1, nAlts
if (Altitude_GB(iLon,iLat,ialt,iBlock)/1000.0 .le. AltMinIono) &
iAltMinIono(iLon,iLat,iBlock) = iAlt
if (ialtminiono(ilon,ilat,iblock) .lt. 1) ialtminiono(ilon,ilat,iblock) = 1
enddo
enddo
enddo
enddo
end subroutine init_isochem
!---------------------------------------------------------------------
! Calculate Eddy Diffusion Coefficient
!---------------------------------------------------------------------
subroutine calc_eddy_diffusion_coefficient(iBlock)
use ModSizeGITM
use ModGITM, only: pressure, NDensity
use ModInputs, only: EddyDiffusionPressure0,EddyDiffusionPressure1, &
EddyDiffusionCoef
use ModSources, only: KappaEddyDiffusion
implicit none
integer, intent(in) :: iBlock
integer :: iAlt, iLat, iLon
integer :: First
real :: PEddyMax
real :: NEddyMax(nLons,nLats)
real :: EddyProfile(nLons,nLats,-1:nAlts+2)
real :: KMax
real :: KMin
KappaEddyDiffusion(:,:,:,iBlock) = 0.0
! KStandard
! KMax = 1000.0
! KMin = 500.0
! KHigh
! KMax = 2000.0
! KMin = 500.0
! KModerate
! KMax = 1500.0
KMax = 2000.0
KMin = 500.0
! KLow
! KMax = 1200.0
! KMin = 500.0
! \
! First, find the altitude level corresponding to the asymptotic
! upper bound for Eddy Diffusion.
! Call this upper limit, NEddyMax
! This upper limit is set to 1.26e-09 bars
! conversion to pascals -> 1 bar = 1e+05 pascals
! Thus, PEddyMax -> 1.26e-04 pascals
PEddyMax = 1.26e-04 ! Pascals (SI Units)
do iLat = 1, nLats
do iLon = 1, nLons
First = 0
do iAlt = 1, nAlts
if (Pressure(iLon,iLat,iAlt,iBlock) > PEddyMax) then
cycle
else
if (First == 0) then
NEddyMax(iLon,iLat) = NDensity(iLon,iLat,iAlt,iBlock)
First = 1
endif
endif
enddo
enddo
enddo
! Now we have all the trigger densities as a function of Longitude and Latitude
! Next, extend the profile downward as 1/sqrt(N) and put a lower bound of 100 m^2/s
do iAlt = -1, nAlts+2
do iLat = 1, nLats
do iLon = 1, nLons
! Krasnopolsky et al. [2005] Helium modeling
! KappaEddyDiffusion(iLon,iLat,iAlt,iBlock) = &
! (1.0e-04)*(1.8e+13)/sqrt( (1.0e-06)*NDensity(iLon,iLat,iAlt,iBlock))
KappaEddyDiffusion(iLon,iLat,iAlt,iBlock) = &
KMax* sqrt( NEddyMax(iLon,iLat) / NDensity(iLon,iLat,iAlt,iBlock))
!
!! \
!! This gives an upper bound of Kmax
KappaEddyDiffusion(iLon,iLat,iAlt,iBlock) = &
min(KMax, KappaEddyDiffusion(iLon,iLat,iAlt,iBlock) )
KappaEddyDiffusion(iLon,iLat,iAlt,iBlock) = &
max(KMin, KappaEddyDiffusion(iLon,iLat,iAlt,iBlock) )
!
!! This gives an lower bound of Kmin
! KappaEddyDiffusion(iLon,iLat,iAlt,iBlock) = &
! max(100.0e+02, KappaEddyDiffusion(iLon,iLat,iAlt,iBlock) )
!
enddo
enddo
enddo
end subroutine calc_eddy_diffusion_coefficient
! ----------------------------------------------------------------------
subroutine calc_gw(iBlock)
use ModInputs
use ModSources
use ModPlanet
use ModGITM
use ModConstants
use ModTime
integer, parameter :: NLAY=nAlts
! real, parameter :: KAP = 0.000025
real, parameter :: KAP = 0.0000025
! declare GWAccel for compilation testing purposes only; this will
! be commented out when the Mod.. files are available
! real :: u(nlay),v(nlay),t(nlay),rhogw(nlay),rholev(nlay), &
! geot(nlay),pz(nlay),du(nlay),uav(nlay),plev(nlay), &
! tavg(nlay),theta(nlay),thtavg(nlay), &
! dtheta(nlay),stress(0:nlay),dstress(nlay), &
! dudt(nlay),cpco2
real :: u(nlay),v(nlay),tgw(nlay),rhogw(nlay),rholev(nlay), &
geot(nlay),pz(nlay),du(nlay),uav(nlay),plev(nlay), &
tavg(nlay),theta(nlay),thtavg(nlay), &
dtheta(nlay),stress(0:nlay),dstress(nlay), &
dudt(nlay),cpco2
real :: N(nlay),dh(nlay),dhsat(nlay),H(nlay), &
dz(nlay),Ri(nlay),Rimin(nlay),eps(nlay)
real :: Nsfc,k,C, VAR,TS,xRi,rhosfc,psfc,RCO2,gravv,gravsfc
integer :: ilon,ilat,ialt,nlgw
PSFC = 400.0
RCO2 = 189.0
VAR = 400.0**2
! MKS Units here
! cpco2=3.5*RGAS*AMU/Mass(iCO2_)
cpco2=3.5*RGAS*1.0E-07*AMU/Mass(iCO2_)*1000.
! MAIN DO LOOPS... OVER LONGITUDE AND LATITUDE
GWAccel(:,:,:,:) = 0.0
if (CurrentTime-StartTime .lt. 3600) then
return
endif
do ilon=1,nLons
do ilat=1,nLats
gravsfc = -Gravity_GB(ilon,ilat,1,iBlock)
! FILL LOCAL VERTICAL VECTORS FROM GITM ARRAY VALUES
U = Velocity(iLon,iLat,1:nAlts,iEast_,iBlock)+1.0E-4
rhogw = Rho(ilon,ilat,1:nAlts,iBlock) ! Is this correct ??
geot = Altitude_GB(ilon,ilat,1:nAlts,iBlock) ! Is this correct ?
TGW = Temperature(ilon,ilat,1:nAlts,iBlock)*TempUnit(ilon,ilat,1:nAlts)
pz = rhogw * RCO2 * tgw
THETA = tgw * (psfc/pz)**(RCO2/CpCO2)
eps = 0.0
dhsat = 0.0
dh = 0.0
Ri=0.0
Rimin = 0.0
stress = 0.0
dstress = 0.0
dudt = 0.0
do nlgw=1,nlay-1
! Calculate the geometric distance between adjacent layer midpoints;
! units are meters
dz(nlgw) = geot(nlgw+1) - geot(nlgw)
! Calculate the average wind speed at the top of each model layer
! (but not the top layer), using a simple averaging of the zonal wind
! speeds at the two neighboring layer midpoints
uav(nlgw) = 0.5 * (u(nlgw)+u(nlgw+1))
! Calculate the potential temperature at layer boundaries, via a simple
! averaging of the potential temperatures at the neighboring layer midpoints
! This can be imrpoved by using the layer boundary pressure (known
! via psfc and sigma) to directly calculate the pressure term
! in the potential temperature calculation.. need a temperature at
! the layer boundary
thtavg(nlgw) = 0.5 * (theta(nlgw)+theta(nlgw+1))
! Calculate the average temperature at layer boundaries, via a simple
! averaging of the temperatures at the neighboring layer midpoints
tavg(nlgw) = 0.5 * (tgw(nlgw)+tgw(nlgw+1))
! Calculate the difference in zonal wind speed across a layer boundary
du(nlgw) = u(nlgw+1) - u(nlgw)
!
! Calculate the density values at layer boundaries using the average of
! the pressures at the two neighboring layer midpoints and the average
! temperature at that same layer boundary; this is a poor way of calculating
! this average density and will be improved upon using independently
! determined values of pressure and temperature at layer boundaries
plev(nlgw) = 0.5*(pz(nlgw)+pz(nlgw+1))/2.0
rholev(nlgw) = 0.5*(pz(nlgw)+pz(nlgw+1))/(RCO2*Tavg(nlgw))
! Difference in potential temperature values across layer boundaries,
! calcultes by calculating the difference between the two neighboring
! layer midpoint potential temperatures; this should be (nlgw-1)-(nlgw)
dtheta(nlgw) = theta(nlgw+1) - theta(nlgw)
enddo
! Calculate the surface drag magnitude, using lowest layer midpoint
! density and wind speed values, and N (Brunt-Vaisala frequency) value
! at the interface between the bottom two atmosphere layers
rhosfc = psfc / (RCO2 * TGW(1))
Nsfc = (gravsfc/theta(1))*(dtheta(1)/dz(1))**0.5
TS = KAP * rhosfc * Nsfc * (U(1)) * VAR
!write(88,*) ts,kap,rhosfc,nsfc,theta(1), &
! dtheta(1),dz(1),u(1)
!print *, TS, KAP,Nsfc,U(1),VAR
! Set STRESS(NLAY+1) value equal to the surface drag value
stress(0) = TS