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

Last change on this file since 1365 was 1365, checked in by boeske, 10 years ago

large scale forcing enabled

  • Property svn:keywords set to Id
File size: 3.9 KB
RevLine 
[1365]1 MODULE calc_mean_profile_mod
2
3!--------------------------------------------------------------------------------!
4! This file is part of PALM.
5!
6! PALM is free software: you can redistribute it and/or modify it under the terms
7! of the GNU General Public License as published by the Free Software Foundation,
8! either version 3 of the License, or (at your option) any later 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-2014 Leibniz Universitaet Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: calc_mean_profile.f90 1365 2014-04-22 15:03:56Z boeske $
27!
28! Description:
29! ------------
30! Calculate the horizontally averaged vertical temperature profile (pr=4 in case
31! of potential temperature, 44 in case of virtual potential temperature, and 64
32! in case of density (ocean runs)).
33!------------------------------------------------------------------------------!
34
35    PRIVATE
36    PUBLIC calc_mean_profile
37
38    INTERFACE calc_mean_profile
39       MODULE PROCEDURE calc_mean_profile
40    END INTERFACE calc_mean_profile
41
42 CONTAINS
43
44    SUBROUTINE calc_mean_profile( var, pr )
45
46       USE control_parameters,                                                 &
47           ONLY:  intermediate_timestep_count, message_string
48
49       USE indices,                                                            &
50           ONLY:  ngp_2dh_s_inner, nxl, nxr, nyn, nys, nzb, nzb_s_inner, nzt
51
52       USE kinds
53
54       USE pegrid
55
56       USE statistics,                                                         &
57           ONLY:  flow_statistics_called, hom, sums, sums_l
58
59
60       IMPLICIT NONE
61       
62       INTEGER(iwp) ::  i                  !:
63       INTEGER(iwp) ::  j                  !:
64       INTEGER(iwp) ::  k                  !:
65       INTEGER(iwp) ::  pr                 !:
66       INTEGER(iwp) ::  omp_get_thread_num !:
67       INTEGER(iwp) ::  tn                 !:
68       
69#if defined( __nopointer )
70       REAL(wp), DIMENSION(:,:,:) ::  var  !:
71#else
72       REAL(wp), DIMENSION(:,:,:), POINTER ::  var
73#endif
74
75!
76!--    Computation of the horizontally averaged profile of variable var, unless
77!--    already done by the relevant call from flow_statistics. The calculation
78!--    is done only for the first respective intermediate timestep in order to
79!--    spare communication time and to produce identical model results with jobs
80!--    which are calling flow_statistics at different time intervals.
81       IF ( .NOT. flow_statistics_called  .AND.                                &
82            intermediate_timestep_count == 1 )  THEN
83
84!
85!--       Horizontal average of variable var
86          tn           =   0  ! Default thread number in case of one thread
87          !$OMP PARALLEL PRIVATE( i, j, k, tn )
88!$        tn = omp_get_thread_num()
89          sums_l(:,pr,tn) = 0.0_wp
90          !$OMP DO
91          DO  i = nxl, nxr
92             DO  j =  nys, nyn
93                DO  k = nzb_s_inner(j,i), nzt+1
94                   sums_l(k,pr,tn) = sums_l(k,pr,tn) + var(k,j,i)
95                ENDDO
96             ENDDO
97          ENDDO
98          !$OMP END PARALLEL
99
100          DO  i = 1, threads_per_task-1
101             sums_l(:,pr,0) = sums_l(:,pr,0) + sums_l(:,pr,i)
102          ENDDO
103
104#if defined( __parallel )
105
106          IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
107          CALL MPI_ALLREDUCE( sums_l(nzb,pr,0), sums(nzb,pr), nzt+2-nzb,       &
108                              MPI_REAL, MPI_SUM, comm2d, ierr )
109
110#else
111
112          sums(:,pr) = sums_l(:,pr,0)
113
114#endif
115
116          hom(:,1,pr,0) = sums(:,pr) / ngp_2dh_s_inner(:,0)
117
118       ENDIF
119
120
121    END SUBROUTINE calc_mean_profile
122
123 END MODULE calc_mean_profile_mod
Note: See TracBrowser for help on using the repository browser.