-
Notifications
You must be signed in to change notification settings - Fork 9
/
carmasolute_mod.F90
177 lines (144 loc) · 6.84 KB
/
carmasolute_mod.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
!! The CARMASOLUTE module contains configuration information about a solute used by CARMA.
!!
!! @version May-2009
!! @author Chuck Bardeen
module carmasolute_mod
use carma_precision_mod
use carma_enums_mod
use carma_constants_mod
use carma_types_mod
! CARMA explicitly declares all variables.
implicit none
! All CARMA variables and procedures are private except those explicitly declared to be public.
private
! Declare the public methods.
public CARMASOLUTE_Create
public CARMASOLUTE_Destroy
public CARMASOLUTE_Get
public CARMASOLUTE_Print
contains
!! Defines a solute used by CARMA for nucleation and growth of cloud and
!! aerosol particles.
!!
!! @author Chuck Bardeen
!! @version May-2009
!!
!! @see CARMA_AddGas
!! @see CARMASOLUTE_Destroy
subroutine CARMASOLUTE_Create(carma, isolute, name, ions, wtmol, rho, rc, shortname)
type(carma_type), intent(inout) :: carma !! the carma object
integer, intent(in) :: isolute !! the solute index
character(*), intent(in) :: name !! the solute name, maximum of 255 characters
integer, intent(in) :: ions !! Number of ions solute dissociates into
real(kind=f), intent(in) :: wtmol !! the solute molecular weight [g/mol]
real(kind=f), intent(in) :: rho !! Mass density of solute
integer, intent(out) :: rc !! return code, negative indicates failure
character(*), optional, intent(in) :: shortname !! the solute shortname, maximum of 6 characters
! Assume success.
rc = RC_OK
! Make sure there are enough solutes allocated.
if (isolute > carma%f_NSOLUTE) then
if (carma%f_do_print) write(carma%f_LUNOPRT, *) "CARMASOLUTE_Create:: ERROR - The specifed solute (", &
isolute, ") is larger than the number of solutes (", carma%f_NSOLUTE, ")."
rc = RC_ERROR
return
end if
! Save off the settings.
carma%f_solute(isolute)%f_name = name
carma%f_solute(isolute)%f_ions = ions
carma%f_solute(isolute)%f_wtmol = wtmol
carma%f_solute(isolute)%f_rho = rho
! Defaults for optional parameters
carma%f_solute(isolute)%f_shortname = ""
! Set optional parameters.
if (present(shortname)) carma%f_solute(isolute)%f_shortname = shortname
return
end subroutine CARMASOLUTE_Create
!! Deallocates the memory associated with a CARMASOLUTE object.
!!
!! @author Chuck Bardeen
!! @version May-2009
!!
!! @see CARMASOLUTE_Create
subroutine CARMASOLUTE_Destroy(carma, isolute, rc)
type(carma_type), intent(inout) :: carma !! the carma object
integer, intent(in) :: isolute !! the solute index
integer, intent(out) :: rc !! return code, negative indicates failure
! Assume success.
rc = RC_OK
! Make sure there are enough solutes allocated.
if (isolute > carma%f_NSOLUTE) then
if (carma%f_do_print) write(carma%f_LUNOPRT, *) "CARMASOLUTE_Destroy:: ERROR - The specifed solute (", &
isolute, ") is larger than the number of solutes (", carma%f_NSOLUTE, ")."
rc = RC_ERROR
return
end if
return
end subroutine CARMASOLUTE_Destroy
!! Gets information about a solute.
!!
!! The group name and other properties are available after a call to
!! CARMASOLUTE_Create().
!!
!! @author Chuck Bardeen
!! @version May-2009
!!
!! @see CARMASOLUTE_Create
!! @see CARMA_GetGas
subroutine CARMASOLUTE_Get(carma, isolute, rc, name, shortname, ions, wtmol, rho)
type(carma_type), intent(in) :: carma !! the carma object
integer, intent(in) :: isolute !! the solute index
integer, intent(out) :: rc !! return code, negative indicates failure
character(len=*), optional, intent(out) :: name !! the solute name
character(len=*), optional, intent(out) :: shortname !! the solute short name
integer, optional, intent(out) :: ions !! Number of ions solute dissociates into
real(kind=f), optional, intent(out) :: wtmol !! the solute molecular weight [g/mol]
real(kind=f), optional, intent(out) :: rho !! Mass density of solute
! Assume success.
rc = RC_OK
! Make sure there are enough solutes allocated.
if (isolute > carma%f_NSOLUTE) then
if (carma%f_do_print) write(carma%f_LUNOPRT, *) "CARMASOLUTE_Get:: ERROR - The specifed solute (", &
isolute, ") is larger than the number of solutes (", carma%f_NSOLUTE, ")."
rc = RC_ERROR
return
end if
! Return any requested properties of the group.
if (present(name)) name = carma%f_solute(isolute)%f_name
if (present(shortname)) shortname = carma%f_solute(isolute)%f_shortname
if (present(ions)) ions = carma%f_solute(isolute)%f_ions
if (present(wtmol)) wtmol = carma%f_solute(isolute)%f_wtmol
if (present(rho)) rho = carma%f_solute(isolute)%f_rho
return
end subroutine CARMASOLUTE_Get
!! Prints information about a solute.
!!
!! @author Chuck Bardeen
!! @version May-2009
!!
!! @see CARMASOLUTE_Get
subroutine CARMASOLUTE_Print(carma, isolute, rc)
type(carma_type), intent(in) :: carma !! the carma object
integer, intent(in) :: isolute !! the solute index
integer, intent(out) :: rc !! return code, negative indicates failure
! Local variables
character(len=CARMA_NAME_LEN) :: name !! name
character(len=CARMA_SHORT_NAME_LEN) :: shortname !! shortname
integer :: ions !! Number of ions solute dissociates into
real(kind=f) :: wtmol !! the solute molecular weight [g/mol]
real(kind=f) :: rho !! Mass density of solute
! Assume success.
rc = RC_OK
! Test out the Get method.
if (carma%f_do_print) then
call CARMASOLUTE_Get(carma, isolute, rc, name=name, shortname=shortname, ions=ions, wtmol=wtmol, rho=rho)
if (rc < 0) return
write(carma%f_LUNOPRT,*) " name : ", trim(name)
write(carma%f_LUNOPRT,*) " shortname : ", trim(shortname)
write(carma%f_LUNOPRT,*) " ions : ", ions
write(carma%f_LUNOPRT,*) " wtmol : ", wtmol, " (g/mol)"
write(carma%f_LUNOPRT,*) " rho : ", rho, " (g/cm3)"
end if
return
end subroutine CARMASOLUTE_Print
end module carmasolute_mod