Line data Source code
1 : !! The CARMASOLUTE module contains configuration information about a solute used by CARMA.
2 : !!
3 : !! @version May-2009
4 : !! @author Chuck Bardeen
5 : module carmasolute_mod
6 :
7 : use carma_precision_mod
8 : use carma_enums_mod
9 : use carma_constants_mod
10 : use carma_types_mod
11 :
12 : ! CARMA explicitly declares all variables.
13 : implicit none
14 :
15 : ! All CARMA variables and procedures are private except those explicitly declared to be public.
16 : private
17 :
18 : ! Declare the public methods.
19 : public CARMASOLUTE_Create
20 : public CARMASOLUTE_Destroy
21 : public CARMASOLUTE_Get
22 : public CARMASOLUTE_Print
23 :
24 : contains
25 :
26 : !! Defines a solute used by CARMA for nucleation and growth of cloud and
27 : !! aerosol particles.
28 : !!
29 : !! @author Chuck Bardeen
30 : !! @version May-2009
31 : !!
32 : !! @see CARMA_AddGas
33 : !! @see CARMASOLUTE_Destroy
34 0 : subroutine CARMASOLUTE_Create(carma, isolute, name, ions, wtmol, rho, rc, shortname)
35 : type(carma_type), intent(inout) :: carma !! the carma object
36 : integer, intent(in) :: isolute !! the solute index
37 : character(*), intent(in) :: name !! the solute name, maximum of 255 characters
38 : integer, intent(in) :: ions !! Number of ions solute dissociates into
39 : real(kind=f), intent(in) :: wtmol !! the solute molecular weight [g/mol]
40 : real(kind=f), intent(in) :: rho !! Mass density of solute
41 : integer, intent(out) :: rc !! return code, negative indicates failure
42 : character(*), optional, intent(in) :: shortname !! the solute shortname, maximum of 6 characters
43 :
44 : ! Assume success.
45 0 : rc = RC_OK
46 :
47 : ! Make sure there are enough solutes allocated.
48 0 : if (isolute > carma%f_NSOLUTE) then
49 0 : if (carma%f_do_print) write(carma%f_LUNOPRT, *) "CARMASOLUTE_Create:: ERROR - The specifed solute (", &
50 0 : isolute, ") is larger than the number of solutes (", carma%f_NSOLUTE, ")."
51 0 : rc = RC_ERROR
52 0 : return
53 : end if
54 :
55 : ! Save off the settings.
56 0 : carma%f_solute(isolute)%f_name = name
57 0 : carma%f_solute(isolute)%f_ions = ions
58 0 : carma%f_solute(isolute)%f_wtmol = wtmol
59 0 : carma%f_solute(isolute)%f_rho = rho
60 :
61 :
62 : ! Defaults for optional parameters
63 0 : carma%f_solute(isolute)%f_shortname = ""
64 :
65 : ! Set optional parameters.
66 0 : if (present(shortname)) carma%f_solute(isolute)%f_shortname = shortname
67 :
68 : return
69 0 : end subroutine CARMASOLUTE_Create
70 :
71 :
72 : !! Deallocates the memory associated with a CARMASOLUTE object.
73 : !!
74 : !! @author Chuck Bardeen
75 : !! @version May-2009
76 : !!
77 : !! @see CARMASOLUTE_Create
78 0 : subroutine CARMASOLUTE_Destroy(carma, isolute, rc)
79 : type(carma_type), intent(inout) :: carma !! the carma object
80 : integer, intent(in) :: isolute !! the solute index
81 : integer, intent(out) :: rc !! return code, negative indicates failure
82 :
83 : ! Assume success.
84 0 : rc = RC_OK
85 :
86 : ! Make sure there are enough solutes allocated.
87 0 : if (isolute > carma%f_NSOLUTE) then
88 0 : if (carma%f_do_print) write(carma%f_LUNOPRT, *) "CARMASOLUTE_Destroy:: ERROR - The specifed solute (", &
89 0 : isolute, ") is larger than the number of solutes (", carma%f_NSOLUTE, ")."
90 0 : rc = RC_ERROR
91 0 : return
92 : end if
93 :
94 : return
95 : end subroutine CARMASOLUTE_Destroy
96 :
97 :
98 : !! Gets information about a solute.
99 : !!
100 : !! The group name and other properties are available after a call to
101 : !! CARMASOLUTE_Create().
102 : !!
103 : !! @author Chuck Bardeen
104 : !! @version May-2009
105 : !!
106 : !! @see CARMASOLUTE_Create
107 : !! @see CARMA_GetGas
108 0 : subroutine CARMASOLUTE_Get(carma, isolute, rc, name, shortname, ions, wtmol, rho)
109 : type(carma_type), intent(in) :: carma !! the carma object
110 : integer, intent(in) :: isolute !! the solute index
111 : integer, intent(out) :: rc !! return code, negative indicates failure
112 : character(len=*), optional, intent(out) :: name !! the solute name
113 : character(len=*), optional, intent(out) :: shortname !! the solute short name
114 : integer, optional, intent(out) :: ions !! Number of ions solute dissociates into
115 : real(kind=f), optional, intent(out) :: wtmol !! the solute molecular weight [g/mol]
116 : real(kind=f), optional, intent(out) :: rho !! Mass density of solute
117 :
118 : ! Assume success.
119 0 : rc = RC_OK
120 :
121 : ! Make sure there are enough solutes allocated.
122 0 : if (isolute > carma%f_NSOLUTE) then
123 0 : if (carma%f_do_print) write(carma%f_LUNOPRT, *) "CARMASOLUTE_Get:: ERROR - The specifed solute (", &
124 0 : isolute, ") is larger than the number of solutes (", carma%f_NSOLUTE, ")."
125 0 : rc = RC_ERROR
126 0 : return
127 : end if
128 :
129 : ! Return any requested properties of the group.
130 0 : if (present(name)) name = carma%f_solute(isolute)%f_name
131 0 : if (present(shortname)) shortname = carma%f_solute(isolute)%f_shortname
132 0 : if (present(ions)) ions = carma%f_solute(isolute)%f_ions
133 0 : if (present(wtmol)) wtmol = carma%f_solute(isolute)%f_wtmol
134 0 : if (present(rho)) rho = carma%f_solute(isolute)%f_rho
135 :
136 : return
137 0 : end subroutine CARMASOLUTE_Get
138 :
139 :
140 : !! Prints information about a solute.
141 : !!
142 : !! @author Chuck Bardeen
143 : !! @version May-2009
144 : !!
145 : !! @see CARMASOLUTE_Get
146 0 : subroutine CARMASOLUTE_Print(carma, isolute, rc)
147 : type(carma_type), intent(in) :: carma !! the carma object
148 : integer, intent(in) :: isolute !! the solute index
149 : integer, intent(out) :: rc !! return code, negative indicates failure
150 :
151 : ! Local variables
152 : character(len=CARMA_NAME_LEN) :: name !! name
153 : character(len=CARMA_SHORT_NAME_LEN) :: shortname !! shortname
154 : integer :: ions !! Number of ions solute dissociates into
155 : real(kind=f) :: wtmol !! the solute molecular weight [g/mol]
156 : real(kind=f) :: rho !! Mass density of solute
157 :
158 : ! Assume success.
159 0 : rc = RC_OK
160 :
161 : ! Test out the Get method.
162 0 : if (carma%f_do_print) then
163 0 : call CARMASOLUTE_Get(carma, isolute, rc, name=name, shortname=shortname, ions=ions, wtmol=wtmol, rho=rho)
164 0 : if (rc < 0) return
165 :
166 :
167 0 : write(carma%f_LUNOPRT,*) " name : ", trim(name)
168 0 : write(carma%f_LUNOPRT,*) " shortname : ", trim(shortname)
169 0 : write(carma%f_LUNOPRT,*) " ions : ", ions
170 0 : write(carma%f_LUNOPRT,*) " wtmol : ", wtmol, " (g/mol)"
171 0 : write(carma%f_LUNOPRT,*) " rho : ", rho, " (g/cm3)"
172 : end if
173 :
174 : return
175 : end subroutine CARMASOLUTE_Print
176 :
177 : end module carmasolute_mod
|