source: palm/trunk/SOURCE/buoyancy.f90 @ 1366

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

last commit documented

  • Property svn:keywords set to Id
File size: 13.3 KB
RevLine 
[1]1 MODULE buoyancy_mod
2
[1036]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!
[1310]17! Copyright 1997-2014 Leibniz Universitaet Hannover
[1036]18!--------------------------------------------------------------------------------!
19!
[1328]20! Current revisions:
[1179]21! ------------------
[1354]22!
[1366]23!
[1321]24! Former revisions:
25! -----------------
26! $Id: buoyancy.f90 1366 2014-04-22 15:06:33Z boeske $
27!
[1366]28! 1365 2014-04-22 15:03:56Z boeske
29! Calculation of reference state in subroutine calc_mean_profile moved to
30! subroutine time_integration,
31! subroutine calc_mean_profile moved to new file calc_mean_profile.f90
32!
[1354]33! 1353 2014-04-08 15:21:23Z heinze
34! REAL constants provided with KIND-attribute
35!
[1321]36! 1320 2014-03-20 08:40:49Z raasch
[1320]37! ONLY-attribute added to USE-statements,
38! kind-parameters added to all INTEGER and REAL declaration statements,
39! kinds are defined in new module kinds,
40! revision history before 2012 removed,
41! comment fields (!:) to be used for variable explanations added to
42! all variable declaration statements
[98]43!
[1258]44! 1257 2013-11-08 15:18:40Z raasch
45! vector length (32) removed from openacc clause
46!
[1242]47! 1241 2013-10-30 11:36:58Z heinze
48! Generalize calc_mean_profile for wider use: use additional steering
49! character loc
50!
[1182]51! 1179 2013-06-14 05:57:58Z raasch
52! steering of reference state revised (var_reference and pr removed from
53! parameter list), use_reference renamed use_single_reference_value
54!
[1172]55! 1171 2013-05-30 11:27:45Z raasch
56! openacc statements added to use_reference-case in accelerator version
57!
[1154]58! 1153 2013-05-10 14:33:08Z raasch
59! code adjustments of accelerator version required by PGI 12.3 / CUDA 5.0
60!
[1132]61! 1128 2013-04-12 06:19:32Z raasch
62! loop index bounds in accelerator version replaced by i_left, i_right, j_south,
63! j_north
64!
[1037]65! 1036 2012-10-22 13:43:42Z raasch
66! code put under GPL (PALM 3.9)
67!
[1017]68! 1015 2012-09-27 09:23:24Z raasch
69! accelerator version (*_acc) added
70!
[1011]71! 1010 2012-09-20 07:59:54Z raasch
72! cpp switch __nopointer added for pointer free version
73!
[1]74! Revision 1.1  1997/08/29 08:56:48  raasch
75! Initial revision
76!
77!
78! Description:
79! ------------
80! Buoyancy term of the third component of the equation of motion.
81! WARNING: humidity is not regarded when using a sloping surface!
82!------------------------------------------------------------------------------!
83
84    PRIVATE
[1365]85    PUBLIC buoyancy, buoyancy_acc
[1]86
87    INTERFACE buoyancy
88       MODULE PROCEDURE buoyancy
89       MODULE PROCEDURE buoyancy_ij
90    END INTERFACE buoyancy
91
[1015]92    INTERFACE buoyancy_acc
93       MODULE PROCEDURE buoyancy_acc
94    END INTERFACE buoyancy_acc
95
[1]96 CONTAINS
97
98
99!------------------------------------------------------------------------------!
100! Call for all grid points
101!------------------------------------------------------------------------------!
[1179]102    SUBROUTINE buoyancy( var, wind_component )
[1]103
[1320]104       USE arrays_3d,                                                          &
105           ONLY:  pt, pt_slope_ref, ref_state, tend
106
107       USE control_parameters,                                                 &
108           ONLY:  atmos_ocean_sign, cos_alpha_surface, g, message_string,      &
109                  pt_surface, sin_alpha_surface, sloping_surface
110
111       USE indices,                                                            &
112           ONLY:  nxl, nxlu, nxr, nyn, nys, nzb_s_inner, nzt
113
114       USE kinds
115
[1]116       USE pegrid
117
[1320]118
[1]119       IMPLICIT NONE
120
[1320]121       INTEGER(iwp) ::  i              !:
122       INTEGER(iwp) ::  j              !:
123       INTEGER(iwp) ::  k              !:
124       INTEGER(iwp) ::  wind_component !:
125       
[1010]126#if defined( __nopointer )
[1320]127       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  var !:
[1010]128#else
[1320]129       REAL(wp), DIMENSION(:,:,:), POINTER ::  var
[1010]130#endif
[1]131
132
133       IF ( .NOT. sloping_surface )  THEN
134!
135!--       Normal case: horizontal surface
[1179]136          DO  i = nxl, nxr
137             DO  j = nys, nyn
138                DO  k = nzb_s_inner(j,i)+1, nzt-1
[1353]139                   tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5_wp * &
140                          (                                                    &
141                             ( var(k,j,i)   - ref_state(k) )   / ref_state(k) + &
142                             ( var(k+1,j,i) - ref_state(k+1) ) / ref_state(k+1) &
143                          )
[57]144                ENDDO
145             ENDDO
[1179]146          ENDDO
[1]147
148       ELSE
149!
150!--       Buoyancy term for a surface with a slope in x-direction. The equations
151!--       for both the u and w velocity-component contain proportionate terms.
152!--       Temperature field at time t=0 serves as environmental temperature.
153!--       Reference temperature (pt_surface) is the one at the lower left corner
154!--       of the total domain.
155          IF ( wind_component == 1 )  THEN
156
[106]157             DO  i = nxlu, nxr
[1]158                DO  j = nys, nyn
159                   DO  k = nzb_s_inner(j,i)+1, nzt-1
160                      tend(k,j,i) = tend(k,j,i) + g * sin_alpha_surface *      &
[1353]161                           0.5_wp * ( ( pt(k,j,i-1)         + pt(k,j,i)         ) &
162                                    - ( pt_slope_ref(k,i-1) + pt_slope_ref(k,i) ) &
163                                    ) / pt_surface
[1]164                   ENDDO
165                ENDDO
166             ENDDO
167
168          ELSEIF ( wind_component == 3 )  THEN
169
170             DO  i = nxl, nxr
171                DO  j = nys, nyn
172                   DO  k = nzb_s_inner(j,i)+1, nzt-1
173                      tend(k,j,i) = tend(k,j,i) + g * cos_alpha_surface *      &
[1353]174                           0.5_wp * ( ( pt(k,j,i)         + pt(k+1,j,i)         ) &
175                                    - ( pt_slope_ref(k,i) + pt_slope_ref(k+1,i) ) &
176                                    ) / pt_surface
[1]177                   ENDDO
178                ENDDO
179            ENDDO
180
181          ELSE
[247]182             
[1320]183             WRITE( message_string, * ) 'no term for component "',             &
[1]184                                       wind_component,'"'
[247]185             CALL message( 'buoyancy', 'PA0159', 1, 2, 0, 6, 0 )
[1]186
187          ENDIF
188
189       ENDIF
190
191    END SUBROUTINE buoyancy
192
193
194!------------------------------------------------------------------------------!
[1015]195! Call for all grid points - accelerator version
196!------------------------------------------------------------------------------!
[1179]197    SUBROUTINE buoyancy_acc( var, wind_component )
[1015]198
[1320]199       USE arrays_3d,                                                          &
200           ONLY:  pt, pt_slope_ref, ref_state, tend
201
202       USE control_parameters,                                                 &
203           ONLY:  atmos_ocean_sign, cos_alpha_surface, g, message_string,      &
204                  pt_surface, sin_alpha_surface, sloping_surface
205
206       USE indices,                                                            &
207           ONLY:  i_left, i_right, j_north, j_south, nxl, nxlu, nxr, nyn, nys, &
208                  nzb_s_inner, nzt
209
210       USE kinds
211
[1015]212       USE pegrid
213
[1320]214
[1015]215       IMPLICIT NONE
216
[1320]217       INTEGER(iwp) ::  i              !:
218       INTEGER(iwp) ::  j              !:
219       INTEGER(iwp) ::  k              !:
220       INTEGER(iwp) ::  wind_component !:
221       
[1015]222#if defined( __nopointer )
[1320]223       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  var !:
[1015]224#else
[1320]225       REAL(wp), DIMENSION(:,:,:), POINTER ::  var
[1015]226#endif
227
228
229       IF ( .NOT. sloping_surface )  THEN
230!
231!--       Normal case: horizontal surface
[1179]232          !$acc kernels present( nzb_s_inner, ref_state, tend, var )
233          !$acc loop
234          DO  i = i_left, i_right
235             DO  j = j_south, j_north
[1257]236                !$acc loop independent vector
[1179]237                DO  k = nzb_s_inner(j,i)+1, nzt-1
[1353]238                   tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5_wp * &
239                          (                                                    &
240                             ( var(k,j,i)   - ref_state(k) )   / ref_state(k) + &
241                             ( var(k+1,j,i) - ref_state(k+1) ) / ref_state(k+1) &
242                          )
[1015]243                ENDDO
244             ENDDO
[1179]245          ENDDO
246          !$acc end kernels
[1015]247
248       ELSE
249!
250!--       Buoyancy term for a surface with a slope in x-direction. The equations
251!--       for both the u and w velocity-component contain proportionate terms.
252!--       Temperature field at time t=0 serves as environmental temperature.
253!--       Reference temperature (pt_surface) is the one at the lower left corner
254!--       of the total domain.
255          IF ( wind_component == 1 )  THEN
256
257             DO  i = nxlu, nxr
258                DO  j = nys, nyn
259                   DO  k = nzb_s_inner(j,i)+1, nzt-1
260                      tend(k,j,i) = tend(k,j,i) + g * sin_alpha_surface *      &
[1353]261                           0.5_wp * ( ( pt(k,j,i-1)         + pt(k,j,i)         ) &
262                                    - ( pt_slope_ref(k,i-1) + pt_slope_ref(k,i) ) &
263                                    ) / pt_surface
[1015]264                   ENDDO
265                ENDDO
266             ENDDO
267
268          ELSEIF ( wind_component == 3 )  THEN
269
270             DO  i = nxl, nxr
271                DO  j = nys, nyn
272                   DO  k = nzb_s_inner(j,i)+1, nzt-1
273                      tend(k,j,i) = tend(k,j,i) + g * cos_alpha_surface *      &
[1353]274                           0.5_wp * ( ( pt(k,j,i)         + pt(k+1,j,i)         ) &
275                                    - ( pt_slope_ref(k,i) + pt_slope_ref(k+1,i) ) &
276                                    ) / pt_surface
[1015]277                   ENDDO
278                ENDDO
279            ENDDO
280
281          ELSE
282
[1320]283             WRITE( message_string, * ) 'no term for component "',             &
[1015]284                                       wind_component,'"'
285             CALL message( 'buoyancy', 'PA0159', 1, 2, 0, 6, 0 )
286
287          ENDIF
288
289       ENDIF
290
291    END SUBROUTINE buoyancy_acc
292
293
294!------------------------------------------------------------------------------!
[1]295! Call for grid point i,j
[515]296! ATTENTION: PGI-compiler creates SIGFPE if opt>1 is used! Therefore, opt=1 is
297!            forced by compiler-directive.
[1]298!------------------------------------------------------------------------------!
[515]299!pgi$r opt=1
[1179]300    SUBROUTINE buoyancy_ij( i, j, var, wind_component )
[1]301
[1320]302       USE arrays_3d,                                                          &
303           ONLY:  pt, pt_slope_ref, ref_state, tend
304
305       USE control_parameters,                                                 &
306           ONLY:  atmos_ocean_sign, cos_alpha_surface, g, message_string,      &
307                  pt_surface, sin_alpha_surface, sloping_surface
308
309       USE indices,                                                            &
310           ONLY:  nzb_s_inner, nzt
311
312       USE kinds
313
[1]314       USE pegrid
315
[1320]316
[1]317       IMPLICIT NONE
318
[1320]319       INTEGER(iwp) ::  i              !:
320       INTEGER(iwp) ::  j              !:
321       INTEGER(iwp) ::  k              !:
322       INTEGER(iwp) ::  pr             !:
323       INTEGER(iwp) ::  wind_component !:
324       
[1010]325#if defined( __nopointer )
[1320]326       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  var !:
[1010]327#else
[1320]328       REAL(wp), DIMENSION(:,:,:), POINTER ::  var
[1010]329#endif
[1]330
331
332       IF ( .NOT. sloping_surface )  THEN
333!
334!--       Normal case: horizontal surface
[1179]335          DO  k = nzb_s_inner(j,i)+1, nzt-1
[1353]336              tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5_wp * (    &
[1320]337                        ( var(k,j,i)   - ref_state(k)   ) / ref_state(k)   +   &
338                        ( var(k+1,j,i) - ref_state(k+1) ) / ref_state(k+1)     &
[1353]339                                                                          )
[1179]340          ENDDO
[1]341
342       ELSE
343!
344!--       Buoyancy term for a surface with a slope in x-direction. The equations
345!--       for both the u and w velocity-component contain proportionate terms.
346!--       Temperature field at time t=0 serves as environmental temperature.
347!--       Reference temperature (pt_surface) is the one at the lower left corner
348!--       of the total domain.
349          IF ( wind_component == 1 )  THEN
350
351             DO  k = nzb_s_inner(j,i)+1, nzt-1
352                tend(k,j,i) = tend(k,j,i) + g * sin_alpha_surface *            &
[1353]353                           0.5_wp * ( ( pt(k,j,i-1)         + pt(k,j,i)         ) &
354                                    - ( pt_slope_ref(k,i-1) + pt_slope_ref(k,i) ) &
355                                    ) / pt_surface
[1]356             ENDDO
357
358          ELSEIF ( wind_component == 3 )  THEN
359
360             DO  k = nzb_s_inner(j,i)+1, nzt-1
361                tend(k,j,i) = tend(k,j,i) + g * cos_alpha_surface *            &
[1353]362                           0.5_wp * ( ( pt(k,j,i)         + pt(k+1,j,i)         ) &
363                                    - ( pt_slope_ref(k,i) + pt_slope_ref(k+1,i) ) &
364                                    ) / pt_surface
[1]365             ENDDO
366
367          ELSE
368
[1320]369             WRITE( message_string, * ) 'no term for component "',             &
[1]370                                       wind_component,'"'
[247]371             CALL message( 'buoyancy', 'PA0159', 1, 2, 0, 6, 0 )
[1]372
373          ENDIF
374
375       ENDIF
376
377    END SUBROUTINE buoyancy_ij
378
379 END MODULE buoyancy_mod
Note: See TracBrowser for help on using the repository browser.