[2505] | 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 | ! |
---|
[3655] | 17 | ! Copyright 1997-2019 Leibniz Universitaet Hannover |
---|
[2505] | 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
| 20 | ! Current revisions: |
---|
| 21 | ! ----------------- |
---|
| 22 | ! |
---|
[2525] | 23 | ! |
---|
[2505] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: salsa_util_mod.f90 3864 2019-04-05 09:01:56Z monakurppa $ |
---|
[3864] | 27 | ! Formatting changes |
---|
| 28 | ! |
---|
| 29 | ! 3845 2019-04-01 13:41:55Z monakurppa |
---|
[2525] | 30 | ! Initial revision |
---|
[2505] | 31 | ! |
---|
[3864] | 32 | ! |
---|
| 33 | ! |
---|
[2505] | 34 | ! Authors: |
---|
| 35 | ! -------- |
---|
| 36 | ! @author monakurppa |
---|
| 37 | ! |
---|
| 38 | ! |
---|
| 39 | ! Description: |
---|
| 40 | ! ------------ |
---|
| 41 | !> Utility functions used in salsa_mod. |
---|
| 42 | !------------------------------------------------------------------------------! |
---|
| 43 | MODULE salsa_util_mod |
---|
[3864] | 44 | |
---|
| 45 | USE control_parameters, & |
---|
| 46 | ONLY: message_string |
---|
| 47 | |
---|
[2505] | 48 | USE kinds |
---|
[3864] | 49 | |
---|
[2754] | 50 | USE pegrid |
---|
[3864] | 51 | |
---|
[2505] | 52 | IMPLICIT NONE |
---|
| 53 | |
---|
[3864] | 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 | ! |
---|
[2505] | 58 | !-- Component index |
---|
| 59 | TYPE component_index |
---|
[3864] | 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 | |
---|
[2505] | 65 | SAVE |
---|
[3864] | 66 | |
---|
[2505] | 67 | INTERFACE component_index_constructor |
---|
| 68 | MODULE PROCEDURE component_index_constructor |
---|
| 69 | END INTERFACE component_index_constructor |
---|
[3864] | 70 | |
---|
[2505] | 71 | INTERFACE get_index |
---|
| 72 | MODULE PROCEDURE get_index |
---|
| 73 | END INTERFACE get_index |
---|
[3864] | 74 | |
---|
[2505] | 75 | INTERFACE is_used |
---|
| 76 | MODULE PROCEDURE is_used |
---|
| 77 | END INTERFACE is_used |
---|
[3864] | 78 | |
---|
[2505] | 79 | PRIVATE |
---|
[3864] | 80 | PUBLIC component_index, component_index_constructor, get_index, is_used, sums_salsa_ws_l |
---|
| 81 | |
---|
[2505] | 82 | CONTAINS |
---|
[3864] | 83 | |
---|
| 84 | !------------------------------------------------------------------------------! |
---|
[2505] | 85 | ! Description: |
---|
| 86 | ! ------------ |
---|
| 87 | !> Creates index tables for different (aerosol) components |
---|
| 88 | !------------------------------------------------------------------------------! |
---|
[3864] | 89 | SUBROUTINE component_index_constructor( self, ncomp, nlist, listcomp ) |
---|
[2505] | 90 | |
---|
| 91 | IMPLICIT NONE |
---|
[3864] | 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 | |
---|
[2754] | 104 | ncomp = 0 |
---|
[3864] | 105 | |
---|
| 106 | DO WHILE ( listcomp(ncomp+1) /= ' ' .AND. ncomp < nlist ) |
---|
[2754] | 107 | ncomp = ncomp + 1 |
---|
| 108 | ENDDO |
---|
[3864] | 109 | |
---|
| 110 | self%ncomp = ncomp |
---|
| 111 | ALLOCATE( self%ind(ncomp), self%comp(ncomp) ) |
---|
| 112 | |
---|
| 113 | DO i = 1, ncomp |
---|
| 114 | self%ind(i) = i |
---|
[2505] | 115 | ENDDO |
---|
[3864] | 116 | |
---|
[2505] | 117 | jj = 1 |
---|
[3864] | 118 | DO i = 1, nlist |
---|
[2505] | 119 | IF ( listcomp(i) == '') CYCLE |
---|
[3864] | 120 | self%comp(jj) = listcomp(i) |
---|
| 121 | jj = jj + 1 |
---|
[2505] | 122 | ENDDO |
---|
[3864] | 123 | |
---|
[2505] | 124 | END SUBROUTINE component_index_constructor |
---|
| 125 | |
---|
| 126 | !------------------------------------------------------------------------------! |
---|
| 127 | ! Description: |
---|
| 128 | ! ------------ |
---|
| 129 | !> Gives the index of a component in the component list |
---|
| 130 | !------------------------------------------------------------------------------! |
---|
[3864] | 131 | INTEGER FUNCTION get_index( self, incomp ) |
---|
[2505] | 132 | |
---|
| 133 | IMPLICIT NONE |
---|
[3864] | 134 | |
---|
[2505] | 135 | CHARACTER(len=*), INTENT(in) :: incomp !< Component name |
---|
| 136 | INTEGER(iwp) :: i |
---|
[3864] | 137 | |
---|
| 138 | TYPE(component_index), INTENT(in) :: self !< Object containing the indices of different |
---|
| 139 | !< aerosol components |
---|
| 140 | IF ( ANY( self%comp == incomp ) ) THEN |
---|
[2505] | 141 | i = 1 |
---|
[3864] | 142 | DO WHILE ( (self%comp(i) /= incomp) ) |
---|
| 143 | i = i + 1 |
---|
[2505] | 144 | ENDDO |
---|
| 145 | get_index = i |
---|
| 146 | ELSEIF ( incomp == 'H2O' ) THEN |
---|
[3864] | 147 | get_index = self%ncomp + 1 |
---|
[2505] | 148 | ELSE |
---|
[3864] | 149 | WRITE( message_string, * ) 'Incorrect component name given!' |
---|
| 150 | CALL message( 'get_index', 'PA0591', 1, 2, 0, 6, 0 ) |
---|
[2505] | 151 | ENDIF |
---|
[3864] | 152 | |
---|
[2505] | 153 | RETURN |
---|
[3864] | 154 | |
---|
[2505] | 155 | END FUNCTION get_index |
---|
| 156 | |
---|
| 157 | !------------------------------------------------------------------------------! |
---|
| 158 | ! Description: |
---|
| 159 | ! ------------ |
---|
[3864] | 160 | !> Tells if the (aerosol) component is being used in the simulation |
---|
[2505] | 161 | !------------------------------------------------------------------------------! |
---|
[3864] | 162 | LOGICAL FUNCTION is_used( self, icomp ) |
---|
[2505] | 163 | |
---|
| 164 | IMPLICIT NONE |
---|
| 165 | |
---|
[3864] | 166 | CHARACTER(len=*), INTENT(in) :: icomp !< Component name |
---|
[2505] | 167 | |
---|
[3864] | 168 | TYPE(component_index), INTENT(in) :: self !< Object containing the indices of different |
---|
| 169 | !< aerosol components |
---|
[2505] | 170 | |
---|
[3864] | 171 | IF ( ANY(self%comp == icomp) ) THEN |
---|
[2505] | 172 | is_used = .TRUE. |
---|
| 173 | ELSE |
---|
| 174 | is_used = .FALSE. |
---|
| 175 | ENDIF |
---|
[3864] | 176 | |
---|
[2505] | 177 | END FUNCTION |
---|
[3467] | 178 | |
---|
[2505] | 179 | END MODULE salsa_util_mod |
---|