1 | !> @file salsa_util_mod.f90 |
---|
2 | !--------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM-4U. |
---|
4 | ! |
---|
5 | ! PALM-4U is free software: you can redistribute it and/or modify it under the |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! version. |
---|
9 | ! |
---|
10 | ! PALM-4U is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 1997-2019 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: salsa_util_mod.f90 3864 2019-04-05 09:01:56Z knoop $ |
---|
27 | ! Formatting changes |
---|
28 | ! |
---|
29 | ! 3845 2019-04-01 13:41:55Z monakurppa |
---|
30 | ! Initial revision |
---|
31 | ! |
---|
32 | ! |
---|
33 | ! |
---|
34 | ! Authors: |
---|
35 | ! -------- |
---|
36 | ! @author monakurppa |
---|
37 | ! |
---|
38 | ! |
---|
39 | ! Description: |
---|
40 | ! ------------ |
---|
41 | !> Utility functions used in salsa_mod. |
---|
42 | !------------------------------------------------------------------------------! |
---|
43 | MODULE salsa_util_mod |
---|
44 | |
---|
45 | USE control_parameters, & |
---|
46 | ONLY: message_string |
---|
47 | |
---|
48 | USE kinds |
---|
49 | |
---|
50 | USE pegrid |
---|
51 | |
---|
52 | IMPLICIT NONE |
---|
53 | |
---|
54 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: sums_salsa_ws_l !< subdomain sum of vertical salsa |
---|
55 | !< flux w's' (5th-order advection |
---|
56 | !< scheme only) |
---|
57 | ! |
---|
58 | !-- Component index |
---|
59 | TYPE component_index |
---|
60 | INTEGER(iwp) :: ncomp !< Number of components |
---|
61 | INTEGER(iwp), ALLOCATABLE :: ind(:) !< Component index |
---|
62 | CHARACTER(len=3), ALLOCATABLE :: comp(:) !< Component name |
---|
63 | END TYPE component_index |
---|
64 | |
---|
65 | SAVE |
---|
66 | |
---|
67 | INTERFACE component_index_constructor |
---|
68 | MODULE PROCEDURE component_index_constructor |
---|
69 | END INTERFACE component_index_constructor |
---|
70 | |
---|
71 | INTERFACE get_index |
---|
72 | MODULE PROCEDURE get_index |
---|
73 | END INTERFACE get_index |
---|
74 | |
---|
75 | INTERFACE is_used |
---|
76 | MODULE PROCEDURE is_used |
---|
77 | END INTERFACE is_used |
---|
78 | |
---|
79 | PRIVATE |
---|
80 | PUBLIC component_index, component_index_constructor, get_index, is_used, sums_salsa_ws_l |
---|
81 | |
---|
82 | CONTAINS |
---|
83 | |
---|
84 | !------------------------------------------------------------------------------! |
---|
85 | ! Description: |
---|
86 | ! ------------ |
---|
87 | !> Creates index tables for different (aerosol) components |
---|
88 | !------------------------------------------------------------------------------! |
---|
89 | SUBROUTINE component_index_constructor( self, ncomp, nlist, listcomp ) |
---|
90 | |
---|
91 | IMPLICIT NONE |
---|
92 | |
---|
93 | INTEGER(iwp) :: i !< |
---|
94 | INTEGER(iwp) :: jj !< |
---|
95 | |
---|
96 | INTEGER(iwp), INTENT(in) :: nlist ! < Maximum number of components |
---|
97 | |
---|
98 | INTEGER(iwp), INTENT(inout) :: ncomp !< Number of components |
---|
99 | |
---|
100 | TYPE(component_index), INTENT(inout) :: self !< Object containing the indices of different |
---|
101 | !< aerosol components |
---|
102 | CHARACTER(len=3), INTENT(in) :: listcomp(nlist) !< List cof component names |
---|
103 | |
---|
104 | ncomp = 0 |
---|
105 | |
---|
106 | DO WHILE ( listcomp(ncomp+1) /= ' ' .AND. ncomp < nlist ) |
---|
107 | ncomp = ncomp + 1 |
---|
108 | ENDDO |
---|
109 | |
---|
110 | self%ncomp = ncomp |
---|
111 | ALLOCATE( self%ind(ncomp), self%comp(ncomp) ) |
---|
112 | |
---|
113 | DO i = 1, ncomp |
---|
114 | self%ind(i) = i |
---|
115 | ENDDO |
---|
116 | |
---|
117 | jj = 1 |
---|
118 | DO i = 1, nlist |
---|
119 | IF ( listcomp(i) == '') CYCLE |
---|
120 | self%comp(jj) = listcomp(i) |
---|
121 | jj = jj + 1 |
---|
122 | ENDDO |
---|
123 | |
---|
124 | END SUBROUTINE component_index_constructor |
---|
125 | |
---|
126 | !------------------------------------------------------------------------------! |
---|
127 | ! Description: |
---|
128 | ! ------------ |
---|
129 | !> Gives the index of a component in the component list |
---|
130 | !------------------------------------------------------------------------------! |
---|
131 | INTEGER FUNCTION get_index( self, incomp ) |
---|
132 | |
---|
133 | IMPLICIT NONE |
---|
134 | |
---|
135 | CHARACTER(len=*), INTENT(in) :: incomp !< Component name |
---|
136 | INTEGER(iwp) :: i |
---|
137 | |
---|
138 | TYPE(component_index), INTENT(in) :: self !< Object containing the indices of different |
---|
139 | !< aerosol components |
---|
140 | IF ( ANY( self%comp == incomp ) ) THEN |
---|
141 | i = 1 |
---|
142 | DO WHILE ( (self%comp(i) /= incomp) ) |
---|
143 | i = i + 1 |
---|
144 | ENDDO |
---|
145 | get_index = i |
---|
146 | ELSEIF ( incomp == 'H2O' ) THEN |
---|
147 | get_index = self%ncomp + 1 |
---|
148 | ELSE |
---|
149 | WRITE( message_string, * ) 'Incorrect component name given!' |
---|
150 | CALL message( 'get_index', 'PA0591', 1, 2, 0, 6, 0 ) |
---|
151 | ENDIF |
---|
152 | |
---|
153 | RETURN |
---|
154 | |
---|
155 | END FUNCTION get_index |
---|
156 | |
---|
157 | !------------------------------------------------------------------------------! |
---|
158 | ! Description: |
---|
159 | ! ------------ |
---|
160 | !> Tells if the (aerosol) component is being used in the simulation |
---|
161 | !------------------------------------------------------------------------------! |
---|
162 | LOGICAL FUNCTION is_used( self, icomp ) |
---|
163 | |
---|
164 | IMPLICIT NONE |
---|
165 | |
---|
166 | CHARACTER(len=*), INTENT(in) :: icomp !< Component name |
---|
167 | |
---|
168 | TYPE(component_index), INTENT(in) :: self !< Object containing the indices of different |
---|
169 | !< aerosol components |
---|
170 | |
---|
171 | IF ( ANY(self%comp == icomp) ) THEN |
---|
172 | is_used = .TRUE. |
---|
173 | ELSE |
---|
174 | is_used = .FALSE. |
---|
175 | ENDIF |
---|
176 | |
---|
177 | END FUNCTION |
---|
178 | |
---|
179 | END MODULE salsa_util_mod |
---|