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

Last change on this file since 4277 was 4182, checked in by scharf, 5 years ago
  • corrected "Former revisions" section
  • minor formatting in "Former revisions" section
  • added "Author" section
  • Property svn:keywords set to Id
File size: 4.7 KB
Line 
1!> @file calc_mean_profile.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: calc_mean_profile.f90 4182 2019-08-22 15:20:23Z schwenkel $
27! Corrected "Former revisions" section
28!
29! 3655 2019-01-07 16:51:22Z knoop
30! nopointer option removed
31!
32! 1365 2014-04-22 15:03:56Z boeske
33! Initial revision
34!
35! Description:
36! ------------
37!> Calculate the horizontally averaged vertical temperature profile (pr=4 in case
38!> of potential temperature, 44 in case of virtual potential temperature, and 64
39!> in case of density (ocean runs)).
40!------------------------------------------------------------------------------!
41 MODULE calc_mean_profile_mod
42 
43
44    PRIVATE
45    PUBLIC calc_mean_profile
46
47    INTERFACE calc_mean_profile
48       MODULE PROCEDURE calc_mean_profile
49    END INTERFACE calc_mean_profile
50
51 CONTAINS
52
53!------------------------------------------------------------------------------!
54! Description:
55! ------------
56!> @todo Missing subroutine description.
57!------------------------------------------------------------------------------!
58    SUBROUTINE calc_mean_profile( var, pr )
59
60       USE control_parameters,                                                 &
61           ONLY:  intermediate_timestep_count
62
63       USE indices,                                                            &
64           ONLY:  ngp_2dh_s_inner, nxl, nxr, nyn, nys, nzb, nzb, nzt,          &
65                  wall_flags_0
66
67       USE kinds
68
69       USE pegrid
70
71       USE statistics,                                                         &
72           ONLY:  flow_statistics_called, hom, sums, sums_l
73
74
75       IMPLICIT NONE
76       
77       INTEGER(iwp) ::  i                  !<
78       INTEGER(iwp) ::  j                  !<
79       INTEGER(iwp) ::  k                  !<
80       INTEGER(iwp) ::  pr                 !<
81!$     INTEGER(iwp) ::  omp_get_thread_num !<
82       INTEGER(iwp) ::  tn                 !<
83       
84       REAL(wp), DIMENSION(:,:,:), POINTER ::  var
85
86!
87!--    Computation of the horizontally averaged profile of variable var, unless
88!--    already done by the relevant call from flow_statistics. The calculation
89!--    is done only for the first respective intermediate timestep in order to
90!--    spare communication time and to produce identical model results with jobs
91!--    which are calling flow_statistics at different time intervals. At
92!--    initialization, intermediate_timestep_count = 0 is considered as well.
93
94       IF ( .NOT. flow_statistics_called  .AND.                                &
95            intermediate_timestep_count <= 1 )  THEN
96
97!
98!--       Horizontal average of variable var
99          tn           =   0  ! Default thread number in case of one thread
100          !$OMP PARALLEL PRIVATE( i, j, k, tn )
101!$        tn = omp_get_thread_num()
102          sums_l(:,pr,tn) = 0.0_wp
103          !$OMP DO
104          DO  i = nxl, nxr
105             DO  j =  nys, nyn
106                DO  k = nzb, nzt+1
107                   sums_l(k,pr,tn) = sums_l(k,pr,tn) + var(k,j,i)              &
108                                     * MERGE( 1.0_wp, 0.0_wp,                  &
109                                              BTEST( wall_flags_0(k,j,i), 22 ) )
110                ENDDO
111             ENDDO
112          ENDDO
113          !$OMP END PARALLEL
114
115          DO  i = 1, threads_per_task-1
116             sums_l(:,pr,0) = sums_l(:,pr,0) + sums_l(:,pr,i)
117          ENDDO
118
119#if defined( __parallel )
120
121          IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
122          CALL MPI_ALLREDUCE( sums_l(nzb,pr,0), sums(nzb,pr), nzt+2-nzb,       &
123                              MPI_REAL, MPI_SUM, comm2d, ierr )
124
125#else
126
127          sums(:,pr) = sums_l(:,pr,0)
128
129#endif
130
131          DO  k = nzb, nzt+1
132             IF ( ngp_2dh_s_inner(k,0) /= 0 )  THEN
133                hom(k,1,pr,0) = sums(k,pr) / ngp_2dh_s_inner(k,0)
134             ENDIF
135          ENDDO
136
137       ENDIF
138
139
140    END SUBROUTINE calc_mean_profile
141
142 END MODULE calc_mean_profile_mod
Note: See TracBrowser for help on using the repository browser.