source: palm/trunk/SOURCE/user_data_output_mask.f90 @ 4131

Last change on this file since 4131 was 4069, checked in by Giersch, 5 years ago

Bugfix for masked output, compiler warning removed, test case for wind turbine model revised

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