Changeset 3864 for palm/trunk/SOURCE/salsa_util_mod.f90
- Timestamp:
- Apr 5, 2019 9:01:56 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/salsa_util_mod.f90
r3655 r3864 25 25 ! ----------------- 26 26 ! $Id$ 27 ! Formatting changes 28 ! 29 ! 3845 2019-04-01 13:41:55Z monakurppa 27 30 ! Initial revision 28 ! 29 ! 31 ! 32 ! 30 33 ! 31 34 ! Authors: … … 39 42 !------------------------------------------------------------------------------! 40 43 MODULE salsa_util_mod 41 44 45 USE control_parameters, & 46 ONLY: message_string 47 42 48 USE kinds 43 49 44 50 USE pegrid 45 51 46 52 IMPLICIT NONE 47 48 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: sums_salsa_ws_l !< subdomain sum49 !< of vertical passive salsa flux w's'50 !< (5th-order advection scheme only)51 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 ! 52 58 !-- Component index 53 59 TYPE component_index 54 INTEGER(iwp) :: ncomp !< Number of components55 INTEGER(iwp), ALLOCATABLE :: ind(:) !< Component index56 CHARACTER(len=3), ALLOCATABLE :: comp(:) !< Component name57 END TYPE component_index 58 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 59 65 SAVE 60 66 61 67 INTERFACE component_index_constructor 62 68 MODULE PROCEDURE component_index_constructor 63 69 END INTERFACE component_index_constructor 64 70 65 71 INTERFACE get_index 66 72 MODULE PROCEDURE get_index 67 73 END INTERFACE get_index 68 69 INTERFACE get_n_comp 70 MODULE PROCEDURE get_n_comp 71 END INTERFACE get_n_comp 72 74 73 75 INTERFACE is_used 74 76 MODULE PROCEDURE is_used 75 77 END INTERFACE is_used 76 78 77 79 PRIVATE 78 PUBLIC component_index, component_index_constructor, get_index, get_n_comp,& 79 is_used, sums_salsa_ws_l 80 80 PUBLIC component_index, component_index_constructor, get_index, is_used, sums_salsa_ws_l 81 81 82 CONTAINS 82 83 !------------------------------------------------------------------------------! 83 84 !------------------------------------------------------------------------------! 84 85 ! Description: 85 86 ! ------------ 86 87 !> Creates index tables for different (aerosol) components 87 88 !------------------------------------------------------------------------------! 88 SUBROUTINE component_index_constructor( SELF, ncomp, nlist, listcomp )89 SUBROUTINE component_index_constructor( self, ncomp, nlist, listcomp ) 89 90 90 91 IMPLICIT NONE 91 92 TYPE(component_index), INTENT(inout) :: SELF !< Object containing the indices 93 !< of different aerosol components 94 INTEGER(iwp), INTENT(inout) :: ncomp !< Number of components 95 INTEGER(iwp), INTENT(in) :: nlist !< Maximum number of components 96 CHARACTER(len=3), INTENT(in) :: listcomp(nlist) !< List cof component 97 !< names 98 INTEGER(iwp) :: i, jj 99 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 100 104 ncomp = 0 101 102 DO 105 106 DO WHILE ( listcomp(ncomp+1) /= ' ' .AND. ncomp < nlist ) 103 107 ncomp = ncomp + 1 104 108 ENDDO 105 106 SELF%ncomp = ncomp107 ALLOCATE( SELF%ind(ncomp), SELF%comp(ncomp) )108 109 DO i = 1, ncomp110 SELF%ind(i) = i109 110 self%ncomp = ncomp 111 ALLOCATE( self%ind(ncomp), self%comp(ncomp) ) 112 113 DO i = 1, ncomp 114 self%ind(i) = i 111 115 ENDDO 112 116 113 117 jj = 1 114 DO i = 1, nlist118 DO i = 1, nlist 115 119 IF ( listcomp(i) == '') CYCLE 116 SELF%comp(jj) = listcomp(i)117 jj = jj +1120 self%comp(jj) = listcomp(i) 121 jj = jj + 1 118 122 ENDDO 119 123 120 124 END SUBROUTINE component_index_constructor 121 125 … … 125 129 !> Gives the index of a component in the component list 126 130 !------------------------------------------------------------------------------! 127 INTEGER FUNCTION get_index( SELF, incomp )131 INTEGER FUNCTION get_index( self, incomp ) 128 132 129 133 IMPLICIT NONE 130 131 TYPE(component_index), INTENT(in) :: SELF !< Object containing the 132 !< indices of different 133 !< aerosol components 134 134 135 CHARACTER(len=*), INTENT(in) :: incomp !< Component name 135 136 INTEGER(iwp) :: i 136 137 IF ( ANY(SELF%comp == incomp) ) THEN 137 138 TYPE(component_index), INTENT(in) :: self !< Object containing the indices of different 139 !< aerosol components 140 IF ( ANY( self%comp == incomp ) ) THEN 138 141 i = 1 139 DO WHILE ( ( SELF%comp(i) /= incomp) )140 i = i +1142 DO WHILE ( (self%comp(i) /= incomp) ) 143 i = i + 1 141 144 ENDDO 142 145 get_index = i 143 146 ELSEIF ( incomp == 'H2O' ) THEN 144 get_index = SELF%ncomp + 1147 get_index = self%ncomp + 1 145 148 ELSE 146 STOP 1 ! "INFO for Developer: please use the message routine to pass the output string" get_index: FAILED, no such component - 149 WRITE( message_string, * ) 'Incorrect component name given!' 150 CALL message( 'get_index', 'PA0591', 1, 2, 0, 6, 0 ) 147 151 ENDIF 148 152 149 153 RETURN 150 154 151 155 END FUNCTION get_index 152 153 !------------------------------------------------------------------------------!154 ! Description:155 ! ------------156 !> Get the number of (aerosol) components used157 !------------------------------------------------------------------------------!158 INTEGER FUNCTION get_n_comp( SELF )159 160 IMPLICIT NONE161 162 TYPE(component_index), INTENT(in) :: SELF !< Object containing the163 !< indices of different164 !< aerosol components165 get_n_comp = SELF%ncomp166 RETURN167 168 END FUNCTION169 156 170 157 !------------------------------------------------------------------------------! … … 173 160 !> Tells if the (aerosol) component is being used in the simulation 174 161 !------------------------------------------------------------------------------! 175 LOGICAL FUNCTION is_used( SELF, icomp )162 LOGICAL FUNCTION is_used( self, icomp ) 176 163 177 164 IMPLICIT NONE 178 179 TYPE(component_index), INTENT(in) :: SELF !< Object containing the 180 !< indices of different 181 !< aerosol components 165 182 166 CHARACTER(len=*), INTENT(in) :: icomp !< Component name 183 184 IF ( ANY(SELF%comp == icomp) ) THEN 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 185 172 is_used = .TRUE. 186 173 ELSE 187 174 is_used = .FALSE. 188 175 ENDIF 189 190 RETURN 191 176 192 177 END FUNCTION 193 178
Note: See TracChangeset
for help on using the changeset viewer.