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