DISPATCH
units_mod.f90
1
!===============================================================================
2
!> Fundamental constants in CGS and SI units
3
!===============================================================================
4
MODULE
units_mod
5
USE
io_unit_mod
6
USE
math_mod
7
USE
omp_mod
8
USE
trace_mod
9
implicit none
10
private
11
!-----------------------------------------------------------------------------
12
! Data type holding constants of nature for a system
13
!-----------------------------------------------------------------------------
14
type
,
public
::
const_t
15
character(len=16)
:: name=
'not set'
16
real(kind=8)
:: m_u, m_h, m_he
17
real(kind=8)
:: amu
18
real(kind=8)
:: k_b
19
real(kind=8)
:: h_p
20
real(kind=8)
:: c
21
real(kind=8)
:: e
22
real(kind=8)
:: stefan
23
real(kind=8)
:: grav
24
real(kind=8)
:: au
25
real(kind=8)
:: pc
26
real(kind=8)
:: yr
27
real(kind=8)
:: kms
28
real(kind=8)
:: mum
29
real(kind=8)
:: myr
30
real(kind=8)
:: m_sun
31
real(kind=8)
:: r_sun
32
real(kind=8)
:: m_earth
33
real(kind=8)
:: r_earth
34
real(kind=8)
:: pi
35
contains
36
procedure
:: init
37
end type
38
type
(
const_t
),
public
:: cgs, si
39
!-----------------------------------------------------------------------------
40
! Data type for transmitting system info as meta-data
41
!-----------------------------------------------------------------------------
42
type
,
public
::
units_t
43
character(len=4)
:: system=
'code'
44
real(kind=8)
:: l=1d0
45
real(kind=8)
:: t=1d0
46
real(kind=8)
:: m=1d0
47
contains
48
procedure
:: output
49
end type
50
type
(
units_t
),
public
:: units
51
CONTAINS
52
53
SUBROUTINE
init (self)
54
class
(
const_t
):: self
55
!-----------------------------------------------------------------------------
56
! CGS units
57
!-----------------------------------------------------------------------------
58
cgs%name =
'cgs'
59
cgs%m_u = 1.6726219d-24
60
cgs%m_h = cgs%m_u
61
cgs%m_he = 6.65e-24
62
cgs%amu = 1.66054d-24
63
cgs%k_b = 1.380658d-16
! [erg/K]
64
cgs%h_p = 6.6260755d-27
65
cgs%c = 2.999792d10
66
cgs%e = 1.602177e-12
67
cgs%stefan = 5.67d-5
68
cgs%grav = 6.6743d-8
69
cgs%AU = 1.496d13
70
cgs%pc = 3.086d18
71
cgs%yr = 3.15542d7
72
cgs%kms = 1d5
73
cgs%mum = 1d-4
74
cgs%Myr = 3.15542d13
75
cgs%m_sun = 1.989d33
76
cgs%r_sun = 6.9598d10
77
cgs%m_earth = 5.972d27
78
cgs%r_earth = 6.371d8
79
cgs%pi = math%pi
80
!-----------------------------------------------------------------------------
81
! SI units
82
!-----------------------------------------------------------------------------
83
si%name =
'SI'
84
si%m_u = 1.6726d-27
85
si%amu = 1.66054d-27
86
si%k_b = 1.3807d-23
87
si%h_p = 6.6260755d-34
88
si%c = 2.999792d8
89
si%e = 1.602177e-19
90
si%stefan = 5.67d-8
91
si%grav = 6.6743d-11
92
si%AU = 1.496d11
93
si%pc = 3.086d16
94
si%yr = 3.15542d7
95
si%kms = 1d3
96
si%mum = 1d-6
97
si%Myr = 3.15542d13
98
si%m_sun = 1.989d30
99
si%r_sun = 6.9598d8
100
si%m_earth = 5.972d25
101
si%r_earth = 6.371d6
102
si%pi = math%pi
103
END SUBROUTINE
init
104
105
!===============================================================================
106
!> Write out unit system info
107
!===============================================================================
108
SUBROUTINE
output (self)
109
class
(
units_t
):: self
110
character(len=4)
:: system
111
real(kind=8)
:: l, t, m
112
namelist /units_nml/ system, l, t, m
113
!----------------------------------------------------------------------------
114
call
trace%begin (
'units_t%init'
)
115
system = self%system
116
l = self%l
117
t = self%t
118
m = self%m
119
if
(omp%master)
then
120
!$omp critical (write_nml_cr)
121
write
(io_unit%nml, units_nml)
122
!$omp end critical (write_nml_cr)
123
end if
124
call
trace%end()
125
END SUBROUTINE
output
126
127
END MODULE
units_mod
trace_mod
Definition:
trace_mod.f90:4
units_mod
Fundamental constants in CGS and SI units.
Definition:
units_mod.f90:4
math_mod
Fundamental constants in CGS and SI units.
Definition:
math_mod.f90:4
io_unit_mod
Definition:
io_unit_mod.f90:5
units_mod::const_t
Definition:
units_mod.f90:14
units_mod::units_t
Definition:
units_mod.f90:42
microphysics
units_mod.f90
Generated by
1.8.13