-
Notifications
You must be signed in to change notification settings - Fork 20
/
init_ramscb.f90
executable file
·212 lines (182 loc) · 6.64 KB
/
init_ramscb.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
!******************************************************************************
! Copyright (c) 2016, Los Alamos National Security, LLC
! All rights reserved.
!******************************************************************************
subroutine init_ramscb
use ModRamMain, ONLY: iPressure, iDomain, boundary, NameBoundMag, &
PPerH, PParH, PPerO, PParO, PPerHe, PParHe, DoInitOnly, PPerE, PParE, &
IsComponent,iCal, TimeRamStart, TimeRamNow, RadiusMin, &
RadiusMax, nR, nT, Lz, Phi, NTL, NEL, NEL_prot, NBD, IsStarttimeSet, &
TimeRamElapsed, timeMax, IsRestart, electrons, kp, f107, DoVarDt, &
electric, UseEfind, DoWriteFlux, IsSHIELDS, nRextend, GridExtend
use Module1, ONLY: method, iDumpRAMFlux
use ModRamIO, ONLY: StringRunDate, read_restart, UseNewFmt, write_prefix, &
DtLogFile
use ModNumConst,ONLY: cTwoPi
use ModTimeConvert
use ModRamIndices, ONLY: init_indices, get_indices
use CON_planet, ONLY: set_planet_defaults
use CON_axes, ONLY: init_axes, test_axes
use ModPlanetConst, ONLY: init_planet_const
use ModRamTiming, ONLY: init_timing
use ModRamMpi
implicit none
character(len=8) :: StringSysDate
character(len=10):: StringSysTime
type(timetype) :: TimeStop
real:: dR, dPhi
integer:: iR, iPhi, iS
character (len=*), parameter:: NameSub='init_ramscb'
logical :: DoTest, DoTestMe
!------------------------------------------------------------------------
call CON_set_do_test(NameSub, DoTest, DoTestMe)
! Build time and date of when this run was started.
call date_and_time(StringSysDate, StringSysTime)
StringRunDate = StringSysDate // ' - ' // StringSysTime
if(DoTest)write(*,*) 'Run started on ' // StringRunDate
! Check for SHIELDSRC mode. If True, set SHIELDSRC params.
if(IsSHIELDS)then
call write_prefix
write(*,*)' RAM-SCB is in SHIELDS-RC MODE.'
DoVarDt = .true. ! Variable timestepping.
boundary = 'LANL' ! LANL plasma BCS.
NameBoundMag = 'DIPL' ! Simple dipole BCS.
electric = 'VOLS' ! Volland-Stern E-field.
UseEfind = .false. ! No induced E-field.
UseNewFmt = .true. ! New output file name format.
DoWriteFlux = .false. ! No large flux files.
iDumpRAMFlux = 0 ! No large flux files.
electrons = .true. ! Electrons ON.
DtLogFile = 300.0 ! Sparser log files.
end if
! Set iPressure and iDomain according to selected BC's
select case(boundary)
case('SWMF')
iPressure = 5
case('LANL')
iPressure = 6
NEL = 36
NTL = 25
case('PTM')
iPressure = 6
NEL = 9 !These are Joachim's energy levels
NEL_prot = 35 ! These are the SWMF energy levels
NTL = 25
NBD = 130
case('TM03')
iPressure = 5 ! Both RAM and SCB model expanded to the same distance
case default
call CON_stop(NameSub//': invalid boundary='//boundary)
end select
select case(NameBoundMag)
case('SWMF')
iDomain = 20
case('T89C')
iDomain = 3
case('TS04')
iDomain = 2
case('DIPL') ! Dipole w/o SCB calculation.
iDomain = 4
method = 3
case('DIPS') ! Dipole w/ SCB calculation.
iDomain = 4
! method = 3 ! DIPS is the case with calculation (within dipole boundary)
case default
call CON_stop(NameSub//': invalid NameBoundMag='//NameBoundMag)
end select
if(IsRestart) then
! If Restart, read restart params and set timings appropriately.
if (IsStarttimeSet) call CON_stop(NameSub//&
': Cannot use #STARTTIME command with #RESTART!')
call read_restart
else
! Otherwise, initialize time correctly.
TimeRamNow % Time = TimeRamStart % Time
call time_real_to_int(TimeRamNow)
TimeRamElapsed=0.0
end if
iCal = 1 !AND set iCal properly.
! Begin tracking code efficiency.
call init_timing()
! Initialize Pressures.
PPerH = 0
PParH = 0
PPerO = 0
PParO = 0
PPerHe = 0
PParHe = 0
PPerE = 0
PParE = 0
! Initialize grid.
! Radial distance
dR = (RadiusMax - RadiusMin)/(nR - 1)
do iR = 1, nR+1 ! DANGER WE SHOULD CHANGE THIS AND ALL ARRAYS USING NR+1
Lz(iR) = RadiusMin + (iR - 1)*dR
end do
! Create extended radial grid for coupling:
do iR=1, nRextend
GridExtend(iR) = RadiusMin + (iR-1)*dR
end do
! Longitude in radians
dPhi = cTwoPi/(nT - 1)
do iPhi = 1, nT
Phi(iPhi) = (iPhi - 1)*dPhi
end do
! Call ram_all.f in initialization mode to
! generate pitch angle and energy grid.
DoInitOnly = .true.
if (electrons) call ram_all(1)
do iS=2,4
call ram_all(iS)
end do
DoInitOnly = .false.
! Set up input indices (Kp, F10.7)
TimeStop%Time = TimeRamStart%Time + TimeMax
call time_real_to_int(TimeStop)
call init_indices(TimeRamStart, TimeStop)
call get_indices(TimeRamNow%Time, Kp, f107)
! Initialize planet and axes if in stand-alone mode.
! In component mode, the framework takes care of this.
! This is needed for correct coordinate transformations.
if(.not. IsComponent) then
call init_planet_const
call set_planet_defaults
call init_axes(TimeRamStart % Time)
end if
! Initialize output files as necessary.
if(iProc==0) call init_output()
contains
!============================================================================
subroutine init_output
! Initialize any output that requires such action.
use ModRamSats, ONLY: read_sat_input, init_sats
use ModRamMain, ONLY: PathRamOut, PathScbOut, nIter
use ModRamIO, ONLY: iUnitLog, DoSaveRamSats, NameFileLog, NameFileDst
use ModIoUnit, ONLY: io_unit_new
use Module1, ONLY : iUnitDst
character(len=*), parameter :: NameSubSub = NameSub//'::init_output'
!------------------------------------------------------------------------
! Initialize virtual satellites.
if(DoSaveRamSats) then
call read_sat_input
call init_sats
end if
! Initialize logfile.
iUnitLog = io_unit_new()
write(NameFileLog, '(a,i6.6, a)') PathRamOut//'log_n', nIter, '.log'
open(iUnitLog, FILE=NameFileLog, STATUS='REPLACE')
write(iUnitLog,*)'RAM-SCB Log'
write(iUnitLog, '(a,a)') &
'time year mo dy hr mn sc msc dstRam dstBiot pparh pperh ', &
'pparo ppero pparhe pperhe ppare ppere'
! Initialize Dstfile.
iUnitDst = io_unit_new()
write(NameFileDst, '(a,i6.6, a)') PathScbOut//'dst_computed_3deq_', nIter, '.txt'
open(iUnitDst, FILE=NameFileDst, STATUS='REPLACE')
write(iUnitDst,*)'SCB Dst File'
write(iUnitDst, *) &
'time year mo dy hr mn sc msc dstDPS dstDPSGeo ', &
'dstBiot dstBiotGeo'
end subroutine init_output
end subroutine init_ramscb
!============================================================================