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

Last change on this file since 1811 was 1739, checked in by raasch, 9 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 4.6 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 terms
6! of the GNU General Public License as published by the Free Software Foundation,
7! either version 3 of the License, or (at your option) any later version.
8!
9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
10! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12!
13! You should have received a copy of the GNU General Public License along with
14! PALM. If not, see <http://www.gnu.org/licenses/>.
15!
16! Copyright 1997-2014 Leibniz Universitaet Hannover
17!--------------------------------------------------------------------------------!
18!
19! Current revisions:
20! -----------------
21!
22!
23! Former revisions:
24! -----------------
25! $Id: calc_mean_profile.f90 1739 2015-12-18 14:16:53Z maronga $
26!
27! 1738 2015-12-18 13:56:05Z raasch
28! bugfix: if a layer is completely filled with topography, no mean is calculated
29!
30! 1682 2015-10-07 23:56:08Z knoop
31! Code annotations made doxygen readable
32!
33! 1365 2014-04-22 15:03:56Z boeske
34! Initial revision
35!
36! Description:
37! ------------
38!> Calculate the horizontally averaged vertical temperature profile (pr=4 in case
39!> of potential temperature, 44 in case of virtual potential temperature, and 64
40!> in case of density (ocean runs)).
41!------------------------------------------------------------------------------!
42 MODULE calc_mean_profile_mod
43 
44
45    PRIVATE
46    PUBLIC calc_mean_profile
47
48    INTERFACE calc_mean_profile
49       MODULE PROCEDURE calc_mean_profile
50    END INTERFACE calc_mean_profile
51
52 CONTAINS
53
54!------------------------------------------------------------------------------!
55! Description:
56! ------------
57!> @todo Missing subroutine description.
58!------------------------------------------------------------------------------!
59    SUBROUTINE calc_mean_profile( var, pr )
60
61       USE control_parameters,                                                 &
62           ONLY:  intermediate_timestep_count, message_string
63
64       USE indices,                                                            &
65           ONLY:  ngp_2dh_s_inner, nxl, nxr, nyn, nys, nzb, nzb_s_inner, nzt
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#if defined( __nopointer )
85       REAL(wp), DIMENSION(:,:,:) ::  var  !<
86#else
87       REAL(wp), DIMENSION(:,:,:), POINTER ::  var
88#endif
89
90!
91!--    Computation of the horizontally averaged profile of variable var, unless
92!--    already done by the relevant call from flow_statistics. The calculation
93!--    is done only for the first respective intermediate timestep in order to
94!--    spare communication time and to produce identical model results with jobs
95!--    which are calling flow_statistics at different time intervals.
96       IF ( .NOT. flow_statistics_called  .AND.                                &
97            intermediate_timestep_count == 1 )  THEN
98
99!
100!--       Horizontal average of variable var
101          tn           =   0  ! Default thread number in case of one thread
102          !$OMP PARALLEL PRIVATE( i, j, k, tn )
103!$        tn = omp_get_thread_num()
104          sums_l(:,pr,tn) = 0.0_wp
105          !$OMP DO
106          DO  i = nxl, nxr
107             DO  j =  nys, nyn
108                DO  k = nzb_s_inner(j,i), nzt+1
109                   sums_l(k,pr,tn) = sums_l(k,pr,tn) + var(k,j,i)
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.