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

Last change on this file since 3634 was 3634, checked in by knoop, 4 years ago

OpenACC port for SPEC

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