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

Last change on this file since 4179 was 4168, checked in by suehring, 5 years ago

Replace get_topography_top_index functions by pre-calculated arrays in order to save computational resources

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