[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 4180 2019-08-21 14:37:54Z scharf $ |
---|
[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 | ! |
---|
[1321] | 40 | ! |
---|
[300] | 41 | ! Description: |
---|
| 42 | ! ------------ |
---|
[1682] | 43 | !> Resorts the user-defined output quantity with indices (k,j,i) to a |
---|
| 44 | !> temporary array with indices (i,j,k) for masked data output. |
---|
[300] | 45 | !------------------------------------------------------------------------------! |
---|
[4069] | 46 | SUBROUTINE user_data_output_mask( av, variable, found, local_pf, mid ) |
---|
[1682] | 47 | |
---|
[300] | 48 | |
---|
| 49 | USE control_parameters |
---|
[1320] | 50 | |
---|
[300] | 51 | USE indices |
---|
[1320] | 52 | |
---|
| 53 | USE kinds |
---|
| 54 | |
---|
[300] | 55 | USE user |
---|
| 56 | |
---|
| 57 | IMPLICIT NONE |
---|
| 58 | |
---|
[3435] | 59 | CHARACTER (LEN=*) :: variable !< |
---|
[300] | 60 | |
---|
[3435] | 61 | INTEGER(iwp) :: av !< |
---|
[4069] | 62 | INTEGER(iwp) :: mid !< masked output running index |
---|
[3768] | 63 | ! INTEGER(iwp) :: i !< |
---|
| 64 | ! INTEGER(iwp) :: j !< |
---|
| 65 | ! INTEGER(iwp) :: k !< |
---|
[4168] | 66 | ! INTEGER(iwp) :: topo_top_index !< k index of highest horizontal surface |
---|
[300] | 67 | |
---|
[3435] | 68 | LOGICAL :: found !< |
---|
[300] | 69 | |
---|
[1320] | 70 | REAL(wp), & |
---|
| 71 | DIMENSION(mask_size_l(mid,1),mask_size_l(mid,2),mask_size_l(mid,3)) :: & |
---|
[1682] | 72 | local_pf !< |
---|
[300] | 73 | |
---|
[3768] | 74 | ! |
---|
| 75 | !-- Next line is to avoid compiler warning about unused variables. Please remove. |
---|
| 76 | IF ( av == 0 .OR. & |
---|
| 77 | local_pf(mask_size_l(mid,1),mask_size_l(mid,2),mask_size_l(mid,3)) == 0.0_wp ) CONTINUE |
---|
[300] | 78 | |
---|
[3768] | 79 | |
---|
[300] | 80 | found = .TRUE. |
---|
| 81 | |
---|
| 82 | SELECT CASE ( TRIM( variable ) ) |
---|
| 83 | |
---|
| 84 | !-- Uncomment and extend the following lines, if necessary. |
---|
| 85 | !-- The arrays for storing the user defined quantities (here u2 and u2_av) |
---|
| 86 | !-- have to be declared and defined by the user! |
---|
| 87 | !-- Sample for user-defined output: |
---|
| 88 | ! CASE ( 'u2' ) |
---|
| 89 | ! IF ( av == 0 ) THEN |
---|
[3435] | 90 | ! IF ( .NOT. mask_surface(mid) ) THEN |
---|
| 91 | !! |
---|
| 92 | !!-- Default masked output |
---|
| 93 | ! DO i = 1, mask_size_l(mid,1) |
---|
| 94 | ! DO j = 1, mask_size_l(mid,2) |
---|
| 95 | ! DO k = 1, mask_size_l(mid,3) |
---|
| 96 | ! local_pf(i,j,k) = u2(mask_k(mid,k), & |
---|
| 97 | ! mask_j(mid,j), & |
---|
| 98 | ! mask_i(mid,i)) |
---|
| 99 | ! ENDDO |
---|
[300] | 100 | ! ENDDO |
---|
| 101 | ! ENDDO |
---|
[3435] | 102 | ! ELSE |
---|
| 103 | !! |
---|
| 104 | !!-- Terrain-following masked output |
---|
| 105 | ! DO i = 1, mask_size_l(mid,1) |
---|
| 106 | ! DO j = 1, mask_size_l(mid,2) |
---|
| 107 | !! |
---|
| 108 | !!-- Get k index of highest horizontal surface |
---|
[4168] | 109 | ! topo_top_index = topo_top_ind( & |
---|
[3435] | 110 | ! mask_j(mid,j), & |
---|
| 111 | ! mask_i(mid,i), & |
---|
[4168] | 112 | ! 1 ) |
---|
[3435] | 113 | !! |
---|
| 114 | !!-- Save output array |
---|
| 115 | ! DO k = 1, mask_size_l(mid,3) |
---|
[4168] | 116 | ! local_pf(i,j,k) = u2(MIN( topo_top_index+mask_k(mid,k),& |
---|
| 117 | ! nzt+1 ), & |
---|
| 118 | ! mask_j(mid,j), & |
---|
[3435] | 119 | ! mask_i(mid,i) ) |
---|
| 120 | ! ENDDO |
---|
| 121 | ! ENDDO |
---|
| 122 | ! ENDDO |
---|
| 123 | ! ENDIF |
---|
[300] | 124 | ! ELSE |
---|
[3435] | 125 | ! IF ( .NOT. mask_surface(mid) ) THEN |
---|
| 126 | !! |
---|
| 127 | !!-- Default masked output |
---|
| 128 | ! DO i = 1, mask_size_l(mid,1) |
---|
| 129 | ! DO j = 1, mask_size_l(mid,2) |
---|
| 130 | ! DO k = 1, mask_size_l(mid,3) |
---|
| 131 | ! local_pf(i,j,k) = u2_av(mask_k(mid,k), & |
---|
| 132 | ! mask_j(mid,j), & |
---|
| 133 | ! mask_i(mid,i) ) |
---|
| 134 | ! ENDDO |
---|
| 135 | ! ENDDO |
---|
| 136 | ! ENDDO |
---|
| 137 | ! ELSE |
---|
| 138 | !! |
---|
| 139 | !!-- Terrain-following masked output |
---|
| 140 | ! DO i = 1, mask_size_l(mid,1) |
---|
| 141 | ! DO j = 1, mask_size_l(mid,2) |
---|
| 142 | !! |
---|
| 143 | !!-- Get k index of highest horizontal surface |
---|
[4168] | 144 | ! topo_top_index = topo_top_ind( & |
---|
[3435] | 145 | ! mask_j(mid,j), & |
---|
| 146 | ! mask_i(mid,i), & |
---|
[4168] | 147 | ! 1 ) |
---|
[3435] | 148 | !! |
---|
| 149 | !!-- Save output array |
---|
| 150 | ! DO k = 1, mask_size_l(mid,3) |
---|
[4168] | 151 | ! local_pf(i,j,k) = u2_av( & |
---|
| 152 | ! MIN( topo_top_index+mask_k(mid,k),& |
---|
| 153 | ! nzt+1 ), & |
---|
| 154 | ! mask_j(mid,j), & |
---|
[3435] | 155 | ! mask_i(mid,i) ) |
---|
| 156 | ! ENDDO |
---|
[300] | 157 | ! ENDDO |
---|
| 158 | ! ENDDO |
---|
[3435] | 159 | ! ENDIF |
---|
[300] | 160 | ! ENDIF |
---|
| 161 | |
---|
| 162 | CASE DEFAULT |
---|
| 163 | found = .FALSE. |
---|
| 164 | |
---|
| 165 | END SELECT |
---|
| 166 | |
---|
| 167 | |
---|
| 168 | END SUBROUTINE user_data_output_mask |
---|