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

Last change on this file since 1873 was 1873, checked in by maronga, 8 years ago

revised renaming of modules

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