Changeset 4583
- Timestamp:
- Jun 29, 2020 12:36:47 PM (4 years ago)
- Location:
- palm/trunk/SOURCE
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/data_output_tseries.f90
r4360 r4583 1 1 !> @file data_output_tseries.f90 2 !------------------------------------------------------------------------------ !2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. 4 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. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 9 8 ! 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 FOR12 ! A PARTICULAR PURPOSE. See the GNU GeneralPublic License for more details.9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 13 12 ! 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/>.13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 1997-2020 Leibniz Universitaet Hannover 18 !------------------------------------------------------------------------------ !17 !--------------------------------------------------------------------------------------------------! 19 18 ! 20 19 ! Current revisions: … … 25 24 ! ----------------- 26 25 ! $Id$ 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4360 2020-01-07 11:25:50Z suehring 27 29 ! Corrected "Former revisions" section 28 ! 30 ! 29 31 ! 3655 2019-01-07 16:51:22Z knoop 30 32 ! unused format removed … … 36 38 ! Description: 37 39 ! ------------ 38 !> Time series output for PROFIL. Always all time series are stored. A selection 39 !> can be applied viathe PROFIL-parameters in close_file.40 !------------------------------------------------------------------------------ !40 !> Time series output for PROFIL. Always all time series are stored. A selection can be applied via 41 !> the PROFIL-parameters in close_file. 42 !--------------------------------------------------------------------------------------------------! 41 43 SUBROUTINE data_output_tseries 42 43 44 44 USE control_parameters, & 45 46 USE control_parameters, & 45 47 ONLY: dots_time_count, time_since_reference_point 46 48 47 USE cpulog, &48 ONLY: cpu_log, log_point 49 USE cpulog, & 50 ONLY: cpu_log, log_point 49 51 50 52 USE kinds … … 53 55 USE NETCDF 54 56 #endif 55 USE netcdf_interface, & 56 ONLY: dots_num, id_set_ts, id_var_dots, id_var_time_ts, nc_stat, & 57 netcdf_handle_error 57 USE netcdf_interface, & 58 ONLY: dots_num, id_set_ts, id_var_dots, id_var_time_ts, nc_stat, netcdf_handle_error 58 59 59 60 USE pegrid 60 61 61 62 USE profil_parameter 62 63 USE statistics, &63 64 USE statistics, & 64 65 ONLY: flow_statistics_called, statistic_regions, ts_value 65 66 … … 84 85 !-- Open file for time series output in NetCDF format 85 86 CALL check_open( 105 ) 86 87 87 88 !-- Increment the counter for number of output times 88 ! CAUTION: The following line has to be after the call of the subroutine 89 ! check_open, since check_open resets the counter dots_time_count 90 ! to 0, if a new file is opened 89 !-- CAUTION: The following line has to be after the call of the subroutine check_open, since 90 !-- check_open resets the counter dots_time_count to 0, if a new file is opened 91 91 dots_time_count = dots_time_count + 1 92 92 93 93 #if defined( __netcdf ) 94 94 ! 95 95 !-- Update the time series time axis 96 nc_stat = NF90_PUT_VAR( id_set_ts, id_var_time_ts, &97 (/ time_since_reference_point /), &98 start = (/ dots_time_count /), &96 nc_stat = NF90_PUT_VAR( id_set_ts, id_var_time_ts, & 97 (/ time_since_reference_point /), & 98 start = (/ dots_time_count /), & 99 99 count = (/ 1 /) ) 100 100 CALL netcdf_handle_error( 'data_output_tseries', 350 ) … … 108 108 #if defined( __netcdf ) 109 109 DO i = 1, dots_num 110 nc_stat = NF90_PUT_VAR( id_set_ts, id_var_dots(i,sr), &111 (/ ts_value(i,sr) /), &112 start = (/ dots_time_count /), &110 nc_stat = NF90_PUT_VAR( id_set_ts, id_var_dots(i,sr), & 111 (/ ts_value(i,sr) /), & 112 start = (/ dots_time_count /), & 113 113 count = (/ 1 /) ) 114 114 CALL netcdf_handle_error( 'data_output_tseries', 351 ) -
palm/trunk/SOURCE/diagnostic_output_quantities_mod.f90
r4560 r4583 1 1 !> @file diagnostic_output_quantities_mod.f90 2 !------------------------------------------------------------------------------ !2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. 4 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/>. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 8 ! 9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 12 ! 13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 1997-2020 Leibniz Universitaet Hannover 18 !------------------------------------------------------------------------------ !17 !--------------------------------------------------------------------------------------------------! 19 18 ! 20 19 ! Current revisions: … … 25 24 ! ----------------- 26 25 ! $Id$ 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4560 2020-06-11 12:19:47Z suehring 27 29 ! - Bugfix in calculation of vertical momentum and scalar fluxes 28 30 ! - remove averaged output variables from PUBLIC list 29 ! 31 ! 30 32 ! 4535 2020-05-15 12:07:23Z raasch 31 33 ! bugfix for restart data format query 32 ! 34 ! 33 35 ! 4518 2020-05-04 15:44:28Z suehring 34 ! * Define arrays over ghost points in order to allow for standard mpi-io 35 ! treatment. By this modularization of restart-data input is possible with 36 ! the module interface. 36 ! * Define arrays over ghost points in order to allow for standard mpi-io treatment. By this 37 ! modularization of restart-data input is possible with the module interface. 37 38 ! * Bugfix: add missing restart input of wtheta_av, wq_av, wu_av, and wv_av. 38 ! 39 ! 39 40 ! 4517 2020-05-03 14:29:30Z raasch 40 41 ! use statement for exchange horiz added, 41 42 ! bugfix for call of exchange horiz 2d 42 ! 43 ! 43 44 ! 4431 2020-02-27 23:23:01Z gronemeier 44 45 ! added wspeed and wdir output; bugfix: set fill_value in case of masked output 45 46 ! 46 47 ! 4360 2020-01-07 11:25:50Z suehring 47 ! added output of wu, wv, wtheta and wq to enable covariance calculation 48 ! according to temporal ECmethod48 ! added output of wu, wv, wtheta and wq to enable covariance calculation according to temporal EC 49 ! method 49 50 ! 50 51 ! 4346 2019-12-18 11:55:56Z motisi 51 ! Introduction of wall_flags_total_0, which currently sets bits based on static 52 ! topographyinformation used in wall_flags_static_052 ! Introduction of wall_flags_total_0, which currently sets bits based on static topography 53 ! information used in wall_flags_static_0 53 54 ! 54 55 ! 4331 2019-12-10 18:25:02Z suehring … … 63 64 ! 64 65 ! 4167 2019-08-16 11:01:48Z suehring 65 ! Changed behaviour of masked output over surface to follow terrain and ignore 66 ! buildings(J.Resler, T.Gronemeier)66 ! Changed behaviour of masked output over surface to follow terrain and ignore buildings 67 ! (J.Resler, T.Gronemeier) 67 68 ! 68 69 ! 4157 2019-08-14 09:19:12Z suehring 69 ! Initialization restructured, in order to work also when data output during 70 ! spin-up is enabled. 70 ! Initialization restructured, in order to work also when data output during spin-up is enabled. 71 71 ! 72 72 ! 4132 2019-08-02 12:34:17Z suehring … … 74 74 ! 75 75 ! 4069 2019-07-01 14:05:51Z Giersch 76 ! Masked output running index mid has been introduced as a local variable to 77 ! avoid runtime error(Loop variable has been modified) in time_integration76 ! Masked output running index mid has been introduced as a local variable to avoid runtime error 77 ! (Loop variable has been modified) in time_integration 78 78 ! 79 79 ! 4039 2019-06-18 10:32:41Z suehring 80 ! - Add output of uu, vv, ww to enable variance calculation according temporal 81 ! EC method 80 ! - Add output of uu, vv, ww to enable variance calculation according temporal EC method 82 81 ! - Allocate arrays only when they are required 83 82 ! - Formatting adjustment … … 89 88 ! 90 89 ! 3995 2019-05-22 18:59:54Z suehring 91 ! Avoid compiler warnings about unused variable and fix string operation which 92 ! is not allowed withPGI compiler90 ! Avoid compiler warnings about unused variable and fix string operation which is not allowed with 91 ! PGI compiler 93 92 ! 94 93 ! 3994 2019-05-22 18:08:09Z suehring … … 103 102 ! ------------ 104 103 !> ... 105 !------------------------------------------------------------------------------ !104 !--------------------------------------------------------------------------------------------------! 106 105 MODULE diagnostic_output_quantities_mod 107 106 108 USE arrays_3d, &109 ONLY: ddzu, &110 pt, &111 q, &112 u, &113 v, &114 w, &115 zu, &107 USE arrays_3d, & 108 ONLY: ddzu, & 109 pt, & 110 q, & 111 u, & 112 v, & 113 w, & 114 zu, & 116 115 zw 117 116 118 USE basic_constants_and_equations_mod, &117 USE basic_constants_and_equations_mod, & 119 118 ONLY: kappa, pi 120 119 121 USE control_parameters, &122 ONLY: current_timestep_number, &123 data_output, &124 message_string, &125 restart_data_format_output, &120 USE control_parameters, & 121 ONLY: current_timestep_number, & 122 data_output, & 123 message_string, & 124 restart_data_format_output, & 126 125 varnamelength 127 126 ! 128 ! USE cpulog, &127 ! USE cpulog, & 129 128 ! ONLY: cpu_log, log_point 130 129 131 USE exchange_horiz_mod, &130 USE exchange_horiz_mod, & 132 131 ONLY: exchange_horiz_2d 133 132 134 USE grid_variables, &133 USE grid_variables, & 135 134 ONLY: ddx, ddy 136 135 137 USE indices, &138 ONLY: nbgp, &139 nxl, &140 nxlg, &141 nxr, &142 nxrg, &143 nyn, &144 nyng, &145 nys, &146 nysg, &147 nzb, &148 nzt, &136 USE indices, & 137 ONLY: nbgp, & 138 nxl, & 139 nxlg, & 140 nxr, & 141 nxrg, & 142 nyn, & 143 nyng, & 144 nys, & 145 nysg, & 146 nzb, & 147 nzt, & 149 148 wall_flags_total_0 150 149 … … 156 155 wrd_mpi_io 157 156 158 USE surface_mod, &159 ONLY: surf_def_h, &160 surf_lsm_h, &161 surf_type, &157 USE surface_mod, & 158 ONLY: surf_def_h, & 159 surf_lsm_h, & 160 surf_type, & 162 161 surf_usm_h 163 162 … … 209 208 ! 210 209 !-- Public variables 211 PUBLIC do_all, &212 initialized_diagnostic_output_quantities, &213 prepared_diagnostic_output_quantities, &210 PUBLIC do_all, & 211 initialized_diagnostic_output_quantities, & 212 prepared_diagnostic_output_quantities, & 214 213 timestep_number_at_prev_calc 215 214 ! 216 215 !-- Public routines 217 PUBLIC doq_3d_data_averaging, &218 doq_calculate, &219 doq_check_data_output, &220 doq_define_netcdf_grid, &221 doq_init, &222 doq_output_2d, &223 doq_output_3d, &224 doq_output_mask, &225 doq_rrd_local, &216 PUBLIC doq_3d_data_averaging, & 217 doq_calculate, & 218 doq_check_data_output, & 219 doq_define_netcdf_grid, & 220 doq_init, & 221 doq_output_2d, & 222 doq_output_3d, & 223 doq_output_mask, & 224 doq_rrd_local, & 226 225 doq_wrd_local 227 226 … … 275 274 CONTAINS 276 275 277 !------------------------------------------------------------------------------ !276 !--------------------------------------------------------------------------------------------------! 278 277 ! Description: 279 278 ! ------------ 280 !> Sum up and time-average diagnostic output quantities as well as allocate 281 !> the array necessary forstoring the average.282 !------------------------------------------------------------------------------ !279 !> Sum up and time-average diagnostic output quantities as well as allocate the array necessary for 280 !> storing the average. 281 !--------------------------------------------------------------------------------------------------! 283 282 SUBROUTINE doq_3d_data_averaging( mode, variable ) 284 283 285 USE control_parameters, &284 USE control_parameters, & 286 285 ONLY: average_count_3d 287 286 … … 293 292 INTEGER(iwp) :: k !< 294 293 294 295 295 IF ( mode == 'allocate' ) THEN 296 296 … … 383 383 384 384 CASE ( 'ti' ) 385 IF ( ALLOCATED( ti_av ) ) THEN385 IF ( ALLOCATED( ti_av ) ) THEN 386 386 DO i = nxl, nxr 387 387 DO j = nys, nyn … … 394 394 395 395 CASE ( 'uu' ) 396 IF ( ALLOCATED( uu_av ) ) THEN396 IF ( ALLOCATED( uu_av ) ) THEN 397 397 DO i = nxl, nxr 398 398 DO j = nys, nyn … … 405 405 406 406 CASE ( 'vv' ) 407 IF ( ALLOCATED( vv_av ) ) THEN407 IF ( ALLOCATED( vv_av ) ) THEN 408 408 DO i = nxl, nxr 409 409 DO j = nys, nyn … … 416 416 417 417 CASE ( 'ww' ) 418 IF ( ALLOCATED( ww_av ) ) THEN418 IF ( ALLOCATED( ww_av ) ) THEN 419 419 DO i = nxl, nxr 420 420 DO j = nys, nyn … … 427 427 428 428 CASE ( 'wu' ) 429 IF ( ALLOCATED( wu_av ) ) THEN429 IF ( ALLOCATED( wu_av ) ) THEN 430 430 DO i = nxl, nxr 431 431 DO j = nys, nyn … … 438 438 439 439 CASE ( 'wv' ) 440 IF ( ALLOCATED( wv_av ) ) THEN440 IF ( ALLOCATED( wv_av ) ) THEN 441 441 DO i = nxl, nxr 442 442 DO j = nys, nyn … … 449 449 450 450 CASE ( 'wtheta' ) 451 IF ( ALLOCATED( wtheta_av ) ) THEN451 IF ( ALLOCATED( wtheta_av ) ) THEN 452 452 DO i = nxl, nxr 453 453 DO j = nys, nyn … … 460 460 461 461 CASE ( 'wq' ) 462 IF ( ALLOCATED( wq_av ) ) THEN462 IF ( ALLOCATED( wq_av ) ) THEN 463 463 DO i = nxl, nxr 464 464 DO j = nys, nyn … … 471 471 472 472 CASE ( 'theta_2m*' ) 473 IF ( ALLOCATED( pt_2m_av ) ) THEN473 IF ( ALLOCATED( pt_2m_av ) ) THEN 474 474 DO i = nxl, nxr 475 475 DO j = nys, nyn … … 480 480 481 481 CASE ( 'wspeed_10m*' ) 482 IF ( ALLOCATED( uv_10m_av ) ) THEN482 IF ( ALLOCATED( uv_10m_av ) ) THEN 483 483 DO i = nxl, nxr 484 484 DO j = nys, nyn … … 489 489 490 490 CASE ( 'wspeed' ) 491 IF ( ALLOCATED( wspeed_av ) ) THEN491 IF ( ALLOCATED( wspeed_av ) ) THEN 492 492 DO i = nxl, nxr 493 493 DO j = nys, nyn … … 500 500 501 501 CASE ( 'wdir' ) 502 IF ( ALLOCATED( u_center_av ) .AND. ALLOCATED( v_center_av ) ) THEN502 IF ( ALLOCATED( u_center_av ) .AND. ALLOCATED( v_center_av ) ) THEN 503 503 DO i = nxl, nxr 504 504 DO j = nys, nyn … … 521 521 522 522 CASE ( 'ti' ) 523 IF ( ALLOCATED( ti_av ) ) THEN523 IF ( ALLOCATED( ti_av ) ) THEN 524 524 DO i = nxl, nxr 525 525 DO j = nys, nyn … … 532 532 533 533 CASE ( 'uu' ) 534 IF ( ALLOCATED( uu_av ) ) THEN534 IF ( ALLOCATED( uu_av ) ) THEN 535 535 DO i = nxl, nxr 536 536 DO j = nys, nyn … … 543 543 544 544 CASE ( 'vv' ) 545 IF ( ALLOCATED( vv_av ) ) THEN545 IF ( ALLOCATED( vv_av ) ) THEN 546 546 DO i = nxl, nxr 547 547 DO j = nys, nyn … … 554 554 555 555 CASE ( 'ww' ) 556 IF ( ALLOCATED( ww_av ) ) THEN556 IF ( ALLOCATED( ww_av ) ) THEN 557 557 DO i = nxl, nxr 558 558 DO j = nys, nyn … … 565 565 566 566 CASE ( 'wu' ) 567 IF ( ALLOCATED( wu_av ) ) THEN567 IF ( ALLOCATED( wu_av ) ) THEN 568 568 DO i = nxl, nxr 569 569 DO j = nys, nyn … … 576 576 577 577 CASE ( 'wv' ) 578 IF ( ALLOCATED( wv_av ) ) THEN578 IF ( ALLOCATED( wv_av ) ) THEN 579 579 DO i = nxl, nxr 580 580 DO j = nys, nyn … … 587 587 588 588 CASE ( 'wtheta' ) 589 IF ( ALLOCATED( wtheta_av ) ) THEN589 IF ( ALLOCATED( wtheta_av ) ) THEN 590 590 DO i = nxl, nxr 591 591 DO j = nys, nyn … … 598 598 599 599 CASE ( 'wq' ) 600 IF ( ALLOCATED( wq_av ) ) THEN600 IF ( ALLOCATED( wq_av ) ) THEN 601 601 DO i = nxl, nxr 602 602 DO j = nys, nyn … … 609 609 610 610 CASE ( 'theta_2m*' ) 611 IF ( ALLOCATED( pt_2m_av ) ) THEN611 IF ( ALLOCATED( pt_2m_av ) ) THEN 612 612 DO i = nxlg, nxrg 613 613 DO j = nysg, nyng … … 619 619 620 620 CASE ( 'wspeed_10m*' ) 621 IF ( ALLOCATED( uv_10m_av ) ) THEN621 IF ( ALLOCATED( uv_10m_av ) ) THEN 622 622 DO i = nxlg, nxrg 623 623 DO j = nysg, nyng … … 629 629 630 630 CASE ( 'wspeed' ) 631 IF ( ALLOCATED( wspeed_av ) ) THEN631 IF ( ALLOCATED( wspeed_av ) ) THEN 632 632 DO i = nxl, nxr 633 633 DO j = nys, nyn … … 640 640 641 641 CASE ( 'wdir' ) 642 IF ( ALLOCATED( u_center_av ) .AND. ALLOCATED( v_center_av ) ) THEN642 IF ( ALLOCATED( u_center_av ) .AND. ALLOCATED( v_center_av ) ) THEN 643 643 644 644 IF ( .NOT. ALLOCATED( wdir_av ) ) THEN … … 652 652 u_center_av(k,j,i) = u_center_av(k,j,i) / REAL( average_count_3d, KIND=wp ) 653 653 v_center_av(k,j,i) = v_center_av(k,j,i) / REAL( average_count_3d, KIND=wp ) 654 wdir_av(k,j,i) = ATAN2( u_center_av(k,j,i), v_center_av(k,j,i) ) &655 / pi * 180.0_wp + 180.0_wp654 wdir_av(k,j,i) = ATAN2( u_center_av(k,j,i), v_center_av(k,j,i) ) & 655 / pi * 180.0_wp + 180.0_wp 656 656 ENDDO 657 657 ENDDO … … 666 666 END SUBROUTINE doq_3d_data_averaging 667 667 668 !------------------------------------------------------------------------------ !668 !--------------------------------------------------------------------------------------------------! 669 669 ! Description: 670 670 ! ------------ 671 671 !> Check data output for diagnostic output 672 !------------------------------------------------------------------------------ !672 !--------------------------------------------------------------------------------------------------! 673 673 SUBROUTINE doq_check_data_output( var, unit, i, ilen, k ) 674 674 … … 682 682 INTEGER(iwp), OPTIONAL, INTENT(IN) :: k !< Output is xy mode? 0 = no, 1 = yes 683 683 684 684 685 SELECT CASE ( TRIM( var ) ) 685 686 … … 719 720 !-- Check if output quantity is _xy only. 720 721 IF ( k == 0 .OR. data_output(i)(ilen-2:ilen) /= '_xy' ) THEN 721 message_string = 'illegal value for data_output: "' // &722 TRIM( var ) // '" & only 2d-horizontal ' // &722 message_string = 'illegal value for data_output: "' // & 723 TRIM( var ) // '" & only 2d-horizontal ' // & 723 724 'cross sections are allowed for this value' 724 725 CALL message( 'diagnostic_output', 'PA0111', 1, 2, 0, 6, 0 ) … … 736 737 END SUBROUTINE doq_check_data_output 737 738 738 !------------------------------------------------------------------------------ !739 !--------------------------------------------------------------------------------------------------! 739 740 ! 740 741 ! Description: 741 742 ! ------------ 742 743 !> Subroutine defining appropriate grid for netcdf variables. 743 !------------------------------------------------------------------------------ !744 !--------------------------------------------------------------------------------------------------! 744 745 SUBROUTINE doq_define_netcdf_grid( variable, found, grid_x, grid_y, grid_z ) 745 746 … … 747 748 748 749 CHARACTER (LEN=*), INTENT(IN) :: variable !< 749 LOGICAL, INTENT(OUT) :: found !<750 750 CHARACTER (LEN=*), INTENT(OUT) :: grid_x !< 751 751 CHARACTER (LEN=*), INTENT(OUT) :: grid_y !< 752 752 CHARACTER (LEN=*), INTENT(OUT) :: grid_z !< 753 753 754 LOGICAL, INTENT(OUT) :: found !< 755 756 754 757 found = .TRUE. 755 758 … … 757 760 ! 758 761 !-- s grid 759 CASE ( 'ti', 'ti_xy', 'ti_xz', 'ti_yz', &760 'wspeed', 'wspeed_xy', 'wspeed_xz', 'wspeed_yz', &762 CASE ( 'ti', 'ti_xy', 'ti_xz', 'ti_yz', & 763 'wspeed', 'wspeed_xy', 'wspeed_xz', 'wspeed_yz', & 761 764 'wdir', 'wdir_xy', 'wdir_xz', 'wdir_yz' ) 762 765 … … 787 790 ! 788 791 !-- w grid 789 CASE ( 'ww', 'ww_xy', 'ww_xz', 'ww_yz', &790 'wu', 'wu_xy', 'wu_xz', 'wu_yz', &791 'wv', 'wv_xy', 'wv_xz', 'wv_yz', &792 'wtheta', 'wtheta_xy', 'wtheta_xz', 'wtheta_yz', &793 'wq', 'wq_xy', 'wq_xz', 'wq_yz' 792 CASE ( 'ww', 'ww_xy', 'ww_xz', 'ww_yz', & 793 'wu', 'wu_xy', 'wu_xz', 'wu_yz', & 794 'wv', 'wv_xy', 'wv_xz', 'wv_yz', & 795 'wtheta', 'wtheta_xy', 'wtheta_xz', 'wtheta_yz', & 796 'wq', 'wq_xy', 'wq_xz', 'wq_yz' ) 794 797 795 798 grid_x = 'x' … … 808 811 END SUBROUTINE doq_define_netcdf_grid 809 812 810 !------------------------------------------------------------------------------ !813 !--------------------------------------------------------------------------------------------------! 811 814 ! 812 815 ! Description: 813 816 ! ------------ 814 817 !> Subroutine defining 2D output variables 815 !------------------------------------------------------------------------------ !816 SUBROUTINE doq_output_2d( av, variable, found, grid, 817 mode, local_pf, two_d, nzb_do, nzt_do,fill_value )818 !--------------------------------------------------------------------------------------------------! 819 SUBROUTINE doq_output_2d( av, variable, found, grid, mode, local_pf, two_d, nzb_do, nzt_do, & 820 fill_value ) 818 821 819 822 … … 841 844 REAL(wp), DIMENSION(:,:,:), POINTER :: to_be_resorted !< points to array which needs to be resorted for output 842 845 846 843 847 flag_nr = 0 844 848 found = .TRUE. … … 852 856 to_be_resorted => ti 853 857 ELSE 854 IF ( .NOT. ALLOCATED( ti_av ) ) THEN858 IF ( .NOT. ALLOCATED( ti_av ) ) THEN 855 859 ALLOCATE( ti_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 856 860 ti_av = REAL( fill_value, KIND = wp ) … … 866 870 to_be_resorted => uu 867 871 ELSE 868 IF ( .NOT. ALLOCATED( uu_av ) ) THEN872 IF ( .NOT. ALLOCATED( uu_av ) ) THEN 869 873 ALLOCATE( uu_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 870 874 uu_av = REAL( fill_value, KIND = wp ) … … 880 884 to_be_resorted => vv 881 885 ELSE 882 IF ( .NOT. ALLOCATED( vv_av ) ) THEN886 IF ( .NOT. ALLOCATED( vv_av ) ) THEN 883 887 ALLOCATE( vv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 884 888 vv_av = REAL( fill_value, KIND = wp ) … … 894 898 to_be_resorted => ww 895 899 ELSE 896 IF ( .NOT. ALLOCATED( ww_av ) ) THEN900 IF ( .NOT. ALLOCATED( ww_av ) ) THEN 897 901 ALLOCATE( ww_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 898 902 ww_av = REAL( fill_value, KIND = wp ) … … 908 912 to_be_resorted => wu 909 913 ELSE 910 IF ( .NOT. ALLOCATED( wu_av ) ) THEN914 IF ( .NOT. ALLOCATED( wu_av ) ) THEN 911 915 ALLOCATE( wu_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 912 916 wu_av = REAL( fill_value, KIND = wp ) … … 922 926 to_be_resorted => wv 923 927 ELSE 924 IF ( .NOT. ALLOCATED( wv_av ) ) THEN928 IF ( .NOT. ALLOCATED( wv_av ) ) THEN 925 929 ALLOCATE( wv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 926 930 wv_av = REAL( fill_value, KIND = wp ) … … 936 940 to_be_resorted => wtheta 937 941 ELSE 938 IF ( .NOT. ALLOCATED( wtheta_av ) ) THEN942 IF ( .NOT. ALLOCATED( wtheta_av ) ) THEN 939 943 ALLOCATE( wtheta_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 940 944 wtheta_av = REAL( fill_value, KIND = wp ) … … 950 954 to_be_resorted => wq 951 955 ELSE 952 IF ( .NOT. ALLOCATED( wq_av ) ) THEN956 IF ( .NOT. ALLOCATED( wq_av ) ) THEN 953 957 ALLOCATE( wq_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 954 958 wq_av = REAL( fill_value, KIND = wp ) … … 968 972 ENDDO 969 973 ELSE 970 IF ( .NOT. ALLOCATED( pt_2m_av ) ) THEN974 IF ( .NOT. ALLOCATED( pt_2m_av ) ) THEN 971 975 ALLOCATE( pt_2m_av(nysg:nyng,nxlg:nxrg) ) 972 976 pt_2m_av = REAL( fill_value, KIND = wp ) … … 990 994 ENDDO 991 995 ELSE 992 IF ( .NOT. ALLOCATED( uv_10m_av ) ) THEN996 IF ( .NOT. ALLOCATED( uv_10m_av ) ) THEN 993 997 ALLOCATE( uv_10m_av(nysg:nyng,nxlg:nxrg) ) 994 998 uv_10m_av = REAL( fill_value, KIND = wp ) … … 1008 1012 to_be_resorted => wspeed 1009 1013 ELSE 1010 IF ( .NOT. ALLOCATED( wspeed_av ) ) THEN1014 IF ( .NOT. ALLOCATED( wspeed_av ) ) THEN 1011 1015 ALLOCATE( wspeed_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1012 1016 wspeed_av = REAL( fill_value, KIND = wp ) … … 1022 1026 to_be_resorted => wdir 1023 1027 ELSE 1024 IF ( .NOT. ALLOCATED( wdir_av ) ) THEN1028 IF ( .NOT. ALLOCATED( wdir_av ) ) THEN 1025 1029 ALLOCATE( wdir_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1026 1030 wdir_av = REAL( fill_value, KIND = wp ) … … 1042 1046 DO j = nys, nyn 1043 1047 DO k = nzb_do, nzt_do 1044 local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), &1045 REAL( fill_value, KIND = wp ),&1046 BTEST( wall_flags_total_0(k,j,i), flag_nr ) )1048 local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), & 1049 REAL( fill_value, KIND = wp ), & 1050 BTEST( wall_flags_total_0(k,j,i), flag_nr ) ) 1047 1051 ENDDO 1048 1052 ENDDO … … 1053 1057 1054 1058 1055 !------------------------------------------------------------------------------ !1059 !--------------------------------------------------------------------------------------------------! 1056 1060 ! 1057 1061 ! Description: 1058 1062 ! ------------ 1059 1063 !> Subroutine defining 3D output variables 1060 !------------------------------------------------------------------------------! 1061 SUBROUTINE doq_output_3d( av, variable, found, local_pf, fill_value, nzb_do, & 1062 nzt_do ) 1064 !--------------------------------------------------------------------------------------------------! 1065 SUBROUTINE doq_output_3d( av, variable, found, local_pf, fill_value, nzb_do, nzt_do ) 1063 1066 1064 1067 IMPLICIT NONE … … 1082 1085 REAL(wp), DIMENSION(:,:,:), POINTER :: to_be_resorted !< points to array which needs to be resorted for output 1083 1086 1087 1084 1088 flag_nr = 0 1085 1089 found = .TRUE. … … 1092 1096 to_be_resorted => ti 1093 1097 ELSE 1094 IF ( .NOT. ALLOCATED( ti_av ) ) THEN1098 IF ( .NOT. ALLOCATED( ti_av ) ) THEN 1095 1099 ALLOCATE( ti_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1096 1100 ti_av = REAL( fill_value, KIND = wp ) … … 1104 1108 to_be_resorted => uu 1105 1109 ELSE 1106 IF ( .NOT. ALLOCATED( uu_av ) ) THEN1110 IF ( .NOT. ALLOCATED( uu_av ) ) THEN 1107 1111 ALLOCATE( uu_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1108 1112 uu_av = REAL( fill_value, KIND = wp ) … … 1116 1120 to_be_resorted => vv 1117 1121 ELSE 1118 IF ( .NOT. ALLOCATED( vv_av ) ) THEN1122 IF ( .NOT. ALLOCATED( vv_av ) ) THEN 1119 1123 ALLOCATE( vv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1120 1124 vv_av = REAL( fill_value, KIND = wp ) … … 1128 1132 to_be_resorted => ww 1129 1133 ELSE 1130 IF ( .NOT. ALLOCATED( ww_av ) ) THEN1134 IF ( .NOT. ALLOCATED( ww_av ) ) THEN 1131 1135 ALLOCATE( ww_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1132 1136 ww_av = REAL( fill_value, KIND = wp ) … … 1140 1144 to_be_resorted => wu 1141 1145 ELSE 1142 IF ( .NOT. ALLOCATED( wu_av ) ) THEN1146 IF ( .NOT. ALLOCATED( wu_av ) ) THEN 1143 1147 ALLOCATE( wu_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1144 1148 wu_av = REAL( fill_value, KIND = wp ) … … 1152 1156 to_be_resorted => wv 1153 1157 ELSE 1154 IF ( .NOT. ALLOCATED( wv_av ) ) THEN1158 IF ( .NOT. ALLOCATED( wv_av ) ) THEN 1155 1159 ALLOCATE( wv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1156 1160 wv_av = REAL( fill_value, KIND = wp ) … … 1164 1168 to_be_resorted => wtheta 1165 1169 ELSE 1166 IF ( .NOT. ALLOCATED( wtheta_av ) ) THEN1170 IF ( .NOT. ALLOCATED( wtheta_av ) ) THEN 1167 1171 ALLOCATE( wtheta_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1168 1172 wtheta_av = REAL( fill_value, KIND = wp ) … … 1176 1180 to_be_resorted => wq 1177 1181 ELSE 1178 IF ( .NOT. ALLOCATED( wq_av ) ) THEN1182 IF ( .NOT. ALLOCATED( wq_av ) ) THEN 1179 1183 ALLOCATE( wq_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1180 1184 wq_av = REAL( fill_value, KIND = wp ) … … 1188 1192 to_be_resorted => wspeed 1189 1193 ELSE 1190 IF ( .NOT. ALLOCATED( wspeed_av ) ) THEN1194 IF ( .NOT. ALLOCATED( wspeed_av ) ) THEN 1191 1195 ALLOCATE( wspeed_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1192 1196 wspeed_av = REAL( fill_value, KIND = wp ) … … 1200 1204 to_be_resorted => wdir 1201 1205 ELSE 1202 IF ( .NOT. ALLOCATED( wdir_av ) ) THEN1206 IF ( .NOT. ALLOCATED( wdir_av ) ) THEN 1203 1207 ALLOCATE( wdir_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1204 1208 wdir_av = REAL( fill_value, KIND = wp ) … … 1217 1221 DO j = nys, nyn 1218 1222 DO k = nzb_do, nzt_do 1219 local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), &1220 REAL( fill_value, KIND = wp ),&1221 BTEST( wall_flags_total_0(k,j,i), flag_nr ) )1223 local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), & 1224 REAL( fill_value, KIND = wp ), & 1225 BTEST( wall_flags_total_0(k,j,i), flag_nr ) ) 1222 1226 ENDDO 1223 1227 ENDDO … … 1227 1231 END SUBROUTINE doq_output_3d 1228 1232 1233 1234 !--------------------------------------------------------------------------------------------------! 1235 ! 1229 1236 ! Description: 1230 1237 ! ------------ 1231 !> Resorts the user-defined output quantity with indices (k,j,i) to a 1232 !> temporary array with indices(i,j,k) for masked data output.1233 !------------------------------------------------------------------------------ !1238 !> Resorts the user-defined output quantity with indices (k,j,i) to a temporary array with indices 1239 !> (i,j,k) for masked data output. 1240 !--------------------------------------------------------------------------------------------------! 1234 1241 SUBROUTINE doq_output_mask( av, variable, found, local_pf, mid ) 1235 1242 … … 1239 1246 1240 1247 IMPLICIT NONE 1248 1249 REAL(wp), PARAMETER :: fill_value = -9999.0_wp !< value for the _FillValue attribute 1241 1250 1242 1251 CHARACTER (LEN=*) :: variable !< … … 1257 1266 LOGICAL :: resorted !< true if array is resorted 1258 1267 1259 REAL(wp), & 1260 DIMENSION(mask_size_l(mid,1),mask_size_l(mid,2),mask_size_l(mid,3)) :: & 1261 local_pf !< 1262 REAL(wp), DIMENSION(:,:,:), POINTER :: to_be_resorted !< points to array which needs to be resorted for output 1263 1264 REAL(wp), PARAMETER :: fill_value = -9999.0_wp !< value for the _FillValue attribute 1268 REAL(wp), DIMENSION(mask_size_l(mid,1),mask_size_l(mid,2),mask_size_l(mid,3)) :: local_pf !< 1269 1270 REAL(wp), DIMENSION(:,:,:), POINTER :: to_be_resorted !< points to array which needs to be resorted for output 1271 1265 1272 1266 1273 flag_nr = 0 … … 1373 1380 DO j = 1, mask_size_l(mid,2) 1374 1381 DO k = 1, mask_size_l(mid,3) 1375 local_pf(i,j,k) = MERGE( to_be_resorted(mask_k(mid,k), & 1376 mask_j(mid,j), & 1377 mask_i(mid,i)), & 1378 REAL( fill_value, KIND = wp ), & 1379 BTEST( wall_flags_total_0( & 1380 mask_k(mid,k), & 1381 mask_j(mid,j), & 1382 mask_i(mid,i)), & 1382 local_pf(i,j,k) = MERGE( to_be_resorted(mask_k(mid,k), & 1383 mask_j(mid,j), & 1384 mask_i(mid,i)), & 1385 REAL( fill_value, KIND = wp ), & 1386 BTEST( wall_flags_total_0(mask_k(mid,k), & 1387 mask_j(mid,j), & 1388 mask_i(mid,i)), & 1383 1389 flag_nr ) ) 1384 1390 ENDDO … … 1395 1401 im = mask_i(mid,i) 1396 1402 jm = mask_j(mid,j) 1397 ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), & 1398 DIM = 1 ) - 1 1403 ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 ) ), DIM=1 ) - 1 1399 1404 DO k = 1, mask_size_l(mid,3) 1400 1405 kk = MIN( ktt+mask_k(mid,k), nzt+1 ) … … 1415 1420 END SUBROUTINE doq_output_mask 1416 1421 1417 !------------------------------------------------------------------------------ !1422 !--------------------------------------------------------------------------------------------------! 1418 1423 ! Description: 1419 1424 ! ------------ 1420 1425 !> Allocate required arrays 1421 !------------------------------------------------------------------------------ !1426 !--------------------------------------------------------------------------------------------------! 1422 1427 SUBROUTINE doq_init 1423 1428 … … 1425 1430 1426 1431 INTEGER(iwp) :: ivar !< loop index over all 2d/3d/mask output quantities 1432 1427 1433 1428 1434 ! … … 1564 1570 1565 1571 ! 1566 !-- Save timestep number to check in time_integration if doq_calculate 1567 !-- has been called already, since the CALL occurs at two locations, but the calculations need to be1568 !-- done only once pertimestep.1572 !-- Save timestep number to check in time_integration if doq_calculate has been called already, 1573 !-- since the CALL occurs at two locations, but the calculations need to be done only once per 1574 !-- timestep. 1569 1575 timestep_number_at_prev_calc = current_timestep_number 1570 1576 … … 1580 1586 DO j = nys, nyn 1581 1587 DO k = nzb+1, nzt 1582 ti(k,j,i) = 0.25_wp * SQRT( &1583 ( ( w(k,j+1,i) + w(k-1,j+1,i)&1584 - w(k,j-1,i) - w(k-1,j-1,i) ) * ddy&1585 - ( v(k+1,j,i) + v(k+1,j+1,i)&1586 - v(k-1,j,i) - v(k-1,j+1,i) ) * ddzu(k) )**2&1587 + ( ( u(k+1,j,i) + u(k+1,j,i+1)&1588 - u(k-1,j,i) - u(k-1,j,i+1) ) * ddzu(k)&1589 - ( w(k,j,i+1) + w(k-1,j,i+1)&1590 - w(k,j,i-1) - w(k-1,j,i-1) ) * ddx )**2&1591 + ( ( v(k,j,i+1) + v(k,j+1,i+1)&1592 - v(k,j,i-1) - v(k,j+1,i-1) ) * ddx&1593 - ( u(k,j+1,i) + u(k,j+1,i+1)&1594 - u(k,j-1,i) - u(k,j-1,i+1) ) * ddy )**2 )&1595 * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0) )1588 ti(k,j,i) = 0.25_wp * SQRT( & 1589 ( ( w(k,j+1,i) + w(k-1,j+1,i) & 1590 - w(k,j-1,i) - w(k-1,j-1,i) ) * ddy & 1591 - ( v(k+1,j,i) + v(k+1,j+1,i) & 1592 - v(k-1,j,i) - v(k-1,j+1,i) ) * ddzu(k) )**2 & 1593 + ( ( u(k+1,j,i) + u(k+1,j,i+1) & 1594 - u(k-1,j,i) - u(k-1,j,i+1) ) * ddzu(k) & 1595 - ( w(k,j,i+1) + w(k-1,j,i+1) & 1596 - w(k,j,i-1) - w(k-1,j,i-1) ) * ddx )**2 & 1597 + ( ( v(k,j,i+1) + v(k,j+1,i+1) & 1598 - v(k,j,i-1) - v(k,j+1,i-1) ) * ddx & 1599 - ( u(k,j+1,i) + u(k,j+1,i+1) & 1600 - u(k,j-1,i) - u(k,j-1,i+1) ) * ddy )**2 ) & 1601 * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 1596 1602 ENDDO 1597 1603 ENDDO … … 1603 1609 DO j = nys, nyn 1604 1610 DO k = nzb+1, nzt 1605 uu(k,j,i) = u(k,j,i) * u(k,j,i) & 1606 * MERGE( 1.0_wp, 0.0_wp, & 1607 BTEST( wall_flags_total_0(k,j,i), 1) ) 1611 uu(k,j,i) = u(k,j,i) * u(k,j,i) & 1612 * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) ) 1608 1613 ENDDO 1609 1614 ENDDO … … 1615 1620 DO j = nys, nyn 1616 1621 DO k = nzb+1, nzt 1617 vv(k,j,i) = v(k,j,i) * v(k,j,i) & 1618 * MERGE( 1.0_wp, 0.0_wp, & 1619 BTEST( wall_flags_total_0(k,j,i), 2) ) 1622 vv(k,j,i) = v(k,j,i) * v(k,j,i) & 1623 * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) ) 1620 1624 ENDDO 1621 1625 ENDDO … … 1627 1631 DO j = nys, nyn 1628 1632 DO k = nzb+1, nzt-1 1629 ww(k,j,i) = w(k,j,i) * w(k,j,i) & 1630 * MERGE( 1.0_wp, 0.0_wp, & 1631 BTEST( wall_flags_total_0(k,j,i), 3) ) 1633 ww(k,j,i) = w(k,j,i) * w(k,j,i) & 1634 * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) ) 1632 1635 ENDDO 1633 1636 ENDDO … … 1639 1642 DO j = nys, nyn 1640 1643 DO k = nzb+1, nzt-1 1641 wu(k,j,i) = w(k,j,i) & 1642 * 0.25_wp * ( u(k,j,i) + u(k,j,i+1) & 1643 + u(k+1,j,i) + u(k+1,j,i+1) ) & 1644 * MERGE( 1.0_wp, 0.0_wp, & 1645 BTEST( wall_flags_total_0(k,j,i), 0) ) 1644 wu(k,j,i) = w(k,j,i) & 1645 * 0.25_wp * ( u(k,j,i) + u(k,j,i+1) + u(k+1,j,i) + u(k+1,j,i+1) )& 1646 * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 1646 1647 ENDDO 1647 1648 ENDDO … … 1653 1654 DO j = nys, nyn 1654 1655 DO k = nzb+1, nzt-1 1655 wv(k,j,i) = w(k,j,i) & 1656 * 0.25_wp * ( v(k,j,i) + v(k,j+1,i) & 1657 + v(k+1,j,i) + v(k+1,j+1,i) ) & 1658 * MERGE( 1.0_wp, 0.0_wp, & 1659 BTEST( wall_flags_total_0(k,j,i), 0) ) 1656 wv(k,j,i) = w(k,j,i) & 1657 * 0.25_wp * ( v(k,j,i) + v(k,j+1,i) + v(k+1,j,i) + v(k+1,j+1,i) )& 1658 * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 1660 1659 ENDDO 1661 1660 ENDDO … … 1667 1666 DO j = nys, nyn 1668 1667 DO k = nzb+1, nzt-1 1669 wtheta(k,j,i) = w(k,j,i) & 1670 * 0.5_wp * ( pt(k,j,i) + pt(k+1,j,i) ) & 1671 * MERGE( 1.0_wp, 0.0_wp, & 1672 BTEST( wall_flags_total_0(k,j,i), 3) ) 1668 wtheta(k,j,i) = w(k,j,i) & 1669 * 0.5_wp * ( pt(k,j,i) + pt(k+1,j,i) ) & 1670 * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 )) 1673 1671 ENDDO 1674 1672 ENDDO … … 1680 1678 DO j = nys, nyn 1681 1679 DO k = nzb+1, nzt-1 1682 wq(k,j,i) = w(k,j,i) * 0.5_wp * ( q(k,j,i) + q(k+1,j,i) )& 1683 * MERGE( 1.0_wp, 0.0_wp, & 1684 BTEST( wall_flags_total_0(k,j,i), 3) ) 1680 wq(k,j,i) = w(k,j,i) * 0.5_wp * ( q(k,j,i) + q(k+1,j,i) ) & 1681 * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) ) 1685 1682 ENDDO 1686 1683 ENDDO … … 1690 1687 CASE ( 'theta_2m*' ) 1691 1688 ! 1692 !-- 2-m potential temperature is caluclated from surface arrays. In 1693 !-- case the 2m level is below the first grid point, MOST is applied, 1694 !-- else, linear interpolation between two vertical grid levels is 1695 !-- applied. To access all surfaces, iterate over all horizontally- 1689 !-- 2-m potential temperature is caluclated from surface arrays. In case the 2m level is 1690 !-- below the first grid point, MOST is applied, else, linear interpolation between two 1691 !-- vertical grid levels is applied. To access all surfaces, iterate over all horizontally- 1696 1692 !-- upward facing surface types. 1697 1693 surf => surf_def_h(0) … … 1705 1701 CASE ( 'wspeed_10m*' ) 1706 1702 ! 1707 !-- 10-m wind speed is caluclated from surface arrays. In 1708 !-- case the 10m level is below the first grid point, MOST is applied, 1709 !-- else, linear interpolation between two vertical grid levels is 1710 !-- applied. To access all surfaces, iterate over all horizontally- 1711 !-- upward facing surface types. 1703 !-- 10-m wind speed is caluclated from surface arrays. In case the 10m level is below the 1704 !-- first grid point, MOST is applied, else, linear interpolation between two vertical grid 1705 !-- levels is applied. To access all surfaces, iterate over all horizontally-upward facing 1706 !-- surface types. 1712 1707 surf => surf_def_h(0) 1713 1708 CALL calc_wind_10m … … 1717 1712 CALL calc_wind_10m 1718 1713 ! 1719 !-- horizontal wind speed1714 !-- Horizontal wind speed 1720 1715 CASE ( 'wspeed' ) 1721 1716 DO i = nxl, nxr 1722 1717 DO j = nys, nyn 1723 1718 DO k = nzb, nzt+1 1724 wspeed(k,j,i) = SQRT( ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) )**2 &1725 + ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) )**2 ) &1726 * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0))1719 wspeed(k,j,i) = SQRT( ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) )**2 & 1720 + ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) )**2 ) & 1721 * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 )) 1727 1722 ENDDO 1728 1723 ENDDO … … 1730 1725 1731 1726 ! 1732 !-- horizontal wind direction1727 !-- Horizontal wind direction 1733 1728 CASE ( 'wdir' ) 1734 1729 DO i = nxl, nxr … … 1738 1733 v_center(k,j,i) = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) 1739 1734 1740 wdir(k,j,i) = ATAN2( u_center(k,j,i), v_center(k,j,i) ) &1741 / pi * 180.0_wp + 180.0_wp1735 wdir(k,j,i) = ATAN2( u_center(k,j,i), v_center(k,j,i) ) & 1736 / pi * 180.0_wp + 180.0_wp 1742 1737 ENDDO 1743 1738 ENDDO … … 1752 1747 1753 1748 ! 1754 !-- The following block contains subroutines to calculate diagnostic 1755 !-- surface quantities. 1749 !-- The following block contains subroutines to calculate diagnostic surface quantities. 1756 1750 CONTAINS 1757 !------------------------------------------------------------------------------ !1751 !--------------------------------------------------------------------------------------------------! 1758 1752 ! Description: 1759 1753 ! ------------ 1760 1754 !> Calculation of 2-m potential temperature. 1761 !------------------------------------------------------------------------------ !1755 !--------------------------------------------------------------------------------------------------! 1762 1756 SUBROUTINE calc_pt_2m 1763 1757 1764 USE surface_layer_fluxes_mod, &1758 USE surface_layer_fluxes_mod, & 1765 1759 ONLY: psi_h 1766 1760 … … 1776 1770 k = surf%k(m) 1777 1771 ! 1778 !-- If 2-m level is below the first grid level, MOST is 1779 !-- used for calculation of2-m temperature.1772 !-- If 2-m level is below the first grid level, MOST is used for calculation of 1773 !-- 2-m temperature. 1780 1774 IF ( surf%z_mo(m) > 2.0_wp ) THEN 1781 pt_2m(j,i) = surf%pt_surface(m) + surf%ts(m) / kappa & 1782 * ( LOG( 2.0_wp / surf%z0h(m) ) & 1783 - psi_h( 2.0_wp / surf%ol(m) ) & 1784 + psi_h( surf%z0h(m) / surf%ol(m) ) ) 1785 ! 1786 !-- If 2-m level is above the first grid level, 2-m temperature 1787 !-- is linearly interpolated between the two nearest vertical grid 1788 !-- levels. Note, since 2-m temperature is only computed for 1789 !-- horizontal upward-facing surfaces, only a vertical 1790 !-- interpolation is necessary. 1775 pt_2m(j,i) = surf%pt_surface(m) + surf%ts(m) / kappa & 1776 * ( LOG( 2.0_wp / surf%z0h(m) ) & 1777 - psi_h( 2.0_wp / surf%ol(m) ) & 1778 + psi_h( surf%z0h(m) / surf%ol(m) ) ) 1779 ! 1780 !-- If 2-m level is above the first grid level, 2-m temperature is linearly interpolated 1781 !-- between the two nearest vertical grid levels. Note, since 2-m temperature is only 1782 !-- computed for horizontal upward-facing surfaces, only a vertical interpolation is 1783 !-- necessary. 1791 1784 ELSE 1792 1785 ! … … 1798 1791 ! 1799 1792 !-- kk defines the index of the first grid level >= 2m. 1800 pt_2m(j,i) = pt(kk-1,j,i) + &1801 ( zw(k-1) + 2.0_wp - zu(kk-1) ) * &1802 ( pt(kk,j,i) - pt(kk-1,j,i) ) / &1793 pt_2m(j,i) = pt(kk-1,j,i) + & 1794 ( zw(k-1) + 2.0_wp - zu(kk-1) ) * & 1795 ( pt(kk,j,i) - pt(kk-1,j,i) ) / & 1803 1796 ( zu(kk) - zu(kk-1) ) 1804 1797 ENDIF … … 1808 1801 END SUBROUTINE calc_pt_2m 1809 1802 1810 !------------------------------------------------------------------------------ !1803 !--------------------------------------------------------------------------------------------------! 1811 1804 ! Description: 1812 1805 ! ------------ 1813 1806 !> Calculation of 10-m wind speed. 1814 !------------------------------------------------------------------------------ !1807 !--------------------------------------------------------------------------------------------------! 1815 1808 SUBROUTINE calc_wind_10m 1816 1809 1817 USE surface_layer_fluxes_mod, &1810 USE surface_layer_fluxes_mod, & 1818 1811 ONLY: psi_m 1819 1812 … … 1825 1818 REAL(wp) :: uv_l !< wind speed at lower grid point 1826 1819 REAL(wp) :: uv_u !< wind speed at upper grid point 1820 1827 1821 1828 1822 DO m = 1, surf%ns … … 1832 1826 k = surf%k(m) 1833 1827 ! 1834 !-- If 10-m level is below the first grid level, MOST is 1835 !-- used for calculation of 10-mtemperature.1828 !-- If 10-m level is below the first grid level, MOST is used for calculation of 10-m 1829 !-- temperature. 1836 1830 IF ( surf%z_mo(m) > 10.0_wp ) THEN 1837 uv_10m(j,i) = surf%us(m) / kappa & 1838 * ( LOG( 10.0_wp / surf%z0(m) ) & 1839 - psi_m( 10.0_wp / surf%ol(m) ) & 1840 + psi_m( surf%z0(m) / surf%ol(m) ) ) 1841 ! 1842 !-- If 10-m level is above the first grid level, 10-m wind speed 1843 !-- is linearly interpolated between the two nearest vertical grid 1844 !-- levels. Note, since 10-m temperature is only computed for 1845 !-- horizontal upward-facing surfaces, only a vertical 1846 !-- interpolation is necessary. 1831 uv_10m(j,i) = surf%us(m) / kappa & 1832 * ( LOG( 10.0_wp / surf%z0(m) ) & 1833 - psi_m( 10.0_wp / surf%ol(m) ) & 1834 + psi_m( surf%z0(m) / surf%ol(m) ) ) 1835 ! 1836 !-- If 10-m level is above the first grid level, 10-m wind speed is linearly interpolated 1837 !-- between the two nearest vertical grid levels. Note, since 10-m temperature is only 1838 !-- computed for horizontal upward-facing surfaces, only a vertical interpolation is 1839 !-- necessary. 1847 1840 ELSE 1848 1841 ! … … 1854 1847 ! 1855 1848 !-- kk defines the index of the first grid level >= 10m. 1856 uv_l = SQRT( ( 0.5_wp * ( u(kk-1,j,i) + u(kk-1,j,i+1) ) )**2 &1849 uv_l = SQRT( ( 0.5_wp * ( u(kk-1,j,i) + u(kk-1,j,i+1) ) )**2 & 1857 1850 + ( 0.5_wp * ( v(kk-1,j,i) + v(kk-1,j+1,i) ) )**2 ) 1858 1851 1859 uv_u = SQRT( ( 0.5_wp * ( u(kk,j,i) + u(kk,j,i+1) ) )**2 &1852 uv_u = SQRT( ( 0.5_wp * ( u(kk,j,i) + u(kk,j,i+1) ) )**2 & 1860 1853 + ( 0.5_wp * ( v(kk,j,i) + v(kk,j+1,i) ) )**2 ) 1861 1854 1862 uv_10m(j,i) = uv_l + ( zw(k-1) + 10.0_wp - zu(kk-1) ) * &1863 ( uv_u - uv_l ) / &1855 uv_10m(j,i) = uv_l + ( zw(k-1) + 10.0_wp - zu(kk-1) ) * & 1856 ( uv_u - uv_l ) / & 1864 1857 ( zu(kk) - zu(kk-1) ) 1865 1858 … … 1873 1866 1874 1867 1875 !------------------------------------------------------------------------------ !1868 !--------------------------------------------------------------------------------------------------! 1876 1869 ! Description: 1877 1870 ! ------------ 1878 !> Preparation of the diagnostic output, counting of the module-specific 1879 !> output quantities andgathering of the output names.1880 !------------------------------------------------------------------------------ !1871 !> Preparation of the diagnostic output, counting of the module-specific output quantities and 1872 !> gathering of the output names. 1873 !--------------------------------------------------------------------------------------------------! 1881 1874 SUBROUTINE doq_prepare 1882 1875 1883 USE control_parameters, &1876 USE control_parameters, & 1884 1877 ONLY: do2d, do3d, domask, masks 1885 1878 1886 1879 IMPLICIT NONE 1887 1880 1888 CHARACTER (LEN=varnamelength), DIMENSION(0:1,500) :: do2d_var = ' ' !< 1889 !< label array for 2d output quantities 1881 CHARACTER (LEN=varnamelength), DIMENSION(0:1,500) :: do2d_var = ' ' !< label array for 2d output quantities 1890 1882 1891 1883 INTEGER(iwp) :: av !< index defining type of output, av=0 instantaneous, av=1 averaged … … 1895 1887 INTEGER(iwp) :: mid !< masked output running index 1896 1888 1889 1897 1890 prepared_diagnostic_output_quantities = .FALSE. 1898 1891 … … 1907 1900 ! 1908 1901 !-- Gather 2d output quantity names. 1909 !-- Check for double occurrence of output quantity, e.g. by _xy, 1910 !-- _yz, _xz. 1902 !-- Check for double occurrence of output quantity, e.g. by _xy, _yz, _xz. 1911 1903 DO WHILE ( do2d_var(av,ivar)(1:1) /= ' ' ) 1912 1904 IF ( .NOT. ANY( do_all == do2d_var(av,ivar) ) ) THEN … … 1930 1922 ivar = 1 1931 1923 ! 1932 !-- Gather masked output quantity names. Also check for double output 1933 !-- e.g. by different masks. 1924 !-- Gather masked output quantity names. Also check for double output e.g. by different masks. 1934 1925 DO mid = 1, masks 1935 1926 DO WHILE ( domask(mid,av,ivar)(1:1) /= ' ' ) … … 1950 1941 END SUBROUTINE doq_prepare 1951 1942 1952 !------------------------------------------------------------------------------ !1943 !--------------------------------------------------------------------------------------------------! 1953 1944 ! Description: 1954 1945 ! ------------ 1955 1946 !> Subroutine reads local (subdomain) restart data 1956 !------------------------------------------------------------------------------! 1957 SUBROUTINE doq_rrd_local_ftn( k, nxlf, nxlc, nxl_on_file, nxrf, nxrc, & 1958 nxr_on_file, nynf, nync, nyn_on_file, nysf, & 1959 nysc, nys_on_file, tmp_2d, tmp_3d, found ) 1947 !--------------------------------------------------------------------------------------------------! 1948 SUBROUTINE doq_rrd_local_ftn( k, nxlf, nxlc, nxl_on_file, nxrf, nxrc, nxr_on_file, nynf, nync, & 1949 nyn_on_file, nysf, nysc, nys_on_file, tmp_2d, tmp_3d, found ) 1960 1950 1961 1951 USE control_parameters … … 2002 1992 pt_2m_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & 2003 1993 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) 2004 1994 2005 1995 CASE ( 'ti_av' ) 2006 1996 IF ( .NOT. ALLOCATED( ti_av ) ) THEN … … 2108 2098 END SUBROUTINE doq_rrd_local_ftn 2109 2099 2110 !------------------------------------------------------------------------------ !2100 !--------------------------------------------------------------------------------------------------! 2111 2101 ! Description: 2112 2102 ! ------------ 2113 2103 !> Read module-specific local restart data arrays (MPI-IO). 2114 !------------------------------------------------------------------------------ !2104 !--------------------------------------------------------------------------------------------------! 2115 2105 SUBROUTINE doq_rrd_local_mpi 2116 2106 … … 2198 2188 END SUBROUTINE doq_rrd_local_mpi 2199 2189 2200 !------------------------------------------------------------------------------ !2190 !--------------------------------------------------------------------------------------------------! 2201 2191 ! Description: 2202 2192 ! ------------ 2203 2193 !> Subroutine writes local (subdomain) restart data 2204 !------------------------------------------------------------------------------ !2194 !--------------------------------------------------------------------------------------------------! 2205 2195 SUBROUTINE doq_wrd_local 2206 2196 2207 2208 2197 IMPLICIT NONE 2198 2209 2199 2210 2200 IF ( TRIM( restart_data_format_output ) == 'fortran_binary' ) THEN -
palm/trunk/SOURCE/diffusion_s.f90
r4360 r4583 1 1 !> @file diffusion_s.f90 2 !------------------------------------------------------------------------------ !2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. 4 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/>. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 8 ! 9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 12 ! 13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 1997-2020 Leibniz Universitaet Hannover 18 !------------------------------------------------------------------------------ !17 !--------------------------------------------------------------------------------------------------! 19 18 ! 20 19 ! Current revisions: … … 25 24 ! ----------------- 26 25 ! $Id$ 27 ! Introduction of wall_flags_total_0, which currently sets bits based on static 28 ! topography information used in wall_flags_static_0 29 ! 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4360 2020-01-07 11:25:50Z suehring 29 ! Introduction of wall_flags_total_0, which currently sets bits based on static topography 30 ! information used in wall_flags_static_0 31 ! 30 32 ! 4329 2019-12-10 15:46:36Z motisi 31 33 ! Renamed wall_flags_0 to wall_flags_total_0 32 ! 34 ! 33 35 ! 4182 2019-08-22 15:20:23Z scharf 34 36 ! Corrected "Former revisions" section 35 ! 37 ! 36 38 ! 3927 2019-04-23 13:24:29Z raasch 37 39 ! pointer attribute removed from scalar 3d-array for performance reasons 38 ! 40 ! 39 41 ! 3761 2019-02-25 15:31:42Z raasch 40 42 ! unused variables removed 41 ! 43 ! 42 44 ! 3655 2019-01-07 16:51:22Z knoop 43 45 ! nopointer option removed … … 50 52 ! ------------ 51 53 !> Diffusion term of scalar quantities (temperature and water content) 52 !------------------------------------------------------------------------------ !54 !--------------------------------------------------------------------------------------------------! 53 55 MODULE diffusion_s_mod 54 56 55 57 56 58 PRIVATE … … 65 67 66 68 67 !------------------------------------------------------------------------------ !69 !--------------------------------------------------------------------------------------------------! 68 70 ! Description: 69 71 ! ------------ 70 72 !> Call for all grid points 71 !------------------------------------------------------------------------------ !72 SUBROUTINE diffusion_s( s, s_flux_def_h_up, s_flux_def_h_down, &73 s_flux_t, &74 s_flux_lsm_h_up, s_flux_usm_h_up, &75 s_flux_def_v_north, s_flux_def_v_south, &76 s_flux_def_v_east, s_flux_def_v_west, &77 s_flux_lsm_v_north, s_flux_lsm_v_south, &78 s_flux_lsm_v_east, s_flux_lsm_v_west, &79 s_flux_usm_v_north, s_flux_usm_v_south, &73 !--------------------------------------------------------------------------------------------------! 74 SUBROUTINE diffusion_s( s, s_flux_def_h_up, s_flux_def_h_down, & 75 s_flux_t, & 76 s_flux_lsm_h_up, s_flux_usm_h_up, & 77 s_flux_def_v_north, s_flux_def_v_south, & 78 s_flux_def_v_east, s_flux_def_v_west, & 79 s_flux_lsm_v_north, s_flux_lsm_v_south, & 80 s_flux_lsm_v_east, s_flux_lsm_v_west, & 81 s_flux_usm_v_north, s_flux_usm_v_south, & 80 82 s_flux_usm_v_east, s_flux_usm_v_west ) 81 83 82 USE arrays_3d, &84 USE arrays_3d, & 83 85 ONLY: ddzu, ddzw, kh, tend, drho_air, rho_air_zw 84 85 USE control_parameters, &86 87 USE control_parameters, & 86 88 ONLY: use_surface_fluxes, use_top_fluxes 87 88 USE grid_variables, &89 90 USE grid_variables, & 89 91 ONLY: ddx, ddx2, ddy, ddy2 90 91 USE indices, & 92 ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt, & 93 wall_flags_total_0 94 92 93 USE indices, & 94 ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt, wall_flags_total_0 95 95 96 USE kinds 96 97 97 USE surface_mod, & 98 ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, & 99 surf_usm_v 98 USE surface_mod, & 99 ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, surf_usm_v 100 100 101 101 IMPLICIT NONE … … 109 109 110 110 REAL(wp) :: flag !< flag to mask topography grid points 111 REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface 112 REAL(wp) :: mask_east !< flag to mask vertical surface east of the grid point 111 REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface 112 REAL(wp) :: mask_east !< flag to mask vertical surface east of the grid point 113 113 REAL(wp) :: mask_north !< flag to mask vertical surface north of the grid point 114 REAL(wp) :: mask_south !< flag to mask vertical surface south of the grid point 114 REAL(wp) :: mask_south !< flag to mask vertical surface south of the grid point 115 REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface 115 116 REAL(wp) :: mask_west !< flag to mask vertical surface west of the grid point 116 REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface 117 117 118 REAL(wp), DIMENSION(1:surf_def_h(1)%ns) :: s_flux_def_h_down !< flux at horizontal donwward-facing default-type surfaces 119 REAL(wp), DIMENSION(1:surf_def_h(0)%ns) :: s_flux_def_h_up !< flux at horizontal upward-facing default-type surfaces 120 REAL(wp), DIMENSION(1:surf_def_v(2)%ns) :: s_flux_def_v_east !< flux at east-facing vertical default-type surfaces 118 121 REAL(wp), DIMENSION(1:surf_def_v(0)%ns) :: s_flux_def_v_north !< flux at north-facing vertical default-type surfaces 119 122 REAL(wp), DIMENSION(1:surf_def_v(1)%ns) :: s_flux_def_v_south !< flux at south-facing vertical default-type surfaces 120 REAL(wp), DIMENSION(1:surf_def_v(2)%ns) :: s_flux_def_v_east !< flux at east-facing vertical default-type surfaces121 123 REAL(wp), DIMENSION(1:surf_def_v(3)%ns) :: s_flux_def_v_west !< flux at west-facing vertical default-type surfaces 122 REAL(wp), DIMENSION(1:surf_def_h(0)%ns) :: s_flux_def_h_up !< flux at horizontal upward-facing default-type surfaces123 REAL(wp), DIMENSION(1:surf_def_h(1)%ns) :: s_flux_def_h_down !< flux at horizontal donwward-facing default-type surfaces124 124 REAL(wp), DIMENSION(1:surf_lsm_h%ns) :: s_flux_lsm_h_up !< flux at horizontal upward-facing natural-type surfaces 125 REAL(wp), DIMENSION(1:surf_lsm_v(2)%ns) :: s_flux_lsm_v_east !< flux at east-facing vertical natural-type surfaces 125 126 REAL(wp), DIMENSION(1:surf_lsm_v(0)%ns) :: s_flux_lsm_v_north !< flux at north-facing vertical natural-type surfaces 126 127 REAL(wp), DIMENSION(1:surf_lsm_v(1)%ns) :: s_flux_lsm_v_south !< flux at south-facing vertical natural-type surfaces 127 REAL(wp), DIMENSION(1:surf_lsm_v(2)%ns) :: s_flux_lsm_v_east !< flux at east-facing vertical natural-type surfaces128 128 REAL(wp), DIMENSION(1:surf_lsm_v(3)%ns) :: s_flux_lsm_v_west !< flux at west-facing vertical natural-type surfaces 129 129 REAL(wp), DIMENSION(1:surf_usm_h%ns) :: s_flux_usm_h_up !< flux at horizontal upward-facing urban-type surfaces 130 REAL(wp), DIMENSION(1:surf_usm_v(2)%ns) :: s_flux_usm_v_east !< flux at east-facing vertical urban-type surfaces 130 131 REAL(wp), DIMENSION(1:surf_usm_v(0)%ns) :: s_flux_usm_v_north !< flux at north-facing vertical urban-type surfaces 131 132 REAL(wp), DIMENSION(1:surf_usm_v(1)%ns) :: s_flux_usm_v_south !< flux at south-facing vertical urban-type surfaces 132 REAL(wp), DIMENSION(1:surf_usm_v(2)%ns) :: s_flux_usm_v_east !< flux at east-facing vertical urban-type surfaces133 133 REAL(wp), DIMENSION(1:surf_usm_v(3)%ns) :: s_flux_usm_v_west !< flux at west-facing vertical urban-type surfaces 134 134 REAL(wp), DIMENSION(1:surf_def_h(2)%ns) :: s_flux_t !< flux at model top … … 164 164 ! 165 165 !-- Predetermine flag to mask topography and wall-bounded grid points 166 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 167 ! 168 !-- Predetermine flag to mask wall-bounded grid points, equivalent to 169 !-- former s_outerarray166 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 167 ! 168 !-- Predetermine flag to mask wall-bounded grid points, equivalent to former s_outer 169 !-- array 170 170 mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i-1), 0 ) ) 171 171 mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i+1), 0 ) ) … … 173 173 mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j+1,i), 0 ) ) 174 174 175 tend(k,j,i) = tend(k,j,i) & 176 + 0.5_wp * ( & 177 mask_east * ( kh(k,j,i) + kh(k,j,i+1) ) & 178 * ( s(k,j,i+1) - s(k,j,i) ) & 179 - mask_west * ( kh(k,j,i) + kh(k,j,i-1) ) & 180 * ( s(k,j,i) - s(k,j,i-1) ) & 181 ) * ddx2 * flag & 182 + 0.5_wp * ( & 183 mask_north * ( kh(k,j,i) + kh(k,j+1,i) ) & 184 * ( s(k,j+1,i) - s(k,j,i) ) & 185 - mask_south * ( kh(k,j,i) + kh(k,j-1,i) ) & 186 * ( s(k,j,i) - s(k,j-1,i) ) & 187 ) * ddy2 * flag 188 ENDDO 189 190 ! 191 !-- Apply prescribed horizontal wall heatflux where necessary. First, 192 !-- determine start and end index for respective (j,i)-index. Please 193 !-- note, in the flat case following loop will not be entered, as 194 !-- surf_s=1 and surf_e=0. Furtermore, note, no vertical natural surfaces 195 !-- so far. 196 !-- First, for default-type surfaces 175 tend(k,j,i) = tend(k,j,i) & 176 + 0.5_wp * ( & 177 mask_east * ( kh(k,j,i) + kh(k,j,i+1) ) & 178 * ( s(k,j,i+1) - s(k,j,i) ) & 179 - mask_west * ( kh(k,j,i) + kh(k,j,i-1) ) & 180 * ( s(k,j,i) - s(k,j,i-1) ) & 181 ) * ddx2 * flag & 182 + 0.5_wp * ( & 183 mask_north * ( kh(k,j,i) + kh(k,j+1,i) ) & 184 * ( s(k,j+1,i) - s(k,j,i) ) & 185 - mask_south * ( kh(k,j,i) + kh(k,j-1,i) ) & 186 * ( s(k,j,i) - s(k,j-1,i) ) & 187 ) * ddy2 * flag 188 ENDDO 189 190 ! 191 !-- Apply prescribed horizontal wall heatflux where necessary. First, determine start and 192 !-- end index for respective (j,i)-index. Please note, in the flat case following loop will 193 !-- not be entered, as surf_s=1 and surf_e=0. Furtermore, note, no vertical natural 194 !-- surfaces so far. 195 !-- First, for default-type surfaces. 197 196 !-- North-facing vertical default-type surfaces 198 197 surf_s = surf_def_v(0)%start_index(j,i) … … 294 293 295 294 ! 296 !-- Compute vertical diffusion. In case that surface fluxes have been 297 !-- prescribed or computed at bottom and/or top, index k starts/ends at 298 !-- nzb+2 or nzt-1, respectively. Model top is also mask if top flux 299 !-- is given. 295 !-- Compute vertical diffusion. In case that surface fluxes have been prescribed or 296 !-- computed at bottom and/or top, index k starts/ends at nzb+2 or nzt-1, respectively. 297 !-- Model top is also mask if top flux is given. 300 298 DO k = nzb+1, nzt 301 299 ! 302 !-- Determine flags to mask topography below and above. Flag 0 is 303 !-- used to mask topography in general, and flag 8 implies 304 !-- information about use_surface_fluxes. Flag 9 is used to control 305 !-- flux at model top. 306 mask_bottom = MERGE( 1.0_wp, 0.0_wp, & 307 BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 308 mask_top = MERGE( 1.0_wp, 0.0_wp, & 309 BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) * & 310 MERGE( 1.0_wp, 0.0_wp, & 311 BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 312 flag = MERGE( 1.0_wp, 0.0_wp, & 313 BTEST( wall_flags_total_0(k,j,i), 0 ) ) 314 315 tend(k,j,i) = tend(k,j,i) & 316 + 0.5_wp * ( & 317 ( kh(k,j,i) + kh(k+1,j,i) ) * & 318 ( s(k+1,j,i)-s(k,j,i) ) * ddzu(k+1) & 319 * rho_air_zw(k) & 320 * mask_top & 321 - ( kh(k,j,i) + kh(k-1,j,i) ) * & 322 ( s(k,j,i)-s(k-1,j,i) ) * ddzu(k) & 323 * rho_air_zw(k-1) & 324 * mask_bottom & 325 ) * ddzw(k) * drho_air(k) & 300 !-- Determine flags to mask topography below and above. Flag 0 is used to mask 301 !-- topography in general, and flag 8 implies information about use_surface_fluxes. 302 !-- Flag 9 is used to control flux at model top. 303 mask_bottom = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 304 mask_top = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) * & 305 MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 306 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 307 308 tend(k,j,i) = tend(k,j,i) & 309 + 0.5_wp * ( & 310 ( kh(k,j,i) + kh(k+1,j,i) ) * & 311 ( s(k+1,j,i)-s(k,j,i) ) * ddzu(k+1) & 312 * rho_air_zw(k) & 313 * mask_top & 314 - ( kh(k,j,i) + kh(k-1,j,i) ) * & 315 ( s(k,j,i)-s(k-1,j,i) ) * ddzu(k) & 316 * rho_air_zw(k-1) & 317 * mask_bottom & 318 ) * ddzw(k) * drho_air(k) & 326 319 * flag 327 320 ENDDO … … 331 324 IF ( use_surface_fluxes ) THEN 332 325 ! 333 !-- Default-type surfaces, upward-facing 326 !-- Default-type surfaces, upward-facing 334 327 surf_s = surf_def_h(0)%start_index(j,i) 335 328 surf_e = surf_def_h(0)%end_index(j,i) … … 337 330 338 331 k = surf_def_h(0)%k(m) 339 tend(k,j,i) = tend(k,j,i) + s_flux_def_h_up(m) & 340 * ddzw(k) * drho_air(k) 332 tend(k,j,i) = tend(k,j,i) + s_flux_def_h_up(m) * ddzw(k) * drho_air(k) 341 333 342 334 ENDDO 343 335 ! 344 !-- Default-type surfaces, downward-facing 336 !-- Default-type surfaces, downward-facing 345 337 surf_s = surf_def_h(1)%start_index(j,i) 346 338 surf_e = surf_def_h(1)%end_index(j,i) … … 348 340 349 341 k = surf_def_h(1)%k(m) 350 tend(k,j,i) = tend(k,j,i) + s_flux_def_h_down(m) & 351 * ddzw(k) * drho_air(k) 342 tend(k,j,i) = tend(k,j,i) + s_flux_def_h_down(m) * ddzw(k) * drho_air(k) 352 343 353 344 ENDDO 354 345 ! 355 !-- Natural-type surfaces, upward-facing 346 !-- Natural-type surfaces, upward-facing 356 347 surf_s = surf_lsm_h%start_index(j,i) 357 348 surf_e = surf_lsm_h%end_index(j,i) … … 359 350 360 351 k = surf_lsm_h%k(m) 361 tend(k,j,i) = tend(k,j,i) + s_flux_lsm_h_up(m) & 362 * ddzw(k) * drho_air(k) 352 tend(k,j,i) = tend(k,j,i) + s_flux_lsm_h_up(m) * ddzw(k) * drho_air(k) 363 353 364 354 ENDDO 365 355 ! 366 !-- Urban-type surfaces, upward-facing 356 !-- Urban-type surfaces, upward-facing 367 357 surf_s = surf_usm_h%start_index(j,i) 368 358 surf_e = surf_usm_h%end_index(j,i) … … 370 360 371 361 k = surf_usm_h%k(m) 372 tend(k,j,i) = tend(k,j,i) + s_flux_usm_h_up(m) & 373 * ddzw(k) * drho_air(k) 362 tend(k,j,i) = tend(k,j,i) + s_flux_usm_h_up(m) * ddzw(k) * drho_air(k) 374 363 375 364 ENDDO … … 384 373 385 374 k = surf_def_h(2)%k(m) 386 tend(k,j,i) = tend(k,j,i) & 387 + ( - s_flux_t(m) ) * ddzw(k) * drho_air(k) 375 tend(k,j,i) = tend(k,j,i) + ( - s_flux_t(m) ) * ddzw(k) * drho_air(k) 388 376 ENDDO 389 377 ENDIF … … 394 382 END SUBROUTINE diffusion_s 395 383 396 !------------------------------------------------------------------------------ !384 !--------------------------------------------------------------------------------------------------! 397 385 ! Description: 398 386 ! ------------ 399 387 !> Call for grid point i,j 400 !------------------------------------------------------------------------------ !401 SUBROUTINE diffusion_s_ij( i, j, s, &402 s_flux_def_h_up, s_flux_def_h_down, &403 s_flux_t, &404 s_flux_lsm_h_up, s_flux_usm_h_up, &405 s_flux_def_v_north, s_flux_def_v_south, &406 s_flux_def_v_east, s_flux_def_v_west, &407 s_flux_lsm_v_north, s_flux_lsm_v_south, &408 s_flux_lsm_v_east, s_flux_lsm_v_west, &409 s_flux_usm_v_north, s_flux_usm_v_south, &410 s_flux_usm_v_east, s_flux_usm_v_west ) 411 412 USE arrays_3d, &388 !--------------------------------------------------------------------------------------------------! 389 SUBROUTINE diffusion_s_ij( i, j, s, & 390 s_flux_def_h_up, s_flux_def_h_down, & 391 s_flux_t, & 392 s_flux_lsm_h_up, s_flux_usm_h_up, & 393 s_flux_def_v_north, s_flux_def_v_south, & 394 s_flux_def_v_east, s_flux_def_v_west, & 395 s_flux_lsm_v_north, s_flux_lsm_v_south, & 396 s_flux_lsm_v_east, s_flux_lsm_v_west, & 397 s_flux_usm_v_north, s_flux_usm_v_south, & 398 s_flux_usm_v_east, s_flux_usm_v_west ) 399 400 USE arrays_3d, & 413 401 ONLY: ddzu, ddzw, kh, tend, drho_air, rho_air_zw 414 415 USE control_parameters, &402 403 USE control_parameters, & 416 404 ONLY: use_surface_fluxes, use_top_fluxes 417 418 USE grid_variables, &405 406 USE grid_variables, & 419 407 ONLY: ddx, ddx2, ddy, ddy2 420 421 USE indices, &408 409 USE indices, & 422 410 ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt, wall_flags_total_0 423 411 424 412 USE kinds 425 413 426 USE surface_mod, & 427 ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, & 428 surf_usm_v 414 USE surface_mod, & 415 ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, surf_usm_v 429 416 430 417 IMPLICIT NONE … … 438 425 439 426 REAL(wp) :: flag !< flag to mask topography grid points 440 REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface 441 REAL(wp) :: mask_east !< flag to mask vertical surface east of the grid point 427 REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface 428 REAL(wp) :: mask_east !< flag to mask vertical surface east of the grid point 442 429 REAL(wp) :: mask_north !< flag to mask vertical surface north of the grid point 443 REAL(wp) :: mask_south !< flag to mask vertical surface south of the grid point 430 REAL(wp) :: mask_south !< flag to mask vertical surface south of the grid point 431 REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface 444 432 REAL(wp) :: mask_west !< flag to mask vertical surface west of the grid point 445 REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface 446 433 434 REAL(wp), DIMENSION(1:surf_def_h(1)%ns) :: s_flux_def_h_down !< flux at horizontal donwward-facing default-type surfaces 435 REAL(wp), DIMENSION(1:surf_def_h(0)%ns) :: s_flux_def_h_up !< flux at horizontal upward-facing default-type surfaces 436 REAL(wp), DIMENSION(1:surf_def_v(2)%ns) :: s_flux_def_v_east !< flux at east-facing vertical default-type surfaces 447 437 REAL(wp), DIMENSION(1:surf_def_v(0)%ns) :: s_flux_def_v_north !< flux at north-facing vertical default-type surfaces 448 438 REAL(wp), DIMENSION(1:surf_def_v(1)%ns) :: s_flux_def_v_south !< flux at south-facing vertical default-type surfaces 449 REAL(wp), DIMENSION(1:surf_def_v(2)%ns) :: s_flux_def_v_east !< flux at east-facing vertical default-type surfaces450 439 REAL(wp), DIMENSION(1:surf_def_v(3)%ns) :: s_flux_def_v_west !< flux at west-facing vertical default-type surfaces 451 REAL(wp), DIMENSION(1:surf_def_h(0)%ns) :: s_flux_def_h_up !< flux at horizontal upward-facing default-type surfaces452 REAL(wp), DIMENSION(1:surf_def_h(1)%ns) :: s_flux_def_h_down !< flux at horizontal donwward-facing default-type surfaces453 440 REAL(wp), DIMENSION(1:surf_lsm_h%ns) :: s_flux_lsm_h_up !< flux at horizontal upward-facing natural-type surfaces 441 REAL(wp), DIMENSION(1:surf_lsm_v(2)%ns) :: s_flux_lsm_v_east !< flux at east-facing vertical urban-type surfaces 454 442 REAL(wp), DIMENSION(1:surf_lsm_v(0)%ns) :: s_flux_lsm_v_north !< flux at north-facing vertical urban-type surfaces 455 443 REAL(wp), DIMENSION(1:surf_lsm_v(1)%ns) :: s_flux_lsm_v_south !< flux at south-facing vertical urban-type surfaces 456 REAL(wp), DIMENSION(1:surf_lsm_v(2)%ns) :: s_flux_lsm_v_east !< flux at east-facing vertical urban-type surfaces457 444 REAL(wp), DIMENSION(1:surf_lsm_v(3)%ns) :: s_flux_lsm_v_west !< flux at west-facing vertical urban-type surfaces 458 445 REAL(wp), DIMENSION(1:surf_usm_h%ns) :: s_flux_usm_h_up !< flux at horizontal upward-facing urban-type surfaces 446 REAL(wp), DIMENSION(1:surf_usm_v(2)%ns) :: s_flux_usm_v_east !< flux at east-facing vertical urban-type surfaces 459 447 REAL(wp), DIMENSION(1:surf_usm_v(0)%ns) :: s_flux_usm_v_north !< flux at north-facing vertical urban-type surfaces 460 448 REAL(wp), DIMENSION(1:surf_usm_v(1)%ns) :: s_flux_usm_v_south !< flux at south-facing vertical urban-type surfaces 461 REAL(wp), DIMENSION(1:surf_usm_v(2)%ns) :: s_flux_usm_v_east !< flux at east-facing vertical urban-type surfaces462 449 REAL(wp), DIMENSION(1:surf_usm_v(3)%ns) :: s_flux_usm_v_west !< flux at west-facing vertical urban-type surfaces 463 450 REAL(wp), DIMENSION(1:surf_def_h(2)%ns) :: s_flux_t !< flux at model top … … 465 452 REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: s !< treated scalar 466 453 454 467 455 ! 468 456 !-- Compute horizontal diffusion … … 470 458 ! 471 459 !-- Predetermine flag to mask topography and wall-bounded grid points 472 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 473 ! 474 !-- Predetermine flag to mask wall-bounded grid points, equivalent to 475 !-- former s_outer array 460 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 461 ! 462 !-- Predetermine flag to mask wall-bounded grid points, equivalent to former s_outer array 476 463 mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i-1), 0 ) ) 477 464 mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i+1), 0 ) ) … … 479 466 mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j+1,i), 0 ) ) 480 467 ! 481 !-- Finally, determine flag to mask both topography itself as well 482 !-- as wall-bounded gridpoints, which will be treated further below483 484 tend(k,j,i) = tend(k,j,i) &485 + 0.5_wp * ( &486 mask_east * ( kh(k,j,i) + kh(k,j,i+1) ) &487 * ( s(k,j,i+1) - s(k,j,i) ) &488 - mask_west * ( kh(k,j,i) + kh(k,j,i-1) ) &489 * ( s(k,j,i) - s(k,j,i-1) ) &490 ) * ddx2 * flag &491 + 0.5_wp * ( &492 mask_north * ( kh(k,j,i) + kh(k,j+1,i) ) &493 * ( s(k,j+1,i) - s(k,j,i) ) &494 - mask_south * ( kh(k,j,i) + kh(k,j-1,i) ) &495 * ( s(k,j,i) - s(k,j-1,i) ) &468 !-- Finally, determine flag to mask both topography itself as well as wall-bounded grid 469 !-- points, which will be treated further below 470 471 tend(k,j,i) = tend(k,j,i) & 472 + 0.5_wp * ( & 473 mask_east * ( kh(k,j,i) + kh(k,j,i+1) ) & 474 * ( s(k,j,i+1) - s(k,j,i) ) & 475 - mask_west * ( kh(k,j,i) + kh(k,j,i-1) ) & 476 * ( s(k,j,i) - s(k,j,i-1) ) & 477 ) * ddx2 * flag & 478 + 0.5_wp * ( & 479 mask_north * ( kh(k,j,i) + kh(k,j+1,i) ) & 480 * ( s(k,j+1,i) - s(k,j,i) ) & 481 - mask_south * ( kh(k,j,i) + kh(k,j-1,i) ) & 482 * ( s(k,j,i) - s(k,j-1,i) ) & 496 483 ) * ddy2 * flag 497 484 ENDDO 498 485 499 486 ! 500 !-- Apply prescribed horizontal wall heatflux where necessary. First, 501 !-- determine start and end index for respective (j,i)-index. Please 502 !-- note, in the flat case following loops will not be entered, as 503 !-- surf_s=1 and surf_e=0. Furtermore, note, no vertical natural surfaces 504 !-- so far. 505 !-- First, for default-type surfaces 487 !-- Apply prescribed horizontal wall heatflux where necessary. First, determine start and end 488 !-- index for respective (j,i)-index. Please note, in the flat case following loops will not be 489 !-- entered, as surf_s=1 and surf_e=0. Furtermore, note, no vertical natural surfaces so far. 490 !-- First, for default-type surfaces. 506 491 !-- North-facing vertical default-type surfaces 507 492 surf_s = surf_def_v(0)%start_index(j,i) … … 604 589 605 590 ! 606 !-- Compute vertical diffusion. In case that surface fluxes have been 607 !-- prescribed or computed at bottom and/or top, index k starts/ends at 608 !-- nzb+2 or nzt-1, respectively. Model top is also mask if top flux 609 !-- is given. 591 !-- Compute vertical diffusion. In case that surface fluxes have been prescribed or computed at 592 !-- bottom and/or top, index k starts/ends at nzb+2 or nzt-1, respectively. Model top is also 593 !-- mask if top flux is given. 610 594 DO k = nzb+1, nzt 611 595 ! 612 !-- Determine flags to mask topography below and above. Flag 0 is 613 !-- used to mask topography in general, and flag 8 implies 614 !-- information about use_surface_fluxes. Flag 9 is used to control 615 !-- flux at model top. 616 mask_bottom = MERGE( 1.0_wp, 0.0_wp, & 617 BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 618 mask_top = MERGE( 1.0_wp, 0.0_wp, & 619 BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) * & 620 MERGE( 1.0_wp, 0.0_wp, & 621 BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 622 flag = MERGE( 1.0_wp, 0.0_wp, & 623 BTEST( wall_flags_total_0(k,j,i), 0 ) ) 624 625 tend(k,j,i) = tend(k,j,i) & 626 + 0.5_wp * ( & 627 ( kh(k,j,i) + kh(k+1,j,i) ) * & 628 ( s(k+1,j,i)-s(k,j,i) ) * ddzu(k+1) & 629 * rho_air_zw(k) & 630 * mask_top & 631 - ( kh(k,j,i) + kh(k-1,j,i) ) * & 632 ( s(k,j,i)-s(k-1,j,i) ) * ddzu(k) & 633 * rho_air_zw(k-1) & 634 * mask_bottom & 635 ) * ddzw(k) * drho_air(k) & 596 !-- Determine flags to mask topography below and above. Flag 0 is used to mask topography in 597 !-- general, and flag 8 implies information about use_surface_fluxes. Flag 9 is used to 598 !-- control flux at model top. 599 mask_bottom = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 600 mask_top = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) * & 601 MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 602 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 603 604 tend(k,j,i) = tend(k,j,i) & 605 + 0.5_wp * ( & 606 ( kh(k,j,i) + kh(k+1,j,i) ) * & 607 ( s(k+1,j,i)-s(k,j,i) ) * ddzu(k+1) & 608 * rho_air_zw(k) & 609 * mask_top & 610 - ( kh(k,j,i) + kh(k-1,j,i) ) * & 611 ( s(k,j,i)-s(k-1,j,i) ) * ddzu(k) & 612 * rho_air_zw(k-1) & 613 * mask_bottom & 614 ) * ddzw(k) * drho_air(k) & 636 615 * flag 637 616 ENDDO … … 649 628 k = surf_def_h(0)%k(m) 650 629 651 tend(k,j,i) = tend(k,j,i) + s_flux_def_h_up(m) & 652 * ddzw(k) * drho_air(k) 630 tend(k,j,i) = tend(k,j,i) + s_flux_def_h_up(m) * ddzw(k) * drho_air(k) 653 631 ENDDO 654 632 ! … … 660 638 k = surf_def_h(1)%k(m) 661 639 662 tend(k,j,i) = tend(k,j,i) + s_flux_def_h_down(m) & 663 * ddzw(k) * drho_air(k) 640 tend(k,j,i) = tend(k,j,i) + s_flux_def_h_down(m) * ddzw(k) * drho_air(k) 664 641 ENDDO 665 642 ! … … 670 647 k = surf_lsm_h%k(m) 671 648 672 tend(k,j,i) = tend(k,j,i) + s_flux_lsm_h_up(m) & 673 * ddzw(k) * drho_air(k) 649 tend(k,j,i) = tend(k,j,i) + s_flux_lsm_h_up(m) * ddzw(k) * drho_air(k) 674 650 ENDDO 675 651 ! … … 680 656 k = surf_usm_h%k(m) 681 657 682 tend(k,j,i) = tend(k,j,i) + s_flux_usm_h_up(m) & 683 * ddzw(k) * drho_air(k) 658 tend(k,j,i) = tend(k,j,i) + s_flux_usm_h_up(m) * ddzw(k) * drho_air(k) 684 659 ENDDO 685 660 ENDIF … … 692 667 693 668 k = surf_def_h(2)%k(m) 694 tend(k,j,i) = tend(k,j,i) & 695 + ( - s_flux_t(m) ) * ddzw(k) * drho_air(k) 669 tend(k,j,i) = tend(k,j,i) + ( - s_flux_t(m) ) * ddzw(k) * drho_air(k) 696 670 ENDDO 697 671 ENDIF -
palm/trunk/SOURCE/diffusion_u.f90
r4360 r4583 1 1 !> @file diffusion_u.f90 2 !------------------------------------------------------------------------------ !2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. 4 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/>. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 8 ! 9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 12 ! 13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 1997-2020 Leibniz Universitaet Hannover 18 !------------------------------------------------------------------------------ !17 !--------------------------------------------------------------------------------------------------! 19 18 ! 20 19 ! Current revisions: … … 25 24 ! ----------------- 26 25 ! $Id$ 27 ! Introduction of wall_flags_total_0, which currently sets bits based on static 28 ! topography information used in wall_flags_static_0 29 ! 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4360 2020-01-07 11:25:50Z suehring 29 ! Introduction of wall_flags_total_0, which currently sets bits based on static topography 30 ! information used in wall_flags_static_0 31 ! 30 32 ! 4329 2019-12-10 15:46:36Z motisi 31 33 ! Renamed wall_flags_0 to wall_flags_static_0 32 ! 34 ! 33 35 ! 4182 2019-08-22 15:20:23Z scharf 34 36 ! Corrected "Former revisions" section 35 ! 37 ! 36 38 ! 3655 2019-01-07 16:51:22Z knoop 37 39 ! OpenACC port for SPEC … … 44 46 ! ------------ 45 47 !> Diffusion term of the u-component 46 !> @todo additional damping (needed for non-cyclic bc) causes bad vectorization 47 ! > and slows down thespeed on NEC about 5-10%48 !------------------------------------------------------------------------------ !48 !> @todo additional damping (needed for non-cyclic bc) causes bad vectorization and slows down the 49 ! speed on NEC about 5-10% 50 !--------------------------------------------------------------------------------------------------! 49 51 MODULE diffusion_u_mod 50 52 51 53 52 54 PRIVATE … … 61 63 62 64 63 !------------------------------------------------------------------------------ !65 !--------------------------------------------------------------------------------------------------! 64 66 ! Description: 65 67 ! ------------ 66 68 !> Call for all grid points 67 !------------------------------------------------------------------------------ !69 !--------------------------------------------------------------------------------------------------! 68 70 SUBROUTINE diffusion_u 69 71 70 USE arrays_3d, & 71 ONLY: ddzu, ddzw, km, tend, u, v, w, drho_air, rho_air_zw 72 73 USE control_parameters, & 74 ONLY: constant_top_momentumflux, use_surface_fluxes, & 75 use_top_fluxes 76 77 USE grid_variables, & 72 USE arrays_3d, & 73 ONLY: ddzu, ddzw, drho_air, km, rho_air_zw, tend, u, v, w 74 75 USE control_parameters, & 76 ONLY: constant_top_momentumflux, use_surface_fluxes, use_top_fluxes 77 78 USE grid_variables, & 78 79 ONLY: ddx, ddx2, ddy 79 80 USE indices, &80 81 USE indices, & 81 82 ONLY: nxlu, nxr, nyn, nys, nzb, nzt, wall_flags_total_0 82 83 83 84 USE kinds 84 85 85 USE surface_mod, & 86 ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, & 87 surf_usm_v 86 USE surface_mod, & 87 ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, surf_usm_v 88 88 89 89 IMPLICIT NONE … … 102 102 REAL(wp) :: kmzm !< diffusion coefficient on bottom of the gridbox - interpolated onto xu-zw grid 103 103 REAL(wp) :: kmzp !< diffusion coefficient on top of the gridbox - interpolated onto xu-zw grid 104 REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface 105 REAL(wp) :: mask_north !< flag to mask vertical surface north of the grid point 106 REAL(wp) :: mask_south !< flag to mask vertical surface south of the grid point 107 REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface 104 REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface 105 REAL(wp) :: mask_north !< flag to mask vertical surface north of the grid point 106 REAL(wp) :: mask_south !< flag to mask vertical surface south of the grid point 107 REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface 108 108 109 109 … … 125 125 DO k = nzb+1, nzt 126 126 ! 127 !-- Predetermine flag to mask topography and wall-bounded grid points. 128 !-- It is sufficient to masked only north- and south-facing surfaces, which 129 !-- need special treatment for the u-component.130 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) ) 127 !-- Predetermine flag to mask topography and wall-bounded grid points. 128 !-- It is sufficient to masked only north- and south-facing surfaces, which need special 129 !-- treatment for the u-component. 130 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) ) 131 131 mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j-1,i), 1 ) ) 132 132 mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j+1,i), 1 ) ) 133 133 ! 134 134 !-- Interpolate eddy diffusivities on staggered gridpoints 135 kmyp = 0.25_wp * & 136 ( km(k,j,i)+km(k,j+1,i)+km(k,j,i-1)+km(k,j+1,i-1) ) 137 kmym = 0.25_wp * & 138 ( km(k,j,i)+km(k,j-1,i)+km(k,j,i-1)+km(k,j-1,i-1) ) 139 140 tend(k,j,i) = tend(k,j,i) & 141 + 2.0_wp * ( & 142 km(k,j,i) * ( u(k,j,i+1) - u(k,j,i) ) & 143 - km(k,j,i-1) * ( u(k,j,i) - u(k,j,i-1) ) & 144 ) * ddx2 * flag & 145 + ( mask_north * ( & 146 kmyp * ( u(k,j+1,i) - u(k,j,i) ) * ddy & 147 + kmyp * ( v(k,j+1,i) - v(k,j+1,i-1) ) * ddx & 148 ) & 149 - mask_south * ( & 150 kmym * ( u(k,j,i) - u(k,j-1,i) ) * ddy & 151 + kmym * ( v(k,j,i) - v(k,j,i-1) ) * ddx & 152 ) & 153 ) * ddy * flag 135 kmyp = 0.25_wp * ( km(k,j,i)+km(k,j+1,i)+km(k,j,i-1)+km(k,j+1,i-1) ) 136 kmym = 0.25_wp * ( km(k,j,i)+km(k,j-1,i)+km(k,j,i-1)+km(k,j-1,i-1) ) 137 138 tend(k,j,i) = tend(k,j,i) & 139 + 2.0_wp * ( & 140 km(k,j,i) * ( u(k,j,i+1) - u(k,j,i) ) & 141 - km(k,j,i-1) * ( u(k,j,i) - u(k,j,i-1) ) & 142 ) * ddx2 * flag & 143 + ( mask_north * ( & 144 kmyp * ( u(k,j+1,i) - u(k,j,i) ) * ddy & 145 + kmyp * ( v(k,j+1,i) - v(k,j+1,i-1) ) * ddx & 146 ) & 147 - mask_south * ( & 148 kmym * ( u(k,j,i) - u(k,j-1,i) ) * ddy & 149 + kmym * ( v(k,j,i) - v(k,j,i-1) ) * ddx & 150 ) & 151 ) * ddy * flag 154 152 ENDDO 155 153 ! 156 !-- Add horizontal momentum flux u'v' at north- (l=0) and south-facing (l=1) 157 !-- surfaces. Note, in the the flat case, loops won't be entered as 158 !-- start_index > end_index. Furtermore, note, no vertical natural surfaces 159 !-- so far. 154 !-- Add horizontal momentum flux u'v' at north- (l=0) and south-facing (l=1) surfaces. 155 !-- Note, in the the flat case, loops won't be entered as start_index > end_index. 156 !-- Furtermore, note, no vertical natural surfaces so far. 160 157 !-- Default-type surfaces 161 158 DO l = 0, 1 … … 164 161 DO m = surf_s, surf_e 165 162 k = surf_def_v(l)%k(m) 166 tend(k,j,i) = tend(k,j,i) + & 167 surf_def_v(l)%mom_flux_uv(m) * ddy 168 ENDDO 163 tend(k,j,i) = tend(k,j,i) + surf_def_v(l)%mom_flux_uv(m) * ddy 164 ENDDO 169 165 ENDDO 170 166 ! … … 175 171 DO m = surf_s, surf_e 176 172 k = surf_lsm_v(l)%k(m) 177 tend(k,j,i) = tend(k,j,i) + & 178 surf_lsm_v(l)%mom_flux_uv(m) * ddy 179 ENDDO 173 tend(k,j,i) = tend(k,j,i) + surf_lsm_v(l)%mom_flux_uv(m) * ddy 174 ENDDO 180 175 ENDDO 181 176 ! … … 186 181 DO m = surf_s, surf_e 187 182 k = surf_usm_v(l)%k(m) 188 tend(k,j,i) = tend(k,j,i) + & 189 surf_usm_v(l)%mom_flux_uv(m) * ddy 190 ENDDO 183 tend(k,j,i) = tend(k,j,i) + surf_usm_v(l)%mom_flux_uv(m) * ddy 184 ENDDO 191 185 ENDDO 192 186 193 187 ! 194 !-- Compute vertical diffusion. In case of simulating a surface layer, 195 !-- respective grid diffusive fluxes are masked (flag 8) within this196 !-- loop, and added further below, else, simple gradient approachis197 !-- applied. Model top is also mask if top-momentum flux is given.188 !-- Compute vertical diffusion. In case of simulating a surface layer, respective grid 189 !-- diffusive fluxes are masked (flag 8) within this loop, and added further below, else, 190 !-- simple gradient approach is applied. Model top is also mask if top-momentum flux is 191 !-- given. 198 192 DO k = nzb+1, nzt 199 193 ! 200 !-- Determine flags to mask topography below and above. Flag 1 is 201 !-- used to mask topography in general, and flag 8 implies 202 !-- information about use_surface_fluxes. Flag 9 is used to control 203 !-- momentum flux at model top. 204 mask_bottom = MERGE( 1.0_wp, 0.0_wp, & 205 BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 206 mask_top = MERGE( 1.0_wp, 0.0_wp, & 207 BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) * & 208 MERGE( 1.0_wp, 0.0_wp, & 209 BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 210 flag = MERGE( 1.0_wp, 0.0_wp, & 211 BTEST( wall_flags_total_0(k,j,i), 1 ) ) 194 !-- Determine flags to mask topography below and above. Flag 1 is used to mask 195 !-- topography in general, and flag 8 implies information about use_surface_fluxes. 196 !-- Flag 9 is used to control momentum flux at model top. 197 mask_bottom = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 198 mask_top = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) * & 199 MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 200 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) ) 212 201 ! 213 202 !-- Interpolate eddy diffusivities on staggered gridpoints 214 kmzp = 0.25_wp * & 215 ( km(k,j,i)+km(k+1,j,i)+km(k,j,i-1)+km(k+1,j,i-1) ) 216 kmzm = 0.25_wp * & 217 ( km(k,j,i)+km(k-1,j,i)+km(k,j,i-1)+km(k-1,j,i-1) ) 218 219 tend(k,j,i) = tend(k,j,i) & 220 + ( kmzp * ( ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & 221 + ( w(k,j,i) - w(k,j,i-1) ) * ddx & 222 ) * rho_air_zw(k) * mask_top & 223 - kmzm * ( ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) & 224 + ( w(k-1,j,i) - w(k-1,j,i-1) ) * ddx & 225 ) * rho_air_zw(k-1) * mask_bottom & 226 ) * ddzw(k) * drho_air(k) * flag 203 kmzp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j,i-1)+km(k+1,j,i-1) ) 204 kmzm = 0.25_wp * ( km(k,j,i)+km(k-1,j,i)+km(k,j,i-1)+km(k-1,j,i-1) ) 205 206 tend(k,j,i) = tend(k,j,i) & 207 + ( kmzp * ( ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & 208 + ( w(k,j,i) - w(k,j,i-1) ) * ddx & 209 ) * rho_air_zw(k) * mask_top & 210 - kmzm * ( ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) & 211 + ( w(k-1,j,i) - w(k-1,j,i-1) ) * ddx & 212 ) * rho_air_zw(k-1) * mask_bottom & 213 ) * ddzw(k) * drho_air(k) * flag 227 214 ENDDO 228 215 229 216 ! 230 !-- Vertical diffusion at the first grid point above the surface, 231 !-- if the momentum flux at the bottom is given by the Prandtl law or 232 !-- if it is prescribed by the user. 233 !-- Difference quotient of the momentum flux is not formed over half 234 !-- of the grid spacing (2.0*ddzw(k)) any more, since the comparison 235 !-- with other (LES) models showed that the values of the momentum 236 !-- flux becomes too large in this case. 237 !-- The term containing w(k-1,..) (see above equation) is removed here 238 !-- because the vertical velocity is assumed to be zero at the surface. 217 !-- Vertical diffusion at the first grid point above the surface, if the momentum flux at 218 !-- the bottom is given by the Prandtl law or if it is prescribed by the user. 219 !-- Difference quotient of the momentum flux is not formed over half of the grid spacing 220 !-- (2.0*ddzw(k)) any more, since the comparison with other (LES) models showed that the 221 !-- values of the momentum flux becomes too large in this case. 222 !-- The term containing w(k-1,..) (see above equation) is removed here because the vertical 223 !-- velocity is assumed to be zero at the surface. 239 224 IF ( use_surface_fluxes ) THEN 240 225 ! … … 246 231 k = surf_def_h(0)%k(m) 247 232 248 tend(k,j,i) = tend(k,j,i) & 249 + ( - ( - surf_def_h(0)%usws(m) ) & 250 ) * ddzw(k) * drho_air(k) 233 tend(k,j,i) = tend(k,j,i) & 234 + ( - ( - surf_def_h(0)%usws(m) ) ) * ddzw(k) * drho_air(k) 251 235 ENDDO 252 236 ! … … 258 242 k = surf_def_h(1)%k(m) 259 243 260 tend(k,j,i) = tend(k,j,i) & 261 + ( - surf_def_h(1)%usws(m) & 262 ) * ddzw(k) * drho_air(k) 244 tend(k,j,i) = tend(k,j,i) & 245 + ( - surf_def_h(1)%usws(m) ) * ddzw(k) * drho_air(k) 263 246 ENDDO 264 247 ! … … 270 253 k = surf_lsm_h%k(m) 271 254 272 tend(k,j,i) = tend(k,j,i) & 273 + ( - ( - surf_lsm_h%usws(m) ) & 274 ) * ddzw(k) * drho_air(k) 255 tend(k,j,i) = tend(k,j,i) & 256 + ( - ( - surf_lsm_h%usws(m) ) ) * ddzw(k) * drho_air(k) 275 257 ENDDO 276 258 ! … … 282 264 k = surf_usm_h%k(m) 283 265 284 tend(k,j,i) = tend(k,j,i) & 285 + ( - ( - surf_usm_h%usws(m) ) & 286 ) * ddzw(k) * drho_air(k) 266 tend(k,j,i) = tend(k,j,i) & 267 + ( - ( - surf_usm_h%usws(m) ) ) * ddzw(k) * drho_air(k) 287 268 ENDDO 288 269 … … 297 278 k = surf_def_h(2)%k(m) 298 279 299 tend(k,j,i) = tend(k,j,i) &300 + ( - surf_def_h(2)%usws(m) ) * ddzw(k) * drho_air(k)280 tend(k,j,i) = tend(k,j,i) & 281 + ( - surf_def_h(2)%usws(m) ) * ddzw(k) * drho_air(k) 301 282 ENDDO 302 283 ENDIF … … 308 289 309 290 310 !------------------------------------------------------------------------------ !291 !--------------------------------------------------------------------------------------------------! 311 292 ! Description: 312 293 ! ------------ 313 294 !> Call for grid point i,j 314 !------------------------------------------------------------------------------ !295 !--------------------------------------------------------------------------------------------------! 315 296 SUBROUTINE diffusion_u_ij( i, j ) 316 297 317 USE arrays_3d, & 318 ONLY: ddzu, ddzw, km, tend, u, v, w, drho_air, rho_air_zw 319 320 USE control_parameters, & 321 ONLY: constant_top_momentumflux, use_surface_fluxes, & 322 use_top_fluxes 323 324 USE grid_variables, & 298 USE arrays_3d, & 299 ONLY: ddzu, ddzw, drho_air, km, tend, u, v, w, rho_air_zw 300 301 USE control_parameters, & 302 ONLY: constant_top_momentumflux, use_surface_fluxes, use_top_fluxes 303 304 USE grid_variables, & 325 305 ONLY: ddx, ddx2, ddy 326 327 USE indices, &306 307 USE indices, & 328 308 ONLY: nzb, nzt, wall_flags_total_0 329 309 330 310 USE kinds 331 311 332 USE surface_mod, & 333 ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, & 334 surf_usm_v 312 USE surface_mod, & 313 ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, surf_usm_v 335 314 336 315 IMPLICIT NONE … … 349 328 REAL(wp) :: kmzm !< diffusion coefficient on bottom of the gridbox - interpolated onto xu-zw grid 350 329 REAL(wp) :: kmzp !< diffusion coefficient on top of the gridbox - interpolated onto xu-zw grid 351 REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface 352 REAL(wp) :: mask_north !< flag to mask vertical surface north of the grid point 353 REAL(wp) :: mask_south !< flag to mask vertical surface south of the grid point 354 REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface 355 ! 330 REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface 331 REAL(wp) :: mask_north !< flag to mask vertical surface north of the grid point 332 REAL(wp) :: mask_south !< flag to mask vertical surface south of the grid point 333 REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface 334 ! 356 335 !-- Compute horizontal diffusion 357 336 DO k = nzb+1, nzt 358 337 ! 359 !-- Predetermine flag to mask topography and wall-bounded grid points. 360 !-- It is sufficient to masked only north- and south-facing surfaces, which 361 !-- need special treatment for the u-component.362 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) ) 338 !-- Predetermine flag to mask topography and wall-bounded grid points. 339 !-- It is sufficient to masked only north- and south-facing surfaces, which need special 340 !-- treatment for the u-component. 341 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) ) 363 342 mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j-1,i), 1 ) ) 364 343 mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j+1,i), 1 ) ) … … 368 347 kmym = 0.25_wp * ( km(k,j,i)+km(k,j-1,i)+km(k,j,i-1)+km(k,j-1,i-1) ) 369 348 370 tend(k,j,i) = tend(k,j,i) & 371 + 2.0_wp * ( & 372 km(k,j,i) * ( u(k,j,i+1) - u(k,j,i) ) & 373 - km(k,j,i-1) * ( u(k,j,i) - u(k,j,i-1) ) & 374 ) * ddx2 * flag & 375 + ( & 376 mask_north * kmyp * ( ( u(k,j+1,i) - u(k,j,i) ) * ddy & 377 + ( v(k,j+1,i) - v(k,j+1,i-1) ) * ddx & 378 ) & 379 - mask_south * kmym * ( ( u(k,j,i) - u(k,j-1,i) ) * ddy & 380 + ( v(k,j,i) - v(k,j,i-1) ) * ddx & 381 ) & 382 ) * ddy * flag 383 ENDDO 384 385 ! 386 !-- Add horizontal momentum flux u'v' at north- (l=0) and south-facing (l=1) 387 !-- surfaces. Note, in the the flat case, loops won't be entered as 388 !-- start_index > end_index. Furtermore, note, no vertical natural surfaces 389 !-- so far. 349 tend(k,j,i) = tend(k,j,i) & 350 + 2.0_wp * ( & 351 km(k,j,i) * ( u(k,j,i+1) - u(k,j,i) ) & 352 - km(k,j,i-1) * ( u(k,j,i) - u(k,j,i-1) ) & 353 ) * ddx2 * flag & 354 + ( & 355 mask_north * kmyp * ( ( u(k,j+1,i) - u(k,j,i) ) * ddy & 356 + ( v(k,j+1,i) - v(k,j+1,i-1) ) * ddx & 357 ) & 358 - mask_south * kmym * ( ( u(k,j,i) - u(k,j-1,i) ) * ddy & 359 + ( v(k,j,i) - v(k,j,i-1) ) * ddx & 360 ) & 361 ) * ddy * flag 362 ENDDO 363 364 ! 365 !-- Add horizontal momentum flux u'v' at north- (l=0) and south-facing (l=1) surfaces. Note, in 366 !-- the the flat case, loops won't be entered as start_index > end_index. Furtermore, note, no 367 !-- vertical natural surfaces so far. 390 368 !-- Default-type surfaces 391 369 DO l = 0, 1 … … 395 373 k = surf_def_v(l)%k(m) 396 374 tend(k,j,i) = tend(k,j,i) + surf_def_v(l)%mom_flux_uv(m) * ddy 397 ENDDO 375 ENDDO 398 376 ENDDO 399 377 ! … … 405 383 k = surf_lsm_v(l)%k(m) 406 384 tend(k,j,i) = tend(k,j,i) + surf_lsm_v(l)%mom_flux_uv(m) * ddy 407 ENDDO 385 ENDDO 408 386 ENDDO 409 387 ! … … 415 393 k = surf_usm_v(l)%k(m) 416 394 tend(k,j,i) = tend(k,j,i) + surf_usm_v(l)%mom_flux_uv(m) * ddy 417 ENDDO 418 ENDDO 419 ! 420 !-- Compute vertical diffusion. In case of simulating a surface layer, 421 !-- respective grid diffusive fluxes are masked (flag 8) within this 422 !-- loop, and added further below, else, simple gradient approach is 423 !-- applied. Model top is also mask if top-momentum flux is given. 395 ENDDO 396 ENDDO 397 ! 398 !-- Compute vertical diffusion. In case of simulating a surface layer, respective grid diffusive 399 !-- fluxes are masked (flag 8) within this loop, and added further below, else, simple gradient 400 !-- approach is applied. Model top is also mask if top-momentum flux is given. 424 401 DO k = nzb+1, nzt 425 402 ! 426 !-- Determine flags to mask topography below and above. Flag 1 is 427 !-- used to mask topography in general, and flag 8 implies 428 !-- information about use_surface_fluxes. Flag 9 is used to control 429 !-- momentum flux at model top. 430 mask_bottom = MERGE( 1.0_wp, 0.0_wp, & 431 BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 432 mask_top = MERGE( 1.0_wp, 0.0_wp, & 433 BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) * & 434 MERGE( 1.0_wp, 0.0_wp, & 435 BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 436 flag = MERGE( 1.0_wp, 0.0_wp, & 437 BTEST( wall_flags_total_0(k,j,i), 1 ) ) 403 !-- Determine flags to mask topography below and above. Flag 1 is used to mask topography in 404 !-- general, and flag 8 implies information about use_surface_fluxes. Flag 9 is used to 405 !-- control momentum flux at model top. 406 mask_bottom = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 407 mask_top = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) * & 408 MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 409 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) ) 438 410 ! 439 411 !-- Interpolate eddy diffusivities on staggered gridpoints … … 441 413 kmzm = 0.25_wp * ( km(k,j,i)+km(k-1,j,i)+km(k,j,i-1)+km(k-1,j,i-1) ) 442 414 443 tend(k,j,i) = tend(k,j,i) &444 + ( kmzp * ( ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) &445 + ( w(k,j,i) - w(k,j,i-1) ) * ddx &446 ) * rho_air_zw(k) * mask_top &447 - kmzm * ( ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) &448 + ( w(k-1,j,i) - w(k-1,j,i-1) ) * ddx &449 ) * rho_air_zw(k-1) * mask_bottom &415 tend(k,j,i) = tend(k,j,i) & 416 + ( kmzp * ( ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & 417 + ( w(k,j,i) - w(k,j,i-1) ) * ddx & 418 ) * rho_air_zw(k) * mask_top & 419 - kmzm * ( ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) & 420 + ( w(k-1,j,i) - w(k-1,j,i-1) ) * ddx & 421 ) * rho_air_zw(k-1) * mask_bottom & 450 422 ) * ddzw(k) * drho_air(k) * flag 451 423 ENDDO 452 424 453 425 ! 454 !-- Vertical diffusion at the first surface grid points, if the 455 !-- momentum flux at the bottom is given by the Prandtl law or if it is 456 !-- prescribed by the user. 457 !-- Difference quotient of the momentum flux is not formed over half of 458 !-- the grid spacing (2.0*ddzw(k)) any more, since the comparison with 459 !-- other (LES) models showed that the values of the momentum flux becomes 460 !-- too large in this case. 426 !-- Vertical diffusion at the first surface grid points, if the momentum flux at the bottom is 427 !-- given by the Prandtl law or if it is prescribed by the user. 428 !-- Difference quotient of the momentum flux is not formed over half of the grid spacing 429 !-- (2.0*ddzw(k)) any more, since the comparison with other (LES) models showed that the values 430 !-- of the momentum flux becomes too large in this case. 461 431 IF ( use_surface_fluxes ) THEN 462 432 ! … … 468 438 k = surf_def_h(0)%k(m) 469 439 470 tend(k,j,i) = tend(k,j,i) & 471 + ( - ( - surf_def_h(0)%usws(m) ) & 472 ) * ddzw(k) * drho_air(k) 440 tend(k,j,i) = tend(k,j,i) + ( - ( - surf_def_h(0)%usws(m) ) ) * ddzw(k) * drho_air(k) 473 441 ENDDO 474 442 ! … … 480 448 k = surf_def_h(1)%k(m) 481 449 482 tend(k,j,i) = tend(k,j,i) & 483 + ( - surf_def_h(1)%usws(m) & 484 ) * ddzw(k) * drho_air(k) 450 tend(k,j,i) = tend(k,j,i) + ( - surf_def_h(1)%usws(m) ) * ddzw(k) * drho_air(k) 485 451 ENDDO 486 452 ! … … 492 458 k = surf_lsm_h%k(m) 493 459 494 tend(k,j,i) = tend(k,j,i) & 495 + ( - ( - surf_lsm_h%usws(m) ) & 496 ) * ddzw(k) * drho_air(k) 460 tend(k,j,i) = tend(k,j,i) + ( - ( - surf_lsm_h%usws(m) ) ) * ddzw(k) * drho_air(k) 497 461 ENDDO 498 462 ! … … 504 468 k = surf_usm_h%k(m) 505 469 506 tend(k,j,i) = tend(k,j,i) & 507 + ( - ( - surf_usm_h%usws(m) ) & 508 ) * ddzw(k) * drho_air(k) 470 tend(k,j,i) = tend(k,j,i) + ( - ( - surf_usm_h%usws(m) ) ) * ddzw(k) * drho_air(k) 509 471 ENDDO 510 472 … … 519 481 k = surf_def_h(2)%k(m) 520 482 521 tend(k,j,i) = tend(k,j,i) & 522 + ( - surf_def_h(2)%usws(m) ) * ddzw(k) * drho_air(k) 483 tend(k,j,i) = tend(k,j,i) + ( - surf_def_h(2)%usws(m) ) * ddzw(k) * drho_air(k) 523 484 ENDDO 524 485 ENDIF -
palm/trunk/SOURCE/diffusion_v.f90
r4360 r4583 1 1 !> @file diffusion_v.f90 2 !------------------------------------------------------------------------------ !2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. 4 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/>. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 8 ! 9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 12 ! 13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 1997-2020 Leibniz Universitaet Hannover 18 !------------------------------------------------------------------------------ !17 !--------------------------------------------------------------------------------------------------! 19 18 ! 20 19 ! Current revisions: … … 25 24 ! ----------------- 26 25 ! $Id$ 27 ! Introduction of wall_flags_total_0, which currently sets bits based on static 28 ! topography information used in wall_flags_static_0 29 ! 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4360 2020-01-07 11:25:50Z suehring 29 ! Introduction of wall_flags_total_0, which currently sets bits based on static topography 30 ! information used in wall_flags_static_0 31 ! 30 32 ! 4329 2019-12-10 15:46:36Z motisi 31 33 ! Renamed wall_flags_0 to wall_flags_static_0 32 ! 34 ! 33 35 ! 4182 2019-08-22 15:20:23Z scharf 34 36 ! Corrected "Former revisions" section 35 ! 37 ! 36 38 ! 3655 2019-01-07 16:51:22Z knoop 37 39 ! OpenACC port for SPEC … … 44 46 ! ------------ 45 47 !> Diffusion term of the v-component 46 !------------------------------------------------------------------------------ !48 !--------------------------------------------------------------------------------------------------! 47 49 MODULE diffusion_v_mod 48 50 49 51 50 52 PRIVATE … … 59 61 60 62 61 !------------------------------------------------------------------------------ !63 !--------------------------------------------------------------------------------------------------! 62 64 ! Description: 63 65 ! ------------ 64 66 !> Call for all grid points 65 !------------------------------------------------------------------------------ !67 !--------------------------------------------------------------------------------------------------! 66 68 SUBROUTINE diffusion_v 67 69 68 USE arrays_3d, & 69 ONLY: ddzu, ddzw, km, tend, u, v, w, drho_air, rho_air_zw 70 71 USE control_parameters, & 72 ONLY: constant_top_momentumflux, use_surface_fluxes, & 73 use_top_fluxes 74 75 USE grid_variables, & 70 USE arrays_3d, & 71 ONLY: ddzu, ddzw, drho_air, km, rho_air_zw, tend, u, v, w 72 73 USE control_parameters, & 74 ONLY: constant_top_momentumflux, use_surface_fluxes, use_top_fluxes 75 76 USE grid_variables, & 76 77 ONLY: ddx, ddy, ddy2 77 78 USE indices, &78 79 USE indices, & 79 80 ONLY: nxl, nxr, nyn, nysv, nzb, nzt, wall_flags_total_0 80 81 81 82 USE kinds 82 83 83 USE surface_mod, & 84 ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, & 85 surf_usm_v 84 USE surface_mod, & 85 ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, surf_usm_v 86 86 87 87 IMPLICIT NONE … … 100 100 REAL(wp) :: kmzm !< diffusion coefficient on bottom of the gridbox - interpolated onto yv-zw grid 101 101 REAL(wp) :: kmzp !< diffusion coefficient on top of the gridbox - interpolated onto yv-zw grid 102 REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface 103 REAL(wp) :: mask_east !< flag to mask vertical surface south of the grid point 104 REAL(wp) :: mask_west !< flag to mask vertical surface north of the grid point 105 REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface 102 REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface 103 REAL(wp) :: mask_east !< flag to mask vertical surface south of the grid point 104 REAL(wp) :: mask_west !< flag to mask vertical surface north of the grid point 105 REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface 106 106 107 107 !$ACC PARALLEL LOOP COLLAPSE(2) PRIVATE(i, j, k, l, m) & … … 122 122 123 123 ! 124 !-- Predetermine flag to mask topography and wall-bounded grid points. 125 !-- It is sufficient to masked only east- and west-facing surfaces, which 126 !-- need special treatment for the v-component.127 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) ) 124 !-- Predetermine flag to mask topography and wall-bounded grid points. 125 !-- It is sufficient to masked only east- and west-facing surfaces, which need special 126 !-- treatment for the v-component. 127 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) ) 128 128 mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i+1), 2 ) ) 129 129 mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i-1), 2 ) ) … … 133 133 kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) 134 134 135 tend(k,j,i) = tend(k,j,i) + (&136 mask_east * kmxp * (&137 ( v(k,j,i+1) - v(k,j,i) ) * ddx&138 + ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy&139 )&140 - mask_west * kmxm * (&141 ( v(k,j,i) - v(k,j,i-1) ) * ddx&142 + ( u(k,j,i) - u(k,j-1,i) ) * ddy&143 )&144 ) * ddx * flag&145 + 2.0_wp * (&146 km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) )&147 - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) )&148 ) * ddy2 * flag135 tend(k,j,i) = tend(k,j,i) + ( & 136 mask_east * kmxp * ( & 137 ( v(k,j,i+1) - v(k,j,i) ) * ddx & 138 + ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & 139 ) & 140 - mask_west * kmxm * ( & 141 ( v(k,j,i) - v(k,j,i-1) ) * ddx & 142 + ( u(k,j,i) - u(k,j-1,i) ) * ddy & 143 ) & 144 ) * ddx * flag & 145 + 2.0_wp * ( & 146 km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & 147 - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & 148 ) * ddy2 * flag 149 149 150 150 ENDDO 151 151 152 152 ! 153 !-- Add horizontal momentum flux v'u' at east- (l=2) and west-facing (l=3) 154 !-- surfaces. Note, in the the flat case, loops won't be entered as 155 !-- start_index > end_index. Furtermore, note, no vertical natural surfaces 156 !-- so far. 153 !-- Add horizontal momentum flux v'u' at east- (l=2) and west-facing (l=3) surfaces. Note, 154 !-- in the the flat case, loops won't be entered as start_index > end_index. Furtermore, 155 !-- note, no vertical natural surfaces so far. 157 156 !-- Default-type surfaces 158 157 DO l = 2, 3 … … 161 160 DO m = surf_s, surf_e 162 161 k = surf_def_v(l)%k(m) 163 tend(k,j,i) = tend(k,j,i) + & 164 surf_def_v(l)%mom_flux_uv(m) * ddx 165 ENDDO 162 tend(k,j,i) = tend(k,j,i) + surf_def_v(l)%mom_flux_uv(m) * ddx 163 ENDDO 166 164 ENDDO 167 165 ! … … 172 170 DO m = surf_s, surf_e 173 171 k = surf_lsm_v(l)%k(m) 174 tend(k,j,i) = tend(k,j,i) + & 175 surf_lsm_v(l)%mom_flux_uv(m) * ddx 176 ENDDO 172 tend(k,j,i) = tend(k,j,i) + surf_lsm_v(l)%mom_flux_uv(m) * ddx 173 ENDDO 177 174 ENDDO 178 175 ! … … 183 180 DO m = surf_s, surf_e 184 181 k = surf_usm_v(l)%k(m) 185 tend(k,j,i) = tend(k,j,i) + & 186 surf_usm_v(l)%mom_flux_uv(m) * ddx 187 ENDDO 182 tend(k,j,i) = tend(k,j,i) + surf_usm_v(l)%mom_flux_uv(m) * ddx 183 ENDDO 188 184 ENDDO 189 185 ! 190 !-- Compute vertical diffusion. In case of simulating a surface layer, 191 !-- respective grid diffusive fluxes are masked (flag 10) within this192 !-- loop, and added further below, else, simple gradient approachis193 !-- applied. Model top is also mask if top-momentum flux is given.186 !-- Compute vertical diffusion. In case of simulating a surface layer, respective grid 187 !-- diffusive fluxes are masked (flag 10) within this loop, and added further below, else, 188 !-- simple gradient approach is applied. Model top is also mask if top-momentum flux is 189 !-- given. 194 190 DO k = nzb+1, nzt 195 191 ! 196 !-- Determine flags to mask topography below and above. Flag 2 is 197 !-- used to mask topography in general, while flag 8 implies also 198 !-- information about use_surface_fluxes. Flag 9 is used to control 199 !-- momentum flux at model top. 200 mask_bottom = MERGE( 1.0_wp, 0.0_wp, & 201 BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 202 mask_top = MERGE( 1.0_wp, 0.0_wp, & 203 BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) * & 204 MERGE( 1.0_wp, 0.0_wp, & 205 BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 206 flag = MERGE( 1.0_wp, 0.0_wp, & 207 BTEST( wall_flags_total_0(k,j,i), 2 ) ) 192 !-- Determine flags to mask topography below and above. Flag 2 is used to mask 193 !-- topography in general, while flag 8 implies also information about 194 !-- use_surface_fluxes. Flag 9 is used to control momentum flux at model top. 195 mask_bottom = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 196 mask_top = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) * & 197 MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 198 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) ) 208 199 ! 209 200 !-- Interpolate eddy diffusivities on staggered gridpoints 210 kmzp = 0.25_wp * & 211 ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) 212 kmzm = 0.25_wp * & 213 ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) 214 215 tend(k,j,i) = tend(k,j,i) & 216 & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & 217 & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & 218 & ) * rho_air_zw(k) * mask_top & 219 & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & 220 & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & 221 & ) * rho_air_zw(k-1) * mask_bottom & 222 & ) * ddzw(k) * drho_air(k) * flag 201 kmzp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) 202 kmzm = 0.25_wp * ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) 203 204 tend(k,j,i) = tend(k,j,i) & 205 & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & 206 & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & 207 & ) * rho_air_zw(k) * mask_top & 208 & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & 209 & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & 210 & ) * rho_air_zw(k-1) * mask_bottom & 211 & ) * ddzw(k) * drho_air(k) * flag 223 212 ENDDO 224 213 225 214 ! 226 !-- Vertical diffusion at the first grid point above the surface, 227 !-- if the momentum flux at the bottom is given by the Prandtl law 228 !-- or if it is prescribed by the user. 229 !-- Difference quotient of the momentum flux is not formed over 230 !-- half of the grid spacing (2.0*ddzw(k)) any more, since the 231 !-- comparison with other (LES) models showed that the values of 232 !-- the momentum flux becomes too large in this case. 215 !-- Vertical diffusion at the first grid point above the surface, if the momentum flux at 216 !-- the bottom is given by the Prandtl law or if it is prescribed by the user. 217 !-- Difference quotient of the momentum flux is not formed over half of the grid spacing 218 !-- (2.0*ddzw(k)) any more, since the comparison with other (LES) models showed that the 219 !-- values of the momentum flux becomes too large in this case. 233 220 IF ( use_surface_fluxes ) THEN 234 221 ! … … 239 226 k = surf_def_h(0)%k(m) 240 227 241 tend(k,j,i) = tend(k,j,i) & 242 + ( - ( - surf_def_h(0)%vsws(m) ) & 243 ) * ddzw(k) * drho_air(k) 228 tend(k,j,i) = tend(k,j,i) & 229 + ( - ( - surf_def_h(0)%vsws(m) ) ) * ddzw(k) * drho_air(k) 244 230 ENDDO 245 231 ! … … 250 236 k = surf_def_h(1)%k(m) 251 237 252 tend(k,j,i) = tend(k,j,i) & 253 + ( - surf_def_h(1)%vsws(m) & 254 ) * ddzw(k) * drho_air(k) 238 tend(k,j,i) = tend(k,j,i) & 239 + ( - surf_def_h(1)%vsws(m) ) * ddzw(k) * drho_air(k) 255 240 ENDDO 256 241 ! … … 261 246 k = surf_lsm_h%k(m) 262 247 263 tend(k,j,i) = tend(k,j,i) & 264 + ( - ( - surf_lsm_h%vsws(m) ) & 265 ) * ddzw(k) * drho_air(k) 248 tend(k,j,i) = tend(k,j,i) & 249 + ( - ( - surf_lsm_h%vsws(m) ) ) * ddzw(k) * drho_air(k) 266 250 267 251 ENDDO … … 273 257 k = surf_usm_h%k(m) 274 258 275 tend(k,j,i) = tend(k,j,i) & 276 + ( - ( - surf_usm_h%vsws(m) ) & 277 ) * ddzw(k) * drho_air(k) 259 tend(k,j,i) = tend(k,j,i) & 260 + ( - ( - surf_usm_h%vsws(m) ) ) * ddzw(k) * drho_air(k) 278 261 279 262 ENDDO … … 288 271 k = surf_def_h(2)%k(m) 289 272 290 tend(k,j,i) = tend(k,j,i) &291 + ( - surf_def_h(2)%vsws(m) ) * ddzw(k) * drho_air(k)273 tend(k,j,i) = tend(k,j,i) & 274 + ( - surf_def_h(2)%vsws(m) ) * ddzw(k) * drho_air(k) 292 275 ENDDO 293 276 ENDIF … … 299 282 300 283 301 !------------------------------------------------------------------------------ !284 !--------------------------------------------------------------------------------------------------! 302 285 ! Description: 303 286 ! ------------ 304 287 !> Call for grid point i,j 305 !------------------------------------------------------------------------------ !288 !--------------------------------------------------------------------------------------------------! 306 289 SUBROUTINE diffusion_v_ij( i, j ) 307 290 308 USE arrays_3d, & 309 ONLY: ddzu, ddzw, km, tend, u, v, w, drho_air, rho_air_zw 310 311 USE control_parameters, & 312 ONLY: constant_top_momentumflux, use_surface_fluxes, & 313 use_top_fluxes 314 315 USE grid_variables, & 291 USE arrays_3d, & 292 ONLY: ddzu, ddzw, drho_air, km, tend, u, v, w, rho_air_zw 293 294 USE control_parameters, & 295 ONLY: constant_top_momentumflux, use_surface_fluxes, use_top_fluxes 296 297 USE grid_variables, & 316 298 ONLY: ddx, ddy, ddy2 317 318 USE indices, &299 300 USE indices, & 319 301 ONLY: nzb, nzt, wall_flags_total_0 320 302 321 303 USE kinds 322 304 323 USE surface_mod, & 324 ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, & 325 surf_usm_v 305 USE surface_mod, & 306 ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, surf_usm_v 326 307 327 308 IMPLICIT NONE … … 341 322 REAL(wp) :: kmzm !< diffusion coefficient on bottom of the gridbox - interpolated onto xu-zw grid 342 323 REAL(wp) :: kmzp !< diffusion coefficient on top of the gridbox - interpolated onto xu-zw grid 343 REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface 344 REAL(wp) :: mask_east !< flag to mask vertical surface south of the grid point 345 REAL(wp) :: mask_west !< flag to mask vertical surface north of the grid point 324 REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface 325 REAL(wp) :: mask_east !< flag to mask vertical surface south of the grid point 326 REAL(wp) :: mask_west !< flag to mask vertical surface north of the grid point 346 327 REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface 347 328 … … 350 331 DO k = nzb+1, nzt 351 332 ! 352 !-- Predetermine flag to mask topography and wall-bounded grid points. 353 !-- It is sufficient to masked only east- and west-facing surfaces, which 354 !-- need special treatment for the v-component.355 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) ) 333 !-- Predetermine flag to mask topography and wall-bounded grid points. 334 !-- It is sufficient to masked only east- and west-facing surfaces, which need special 335 !-- treatment for the v-component. 336 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) ) 356 337 mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i+1), 2 ) ) 357 338 mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i-1), 2 ) ) … … 361 342 kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) 362 343 363 tend(k,j,i) = tend(k,j,i) + ( &364 mask_east * kmxp * ( &365 ( v(k,j,i+1) - v(k,j,i) ) * ddx &366 + ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy &367 ) &368 - mask_west * kmxm * ( &369 ( v(k,j,i) - v(k,j,i-1) ) * ddx &370 + ( u(k,j,i) - u(k,j-1,i) ) * ddy &371 ) &372 ) * ddx * flag &373 + 2.0_wp * ( &374 km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) &375 - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) &344 tend(k,j,i) = tend(k,j,i) + ( & 345 mask_east * kmxp * ( & 346 ( v(k,j,i+1) - v(k,j,i) ) * ddx & 347 + ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & 348 ) & 349 - mask_west * kmxm * ( & 350 ( v(k,j,i) - v(k,j,i-1) ) * ddx & 351 + ( u(k,j,i) - u(k,j-1,i) ) * ddy & 352 ) & 353 ) * ddx * flag & 354 + 2.0_wp * ( & 355 km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & 356 - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & 376 357 ) * ddy2 * flag 377 358 ENDDO 378 359 379 360 ! 380 !-- Add horizontal momentum flux v'u' at east- (l=2) and west-facing (l=3) 381 !-- surfaces. Note, in the the flat case, loops won't be entered as 382 !-- start_index > end_index. Furtermore, note, no vertical natural surfaces 383 !-- so far. 361 !-- Add horizontal momentum flux v'u' at east- (l=2) and west-facing (l=3) surfaces. Note, in the 362 !-- the flat case, loops won't be entered as start_index > end_index. Furtermore, note, no 363 !-- vertical natural surfaces so far. 384 364 !-- Default-type surfaces 385 365 DO l = 2, 3 … … 389 369 k = surf_def_v(l)%k(m) 390 370 tend(k,j,i) = tend(k,j,i) + surf_def_v(l)%mom_flux_uv(m) * ddx 391 ENDDO 371 ENDDO 392 372 ENDDO 393 373 ! … … 399 379 k = surf_lsm_v(l)%k(m) 400 380 tend(k,j,i) = tend(k,j,i) + surf_lsm_v(l)%mom_flux_uv(m) * ddx 401 ENDDO 381 ENDDO 402 382 ENDDO 403 383 ! … … 409 389 k = surf_usm_v(l)%k(m) 410 390 tend(k,j,i) = tend(k,j,i) + surf_usm_v(l)%mom_flux_uv(m) * ddx 411 ENDDO 412 ENDDO 413 ! 414 !-- Compute vertical diffusion. In case of simulating a surface layer, 415 !-- respective grid diffusive fluxes are masked (flag 8) within this 416 !-- loop, and added further below, else, simple gradient approach is 417 !-- applied. Model top is also mask if top-momentum flux is given. 391 ENDDO 392 ENDDO 393 ! 394 !-- Compute vertical diffusion. In case of simulating a surface layer, respective grid diffusive 395 !-- fluxes are masked (flag 8) within this loop, and added further below, else, simple gradient 396 !-- approach is applied. Model top is also mask if top-momentum flux is given. 418 397 DO k = nzb+1, nzt 419 398 ! 420 !-- Determine flags to mask topography below and above. Flag 2 is 421 !-- used to mask topography in general, while flag 10 implies also 422 !-- information about use_surface_fluxes. Flag 9 is used to control 423 !-- momentum flux at model top. 424 mask_bottom = MERGE( 1.0_wp, 0.0_wp, & 425 BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 426 mask_top = MERGE( 1.0_wp, 0.0_wp, & 427 BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) * & 428 MERGE( 1.0_wp, 0.0_wp, & 429 BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 430 flag = MERGE( 1.0_wp, 0.0_wp, & 431 BTEST( wall_flags_total_0(k,j,i), 2 ) ) 399 !-- Determine flags to mask topography below and above. Flag 2 is used to mask topography in 400 !-- general, while flag 10 implies also information about use_surface_fluxes. Flag 9 is used 401 !-- to control momentum flux at model top. 402 mask_bottom = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 403 mask_top = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) * & 404 MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 405 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) ) 432 406 ! 433 407 !-- Interpolate eddy diffusivities on staggered gridpoints … … 435 409 kmzm = 0.25_wp * ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) 436 410 437 tend(k,j,i) = tend(k,j,i) & 438 & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & 439 & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & 440 & ) * rho_air_zw(k) * mask_top & 441 & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & 442 & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & 443 & ) * rho_air_zw(k-1) * mask_bottom & 444 & ) * ddzw(k) * drho_air(k) * flag 445 ENDDO 446 447 ! 448 !-- Vertical diffusion at the first grid point above the surface, if the 449 !-- momentum flux at the bottom is given by the Prandtl law or if it is 450 !-- prescribed by the user. 451 !-- Difference quotient of the momentum flux is not formed over half of 452 !-- the grid spacing (2.0*ddzw(k)) any more, since the comparison with 453 !-- other (LES) models showed that the values of the momentum flux becomes 454 !-- too large in this case. 411 tend(k,j,i) = tend(k,j,i) & 412 & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & 413 & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & 414 & ) * rho_air_zw(k) * mask_top & 415 & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & 416 & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & 417 & ) * rho_air_zw(k-1) * mask_bottom & 418 & ) * ddzw(k) * drho_air(k) * flag 419 ENDDO 420 421 ! 422 !-- Vertical diffusion at the first grid point above the surface, if the momentum flux at the 423 !-- bottom is given by the Prandtl law or if it is prescribed by the user. 424 !-- Difference quotient of the momentum flux is not formed over half of the grid spacing 425 !-- (2.0*ddzw(k)) any more, since the comparison with other (LES) models showed that the values 426 !-- of the momentum flux becomes too large in this case. 455 427 IF ( use_surface_fluxes ) THEN 456 428 ! … … 461 433 k = surf_def_h(0)%k(m) 462 434 463 tend(k,j,i) = tend(k,j,i) & 464 + ( - ( - surf_def_h(0)%vsws(m) ) & 465 ) * ddzw(k) * drho_air(k) 435 tend(k,j,i) = tend(k,j,i) + ( - ( - surf_def_h(0)%vsws(m) ) ) * ddzw(k) * drho_air(k) 466 436 ENDDO 467 437 ! … … 472 442 k = surf_def_h(1)%k(m) 473 443 474 tend(k,j,i) = tend(k,j,i) & 475 + ( - surf_def_h(1)%vsws(m) & 476 ) * ddzw(k) * drho_air(k) 444 tend(k,j,i) = tend(k,j,i) + ( - surf_def_h(1)%vsws(m) ) * ddzw(k) * drho_air(k) 477 445 ENDDO 478 446 ! … … 483 451 k = surf_lsm_h%k(m) 484 452 485 tend(k,j,i) = tend(k,j,i) & 486 + ( - ( - surf_lsm_h%vsws(m) ) & 487 ) * ddzw(k) * drho_air(k) 453 tend(k,j,i) = tend(k,j,i) + ( - ( - surf_lsm_h%vsws(m) ) ) * ddzw(k) * drho_air(k) 488 454 489 455 ENDDO … … 495 461 k = surf_usm_h%k(m) 496 462 497 tend(k,j,i) = tend(k,j,i) & 498 + ( - ( - surf_usm_h%vsws(m) ) & 499 ) * ddzw(k) * drho_air(k) 463 tend(k,j,i) = tend(k,j,i) + ( - ( - surf_usm_h%vsws(m) ) ) * ddzw(k) * drho_air(k) 500 464 501 465 ENDDO … … 510 474 k = surf_def_h(2)%k(m) 511 475 512 tend(k,j,i) = tend(k,j,i) & 513 + ( - surf_def_h(2)%vsws(m) ) * ddzw(k) * drho_air(k) 476 tend(k,j,i) = tend(k,j,i) + ( - surf_def_h(2)%vsws(m) ) * ddzw(k) * drho_air(k) 514 477 ENDDO 515 478 ENDIF -
palm/trunk/SOURCE/diffusion_w.f90
r4360 r4583 1 1 !> @file diffusion_w.f90 2 !------------------------------------------------------------------------------ !2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. 4 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/>. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 8 ! 9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 12 ! 13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 1997-2020 Leibniz Universitaet Hannover 18 !------------------------------------------------------------------------------ !17 !--------------------------------------------------------------------------------------------------! 19 18 ! 20 19 ! Current revisions: … … 25 24 ! ----------------- 26 25 ! $Id$ 27 ! Introduction of wall_flags_total_0, which currently sets bits based on static 28 ! topography information used in wall_flags_static_0 29 ! 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4360 2020-01-07 11:25:50Z suehring 29 ! Introduction of wall_flags_total_0, which currently sets bits based on static topography 30 ! information used in wall_flags_static_0 31 ! 30 32 ! 4329 2019-12-10 15:46:36Z motisi 31 33 ! Renamed wall_flags_0 to wall_flags_static_0 32 ! 34 ! 33 35 ! 4182 2019-08-22 15:20:23Z scharf 34 36 ! Corrected "Former revisions" section 35 ! 37 ! 36 38 ! 3655 2019-01-07 16:51:22Z knoop 37 39 ! OpenACC port for SPEC … … 44 46 ! ------------ 45 47 !> Diffusion term of the w-component 46 !------------------------------------------------------------------------------ !48 !--------------------------------------------------------------------------------------------------! 47 49 MODULE diffusion_w_mod 48 50 49 51 50 52 PRIVATE … … 59 61 60 62 61 !------------------------------------------------------------------------------ !63 !--------------------------------------------------------------------------------------------------! 62 64 ! Description: 63 65 ! ------------ 64 66 !> Call for all grid points 65 !------------------------------------------------------------------------------ !67 !--------------------------------------------------------------------------------------------------! 66 68 SUBROUTINE diffusion_w 67 69 68 USE arrays_3d, &69 ONLY : ddzu, ddzw, km, tend, u, v, w, drho_air_zw, rho_air70 71 USE grid_variables, &70 USE arrays_3d, & 71 ONLY : ddzu, ddzw, drho_air_zw, km, rho_air, tend, u, v, w 72 73 USE grid_variables, & 72 74 ONLY : ddx, ddy 73 74 USE indices, &75 76 USE indices, & 75 77 ONLY : nxl, nxr, nyn, nys, nzb, nzt, wall_flags_total_0 76 78 77 79 USE kinds 78 80 79 USE surface_mod, &81 USE surface_mod, & 80 82 ONLY : surf_def_v, surf_lsm_v, surf_usm_v 81 83 … … 89 91 INTEGER(iwp) :: surf_e !< End index of surface elements at (j,i)-gridpoint 90 92 INTEGER(iwp) :: surf_s !< Start index of surface elements at (j,i)-gridpoint 91 93 92 94 REAL(wp) :: flag !< flag to mask topography grid points 93 95 REAL(wp) :: kmxm !< diffusion coefficient on leftward side of the w-gridbox - interpolated onto xu-y grid … … 95 97 REAL(wp) :: kmym !< diffusion coefficient on southward side of the w-gridbox - interpolated onto x-yv grid 96 98 REAL(wp) :: kmyp !< diffusion coefficient on northward side of the w-gridbox - interpolated onto x-yv grid 99 REAL(wp) :: mask_east !< flag to mask vertical wall east of the grid point 100 REAL(wp) :: mask_north !< flag to mask vertical wall north of the grid point 101 REAL(wp) :: mask_south !< flag to mask vertical wall south of the grid point 97 102 REAL(wp) :: mask_west !< flag to mask vertical wall west of the grid point 98 REAL(wp) :: mask_east !< flag to mask vertical wall east of the grid point99 REAL(wp) :: mask_south !< flag to mask vertical wall south of the grid point100 REAL(wp) :: mask_north !< flag to mask vertical wall north of the grid point101 103 102 104 … … 116 118 DO k = nzb+1, nzt-1 117 119 ! 118 !-- Predetermine flag to mask topography and wall-bounded grid points. 119 flag = MERGE( 1.0_wp, 0.0_wp, & 120 BTEST( wall_flags_total_0(k,j,i), 3 ) ) 121 mask_east = MERGE( 1.0_wp, 0.0_wp, & 122 BTEST( wall_flags_total_0(k,j,i+1), 3 ) ) 123 mask_west = MERGE( 1.0_wp, 0.0_wp, & 124 BTEST( wall_flags_total_0(k,j,i-1), 3 ) ) 125 mask_south = MERGE( 1.0_wp, 0.0_wp, & 126 BTEST( wall_flags_total_0(k,j-1,i), 3 ) ) 127 mask_north = MERGE( 1.0_wp, 0.0_wp, & 128 BTEST( wall_flags_total_0(k,j+1,i), 3 ) ) 120 !-- Predetermine flag to mask topography and wall-bounded grid points. 121 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) ) 122 mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i+1), 3 ) ) 123 mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i-1), 3 ) ) 124 mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j-1,i), 3 ) ) 125 mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j+1,i), 3 ) ) 129 126 ! 130 127 !-- Interpolate eddy diffusivities on staggered gridpoints 131 kmxp = 0.25_wp * ( km(k,j,i) + km(k,j,i+1) + &128 kmxp = 0.25_wp * ( km(k,j,i) + km(k,j,i+1) + & 132 129 km(k+1,j,i) + km(k+1,j,i+1) ) 133 kmxm = 0.25_wp * ( km(k,j,i) + km(k,j,i-1) + &130 kmxm = 0.25_wp * ( km(k,j,i) + km(k,j,i-1) + & 134 131 km(k+1,j,i) + km(k+1,j,i-1) ) 135 kmyp = 0.25_wp * ( km(k,j,i) + km(k+1,j,i) + &132 kmyp = 0.25_wp * ( km(k,j,i) + km(k+1,j,i) + & 136 133 km(k,j+1,i) + km(k+1,j+1,i) ) 137 kmym = 0.25_wp * ( km(k,j,i) + km(k+1,j,i) + &134 kmym = 0.25_wp * ( km(k,j,i) + km(k+1,j,i) + & 138 135 km(k,j-1,i) + km(k+1,j-1,i) ) 139 136 140 tend(k,j,i) = tend(k,j,i) & 141 + ( mask_east * kmxp * ( & 142 ( w(k,j,i+1) - w(k,j,i) ) * ddx & 143 + ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & 144 ) & 145 - mask_west * kmxm * ( & 146 ( w(k,j,i) - w(k,j,i-1) ) * ddx & 147 + ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & 148 ) & 149 ) * ddx * flag & 150 + ( mask_north * kmyp * ( & 151 ( w(k,j+1,i) - w(k,j,i) ) * ddy & 152 + ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & 153 ) & 154 - mask_south * kmym * ( & 155 ( w(k,j,i) - w(k,j-1,i) ) * ddy & 156 + ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & 157 ) & 158 ) * ddy * flag & 159 + 2.0_wp * ( & 160 km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & 161 * rho_air(k+1) & 162 - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & 163 * rho_air(k) & 164 ) * ddzu(k+1) * drho_air_zw(k) * flag 165 ENDDO 166 167 ! 168 !-- Add horizontal momentum flux v'w' at north- (l=0) and south-facing (l=1) 169 !-- surfaces. Note, in the the flat case, loops won't be entered as 170 !-- start_index > end_index. Furtermore, note, no vertical natural surfaces 171 !-- so far. 137 tend(k,j,i) = tend(k,j,i) & 138 + ( mask_east * kmxp * ( & 139 ( w(k,j,i+1) - w(k,j,i) ) * ddx & 140 + ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & 141 ) & 142 - mask_west * kmxm * ( & 143 ( w(k,j,i) - w(k,j,i-1) ) * ddx & 144 + ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & 145 ) & 146 ) * ddx * flag & 147 + ( mask_north * kmyp * ( & 148 ( w(k,j+1,i) - w(k,j,i) ) * ddy & 149 + ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & 150 ) & 151 - mask_south * kmym * ( & 152 ( w(k,j,i) - w(k,j-1,i) ) * ddy & 153 + ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & 154 ) & 155 ) * ddy * flag & 156 + 2.0_wp * ( & 157 km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & 158 * rho_air(k+1) & 159 - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & 160 * rho_air(k) & 161 ) * ddzu(k+1) * drho_air_zw(k) * flag 162 ENDDO 163 164 ! 165 !-- Add horizontal momentum flux v'w' at north- (l=0) and south-facing (l=1) surfaces. 166 !-- Note, in the the flat case, loops won't be entered as start_index > end_index. 167 !-- Furtermore, note, no vertical natural surfaces so far. 172 168 !-- Default-type surfaces 173 169 DO l = 0, 1 … … 176 172 DO m = surf_s, surf_e 177 173 k = surf_def_v(l)%k(m) 178 tend(k,j,i) = tend(k,j,i) + & 179 surf_def_v(l)%mom_flux_w(m) * ddy 180 ENDDO 174 tend(k,j,i) = tend(k,j,i) + surf_def_v(l)%mom_flux_w(m) * ddy 175 ENDDO 181 176 ENDDO 182 177 ! … … 187 182 DO m = surf_s, surf_e 188 183 k = surf_lsm_v(l)%k(m) 189 tend(k,j,i) = tend(k,j,i) + & 190 surf_lsm_v(l)%mom_flux_w(m) * ddy 191 ENDDO 184 tend(k,j,i) = tend(k,j,i) + surf_lsm_v(l)%mom_flux_w(m) * ddy 185 ENDDO 192 186 ENDDO 193 187 ! … … 198 192 DO m = surf_s, surf_e 199 193 k = surf_usm_v(l)%k(m) 200 tend(k,j,i) = tend(k,j,i) + & 201 surf_usm_v(l)%mom_flux_w(m) * ddy 202 ENDDO 203 ENDDO 204 ! 205 !-- Add horizontal momentum flux u'w' at east- (l=2) and west-facing (l=3) 206 !-- surface. 194 tend(k,j,i) = tend(k,j,i) + surf_usm_v(l)%mom_flux_w(m) * ddy 195 ENDDO 196 ENDDO 197 ! 198 !-- Add horizontal momentum flux u'w' at east- (l=2) and west-facing (l=3) surface. 207 199 !-- Default-type surfaces 208 200 DO l = 2, 3 … … 211 203 DO m = surf_s, surf_e 212 204 k = surf_def_v(l)%k(m) 213 tend(k,j,i) = tend(k,j,i) + & 214 surf_def_v(l)%mom_flux_w(m) * ddx 215 ENDDO 205 tend(k,j,i) = tend(k,j,i) + surf_def_v(l)%mom_flux_w(m) * ddx 206 ENDDO 216 207 ENDDO 217 208 ! … … 222 213 DO m = surf_s, surf_e 223 214 k = surf_lsm_v(l)%k(m) 224 tend(k,j,i) = tend(k,j,i) + & 225 surf_lsm_v(l)%mom_flux_w(m) * ddx 226 ENDDO 215 tend(k,j,i) = tend(k,j,i) + surf_lsm_v(l)%mom_flux_w(m) * ddx 216 ENDDO 227 217 ENDDO 228 218 ! … … 233 223 DO m = surf_s, surf_e 234 224 k = surf_usm_v(l)%k(m) 235 tend(k,j,i) = tend(k,j,i) + & 236 surf_usm_v(l)%mom_flux_w(m) * ddx 237 ENDDO 225 tend(k,j,i) = tend(k,j,i) + surf_usm_v(l)%mom_flux_w(m) * ddx 226 ENDDO 238 227 ENDDO 239 228 … … 244 233 245 234 246 !------------------------------------------------------------------------------ !235 !--------------------------------------------------------------------------------------------------! 247 236 ! Description: 248 237 ! ------------ 249 238 !> Call for grid point i,j 250 !------------------------------------------------------------------------------ !239 !--------------------------------------------------------------------------------------------------! 251 240 SUBROUTINE diffusion_w_ij( i, j ) 252 241 253 USE arrays_3d, &254 ONLY : ddzu, ddzw, km, tend, u, v, w, drho_air_zw, rho_air255 256 USE grid_variables, &242 USE arrays_3d, & 243 ONLY : ddzu, ddzw, drho_air_zw, km, rho_air, tend, u, v, w 244 245 USE grid_variables, & 257 246 ONLY : ddx, ddy 258 259 USE indices, &247 248 USE indices, & 260 249 ONLY : nzb, nzt, wall_flags_total_0 261 250 262 251 USE kinds 263 252 264 USE surface_mod, &253 USE surface_mod, & 265 254 ONLY : surf_def_v, surf_lsm_v, surf_usm_v 266 255 … … 275 264 INTEGER(iwp) :: surf_e !< End index of surface elements at (j,i)-gridpoint 276 265 INTEGER(iwp) :: surf_s !< Start index of surface elements at (j,i)-gridpoint 277 266 278 267 REAL(wp) :: flag !< flag to mask topography grid points 279 268 REAL(wp) :: kmxm !< diffusion coefficient on leftward side of the w-gridbox - interpolated onto xu-y grid … … 281 270 REAL(wp) :: kmym !< diffusion coefficient on southward side of the w-gridbox - interpolated onto x-yv grid 282 271 REAL(wp) :: kmyp !< diffusion coefficient on northward side of the w-gridbox - interpolated onto x-yv grid 272 REAL(wp) :: mask_east !< flag to mask vertical wall east of the grid point 273 REAL(wp) :: mask_north !< flag to mask vertical wall north of the grid point 274 REAL(wp) :: mask_south !< flag to mask vertical wall south of the grid point 283 275 REAL(wp) :: mask_west !< flag to mask vertical wall west of the grid point 284 REAL(wp) :: mask_east !< flag to mask vertical wall east of the grid point285 REAL(wp) :: mask_south !< flag to mask vertical wall south of the grid point286 REAL(wp) :: mask_north !< flag to mask vertical wall north of the grid point287 276 288 277 289 278 DO k = nzb+1, nzt-1 290 279 ! 291 !-- Predetermine flag to mask topography and wall-bounded grid points. 292 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) ) 280 !-- Predetermine flag to mask topography and wall-bounded grid points. 281 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) ) 293 282 mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i+1), 3 ) ) 294 283 mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i-1), 3 ) ) … … 302 291 kmym = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) 303 292 304 tend(k,j,i) = tend(k,j,i) & 305 + ( mask_east * kmxp * ( & 306 ( w(k,j,i+1) - w(k,j,i) ) * ddx & 307 + ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & 308 ) & 309 - mask_west * kmxm * ( & 310 ( w(k,j,i) - w(k,j,i-1) ) * ddx & 311 + ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & 312 ) & 313 ) * ddx * flag & 314 + ( mask_north * kmyp * ( & 315 ( w(k,j+1,i) - w(k,j,i) ) * ddy & 316 + ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & 317 ) & 318 - mask_south * kmym * ( & 319 ( w(k,j,i) - w(k,j-1,i) ) * ddy & 320 + ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & 321 ) & 322 ) * ddy * flag & 323 + 2.0_wp * ( & 324 km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & 325 * rho_air(k+1) & 326 - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & 327 * rho_air(k) & 328 ) * ddzu(k+1) * drho_air_zw(k) * flag 329 ENDDO 330 ! 331 !-- Add horizontal momentum flux v'w' at north- (l=0) and south-facing (l=1) 332 !-- surfaces. Note, in the the flat case, loops won't be entered as 333 !-- start_index > end_index. Furtermore, note, no vertical natural surfaces 334 !-- so far. 293 tend(k,j,i) = tend(k,j,i) & 294 + ( mask_east * kmxp * ( & 295 ( w(k,j,i+1) - w(k,j,i) ) * ddx & 296 + ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & 297 ) & 298 - mask_west * kmxm * ( & 299 ( w(k,j,i) - w(k,j,i-1) ) * ddx & 300 + ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & 301 ) & 302 ) * ddx * flag & 303 + ( mask_north * kmyp * ( & 304 ( w(k,j+1,i) - w(k,j,i) ) * ddy & 305 + ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & 306 ) & 307 - mask_south * kmym * ( & 308 ( w(k,j,i) - w(k,j-1,i) ) * ddy & 309 + ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & 310 ) & 311 ) * ddy * flag & 312 + 2.0_wp * ( & 313 km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & 314 * rho_air(k+1) & 315 - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & 316 * rho_air(k) & 317 ) * ddzu(k+1) * drho_air_zw(k) * flag 318 ENDDO 319 ! 320 !-- Add horizontal momentum flux v'w' at north- (l=0) and south-facing (l=1) surfaces. Note, in 321 !-- the the flat case, loops won't be entered as start_index > end_index. Furtermore, note, no 322 !-- vertical natural surfaces so far. 335 323 !-- Default-type surfaces 336 324 DO l = 0, 1 … … 339 327 DO m = surf_s, surf_e 340 328 k = surf_def_v(l)%k(m) 341 tend(k,j,i) = tend(k,j,i) + & 342 surf_def_v(l)%mom_flux_w(m) * ddy 343 ENDDO 329 tend(k,j,i) = tend(k,j,i) + surf_def_v(l)%mom_flux_w(m) * ddy 330 ENDDO 344 331 ENDDO 345 332 ! … … 350 337 DO m = surf_s, surf_e 351 338 k = surf_lsm_v(l)%k(m) 352 tend(k,j,i) = tend(k,j,i) + & 353 surf_lsm_v(l)%mom_flux_w(m) * ddy 354 ENDDO 339 tend(k,j,i) = tend(k,j,i) + surf_lsm_v(l)%mom_flux_w(m) * ddy 340 ENDDO 355 341 ENDDO 356 342 ! … … 361 347 DO m = surf_s, surf_e 362 348 k = surf_usm_v(l)%k(m) 363 tend(k,j,i) = tend(k,j,i) + & 364 surf_usm_v(l)%mom_flux_w(m) * ddy 365 ENDDO 366 ENDDO 367 ! 368 !-- Add horizontal momentum flux u'w' at east- (l=2) and west-facing (l=3) 369 !-- surfaces. 349 tend(k,j,i) = tend(k,j,i) + surf_usm_v(l)%mom_flux_w(m) * ddy 350 ENDDO 351 ENDDO 352 ! 353 !-- Add horizontal momentum flux u'w' at east- (l=2) and west-facing (l=3) surfaces. 370 354 !-- Default-type surfaces 371 355 DO l = 2, 3 … … 374 358 DO m = surf_s, surf_e 375 359 k = surf_def_v(l)%k(m) 376 tend(k,j,i) = tend(k,j,i) + & 377 surf_def_v(l)%mom_flux_w(m) * ddx 378 ENDDO 360 tend(k,j,i) = tend(k,j,i) + surf_def_v(l)%mom_flux_w(m) * ddx 361 ENDDO 379 362 ENDDO 380 363 ! … … 385 368 DO m = surf_s, surf_e 386 369 k = surf_lsm_v(l)%k(m) 387 tend(k,j,i) = tend(k,j,i) + & 388 surf_lsm_v(l)%mom_flux_w(m) * ddx 389 ENDDO 370 tend(k,j,i) = tend(k,j,i) + surf_lsm_v(l)%mom_flux_w(m) * ddx 371 ENDDO 390 372 ENDDO 391 373 ! … … 396 378 DO m = surf_s, surf_e 397 379 k = surf_usm_v(l)%k(m) 398 tend(k,j,i) = tend(k,j,i) + & 399 surf_usm_v(l)%mom_flux_w(m) * ddx 400 ENDDO 380 tend(k,j,i) = tend(k,j,i) + surf_usm_v(l)%mom_flux_w(m) * ddx 381 ENDDO 401 382 ENDDO 402 383 -
palm/trunk/SOURCE/disturb_field.f90
r4457 r4583 1 1 !> @file disturb_field.f90 2 !------------------------------------------------------------------------------ !2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. 4 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/>. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 8 ! 9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 12 ! 13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 1997-2020 Leibniz Universitaet Hannover 18 !------------------------------------------------------------------------------ !17 !--------------------------------------------------------------------------------------------------! 19 18 ! 20 19 ! Current revisions: … … 25 24 ! ----------------- 26 25 ! $Id$ 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4457 2020-03-11 14:20:43Z raasch 27 29 ! use statement for exchange horiz added 28 ! 30 ! 29 31 ! 4360 2020-01-07 11:25:50Z suehring 30 ! Introduction of wall_flags_total_0, which currently sets bits based on static 31 ! topographyinformation used in wall_flags_static_032 ! 32 ! Introduction of wall_flags_total_0, which currently sets bits based on static topography 33 ! information used in wall_flags_static_0 34 ! 33 35 ! 4329 2019-12-10 15:46:36Z motisi 34 36 ! Renamed wall_flags_0 to wall_flags_static_0 35 ! 37 ! 36 38 ! 4237 2019-09-25 11:33:42Z knoop 37 39 ! Added missing OpenMP directives 38 ! 40 ! 39 41 ! 4182 2019-08-22 15:20:23Z scharf 40 42 ! Corrected "Former revisions" section 41 ! 43 ! 42 44 ! 3849 2019-04-01 16:35:16Z knoop 43 45 ! Corrected "Former revisions" section … … 50 52 ! ------------ 51 53 !> Imposing a random perturbation on a 3D-array. 52 !> On parallel computers, the random number generator is as well called for all 53 !> gridpoints of the total domain to ensure, regardless of the number of PEs 54 !> used, that the elements of the array have the same values in the same 55 !> order in every case. The perturbation range is steered by dist_range. 56 !------------------------------------------------------------------------------! 54 !> On parallel computers, the random number generator is as well called for all gridpoints of the 55 !> total domain to ensure, regardless of the number of PEs used, that the elements of the array have 56 !> the same values in the same order in every case. The perturbation range is steered by dist_range. 57 !--------------------------------------------------------------------------------------------------! 57 58 SUBROUTINE disturb_field( var_char, dist1, field ) 58 59 60 USE control_parameters, & 61 ONLY: dist_nxl, dist_nxr, dist_nyn, dist_nys, dist_range, & 62 disturbance_amplitude, disturbance_created, & 63 disturbance_level_ind_b, disturbance_level_ind_t, iran, & 59 60 61 USE control_parameters, & 62 ONLY: dist_nxl, dist_nxr, dist_nyn, dist_nys, dist_range, disturbance_amplitude, & 63 disturbance_created, disturbance_level_ind_b, disturbance_level_ind_t, iran, & 64 64 random_generator, topography 65 66 USE cpulog, &65 66 USE cpulog, & 67 67 ONLY: cpu_log, log_point 68 69 USE exchange_horiz_mod, &68 69 USE exchange_horiz_mod, & 70 70 ONLY: exchange_horiz 71 71 72 USE indices, &73 ONLY: nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzb_max, &74 nzt,wall_flags_total_075 72 USE indices, & 73 ONLY: nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzb_max, nzt, & 74 wall_flags_total_0 75 76 76 USE kinds 77 78 USE random_function_mod, &77 78 USE random_function_mod, & 79 79 ONLY: random_function 80 81 USE random_generator_parallel, & 82 ONLY: random_number_parallel, random_seed_parallel, random_dummy, & 83 seq_random_array 80 81 USE random_generator_parallel, & 82 ONLY: random_number_parallel, random_seed_parallel, random_dummy, seq_random_array 84 83 85 84 IMPLICIT NONE … … 87 86 CHARACTER (LEN = *) :: var_char !< flag to distinguish betwenn u- and v-component 88 87 89 INTEGER(iwp) :: flag_nr !< number of respective flag for u- or v-grid 88 INTEGER(iwp) :: flag_nr !< number of respective flag for u- or v-grid 90 89 INTEGER(iwp) :: i !< index variable 91 90 INTEGER(iwp) :: j !< index variable … … 93 92 94 93 REAL(wp) :: randomnumber !< 95 94 96 95 REAL(wp) :: dist1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) !< 97 96 REAL(wp) :: field(nzb:nzt+1,nysg:nyng,nxlg:nxrg) !< 98 97 99 98 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: dist2 !< 100 99 … … 105 104 flag_nr = MERGE( 20, 21, TRIM(var_char) == 'u' ) 106 105 ! 107 !-- Create an additional temporary array and initialize the arrays needed 108 !-- to store the disturbance 106 !-- Create an additional temporary array and initialize the arrays needed to store the disturbance 109 107 ALLOCATE( dist2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 110 108 !$ACC DATA CREATE(dist2(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) … … 123 121 DO j = dist_nys(dist_range), dist_nyn(dist_range) 124 122 DO k = disturbance_level_ind_b, disturbance_level_ind_t 125 randomnumber = 3.0_wp * disturbance_amplitude * & 126 ( random_function( iran ) - 0.5_wp ) 127 IF ( nxl <= i .AND. nxr >= i .AND. nys <= j .AND. & 128 nyn >= j ) & 129 THEN 123 randomnumber = 3.0_wp * disturbance_amplitude * ( random_function( iran ) - 0.5_wp ) 124 IF ( nxl <= i .AND. nxr >= i .AND. nys <= j .AND. nyn >= j ) THEN 130 125 dist1(k,j,i) = randomnumber 131 126 ENDIF … … 139 134 DO k = disturbance_level_ind_b, disturbance_level_ind_t 140 135 CALL random_number_parallel( random_dummy ) 141 randomnumber = 3.0_wp * disturbance_amplitude * & 142 ( random_dummy - 0.5_wp ) 143 IF ( nxl <= i .AND. nxr >= i .AND. nys <= j .AND. & 144 nyn >= j ) & 145 THEN 136 randomnumber = 3.0_wp * disturbance_amplitude * ( random_dummy - 0.5_wp ) 137 IF ( nxl <= i .AND. nxr >= i .AND. nys <= j .AND. nyn >= j ) THEN 146 138 dist1(k,j,i) = randomnumber 147 139 ENDIF … … 155 147 DO k = disturbance_level_ind_b, disturbance_level_ind_t 156 148 CALL RANDOM_NUMBER( randomnumber ) 157 randomnumber = 3.0_wp * disturbance_amplitude * & 158 ( randomnumber - 0.5_wp ) 159 IF ( nxl <= i .AND. nxr >= i .AND. nys <= j .AND. nyn >= j ) & 160 THEN 149 randomnumber = 3.0_wp * disturbance_amplitude * ( randomnumber - 0.5_wp ) 150 IF ( nxl <= i .AND. nxr >= i .AND. nys <= j .AND. nyn >= j ) THEN 161 151 dist1(k,j,i) = randomnumber 162 152 ENDIF … … 177 167 ! 178 168 !-- Applying the Shuman filter in order to smooth the perturbations. 179 !-- Neighboured grid points in all three directions are used for the 180 !-- filter operation. 181 !-- Loop has been splitted to make runs reproducible on HLRN systems using 182 !-- compiler option -O3 169 !-- Neighboured grid points in all three directions are used for the filter operation. 170 !-- Loop has been splitted to make runs reproducible on HLRN systems using compiler option -O3 183 171 !$ACC PARALLEL LOOP COLLAPSE(2) PRIVATE(i, j, k) PRESENT(dist1, dist2) 184 172 !$OMP PARALLEL DO PRIVATE(i, j, k) … … 186 174 DO j = nys, nyn 187 175 DO k = disturbance_level_ind_b-1, disturbance_level_ind_t+1 188 dist2(k,j,i) = ( dist1(k,j,i-1) + dist1(k,j,i+1) &189 + dist1(k,j+1,i) + dist1(k+1,j,i) &176 dist2(k,j,i) = ( dist1(k,j,i-1) + dist1(k,j,i+1) & 177 + dist1(k,j+1,i) + dist1(k+1,j,i) & 190 178 ) / 12.0_wp 191 179 ENDDO 192 180 DO k = disturbance_level_ind_b-1, disturbance_level_ind_t+1 193 dist2(k,j,i) = dist2(k,j,i) + ( dist1(k,j-1,i) + dist1(k-1,j,i) &194 + 6.0_wp * dist1(k,j,i) &195 ) / 12.0_wp181 dist2(k,j,i) = dist2(k,j,i) + ( dist1(k,j-1,i) + dist1(k-1,j,i) & 182 + 6.0_wp * dist1(k,j,i) & 183 ) / 12.0_wp 196 184 ENDDO 197 185 ENDDO … … 208 196 DO j = nys, nyn 209 197 DO k = disturbance_level_ind_b-2, disturbance_level_ind_t+2 210 dist1(k,j,i) = ( dist2(k,j,i-1) + dist2(k,j,i+1) + dist2(k,j-1,i) &211 + dist2(k,j+1,i) + dist2(k+1,j,i) + dist2(k-1,j,i) &212 + 6.0_wp * dist2(k,j,i) &198 dist1(k,j,i) = ( dist2(k,j,i-1) + dist2(k,j,i+1) + dist2(k,j-1,i) & 199 + dist2(k,j+1,i) + dist2(k+1,j,i) + dist2(k-1,j,i) & 200 + 6.0_wp * dist2(k,j,i) & 213 201 ) / 12.0_wp 214 202 ENDDO … … 219 207 220 208 ! 221 !-- Remove perturbations below topography (including one gridpoint above it 222 !-- in order to allow for larger timesteps at the beginning of the simulation 223 !-- (diffusion criterion)) 209 !-- Remove perturbations below topography (including one gridpoint above it in order to allow for 210 !-- larger timesteps at the beginning of the simulation (diffusion criterion)) 224 211 IF ( TRIM( topography ) /= 'flat' ) THEN 225 212 DO i = nxlg, nxrg 226 213 DO j = nysg, nyng 227 214 DO k = nzb, nzb_max 228 dist1(k,j,i) = MERGE( dist1(k,j,i), 0.0_wp, &229 BTEST( wall_flags_total_0(k,j,i), flag_nr ) &215 dist1(k,j,i) = MERGE( dist1(k,j,i), 0.0_wp, & 216 BTEST( wall_flags_total_0(k,j,i), flag_nr ) & 230 217 ) 231 218 ENDDO
Note: See TracChangeset
for help on using the changeset viewer.