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