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 4182 2019-08-22 15:20:23Z resler $ |
---|
27 | ! Corrected "Former revisions" section |
---|
28 | ! |
---|
29 | ! 4168 2019-08-16 13:50:17Z suehring |
---|
30 | ! Remove dependency on surface_mod + example for terrain-following output |
---|
31 | ! adjusted |
---|
32 | ! |
---|
33 | ! 4069 2019-07-01 14:05:51Z Giersch |
---|
34 | ! Masked output running index mid has been introduced as a local variable to |
---|
35 | ! avoid runtime error (Loop variable has been modified) in time_integration |
---|
36 | ! |
---|
37 | ! 3768 2019-02-27 14:35:58Z raasch |
---|
38 | ! variables commented + statement added to avoid compiler warnings about unused variables |
---|
39 | ! |
---|
40 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
41 | ! Add terrain-following output |
---|
42 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
43 | ! code put under GPL (PALM 3.9) |
---|
44 | ! |
---|
45 | ! Description: |
---|
46 | ! ------------ |
---|
47 | !> Resorts the user-defined output quantity with indices (k,j,i) to a |
---|
48 | !> temporary array with indices (i,j,k) for masked data output. |
---|
49 | !------------------------------------------------------------------------------! |
---|
50 | SUBROUTINE user_data_output_mask( av, variable, found, local_pf, mid ) |
---|
51 | |
---|
52 | |
---|
53 | USE control_parameters |
---|
54 | |
---|
55 | USE indices |
---|
56 | |
---|
57 | USE kinds |
---|
58 | |
---|
59 | USE user |
---|
60 | |
---|
61 | IMPLICIT NONE |
---|
62 | |
---|
63 | CHARACTER (LEN=*) :: variable !< |
---|
64 | |
---|
65 | INTEGER(iwp) :: av !< |
---|
66 | INTEGER(iwp) :: mid !< masked output running index |
---|
67 | ! INTEGER(iwp) :: i !< |
---|
68 | ! INTEGER(iwp) :: j !< |
---|
69 | ! INTEGER(iwp) :: k !< |
---|
70 | ! INTEGER(iwp) :: topo_top_index !< k index of highest horizontal surface |
---|
71 | |
---|
72 | LOGICAL :: found !< |
---|
73 | |
---|
74 | REAL(wp), & |
---|
75 | DIMENSION(mask_size_l(mid,1),mask_size_l(mid,2),mask_size_l(mid,3)) :: & |
---|
76 | local_pf !< |
---|
77 | |
---|
78 | ! |
---|
79 | !-- Next line is to avoid compiler warning about unused variables. Please remove. |
---|
80 | IF ( av == 0 .OR. & |
---|
81 | local_pf(mask_size_l(mid,1),mask_size_l(mid,2),mask_size_l(mid,3)) == 0.0_wp ) CONTINUE |
---|
82 | |
---|
83 | |
---|
84 | found = .TRUE. |
---|
85 | |
---|
86 | SELECT CASE ( TRIM( variable ) ) |
---|
87 | |
---|
88 | !-- Uncomment and extend the following lines, if necessary. |
---|
89 | !-- The arrays for storing the user defined quantities (here u2 and u2_av) |
---|
90 | !-- have to be declared and defined by the user! |
---|
91 | !-- Sample for user-defined output: |
---|
92 | ! CASE ( 'u2' ) |
---|
93 | ! IF ( av == 0 ) THEN |
---|
94 | ! IF ( .NOT. mask_surface(mid) ) THEN |
---|
95 | !! |
---|
96 | !!-- Default masked output |
---|
97 | ! DO i = 1, mask_size_l(mid,1) |
---|
98 | ! DO j = 1, mask_size_l(mid,2) |
---|
99 | ! DO k = 1, mask_size_l(mid,3) |
---|
100 | ! local_pf(i,j,k) = u2(mask_k(mid,k), & |
---|
101 | ! mask_j(mid,j), & |
---|
102 | ! mask_i(mid,i)) |
---|
103 | ! ENDDO |
---|
104 | ! ENDDO |
---|
105 | ! ENDDO |
---|
106 | ! ELSE |
---|
107 | !! |
---|
108 | !!-- Terrain-following masked output |
---|
109 | ! DO i = 1, mask_size_l(mid,1) |
---|
110 | ! DO j = 1, mask_size_l(mid,2) |
---|
111 | !! |
---|
112 | !!-- Get k index of highest horizontal surface |
---|
113 | ! topo_top_index = topo_top_ind( & |
---|
114 | ! mask_j(mid,j), & |
---|
115 | ! mask_i(mid,i), & |
---|
116 | ! 1 ) |
---|
117 | !! |
---|
118 | !!-- Save output array |
---|
119 | ! DO k = 1, mask_size_l(mid,3) |
---|
120 | ! local_pf(i,j,k) = u2(MIN( topo_top_index+mask_k(mid,k),& |
---|
121 | ! nzt+1 ), & |
---|
122 | ! mask_j(mid,j), & |
---|
123 | ! mask_i(mid,i) ) |
---|
124 | ! ENDDO |
---|
125 | ! ENDDO |
---|
126 | ! ENDDO |
---|
127 | ! ENDIF |
---|
128 | ! ELSE |
---|
129 | ! IF ( .NOT. mask_surface(mid) ) THEN |
---|
130 | !! |
---|
131 | !!-- Default masked output |
---|
132 | ! DO i = 1, mask_size_l(mid,1) |
---|
133 | ! DO j = 1, mask_size_l(mid,2) |
---|
134 | ! DO k = 1, mask_size_l(mid,3) |
---|
135 | ! local_pf(i,j,k) = u2_av(mask_k(mid,k), & |
---|
136 | ! mask_j(mid,j), & |
---|
137 | ! mask_i(mid,i) ) |
---|
138 | ! ENDDO |
---|
139 | ! ENDDO |
---|
140 | ! ENDDO |
---|
141 | ! ELSE |
---|
142 | !! |
---|
143 | !!-- Terrain-following masked output |
---|
144 | ! DO i = 1, mask_size_l(mid,1) |
---|
145 | ! DO j = 1, mask_size_l(mid,2) |
---|
146 | !! |
---|
147 | !!-- Get k index of highest horizontal surface |
---|
148 | ! topo_top_index = topo_top_ind( & |
---|
149 | ! mask_j(mid,j), & |
---|
150 | ! mask_i(mid,i), & |
---|
151 | ! 1 ) |
---|
152 | !! |
---|
153 | !!-- Save output array |
---|
154 | ! DO k = 1, mask_size_l(mid,3) |
---|
155 | ! local_pf(i,j,k) = u2_av( & |
---|
156 | ! MIN( topo_top_index+mask_k(mid,k),& |
---|
157 | ! nzt+1 ), & |
---|
158 | ! mask_j(mid,j), & |
---|
159 | ! mask_i(mid,i) ) |
---|
160 | ! ENDDO |
---|
161 | ! ENDDO |
---|
162 | ! ENDDO |
---|
163 | ! ENDIF |
---|
164 | ! ENDIF |
---|
165 | |
---|
166 | CASE DEFAULT |
---|
167 | found = .FALSE. |
---|
168 | |
---|
169 | END SELECT |
---|
170 | |
---|
171 | |
---|
172 | END SUBROUTINE user_data_output_mask |
---|