Changeset 2945 for palm/trunk


Ignore:
Timestamp:
Apr 4, 2018 4:27:14 PM (6 years ago)
Author:
suehring
Message:

Bugfix in parallelization of synthetic turbulence generator; revision in control mimic of synthetic turbulence generator in case of RAN-LES nesting; checks for dynamic input file added; control mimic for topography input slightly revised.

Location:
palm/trunk/SOURCE
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/netcdf_data_input_mod.f90

    r2938 r2945  
    2525! -----------------
    2626! $Id$
     27! - Mimic for topography input slightly revised, in order to enable consistency
     28!   checks
     29! - Add checks for dimensions in dynamic input file and move already existing
     30!   checks
     31!
     32! 2938 2018-03-27 15:52:42Z suehring
    2733! Initial read of geostrophic wind components from dynamic driver.
    2834!
     
    104110       INTEGER(iwp) :: nx                             !< dimension length in x
    105111       INTEGER(iwp) :: ny                             !< dimension length in y
     112       INTEGER(iwp) :: nz                             !< dimension length in z
    106113       REAL(wp), DIMENSION(:), ALLOCATABLE :: x       !< dimension array in x
    107114       REAL(wp), DIMENSION(:), ALLOCATABLE :: y       !< dimension array in y
     115       REAL(wp), DIMENSION(:), ALLOCATABLE :: z       !< dimension array in z
    108116    END TYPE dims_xy
    109117!
     
    316324!
    317325!-- Define variables
    318     TYPE(dims_xy)    ::  dim_static !< data structure for x, y-dimension in static input file
     326    TYPE(dims_xy)    ::  dim_static  !< data structure for x, y-dimension in static input file
    319327
    320328    TYPE(force_type) ::  force     !< data structure for data input at lateral and top boundaries (provided by Inifor) 
     
    16721680       REAL(wp) ::  dum           !< dummy variable to skip columns while reading topography file   
    16731681
    1674        IF ( TRIM( topography ) /= 'read_from_file' )  RETURN
    16751682
    16761683       DO  ii = 0, io_blocks-1
     
    16951702                CALL inquire_variable_names( id_topo, var_names )
    16961703!
    1697 !--             Read x, y - dimensions
     1704!--             Read x, y - dimensions. Only required for consistency checks.
    16981705                CALL get_dimension_length( id_topo, dim_static%nx, 'x' )
    16991706                CALL get_dimension_length( id_topo, dim_static%ny, 'y' )
     
    18301837!
    18311838!--          ASCII input
    1832              ELSE
     1839             ELSEIF ( TRIM( topography ) == 'read_from_file' )  THEN
    18331840
    18341841                OPEN( 90, FILE='TOPOGRAPHY_DATA'//TRIM( coupling_char ),       &
     
    20132020             CALL get_dimension_length( id_dynamic, init_3d%ny,  'y'  )
    20142021             CALL get_dimension_length( id_dynamic, init_3d%nyv, 'yv' )
    2015 !
    2016 !--          Check for correct horizontal dimension. Please note, u- and v-grid
    2017 !--          hase 1 grid point less on Inifor grid.
    2018              IF ( init_3d%nx-1 /= nx  .OR.  init_3d%nxu-1 /= nx - 1  .OR.      &
    2019                   init_3d%ny-1 /= ny  .OR.  init_3d%nyv-1 /= ny - 1 )  THEN
    2020                 message_string = 'Number of inifor grid points does not '  //  &
    2021                                  'match the number of numeric grid points.'
    2022                 CALL message( 'netcdf_data_input_mod', 'NDI003', 1, 2, 0, 6, 0 )
    2023              ENDIF
    20242022!
    20252023!--          Read vertical dimensions. Later, these are required for eventual
     
    23762374
    23772375       USE indices,                                                            &
    2378            ONLY:  nx, nxl, nxlu, nxr, ny, nyn, nys, nysv, nzb, nzt
     2376           ONLY:  nxl, nxlu, nxr, nyn, nys, nysv, nzb, nzt
    23792377
    23802378       IMPLICIT NONE
     
    27802778           ONLY:  initializing_actions, forcing, message_string
    27812779
     2780       USE indices,                                                            &
     2781           ONLY:  nx, ny, nz
     2782
    27822783       IMPLICIT NONE
    27832784
     
    27982799                           TRIM( coupling_char )
    27992800          CALL message( 'netcdf_data_input_mod', 'NDI010', 1, 2, 0, 6, 0 )
     2801       ENDIF
     2802!
     2803!--    Check for correct horizontal and vertical dimension.
     2804!--    Please note, u- and v-grid has 1 grid point less on Inifor grid.
     2805       IF ( init_3d%nx-1 /= nx  .OR.  init_3d%nxu-1 /= nx - 1  .OR.            &
     2806            init_3d%ny-1 /= ny  .OR.  init_3d%nyv-1 /= ny - 1 )  THEN
     2807          message_string = 'Number of inifor horizontal grid points does '  // &
     2808                           'not match the number of numeric grid points.'
     2809          CALL message( 'netcdf_data_input_mod', 'NDI003', 1, 2, 0, 6, 0 )
     2810       ENDIF
     2811
     2812       IF ( init_3d%nzu /= nz )  THEN
     2813          message_string = 'Number of inifor vertical grid points does '  // &
     2814                           'not match the number of numeric grid points.'
     2815          CALL message( 'netcdf_data_input_mod', 'NDI003', 1, 2, 0, 6, 0 )
    28002816       ENDIF
    28012817
  • palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90

    r2938 r2945  
    2525! -----------------
    2626! $Id$
     27! - Bugfix in parallelization of synthetic turbulence generator in case the
     28!   z-dimension is not an integral divisor of the number of processors along 
     29!   the x- and y-dimension
     30! - Revision in control mimic in case of RAN-LES nesting
     31!
     32! 2938 2018-03-27 15:52:42Z suehring
    2733! Apply turbulence generator at all non-cyclic lateral boundaries in case of
    2834! realistic Inifor large-scale forcing or RANS-LES nesting
     
    8793!>       enable cyclic_fill
    8894!>       implement turbulence generation for e and pt
     95!> @todo Input of height-constant length scales via namelist
    8996!> @note <Enter notes on the module>
    9097!> @bug  Height information from input file is not used. Profiles from input
     
    388395
    389396    USE control_parameters,                                                    &
    390         ONLY:  coupling_char, dz, e_init, forcing, nest_domain
     397        ONLY:  coupling_char, dz, e_init, forcing, nest_domain, rans_mode
    391398
    392399    USE grid_variables,                                                        &
     
    395402    USE indices,                                                               &
    396403        ONLY:  nz
     404
     405    USE pmc_interface,                                                         &
     406        ONLY : rans_mode_parent
    397407
    398408
     
    411421    INTEGER(iwp) :: newtype                  !< dummy MPI type
    412422    INTEGER(iwp) :: realsize                 !< size of REAL variables
    413     INTEGER(iwp) :: nnz                      !< increment used to determine processor decomposition of z-axis along x and y direction 
    414423    INTEGER(iwp) :: nseed                    !< dimension of random number seed
    415424    INTEGER(iwp) :: startseed = 1234567890   !< start seed for random number generator
     
    431440    REAL(wp) :: lwy     !< length scale for w in y direction
    432441    REAL(wp) :: lwz     !< length scale for w in z direction
     442    REAL(wp) :: nnz     !< increment used to determine processor decomposition of z-axis along x and y direction 
    433443    REAL(wp) :: zz      !< height
    434444
     
    463473!-- Determine processor decomposition of z-axis along x- and y-direction
    464474    nnz = nz / pdims(1)
    465     nzb_x_stg = 1 + myidx * nnz
    466     nzt_x_stg = ( myidx + 1 ) * nnz
     475    nzb_x_stg = 1 + myidx * INT( nnz )
     476    nzt_x_stg = ( myidx + 1 ) * INT( nnz )
    467477
    468478    IF ( MOD( nz , pdims(1) ) /= 0  .AND.  myidx == id_stg_right )             & 
    469        nzt_x_stg = myidx * nnz + MOD( nz , pdims(1) )
    470 
    471     IF ( forcing  .OR.  nest_domain )  THEN
     479       nzt_x_stg = nzt_x_stg + myidx * ( nnz - INT( nnz ) )
     480!        nzt_x_stg = myidx * nnz + MOD( nz , pdims(1) )
     481
     482    IF ( forcing  .OR.  ( nest_domain .AND.  rans_mode_parent  .AND.           &
     483                   .NOT.  rans_mode ) )  THEN
    472484       nnz = nz / pdims(2)
    473        nzb_y_stg = 1 + myidy * nnz
    474        nzt_y_stg = ( myidy + 1 ) * nnz
    475 
    476        IF ( MOD( nz , pdims(2) ) /= 0  .AND.  myidy == id_stg_north )          & 
    477           nzt_y_stg = myidy * nnz + MOD( nz , pdims(2) )
     485       nzb_y_stg = 1 + myidy * INT( nnz )
     486       nzt_y_stg = ( myidy + 1 ) * INT( nnz )
     487
     488       IF ( MOD( nz , pdims(2) ) /= 0  .AND.  myidy == id_stg_north )          &
     489          nzt_y_stg = nzt_y_stg + myidy * ( nnz - INT( nnz ) ) 
     490!           nzt_y_stg = myidy * nnz + MOD( nz , pdims(2) )
    478491    ENDIF
    479492
     
    494507
    495508    ! stg_type_yz_small: yz-slice with vertical bounds nzb_x_stg:nzt_x_stg+1
    496     CALL MPI_TYPE_CREATE_SUBARRAY( 2, [nzt_x_stg-nzb_x_stg+2,nyng-nysg+1],             &
     509    CALL MPI_TYPE_CREATE_SUBARRAY( 2, [nzt_x_stg-nzb_x_stg+2,nyng-nysg+1],     &
    497510            [1,nyng-nysg+1], [0,0], MPI_ORDER_FORTRAN, MPI_REAL, newtype, ierr )
    498511    CALL MPI_TYPE_CREATE_RESIZED( newtype, tob, extent, stg_type_yz_small, ierr )
     
    513526!-- layer
    514527!-- stg_type_xz: xz-slice with vertical bounds nzb:nzt+1
    515     IF ( forcing  .OR.  nest_domain)  THEN
    516        CALL MPI_TYPE_CREATE_SUBARRAY( 2, [nzt-nzb+2,nxrg-nxlg+1],                 &
     528    IF ( forcing  .OR.  ( nest_domain .AND.  rans_mode_parent  .AND.           &
     529                   .NOT.  rans_mode ) )  THEN
     530       CALL MPI_TYPE_CREATE_SUBARRAY( 2, [nzt-nzb+2,nxrg-nxlg+1],              &
    517531               [1,nxrg-nxlg+1], [0,0], MPI_ORDER_FORTRAN, MPI_REAL, newtype, ierr )
    518532       CALL MPI_TYPE_CREATE_RESIZED( newtype, tob, extent, stg_type_xz, ierr )
     
    521535
    522536       ! stg_type_yz_small: xz-slice with vertical bounds nzb_x_stg:nzt_x_stg+1
    523        CALL MPI_TYPE_CREATE_SUBARRAY( 2, [nzt_y_stg-nzb_y_stg+2,nxrg-nxlg+1],             &
     537       CALL MPI_TYPE_CREATE_SUBARRAY( 2, [nzt_y_stg-nzb_y_stg+2,nxrg-nxlg+1],  &
    524538               [1,nxrg-nxlg+1], [0,0], MPI_ORDER_FORTRAN, MPI_REAL, newtype, ierr )
    525539       CALL MPI_TYPE_CREATE_RESIZED( newtype, tob, extent, stg_type_xz_small, ierr )
     
    600614!--    Set-up defaul length scales. Assume exponentially decreasing length
    601615!--    scales and isotropic turbulence.
    602 !--    Typical length (time) scales of 100 m (s) should be a goog compromise
     616!--    Typical length (time) scales of 100 m (s) should be a good compromise
    603617!--    between all stratrifications. Near-surface variances are fixed to
    604618!--    0.1 m2/s2, vertical fluxes are one order of magnitude smaller.
     
    9981012    USE control_parameters,                                                    &
    9991013        ONLY:  dt_3d, forcing, intermediate_timestep_count,  nest_domain,      &
    1000                simulated_time, volume_flow_initial
     1014               rans_mode, simulated_time, volume_flow_initial
    10011015
    10021016    USE grid_variables,                                                        &
     
    10081022    USE statistics,                                                            &
    10091023        ONLY:  weight_substep
     1024
     1025    USE pmc_interface,                                                         &
     1026        ONLY : rans_mode_parent
    10101027
    10111028
     
    10381055       CALL stg_generate_seed_yz( nwy, nwz, bwy, bwz, fw_yz, id_stg_left )
    10391056
    1040        IF ( forcing  .OR.  nest_domain )  THEN
     1057       IF ( forcing  .OR.  ( nest_domain .AND.  rans_mode_parent  .AND.        &
     1058                      .NOT.  rans_mode ) )  THEN
    10411059!
    10421060!--       Generate turbulence at right boundary
     
    10631081    CALL stg_generate_seed_yz( nwy, nwz, bwy, bwz, fwo_yz, id_stg_left )
    10641082
    1065     IF ( forcing  .OR.  nest_domain )  THEN
     1083    IF ( forcing  .OR.  ( nest_domain .AND.  rans_mode_parent  .AND.           &
     1084                   .NOT.  rans_mode ) )  THEN
    10661085!
    10671086!--       Generate turbulence at right boundary
     
    11201139                dist_yz(k,j,1) = a11(k) * fu_yz(k,j)
    11211140                !experimental test of 1.2
    1122                 dist_yz(k,j,2) = ( SQRT( a22(k) / MAXVAL(a22) )                   &
     1141                dist_yz(k,j,2) = ( SQRT( a22(k) / MAXVAL(a22) )                &
    11231142                                         * 1.2_wp )                            &
    1124                                        * (   a21(k) * fu_yz(k,j)                  &
     1143                                       * (   a21(k) * fu_yz(k,j)               &
    11251144                                           + a22(k) * fv_yz(k,j) )
    1126                 dist_yz(k,j,3) = ( SQRT(a33(k) / MAXVAL(a33) )                    &
     1145                dist_yz(k,j,3) = ( SQRT(a33(k) / MAXVAL(a33) )                 &
    11271146                                         * 1.3_wp )                            &
    1128                                        * (   a31(k) * fu_yz(k,j)                  &
    1129                                            + a32(k) * fv_yz(k,j)                  &
     1147                                       * (   a31(k) * fu_yz(k,j)               &
     1148                                           + a32(k) * fv_yz(k,j)               &
    11301149                                           + a33(k) * fw_yz(k,j) )
    11311150                ! Calculation for pt and e not yet implemented
     
    13031322       DO  i = nxl, nxr
    13041323          DO  k = nzb+1, nzt
    1305              volume_flow_l = volume_flow_l + v(k,j,i) * dzw(k) * dx         &
    1306                                   * MERGE( 1.0_wp, 0.0_wp,                  &   
     1324             volume_flow_l = volume_flow_l + v(k,j,i) * dzw(k) * dx            &
     1325                                  * MERGE( 1.0_wp, 0.0_wp,                     &   
    13071326                                           BTEST( wall_flags_0(k,j,i), 2 ) )
    13081327
    1309              mc_factor_l = mc_factor_l     + ( v(k,j,i) + dist_xz(k,i,2) )  &
    1310                                                       * dzw(k) * dx         &
    1311                                   * MERGE( 1.0_wp, 0.0_wp,                  &   
     1328             mc_factor_l = mc_factor_l     + ( v(k,j,i) + dist_xz(k,i,2) )     &
     1329                                                      * dzw(k) * dx            &
     1330                                  * MERGE( 1.0_wp, 0.0_wp,                     &   
    13121331                                           BTEST( wall_flags_0(k,j,i), 2 ) )
    13131332          ENDDO
    13141333       ENDDO
    13151334#if defined( __parallel )
    1316        CALL MPI_ALLREDUCE( volume_flow_l, volume_flow,                      &
     1335       CALL MPI_ALLREDUCE( volume_flow_l, volume_flow,                         &
    13171336                           1, MPI_REAL, MPI_SUM, comm1dx, ierr )
    1318        CALL MPI_ALLREDUCE( mc_factor_l, mc_factor,                          &
     1337       CALL MPI_ALLREDUCE( mc_factor_l, mc_factor,                             &
    13191338                           1, MPI_REAL, MPI_SUM, comm1dx, ierr )
    13201339#else
     
    13741393        ONLY: ny
    13751394
     1395    USE pegrid
    13761396
    13771397    IMPLICIT NONE
     
    14671487
    14681488    DEALLOCATE( rand_it )
    1469 
    14701489!
    14711490!-- Gather velocity seeds of full subdomain
     
    14741493
    14751494#if defined( __parallel )
    1476     CALL MPI_GATHERV( f_n_l(nzb_x_stg,nysg), send_count, stg_type_yz_small,        &
    1477                       f_n(nzb+1,nysg), recv_count_yz, displs_yz, stg_type_yz,        &
     1495    CALL MPI_GATHERV( f_n_l(nzb_x_stg,nysg), send_count, stg_type_yz_small,    &
     1496                      f_n(nzb+1,nysg), recv_count_yz, displs_yz, stg_type_yz,  &
    14781497                      id, comm1dx, ierr )
    14791498#else
     
    16031622
    16041623#if defined( __parallel )
    1605     CALL MPI_GATHERV( f_n_l(nzb_y_stg,nxlg), send_count, stg_type_xz_small,        &
     1624    CALL MPI_GATHERV( f_n_l(nzb_y_stg,nxlg), send_count, stg_type_xz_small,    &
    16061625                      f_n(nzb+1,nxlg), recv_count_xz, displs_xz, stg_type_xz,  &
    16071626                      id, comm1dy, ierr )
Note: See TracChangeset for help on using the changeset viewer.