1 | !> @file user_data_output_mask.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
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. |
---|
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 | ! |
---|
17 | ! Copyright 1997-2019 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ------------------ |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: user_data_output_mask.f90 3768 2019-02-27 14:35:58Z knoop $ |
---|
27 | ! variables commented + statement added to avoid compiler warnings about unused variables |
---|
28 | ! |
---|
29 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
30 | ! Add terrain-following output |
---|
31 | ! |
---|
32 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
33 | ! Corrected "Former revisions" section |
---|
34 | ! |
---|
35 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
36 | ! Change in file header (GPL part) |
---|
37 | ! |
---|
38 | ! 2101 2017-01-05 16:42:31Z suehring |
---|
39 | ! |
---|
40 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
41 | ! Forced header and separation lines into 80 columns |
---|
42 | ! |
---|
43 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
44 | ! Code annotations made doxygen readable |
---|
45 | ! |
---|
46 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
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 |
---|
52 | ! |
---|
53 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
54 | ! code put under GPL (PALM 3.9) |
---|
55 | ! |
---|
56 | ! Description: |
---|
57 | ! ------------ |
---|
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. |
---|
60 | !------------------------------------------------------------------------------! |
---|
61 | SUBROUTINE user_data_output_mask( av, variable, found, local_pf ) |
---|
62 | |
---|
63 | |
---|
64 | USE control_parameters |
---|
65 | |
---|
66 | USE indices |
---|
67 | |
---|
68 | USE kinds |
---|
69 | |
---|
70 | USE surface_mod, & |
---|
71 | ONLY: get_topography_top_index_ji |
---|
72 | |
---|
73 | USE user |
---|
74 | |
---|
75 | IMPLICIT NONE |
---|
76 | |
---|
77 | CHARACTER (LEN=*) :: variable !< |
---|
78 | CHARACTER (LEN=5) :: grid !< flag to distinquish between staggered grids |
---|
79 | |
---|
80 | INTEGER(iwp) :: av !< |
---|
81 | ! INTEGER(iwp) :: i !< |
---|
82 | ! INTEGER(iwp) :: j !< |
---|
83 | ! INTEGER(iwp) :: k !< |
---|
84 | ! INTEGER(iwp) :: topo_top_ind !< k index of highest horizontal surface |
---|
85 | |
---|
86 | LOGICAL :: found !< |
---|
87 | |
---|
88 | REAL(wp), & |
---|
89 | DIMENSION(mask_size_l(mid,1),mask_size_l(mid,2),mask_size_l(mid,3)) :: & |
---|
90 | local_pf !< |
---|
91 | |
---|
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 |
---|
96 | |
---|
97 | |
---|
98 | found = .TRUE. |
---|
99 | grid = 's' |
---|
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 |
---|
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 |
---|
119 | ! ENDDO |
---|
120 | ! ENDDO |
---|
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 |
---|
143 | ! ELSE |
---|
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 |
---|
176 | ! ENDDO |
---|
177 | ! ENDDO |
---|
178 | ! ENDIF |
---|
179 | ! ENDIF |
---|
180 | |
---|
181 | CASE DEFAULT |
---|
182 | found = .FALSE. |
---|
183 | |
---|
184 | END SELECT |
---|
185 | |
---|
186 | |
---|
187 | END SUBROUTINE user_data_output_mask |
---|