source: palm/trunk/SOURCE/calc_mean_profile.f90 @ 2579

Last change on this file since 2579 was 2233, checked in by suehring, 7 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 5.1 KB
Line 
1!> @file calc_mean_profile.f90
2!------------------------------------------------------------------------------!
3! This file is part of PALM.
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-2017 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: calc_mean_profile.f90 2233 2017-05-30 18:08:54Z knoop $
27!
28! 2232 2017-05-30 17:47:52Z suehring
29! Adjustments to new topography concept
30!
31! 2000 2016-08-20 18:09:15Z knoop
32! Forced header and separation lines into 80 columns
33!
34! 1873 2016-04-18 14:50:06Z maronga
35! Module renamed (removed _mod)
36!
37!
38! 1850 2016-04-08 13:29:27Z maronga
39! Module renamed
40!
41!
42! 1738 2015-12-18 13:56:05Z raasch
43! bugfix: if a layer is completely filled with topography, no mean is calculated
44!
45! 1682 2015-10-07 23:56:08Z knoop
46! Code annotations made doxygen readable
47!
48! 1365 2014-04-22 15:03:56Z boeske
49! Initial revision
50!
51! Description:
52! ------------
53!> Calculate the horizontally averaged vertical temperature profile (pr=4 in case
54!> of potential temperature, 44 in case of virtual potential temperature, and 64
55!> in case of density (ocean runs)).
56!------------------------------------------------------------------------------!
57 MODULE calc_mean_profile_mod
58 
59
60    PRIVATE
61    PUBLIC calc_mean_profile
62
63    INTERFACE calc_mean_profile
64       MODULE PROCEDURE calc_mean_profile
65    END INTERFACE calc_mean_profile
66
67 CONTAINS
68
69!------------------------------------------------------------------------------!
70! Description:
71! ------------
72!> @todo Missing subroutine description.
73!------------------------------------------------------------------------------!
74    SUBROUTINE calc_mean_profile( var, pr )
75
76       USE control_parameters,                                                 &
77           ONLY:  intermediate_timestep_count, message_string
78
79       USE indices,                                                            &
80           ONLY:  ngp_2dh_s_inner, nxl, nxr, nyn, nys, nzb, nzb, nzt,          &
81                  wall_flags_0
82
83       USE kinds
84
85       USE pegrid
86
87       USE statistics,                                                         &
88           ONLY:  flow_statistics_called, hom, sums, sums_l
89
90
91       IMPLICIT NONE
92       
93       INTEGER(iwp) ::  i                  !<
94       INTEGER(iwp) ::  j                  !<
95       INTEGER(iwp) ::  k                  !<
96       INTEGER(iwp) ::  pr                 !<
97       INTEGER(iwp) ::  omp_get_thread_num !<
98       INTEGER(iwp) ::  tn                 !<
99       
100#if defined( __nopointer )
101       REAL(wp), DIMENSION(:,:,:) ::  var  !<
102#else
103       REAL(wp), DIMENSION(:,:,:), POINTER ::  var
104#endif
105
106!
107!--    Computation of the horizontally averaged profile of variable var, unless
108!--    already done by the relevant call from flow_statistics. The calculation
109!--    is done only for the first respective intermediate timestep in order to
110!--    spare communication time and to produce identical model results with jobs
111!--    which are calling flow_statistics at different time intervals.
112       IF ( .NOT. flow_statistics_called  .AND.                                &
113            intermediate_timestep_count == 1 )  THEN
114
115!
116!--       Horizontal average of variable var
117          tn           =   0  ! Default thread number in case of one thread
118          !$OMP PARALLEL PRIVATE( i, j, k, tn )
119!$        tn = omp_get_thread_num()
120          sums_l(:,pr,tn) = 0.0_wp
121          !$OMP DO
122          DO  i = nxl, nxr
123             DO  j =  nys, nyn
124                DO  k = nzb, nzt+1
125                   sums_l(k,pr,tn) = sums_l(k,pr,tn) + var(k,j,i)              &
126                                     * MERGE( 1.0_wp, 0.0_wp,                  &
127                                              BTEST( wall_flags_0(k,j,i), 22 ) )
128                ENDDO
129             ENDDO
130          ENDDO
131          !$OMP END PARALLEL
132
133          DO  i = 1, threads_per_task-1
134             sums_l(:,pr,0) = sums_l(:,pr,0) + sums_l(:,pr,i)
135          ENDDO
136
137#if defined( __parallel )
138
139          IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
140          CALL MPI_ALLREDUCE( sums_l(nzb,pr,0), sums(nzb,pr), nzt+2-nzb,       &
141                              MPI_REAL, MPI_SUM, comm2d, ierr )
142
143#else
144
145          sums(:,pr) = sums_l(:,pr,0)
146
147#endif
148
149          DO  k = nzb, nzt+1
150             IF ( ngp_2dh_s_inner(k,0) /= 0 )  THEN
151                hom(k,1,pr,0) = sums(k,pr) / ngp_2dh_s_inner(k,0)
152             ENDIF
153          ENDDO
154
155       ENDIF
156
157
158    END SUBROUTINE calc_mean_profile
159
160 END MODULE calc_mean_profile_mod
Note: See TracBrowser for help on using the repository browser.