[1682] | 1 | !> @file user_data_output_mask.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 4 | ! |
---|
[2000] | 5 | ! PALM 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. |
---|
[1036] | 9 | ! |
---|
| 10 | ! PALM 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 |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[300] | 20 | ! Current revisions: |
---|
| 21 | ! ------------------ |
---|
[1683] | 22 | ! |
---|
[2001] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: user_data_output_mask.f90 4168 2019-08-16 13:50:17Z suehring $ |
---|
[4168] | 27 | ! Remove dependency on surface_mod + example for terrain-following output |
---|
| 28 | ! adjusted |
---|
| 29 | ! |
---|
| 30 | ! 4069 2019-07-01 14:05:51Z Giersch |
---|
[4069] | 31 | ! Masked output running index mid has been introduced as a local variable to |
---|
| 32 | ! avoid runtime error (Loop variable has been modified) in time_integration |
---|
| 33 | ! |
---|
| 34 | ! 3768 2019-02-27 14:35:58Z raasch |
---|
[3768] | 35 | ! variables commented + statement added to avoid compiler warnings about unused variables |
---|
| 36 | ! |
---|
| 37 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
[3435] | 38 | ! Add terrain-following output |
---|
| 39 | ! |
---|
| 40 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 41 | ! Corrected "Former revisions" section |
---|
| 42 | ! |
---|
| 43 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 44 | ! Change in file header (GPL part) |
---|
[1321] | 45 | ! |
---|
[2716] | 46 | ! 2101 2017-01-05 16:42:31Z suehring |
---|
| 47 | ! |
---|
[2001] | 48 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 49 | ! Forced header and separation lines into 80 columns |
---|
| 50 | ! |
---|
[1683] | 51 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 52 | ! Code annotations made doxygen readable |
---|
| 53 | ! |
---|
[1321] | 54 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 55 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 56 | ! kinds are defined in new module kinds, |
---|
| 57 | ! old module precision_kind is removed, |
---|
| 58 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 59 | ! all variable declaration statements |
---|
[300] | 60 | ! |
---|
[1037] | 61 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 62 | ! code put under GPL (PALM 3.9) |
---|
| 63 | ! |
---|
[300] | 64 | ! Description: |
---|
| 65 | ! ------------ |
---|
[1682] | 66 | !> Resorts the user-defined output quantity with indices (k,j,i) to a |
---|
| 67 | !> temporary array with indices (i,j,k) for masked data output. |
---|
[300] | 68 | !------------------------------------------------------------------------------! |
---|
[4069] | 69 | SUBROUTINE user_data_output_mask( av, variable, found, local_pf, mid ) |
---|
[1682] | 70 | |
---|
[300] | 71 | |
---|
| 72 | USE control_parameters |
---|
[1320] | 73 | |
---|
[300] | 74 | USE indices |
---|
[1320] | 75 | |
---|
| 76 | USE kinds |
---|
| 77 | |
---|
[300] | 78 | USE user |
---|
| 79 | |
---|
| 80 | IMPLICIT NONE |
---|
| 81 | |
---|
[3435] | 82 | CHARACTER (LEN=*) :: variable !< |
---|
[300] | 83 | |
---|
[3435] | 84 | INTEGER(iwp) :: av !< |
---|
[4069] | 85 | INTEGER(iwp) :: mid !< masked output running index |
---|
[3768] | 86 | ! INTEGER(iwp) :: i !< |
---|
| 87 | ! INTEGER(iwp) :: j !< |
---|
| 88 | ! INTEGER(iwp) :: k !< |
---|
[4168] | 89 | ! INTEGER(iwp) :: topo_top_index !< k index of highest horizontal surface |
---|
[300] | 90 | |
---|
[3435] | 91 | LOGICAL :: found !< |
---|
[300] | 92 | |
---|
[1320] | 93 | REAL(wp), & |
---|
| 94 | DIMENSION(mask_size_l(mid,1),mask_size_l(mid,2),mask_size_l(mid,3)) :: & |
---|
[1682] | 95 | local_pf !< |
---|
[300] | 96 | |
---|
[3768] | 97 | ! |
---|
| 98 | !-- Next line is to avoid compiler warning about unused variables. Please remove. |
---|
| 99 | IF ( av == 0 .OR. & |
---|
| 100 | local_pf(mask_size_l(mid,1),mask_size_l(mid,2),mask_size_l(mid,3)) == 0.0_wp ) CONTINUE |
---|
[300] | 101 | |
---|
[3768] | 102 | |
---|
[300] | 103 | found = .TRUE. |
---|
| 104 | |
---|
| 105 | SELECT CASE ( TRIM( variable ) ) |
---|
| 106 | |
---|
| 107 | !-- Uncomment and extend the following lines, if necessary. |
---|
| 108 | !-- The arrays for storing the user defined quantities (here u2 and u2_av) |
---|
| 109 | !-- have to be declared and defined by the user! |
---|
| 110 | !-- Sample for user-defined output: |
---|
| 111 | ! CASE ( 'u2' ) |
---|
| 112 | ! IF ( av == 0 ) THEN |
---|
[3435] | 113 | ! IF ( .NOT. mask_surface(mid) ) THEN |
---|
| 114 | !! |
---|
| 115 | !!-- Default masked output |
---|
| 116 | ! DO i = 1, mask_size_l(mid,1) |
---|
| 117 | ! DO j = 1, mask_size_l(mid,2) |
---|
| 118 | ! DO k = 1, mask_size_l(mid,3) |
---|
| 119 | ! local_pf(i,j,k) = u2(mask_k(mid,k), & |
---|
| 120 | ! mask_j(mid,j), & |
---|
| 121 | ! mask_i(mid,i)) |
---|
| 122 | ! ENDDO |
---|
[300] | 123 | ! ENDDO |
---|
| 124 | ! ENDDO |
---|
[3435] | 125 | ! ELSE |
---|
| 126 | !! |
---|
| 127 | !!-- Terrain-following masked output |
---|
| 128 | ! DO i = 1, mask_size_l(mid,1) |
---|
| 129 | ! DO j = 1, mask_size_l(mid,2) |
---|
| 130 | !! |
---|
| 131 | !!-- Get k index of highest horizontal surface |
---|
[4168] | 132 | ! topo_top_index = topo_top_ind( & |
---|
[3435] | 133 | ! mask_j(mid,j), & |
---|
| 134 | ! mask_i(mid,i), & |
---|
[4168] | 135 | ! 1 ) |
---|
[3435] | 136 | !! |
---|
| 137 | !!-- Save output array |
---|
| 138 | ! DO k = 1, mask_size_l(mid,3) |
---|
[4168] | 139 | ! local_pf(i,j,k) = u2(MIN( topo_top_index+mask_k(mid,k),& |
---|
| 140 | ! nzt+1 ), & |
---|
| 141 | ! mask_j(mid,j), & |
---|
[3435] | 142 | ! mask_i(mid,i) ) |
---|
| 143 | ! ENDDO |
---|
| 144 | ! ENDDO |
---|
| 145 | ! ENDDO |
---|
| 146 | ! ENDIF |
---|
[300] | 147 | ! ELSE |
---|
[3435] | 148 | ! IF ( .NOT. mask_surface(mid) ) THEN |
---|
| 149 | !! |
---|
| 150 | !!-- Default masked output |
---|
| 151 | ! DO i = 1, mask_size_l(mid,1) |
---|
| 152 | ! DO j = 1, mask_size_l(mid,2) |
---|
| 153 | ! DO k = 1, mask_size_l(mid,3) |
---|
| 154 | ! local_pf(i,j,k) = u2_av(mask_k(mid,k), & |
---|
| 155 | ! mask_j(mid,j), & |
---|
| 156 | ! mask_i(mid,i) ) |
---|
| 157 | ! ENDDO |
---|
| 158 | ! ENDDO |
---|
| 159 | ! ENDDO |
---|
| 160 | ! ELSE |
---|
| 161 | !! |
---|
| 162 | !!-- Terrain-following masked output |
---|
| 163 | ! DO i = 1, mask_size_l(mid,1) |
---|
| 164 | ! DO j = 1, mask_size_l(mid,2) |
---|
| 165 | !! |
---|
| 166 | !!-- Get k index of highest horizontal surface |
---|
[4168] | 167 | ! topo_top_index = topo_top_ind( & |
---|
[3435] | 168 | ! mask_j(mid,j), & |
---|
| 169 | ! mask_i(mid,i), & |
---|
[4168] | 170 | ! 1 ) |
---|
[3435] | 171 | !! |
---|
| 172 | !!-- Save output array |
---|
| 173 | ! DO k = 1, mask_size_l(mid,3) |
---|
[4168] | 174 | ! local_pf(i,j,k) = u2_av( & |
---|
| 175 | ! MIN( topo_top_index+mask_k(mid,k),& |
---|
| 176 | ! nzt+1 ), & |
---|
| 177 | ! mask_j(mid,j), & |
---|
[3435] | 178 | ! mask_i(mid,i) ) |
---|
| 179 | ! ENDDO |
---|
[300] | 180 | ! ENDDO |
---|
| 181 | ! ENDDO |
---|
[3435] | 182 | ! ENDIF |
---|
[300] | 183 | ! ENDIF |
---|
| 184 | |
---|
| 185 | CASE DEFAULT |
---|
| 186 | found = .FALSE. |
---|
| 187 | |
---|
| 188 | END SELECT |
---|
| 189 | |
---|
| 190 | |
---|
| 191 | END SUBROUTINE user_data_output_mask |
---|