-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinit_msis.Jupiter.f90
289 lines (209 loc) · 7.74 KB
/
init_msis.Jupiter.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
!--------------------------------------------------------------
!
!--------------------------------------------------------------
subroutine get_msis_temperature(lon, lat, alt, t, h)
use ModTime
use ModInputs
use GITM_planet
use ModGITM
implicit none
real, intent(in) :: lon, lat, alt
real, intent(out) :: t, h
real :: nCO2, nO2, nN2, nCO, m, r, g
integer :: i
i = 1
do while (alt >= newalt(i))
i = i + 1
enddo
i = i - 1
t = InTemp(i)
nCO2 = InNDensityS(i,iCO2_)
nO2 = InNDensityS(i,iO2_)
nCO = InNDensityS(i,iCO_)
nN2 = InNDensityS(i,iN2_)
m = (nCO2 * mass(iCO2_) + &
nO2 * mass(iO2_) + &
nN2 * mass(iN2_) + &
nCO * mass(iCO_)) / (nCO2 + nO2 + nN2 + nCO)
r = RBody + alt
! g = Gravitational_Constant * (RBody/r) ** 2
g = Gravitational_Constant
h = Boltzmanns_Constant * t / (m*g)
end subroutine get_msis_temperature
subroutine init_msis
use GITM_planet
use ModGITM
use ModEUV
use ModInputs, only: iDebugLevel, iInputUnit_
implicit none
integer :: iBlock
integer :: iiLon,iiLat,iiAlt
integer :: iLon,iLat,iAlt, iSpecies, iIon
write(*,*) "here!"
do iBlock = 1, nBlocks
write(*,*) '==> Now Initializing Mars Background Composition', iBlock
!\
! Initializes the Planet with the same Chemistry as Above
!/
do iLat = -1, nLats + 2
do iLon = -1, nLons + 2
Temperature(iLon,iLat,-1:nAlts+2,iBlock) = &
InTemp(-1:nAlts+2)
eTemperature(iLon,iLat,-1:nAlts+2,iBlock) = &
IneTemp(-1:nAlts+2)
ITemperature(iLon,iLat,-1:nAlts+2,iBlock) = &
InITemp(-1:nAlts+2)
NDensityS(iLon,iLat,-1:nAlts + 2,1:nSpeciesTotal,iBlock) = 1.0
do iSpecies = 1, nSpeciesTotal
! Converts from cm^-3 to m^-3
NDensityS(iLon,iLat,-1:nAlts+2,iSpecies,iBlock) = &
InNDensityS(-1:nAlts+2,iSpecies)*(1.0e+06)
enddo ! end inner ispecies loop
!\
! These first few are from the input file read in earlier
!
!\
! This just arbitrarily sets the ionospheric densities to 1.0
!
do iIon = 1, nIons-1
IDensityS(iLon,iLat,-1:nAlts + 2,iIon,iBlock) = 1.0e6
IDensityS(iLon,iLat,-1:nAlts + 2,ie_,iBlock) = &
IDensityS(iLon,iLat,-1:nAlts + 2,ie_,iBlock) + &
IDensityS(iLon,iLat,-1:nAlts + 2,iIon,iBlock)
enddo ! end inner ispecies loop
!
! End ion loop
!/
enddo! end iLon loop
enddo ! end iLat loop
write(*,*) '============> init_msis.Mars.f90 Major Diagnostics: Begin'
where(NDensityS < 1.0e+03)
NDensityS = 1.0e+03
end where
where(IDensityS < 1.0e+03)
IDensityS = 1.0e+03
end where
!\
! Altitude Ghost Cells
Temperature(:,:,-1,iBlock) = Temperature(:,:,1,iBlock)
Temperature(:,:,0,iBlock) = Temperature(:,:,1,iBlock)
Temperature(:,:,nAlts+1,iBlock) = Temperature(:,:,nAlts,iBlock)
Temperature(:,:,nAlts+2,iBlock) = Temperature(:,:,nAlts,iBlock)
!\
! Longitude Ghost Cells
Temperature(-1,:,:,iBlock) = Temperature(1,:,:,iBlock)
Temperature(0,:,:,iBlock) = Temperature(1,:,:,iBlock)
Temperature(nLons+1,:,:,iBlock) = Temperature(nLons,:,:,iBlock)
Temperature(nLons+2,:,:,iBlock) = Temperature(nLons,:,:,iBlock)
!\
! Latitude Ghost Cells
Temperature(:,-1,:,iBlock) = Temperature(:,1,:,iBlock)
Temperature(:,0,:,iBlock) = Temperature(:,1,:,iBlock)
Temperature(:,nLats+1,:,iBlock) = Temperature(:,nLats,:,iBlock)
Temperature(:,nLats+2,:,iBlock) = Temperature(:,nLats,:,iBlock)
! do iSpecies = 1, nSpeciesTotal
! write(*,*) 'iSpecies =', iSpecies
!
! do iAlt = -1, nAlts + 2
! write(*,*) 'iAlt =', iAlt
!
! do iLat = -1, nLats + 2
! write(*,*) 'iLat =', iLat
!
! do iLon = -1, nLons + 2
! write(*,*) 'iLon =', iLon
!
! write(*,*) 'NDensityS(', iLon, iLat, iAlt, iSpecies,') =', &
! NDensityS(iLon,iLat,iAlt,iSpecies,iBlock)
! write(*,*) 'Temperature(', iLon, iLat, iAlt,') =', &
! Temperature(iLon,iLat,iAlt,iBlock)
!
! enddo
! enddo
! enddo
! enddo
!\
! Diagnostic Outputs
!/
!112 FORMAT(F6.1,1X,F8.4,1X,ES10.3,1X,ES10.3,1X,ES10.3,1X,ES10.3,1X,ES10.3, &
! 1X,ES10.3,1X,ES10.3,1X,ES10.3,1X,ES10.3,1X,ES10.3,1X,ES10.3, &
! 1X,ES10.3,1X,ES10.3)
!
! open(UNIT = 26, FILE = 'test_neutrals.txt', STATUS='NEW',ACTION = 'WRITE')
!
! do iiAlt = -1,nAlts + 2
! write(26,112) &
! newalt(iiAlt), &
! Temperature(iiLon,iiLat,iiAlt,iBlock), &
! NDensityS(iiLon,iiLat,iiAlt,iH_,iBlock), &
! NDensityS(iiLon,iiLat,iiAlt,iH2_,iBlock), &
! NDensityS(iiLon,iiLat,iiAlt,iCH_,iBlock), &
! NDensityS(iiLon,iiLat,iiAlt,i1CH2_,iBlock), &
! NDensityS(iiLon,iiLat,iiAlt,i3CH2_,iBlock), &
! NDensityS(iiLon,iiLat,iiAlt,iCH3_,iBlock), &
! NDensityS(iiLon,iiLat,iiAlt,iCH4_,iBlock), &
! NDensityS(iiLon,iiLat,iiAlt,iC2H4_,iBlock), &
! NDensityS(iiLon,iiLat,iiAlt,iN4S_,iBlock), &
! NDensityS(iiLon,iiLat,iiAlt,iN2_,iBlock), &
! NDensityS(iiLon,iiLat,iiAlt,iHCN_,iBlock), &
! NDensityS(iiLon,iiLat,iiAlt,iH2CN_,iBlock), &
! end do
!
! close(Unit = 26)
!\
! Calculating MeanMajorMass -----------------------------
!/
!\
! Initialize MeanMajorMass to 0.0
!/
MeanMajorMass(-1:nLons+2,-1:nLats+2,-1:nAlts+2) = 0.0
MeanIonMass(-1:nLons+2,-1:nLats+2,-1:nAlts+2) = 0.0
! Calculate MeanMajorMass -----------------------------
! Calculate TempUnit -----------------------------
do iLat = -1,nLats + 2
do iLon = -1,nLons + 2
do iAlt = -1,nAlts + 2
NDensity(iLon,iLat,iAlt,iBlock) = 0.0
do iSpecies = 1,nSpeciesTotal
NDensity(iLon,iLat,iAlt,iBlock) = &
NDensity(iLon,iLat,iAlt,iBlock) + &
NDensityS(iLon,iLat,iAlt,iSpecies,iBlock)
enddo
do iSpecies = 1,nSpeciesTotal
MeanMajorMass(iLon,iLat,iAlt) = &
MeanMajorMass(iLon,iLat,iAlt) + &
Mass(iSpecies)*NDensityS(iLon,iLat,iAlt,iSpecies,iBlock)/ &
NDensity(iLon,iLat,iAlt,iBlock)
enddo
do iIon = 1,nIons - 1
MeanIonMass(iLon,iLat,iAlt) = &
MeanIonMass(iLon,iLat,iAlt) + &
MassI(iIon)*IDensityS(iLon,iLat,iAlt,iIon,iBlock)/ &
IDensityS(iLon,iLat,iAlt,ie_,iBlock)
enddo
enddo
enddo
enddo
TempUnit(-1:nLons+2,-1:nLats+2,-1:nAlts+2) = &
MeanMajorMass(-1:nLons+2,-1:nLats+2,-1:nAlts+2)/&
Boltzmanns_Constant
!\
! Initialize Rho to 0.0
!/
Rho(-1:nLons+2,-1:nLats+2,-1:nAlts+2,iBlock) = 0.0
Temperature(-1:nLons+2,-1:nLats+2,-1:nAlts+2,iBlock) = &
Temperature(-1:nLons+2,-1:nLats+2,-1:nAlts+2,iBlock) / &
TempUnit(-1:nLons+2,-1:nLats+2,-1:nAlts+2)
Rho(-1:nLons+2,-1:nLats+2,-1:nAlts+2,iBlock) = &
MeanMajorMass(-1:nLons+2,-1:nLats+2,-1:nAlts+2)* &
NDensity(-1:nLons+2,-1:nLats+2,-1:nAlts+2,iBlock)
write(*,*) '==> Now Completing Mars Background Composition: END', iBlock
enddo
end subroutine init_msis
subroutine msis_bcs(iJulianDay,UTime,Alt,Lat,Lon,Lst, &
F107A,F107,AP,LogNS, Temp, LogRho)
write(*,*) "You can not use MSIS with any planet except Earth!!!"
write(*,*) "If you ARE running Earth, then make the code again, using"
write(*,*) "configure Earth ; make"
call stop_gitm("I can not continue...")
end subroutine msis_bcs