[1] | 1 | MODULE buoyancy_mod |
---|
| 2 | |
---|
| 3 | !------------------------------------------------------------------------------! |
---|
| 4 | ! Actual revisions: |
---|
| 5 | ! ----------------- |
---|
[139] | 6 | ! |
---|
[98] | 7 | ! |
---|
| 8 | ! Former revisions: |
---|
| 9 | ! ----------------- |
---|
| 10 | ! $Id: buoyancy.f90 139 2007-11-29 09:37:41Z heinze $ |
---|
| 11 | ! |
---|
[139] | 12 | ! 132 2007-11-20 09:46:11Z letzel |
---|
| 13 | ! Vertical scalar profiles now based on nzb_s_inner and ngp_2dh_s_inner. |
---|
| 14 | ! |
---|
[110] | 15 | ! 106 2007-08-16 14:30:26Z raasch |
---|
| 16 | ! i loop for u-component (sloping surface) is starting from nxlu (needed for |
---|
| 17 | ! non-cyclic boundary conditions) |
---|
| 18 | ! |
---|
[98] | 19 | ! 97 2007-06-21 08:23:15Z raasch |
---|
[97] | 20 | ! Routine reneralized to be used with temperature AND density: |
---|
| 21 | ! argument theta renamed var, new argument var_reference, |
---|
| 22 | ! use_pt_reference renamed use_reference, |
---|
[96] | 23 | ! calc_mean_pt_profile renamed calc_mean_profile |
---|
[1] | 24 | ! |
---|
[77] | 25 | ! 57 2007-03-09 12:05:41Z raasch |
---|
| 26 | ! Reference temperature pt_reference can be used. |
---|
| 27 | ! |
---|
[3] | 28 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
| 29 | ! |
---|
[1] | 30 | ! Revision 1.19 2006/04/26 12:09:56 raasch |
---|
| 31 | ! OpenMP optimization (one dimension added to sums_l) |
---|
| 32 | ! |
---|
| 33 | ! Revision 1.1 1997/08/29 08:56:48 raasch |
---|
| 34 | ! Initial revision |
---|
| 35 | ! |
---|
| 36 | ! |
---|
| 37 | ! Description: |
---|
| 38 | ! ------------ |
---|
| 39 | ! Buoyancy term of the third component of the equation of motion. |
---|
| 40 | ! WARNING: humidity is not regarded when using a sloping surface! |
---|
| 41 | !------------------------------------------------------------------------------! |
---|
| 42 | |
---|
| 43 | PRIVATE |
---|
[96] | 44 | PUBLIC buoyancy, calc_mean_profile |
---|
[1] | 45 | |
---|
| 46 | INTERFACE buoyancy |
---|
| 47 | MODULE PROCEDURE buoyancy |
---|
| 48 | MODULE PROCEDURE buoyancy_ij |
---|
| 49 | END INTERFACE buoyancy |
---|
| 50 | |
---|
[96] | 51 | INTERFACE calc_mean_profile |
---|
| 52 | MODULE PROCEDURE calc_mean_profile |
---|
| 53 | END INTERFACE calc_mean_profile |
---|
[1] | 54 | |
---|
| 55 | CONTAINS |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | !------------------------------------------------------------------------------! |
---|
| 59 | ! Call for all grid points |
---|
| 60 | !------------------------------------------------------------------------------! |
---|
[97] | 61 | SUBROUTINE buoyancy( var, var_reference, wind_component, pr ) |
---|
[1] | 62 | |
---|
| 63 | USE arrays_3d |
---|
| 64 | USE control_parameters |
---|
| 65 | USE indices |
---|
| 66 | USE pegrid |
---|
| 67 | USE statistics |
---|
| 68 | |
---|
| 69 | IMPLICIT NONE |
---|
| 70 | |
---|
| 71 | INTEGER :: i, j, k, pr, wind_component |
---|
[97] | 72 | REAL :: var_reference |
---|
| 73 | REAL, DIMENSION(:,:,:), POINTER :: var |
---|
[1] | 74 | |
---|
| 75 | |
---|
| 76 | IF ( .NOT. sloping_surface ) THEN |
---|
| 77 | ! |
---|
| 78 | !-- Normal case: horizontal surface |
---|
[97] | 79 | IF ( use_reference ) THEN |
---|
[57] | 80 | DO i = nxl, nxr |
---|
| 81 | DO j = nys, nyn |
---|
| 82 | DO k = nzb_s_inner(j,i)+1, nzt-1 |
---|
[97] | 83 | tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5 * & |
---|
| 84 | ( & |
---|
| 85 | ( var(k,j,i) - hom(k,1,pr,0) ) / var_reference + & |
---|
| 86 | ( var(k+1,j,i) - hom(k+1,1,pr,0) ) / var_reference & |
---|
[57] | 87 | ) |
---|
| 88 | ENDDO |
---|
| 89 | ENDDO |
---|
| 90 | ENDDO |
---|
| 91 | ELSE |
---|
| 92 | DO i = nxl, nxr |
---|
| 93 | DO j = nys, nyn |
---|
| 94 | DO k = nzb_s_inner(j,i)+1, nzt-1 |
---|
[97] | 95 | tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5 * & |
---|
| 96 | ( & |
---|
| 97 | ( var(k,j,i) - hom(k,1,pr,0) ) / hom(k,1,pr,0) + & |
---|
| 98 | ( var(k+1,j,i) - hom(k+1,1,pr,0) ) / hom(k+1,1,pr,0) & |
---|
[57] | 99 | ) |
---|
| 100 | ENDDO |
---|
[1] | 101 | ENDDO |
---|
| 102 | ENDDO |
---|
[57] | 103 | ENDIF |
---|
[1] | 104 | |
---|
| 105 | ELSE |
---|
| 106 | ! |
---|
| 107 | !-- Buoyancy term for a surface with a slope in x-direction. The equations |
---|
| 108 | !-- for both the u and w velocity-component contain proportionate terms. |
---|
| 109 | !-- Temperature field at time t=0 serves as environmental temperature. |
---|
| 110 | !-- Reference temperature (pt_surface) is the one at the lower left corner |
---|
| 111 | !-- of the total domain. |
---|
| 112 | IF ( wind_component == 1 ) THEN |
---|
| 113 | |
---|
[106] | 114 | DO i = nxlu, nxr |
---|
[1] | 115 | DO j = nys, nyn |
---|
| 116 | DO k = nzb_s_inner(j,i)+1, nzt-1 |
---|
| 117 | tend(k,j,i) = tend(k,j,i) + g * sin_alpha_surface * & |
---|
| 118 | 0.5 * ( ( pt(k,j,i-1) + pt(k,j,i) ) & |
---|
| 119 | - ( pt_slope_ref(k,i-1) + pt_slope_ref(k,i) ) & |
---|
| 120 | ) / pt_surface |
---|
| 121 | ENDDO |
---|
| 122 | ENDDO |
---|
| 123 | ENDDO |
---|
| 124 | |
---|
| 125 | ELSEIF ( wind_component == 3 ) THEN |
---|
| 126 | |
---|
| 127 | DO i = nxl, nxr |
---|
| 128 | DO j = nys, nyn |
---|
| 129 | DO k = nzb_s_inner(j,i)+1, nzt-1 |
---|
| 130 | tend(k,j,i) = tend(k,j,i) + g * cos_alpha_surface * & |
---|
| 131 | 0.5 * ( ( pt(k,j,i) + pt(k+1,j,i) ) & |
---|
| 132 | - ( pt_slope_ref(k,i) + pt_slope_ref(k+1,i) ) & |
---|
| 133 | ) / pt_surface |
---|
| 134 | ENDDO |
---|
| 135 | ENDDO |
---|
| 136 | ENDDO |
---|
| 137 | |
---|
| 138 | ELSE |
---|
| 139 | |
---|
| 140 | IF ( myid == 0 ) PRINT*, '+++ buoyancy: no term for component "',& |
---|
| 141 | wind_component,'"' |
---|
| 142 | CALL local_stop |
---|
| 143 | |
---|
| 144 | ENDIF |
---|
| 145 | |
---|
| 146 | ENDIF |
---|
| 147 | |
---|
| 148 | END SUBROUTINE buoyancy |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | !------------------------------------------------------------------------------! |
---|
| 152 | ! Call for grid point i,j |
---|
| 153 | !------------------------------------------------------------------------------! |
---|
[97] | 154 | SUBROUTINE buoyancy_ij( i, j, var, var_reference, wind_component, pr ) |
---|
[1] | 155 | |
---|
| 156 | USE arrays_3d |
---|
| 157 | USE control_parameters |
---|
| 158 | USE indices |
---|
| 159 | USE pegrid |
---|
| 160 | USE statistics |
---|
| 161 | |
---|
| 162 | IMPLICIT NONE |
---|
| 163 | |
---|
| 164 | INTEGER :: i, j, k, pr, wind_component |
---|
[97] | 165 | REAL :: var_reference |
---|
| 166 | REAL, DIMENSION(:,:,:), POINTER :: var |
---|
[1] | 167 | |
---|
| 168 | |
---|
| 169 | IF ( .NOT. sloping_surface ) THEN |
---|
| 170 | ! |
---|
| 171 | !-- Normal case: horizontal surface |
---|
[97] | 172 | IF ( use_reference ) THEN |
---|
[57] | 173 | DO k = nzb_s_inner(j,i)+1, nzt-1 |
---|
[97] | 174 | tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5 * ( & |
---|
| 175 | ( var(k,j,i) - hom(k,1,pr,0) ) / var_reference + & |
---|
| 176 | ( var(k+1,j,i) - hom(k+1,1,pr,0) ) / var_reference & |
---|
| 177 | ) |
---|
[57] | 178 | ENDDO |
---|
| 179 | ELSE |
---|
| 180 | DO k = nzb_s_inner(j,i)+1, nzt-1 |
---|
[97] | 181 | tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5 * ( & |
---|
| 182 | ( var(k,j,i) - hom(k,1,pr,0) ) / hom(k,1,pr,0) + & |
---|
| 183 | ( var(k+1,j,i) - hom(k+1,1,pr,0) ) / hom(k+1,1,pr,0) & |
---|
| 184 | ) |
---|
[57] | 185 | ENDDO |
---|
| 186 | ENDIF |
---|
[1] | 187 | |
---|
| 188 | ELSE |
---|
| 189 | ! |
---|
| 190 | !-- Buoyancy term for a surface with a slope in x-direction. The equations |
---|
| 191 | !-- for both the u and w velocity-component contain proportionate terms. |
---|
| 192 | !-- Temperature field at time t=0 serves as environmental temperature. |
---|
| 193 | !-- Reference temperature (pt_surface) is the one at the lower left corner |
---|
| 194 | !-- of the total domain. |
---|
| 195 | IF ( wind_component == 1 ) THEN |
---|
| 196 | |
---|
| 197 | DO k = nzb_s_inner(j,i)+1, nzt-1 |
---|
| 198 | tend(k,j,i) = tend(k,j,i) + g * sin_alpha_surface * & |
---|
| 199 | 0.5 * ( ( pt(k,j,i-1) + pt(k,j,i) ) & |
---|
| 200 | - ( pt_slope_ref(k,i-1) + pt_slope_ref(k,i) ) & |
---|
| 201 | ) / pt_surface |
---|
| 202 | ENDDO |
---|
| 203 | |
---|
| 204 | ELSEIF ( wind_component == 3 ) THEN |
---|
| 205 | |
---|
| 206 | DO k = nzb_s_inner(j,i)+1, nzt-1 |
---|
| 207 | tend(k,j,i) = tend(k,j,i) + g * cos_alpha_surface * & |
---|
| 208 | 0.5 * ( ( pt(k,j,i) + pt(k+1,j,i) ) & |
---|
| 209 | - ( pt_slope_ref(k,i) + pt_slope_ref(k+1,i) ) & |
---|
| 210 | ) / pt_surface |
---|
| 211 | ENDDO |
---|
| 212 | |
---|
| 213 | ELSE |
---|
| 214 | |
---|
| 215 | IF ( myid == 0 ) PRINT*, '+++ buoyancy: no term for component "',& |
---|
| 216 | wind_component,'"' |
---|
| 217 | CALL local_stop |
---|
| 218 | |
---|
| 219 | ENDIF |
---|
| 220 | |
---|
| 221 | ENDIF |
---|
| 222 | |
---|
| 223 | END SUBROUTINE buoyancy_ij |
---|
| 224 | |
---|
| 225 | |
---|
[96] | 226 | SUBROUTINE calc_mean_profile( var, pr ) |
---|
[1] | 227 | |
---|
| 228 | !------------------------------------------------------------------------------! |
---|
| 229 | ! Description: |
---|
| 230 | ! ------------ |
---|
| 231 | ! Calculate the horizontally averaged vertical temperature profile (pr=4 in case |
---|
| 232 | ! of potential temperature and 44 in case of virtual potential temperature). |
---|
| 233 | !------------------------------------------------------------------------------! |
---|
| 234 | |
---|
| 235 | USE control_parameters |
---|
| 236 | USE indices |
---|
| 237 | USE pegrid |
---|
| 238 | USE statistics |
---|
| 239 | |
---|
| 240 | IMPLICIT NONE |
---|
| 241 | |
---|
| 242 | INTEGER :: i, j, k, omp_get_thread_num, pr, tn |
---|
[96] | 243 | REAL, DIMENSION(:,:,:), POINTER :: var |
---|
[1] | 244 | |
---|
| 245 | ! |
---|
[96] | 246 | !-- Computation of the horizontally averaged profile of variable var, unless |
---|
[1] | 247 | !-- already done by the relevant call from flow_statistics. The calculation |
---|
| 248 | !-- is done only for the first respective intermediate timestep in order to |
---|
| 249 | !-- spare communication time and to produce identical model results with jobs |
---|
| 250 | !-- which are calling flow_statistics at different time intervals. |
---|
| 251 | IF ( .NOT. flow_statistics_called .AND. & |
---|
| 252 | intermediate_timestep_count == 1 ) THEN |
---|
| 253 | |
---|
| 254 | ! |
---|
[96] | 255 | !-- Horizontal average of variable var |
---|
[1] | 256 | tn = 0 ! Default thread number in case of one thread |
---|
| 257 | !$OMP PARALLEL PRIVATE( i, j, k, tn ) |
---|
| 258 | !$ tn = omp_get_thread_num() |
---|
| 259 | sums_l(:,pr,tn) = 0.0 |
---|
| 260 | !$OMP DO |
---|
| 261 | DO i = nxl, nxr |
---|
| 262 | DO j = nys, nyn |
---|
[132] | 263 | DO k = nzb_s_inner(j,i), nzt+1 |
---|
[96] | 264 | sums_l(k,pr,tn) = sums_l(k,pr,tn) + var(k,j,i) |
---|
[1] | 265 | ENDDO |
---|
| 266 | ENDDO |
---|
| 267 | ENDDO |
---|
| 268 | !$OMP END PARALLEL |
---|
| 269 | |
---|
| 270 | DO i = 1, threads_per_task-1 |
---|
| 271 | sums_l(:,pr,0) = sums_l(:,pr,0) + sums_l(:,pr,i) |
---|
| 272 | ENDDO |
---|
| 273 | |
---|
| 274 | #if defined( __parallel ) |
---|
| 275 | |
---|
| 276 | CALL MPI_ALLREDUCE( sums_l(nzb,pr,0), sums(nzb,pr), nzt+2-nzb, & |
---|
| 277 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 278 | |
---|
| 279 | #else |
---|
| 280 | |
---|
| 281 | sums(:,pr) = sums_l(:,pr,0) |
---|
| 282 | |
---|
| 283 | #endif |
---|
| 284 | |
---|
[132] | 285 | hom(:,1,pr,0) = sums(:,pr) / ngp_2dh_s_inner(:,0) |
---|
[1] | 286 | |
---|
| 287 | ENDIF |
---|
| 288 | |
---|
[96] | 289 | END SUBROUTINE calc_mean_profile |
---|
[1] | 290 | |
---|
| 291 | END MODULE buoyancy_mod |
---|