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

Last change on this file since 4100 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
RevLine 
[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 4069 2019-07-01 14:05:51Z forkel $
[4069]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
[3768]31! variables commented + statement added to avoid compiler warnings about unused variables
32!
33! 3655 2019-01-07 16:51:22Z knoop
[3435]34! Add terrain-following output
35!
36! 2718 2018-01-02 08:49:38Z maronga
[2716]37! Corrected "Former revisions" section
38!
39! 2696 2017-12-14 17:12:51Z kanani
40! Change in file header (GPL part)
[1321]41!
[2716]42! 2101 2017-01-05 16:42:31Z suehring
43!
[2001]44! 2000 2016-08-20 18:09:15Z knoop
45! Forced header and separation lines into 80 columns
46!
[1683]47! 1682 2015-10-07 23:56:08Z knoop
48! Code annotations made doxygen readable
49!
[1321]50! 1320 2014-03-20 08:40:49Z raasch
[1320]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
[300]56!
[1037]57! 1036 2012-10-22 13:43:42Z raasch
58! code put under GPL (PALM 3.9)
59!
[300]60! Description:
61! ------------
[1682]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.
[300]64!------------------------------------------------------------------------------!
[4069]65 SUBROUTINE user_data_output_mask( av, variable, found, local_pf, mid )
[1682]66 
[300]67
68    USE control_parameters
[1320]69       
[300]70    USE indices
[1320]71   
72    USE kinds
73   
[3435]74    USE surface_mod,                                                           &
75        ONLY:  get_topography_top_index_ji
76   
[300]77    USE user
78
79    IMPLICIT NONE
80
[3435]81    CHARACTER (LEN=*) ::  variable  !<
82    CHARACTER (LEN=5) ::  grid      !< flag to distinquish between staggered grids
[300]83
[3435]84    INTEGER(iwp) ::  av             !<
[4069]85    INTEGER(iwp) ::  mid            !< masked output running index
[3768]86!    INTEGER(iwp) ::  i              !<
87!    INTEGER(iwp) ::  j              !<
88!    INTEGER(iwp) ::  k              !<
89!    INTEGER(iwp) ::  topo_top_ind   !< k index of highest horizontal surface
[300]90
[3435]91    LOGICAL ::  found               !<
[300]92
[1320]93    REAL(wp),                                                                  &
94       DIMENSION(mask_size_l(mid,1),mask_size_l(mid,2),mask_size_l(mid,3)) ::  &
[1682]95          local_pf   !<
[300]96
[3768]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
[300]101
[3768]102
[300]103    found = .TRUE.
[3435]104    grid  = 's'
[300]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
[3435]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
[300]124!                   ENDDO
125!                ENDDO
[3435]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
[300]148!          ELSE
[3435]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
[300]181!                   ENDDO
182!                ENDDO
[3435]183!             ENDIF
[300]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.