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

Last change on this file since 2119 was 2119, checked in by raasch, 7 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 10.2 KB
RevLine 
[1873]1!> @file buoyancy.f90
[2000]2!------------------------------------------------------------------------------!
[1036]3! This file is part of PALM.
4!
[2000]5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! version.
[1036]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!
[2101]17! Copyright 1997-2017 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[1328]20! Current revisions:
[1179]21! ------------------
[1354]22!
[2119]23!
[1321]24! Former revisions:
25! -----------------
26! $Id: buoyancy.f90 2119 2017-01-17 16:51:50Z raasch $
27!
[2119]28! 2118 2017-01-17 16:38:49Z raasch
29! OpenACC version of subroutine removed
30!
[2001]31! 2000 2016-08-20 18:09:15Z knoop
32! Forced header and separation lines into 80 columns
33!
[1874]34! 1873 2016-04-18 14:50:06Z maronga
35! Module renamed (removed _mod)
36!
37!
[1851]38! 1850 2016-04-08 13:29:27Z maronga
39! Module renamed
40!
41!
[1683]42! 1682 2015-10-07 23:56:08Z knoop
43! Code annotations made doxygen readable
44!
[1375]45! 1374 2014-04-25 12:55:07Z raasch
46! missing variables added to ONLY list
47!
[1366]48! 1365 2014-04-22 15:03:56Z boeske
49! Calculation of reference state in subroutine calc_mean_profile moved to
50! subroutine time_integration,
51! subroutine calc_mean_profile moved to new file calc_mean_profile.f90
52!
[1354]53! 1353 2014-04-08 15:21:23Z heinze
54! REAL constants provided with KIND-attribute
55!
[1321]56! 1320 2014-03-20 08:40:49Z raasch
[1320]57! ONLY-attribute added to USE-statements,
58! kind-parameters added to all INTEGER and REAL declaration statements,
59! kinds are defined in new module kinds,
60! revision history before 2012 removed,
61! comment fields (!:) to be used for variable explanations added to
62! all variable declaration statements
[98]63!
[1258]64! 1257 2013-11-08 15:18:40Z raasch
65! vector length (32) removed from openacc clause
66!
[1242]67! 1241 2013-10-30 11:36:58Z heinze
68! Generalize calc_mean_profile for wider use: use additional steering
69! character loc
70!
[1182]71! 1179 2013-06-14 05:57:58Z raasch
72! steering of reference state revised (var_reference and pr removed from
73! parameter list), use_reference renamed use_single_reference_value
74!
[1172]75! 1171 2013-05-30 11:27:45Z raasch
76! openacc statements added to use_reference-case in accelerator version
77!
[1154]78! 1153 2013-05-10 14:33:08Z raasch
79! code adjustments of accelerator version required by PGI 12.3 / CUDA 5.0
80!
[1132]81! 1128 2013-04-12 06:19:32Z raasch
82! loop index bounds in accelerator version replaced by i_left, i_right, j_south,
83! j_north
84!
[1037]85! 1036 2012-10-22 13:43:42Z raasch
86! code put under GPL (PALM 3.9)
87!
[1017]88! 1015 2012-09-27 09:23:24Z raasch
89! accelerator version (*_acc) added
90!
[1011]91! 1010 2012-09-20 07:59:54Z raasch
92! cpp switch __nopointer added for pointer free version
93!
[1]94! Revision 1.1  1997/08/29 08:56:48  raasch
95! Initial revision
96!
97!
98! Description:
99! ------------
[1682]100!> Buoyancy term of the third component of the equation of motion.
101!> @attention Humidity is not regarded when using a sloping surface!
[1]102!------------------------------------------------------------------------------!
[1682]103 MODULE buoyancy_mod
104 
[1]105
106    PRIVATE
[2118]107    PUBLIC buoyancy
[1]108
109    INTERFACE buoyancy
110       MODULE PROCEDURE buoyancy
111       MODULE PROCEDURE buoyancy_ij
112    END INTERFACE buoyancy
113
114 CONTAINS
115
116
117!------------------------------------------------------------------------------!
[1682]118! Description:
119! ------------
120!> Call for all grid points
[1]121!------------------------------------------------------------------------------!
[1179]122    SUBROUTINE buoyancy( var, wind_component )
[1]123
[1320]124       USE arrays_3d,                                                          &
125           ONLY:  pt, pt_slope_ref, ref_state, tend
126
127       USE control_parameters,                                                 &
128           ONLY:  atmos_ocean_sign, cos_alpha_surface, g, message_string,      &
129                  pt_surface, sin_alpha_surface, sloping_surface
130
131       USE indices,                                                            &
[1374]132           ONLY:  nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nzb,       &
133                  nzb_s_inner, nzt
[1320]134
135       USE kinds
136
[1]137       USE pegrid
138
[1320]139
[1]140       IMPLICIT NONE
141
[1682]142       INTEGER(iwp) ::  i              !<
143       INTEGER(iwp) ::  j              !<
144       INTEGER(iwp) ::  k              !<
145       INTEGER(iwp) ::  wind_component !<
[1320]146       
[1010]147#if defined( __nopointer )
[1682]148       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  var !<
[1010]149#else
[1320]150       REAL(wp), DIMENSION(:,:,:), POINTER ::  var
[1010]151#endif
[1]152
153
154       IF ( .NOT. sloping_surface )  THEN
155!
156!--       Normal case: horizontal surface
[1179]157          DO  i = nxl, nxr
158             DO  j = nys, nyn
159                DO  k = nzb_s_inner(j,i)+1, nzt-1
[1353]160                   tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5_wp * &
161                          (                                                    &
162                             ( var(k,j,i)   - ref_state(k) )   / ref_state(k) + &
163                             ( var(k+1,j,i) - ref_state(k+1) ) / ref_state(k+1) &
164                          )
[57]165                ENDDO
166             ENDDO
[1179]167          ENDDO
[1]168
169       ELSE
170!
171!--       Buoyancy term for a surface with a slope in x-direction. The equations
172!--       for both the u and w velocity-component contain proportionate terms.
173!--       Temperature field at time t=0 serves as environmental temperature.
174!--       Reference temperature (pt_surface) is the one at the lower left corner
175!--       of the total domain.
176          IF ( wind_component == 1 )  THEN
177
[106]178             DO  i = nxlu, nxr
[1]179                DO  j = nys, nyn
180                   DO  k = nzb_s_inner(j,i)+1, nzt-1
181                      tend(k,j,i) = tend(k,j,i) + g * sin_alpha_surface *      &
[1353]182                           0.5_wp * ( ( pt(k,j,i-1)         + pt(k,j,i)         ) &
183                                    - ( pt_slope_ref(k,i-1) + pt_slope_ref(k,i) ) &
184                                    ) / pt_surface
[1]185                   ENDDO
186                ENDDO
187             ENDDO
188
189          ELSEIF ( wind_component == 3 )  THEN
190
191             DO  i = nxl, nxr
192                DO  j = nys, nyn
193                   DO  k = nzb_s_inner(j,i)+1, nzt-1
194                      tend(k,j,i) = tend(k,j,i) + g * cos_alpha_surface *      &
[1353]195                           0.5_wp * ( ( pt(k,j,i)         + pt(k+1,j,i)         ) &
196                                    - ( pt_slope_ref(k,i) + pt_slope_ref(k+1,i) ) &
197                                    ) / pt_surface
[1]198                   ENDDO
199                ENDDO
200            ENDDO
201
202          ELSE
[247]203             
[1320]204             WRITE( message_string, * ) 'no term for component "',             &
[1]205                                       wind_component,'"'
[247]206             CALL message( 'buoyancy', 'PA0159', 1, 2, 0, 6, 0 )
[1]207
208          ENDIF
209
210       ENDIF
211
212    END SUBROUTINE buoyancy
213
214
215!------------------------------------------------------------------------------!
[1682]216! Description:
217! ------------
218!> Call for grid point i,j
219!> @attention PGI-compiler creates SIGFPE if opt>1 is used! Therefore, opt=1 is
220!>            forced by compiler-directive.
[1]221!------------------------------------------------------------------------------!
[515]222!pgi$r opt=1
[1179]223    SUBROUTINE buoyancy_ij( i, j, var, wind_component )
[1]224
[1320]225       USE arrays_3d,                                                          &
226           ONLY:  pt, pt_slope_ref, ref_state, tend
227
228       USE control_parameters,                                                 &
229           ONLY:  atmos_ocean_sign, cos_alpha_surface, g, message_string,      &
230                  pt_surface, sin_alpha_surface, sloping_surface
231
232       USE indices,                                                            &
[1374]233           ONLY:  nxlg, nxrg, nyng, nysg, nzb, nzb_s_inner, nzt
[1320]234
235       USE kinds
236
[1]237       USE pegrid
238
[1320]239
[1]240       IMPLICIT NONE
241
[1682]242       INTEGER(iwp) ::  i              !<
243       INTEGER(iwp) ::  j              !<
244       INTEGER(iwp) ::  k              !<
245       INTEGER(iwp) ::  pr             !<
246       INTEGER(iwp) ::  wind_component !<
[1320]247       
[1010]248#if defined( __nopointer )
[1682]249       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  var !<
[1010]250#else
[1320]251       REAL(wp), DIMENSION(:,:,:), POINTER ::  var
[1010]252#endif
[1]253
254
255       IF ( .NOT. sloping_surface )  THEN
256!
257!--       Normal case: horizontal surface
[1179]258          DO  k = nzb_s_inner(j,i)+1, nzt-1
[1353]259              tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5_wp * (    &
[1320]260                        ( var(k,j,i)   - ref_state(k)   ) / ref_state(k)   +   &
261                        ( var(k+1,j,i) - ref_state(k+1) ) / ref_state(k+1)     &
[1353]262                                                                          )
[1179]263          ENDDO
[1]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  k = nzb_s_inner(j,i)+1, nzt-1
275                tend(k,j,i) = tend(k,j,i) + g * sin_alpha_surface *            &
[1353]276                           0.5_wp * ( ( pt(k,j,i-1)         + pt(k,j,i)         ) &
277                                    - ( pt_slope_ref(k,i-1) + pt_slope_ref(k,i) ) &
278                                    ) / pt_surface
[1]279             ENDDO
280
281          ELSEIF ( wind_component == 3 )  THEN
282
283             DO  k = nzb_s_inner(j,i)+1, nzt-1
284                tend(k,j,i) = tend(k,j,i) + g * cos_alpha_surface *            &
[1353]285                           0.5_wp * ( ( pt(k,j,i)         + pt(k+1,j,i)         ) &
286                                    - ( pt_slope_ref(k,i) + pt_slope_ref(k+1,i) ) &
287                                    ) / pt_surface
[1]288             ENDDO
289
290          ELSE
291
[1320]292             WRITE( message_string, * ) 'no term for component "',             &
[1]293                                       wind_component,'"'
[247]294             CALL message( 'buoyancy', 'PA0159', 1, 2, 0, 6, 0 )
[1]295
296          ENDIF
297
298       ENDIF
299
300    END SUBROUTINE buoyancy_ij
301
302 END MODULE buoyancy_mod
Note: See TracBrowser for help on using the repository browser.