Ignore:
Timestamp:
Mar 2, 2021 4:39:14 PM (3 years ago)
Author:
raasch
Message:

revised output of surface data via MPI-IO for better performance

File:
1 edited

Legend:

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

    r4882 r4893  
    2525! -----------------
    2626! $Id$
     27! revised output of surface data via MPI-IO for better performance
     28!
     29! 4882 2021-02-19 22:49:44Z forkel
    2730! removed lsp in subroutine nitialize_top
    28 !
    2931!
    3032! 4881 2021-02-19 22:05:08Z forkel
    3133! removed constant_top_csflux option
    32 !
    3334!
    3435! 4877 2021-02-17 16:17:35Z suehring
     
    14841485!> Allocating memory for upward and downward-facing horizontal surface types, except for top fluxes.
    14851486!--------------------------------------------------------------------------------------------------!
    1486  SUBROUTINE allocate_surface_attributes_h( surfaces, nys_l, nyn_l, nxl_l, nxr_l )
     1487 SUBROUTINE allocate_surface_attributes_h( surfaces, nys_l, nyn_l, nxl_l, nxr_l,                   &
     1488                                           no_allocate_index_arrays )
    14871489
    14881490    IMPLICIT NONE
     
    14931495    INTEGER(iwp) ::  nxr_l  !< east bound of local 2d array start/end_index, is equal to nyn, except for restart-array
    14941496
     1497    LOGICAL ::  allocate_index_arrays
     1498    LOGICAL, INTENT(IN), OPTIONAL  :: no_allocate_index_arrays
     1499
    14951500    TYPE(surf_type) ::  surfaces  !< respective surface type
    14961501
     1502
     1503    IF ( PRESENT( no_allocate_index_arrays ) )  THEN
     1504       allocate_index_arrays = .NOT. no_allocate_index_arrays
     1505    ELSE
     1506       allocate_index_arrays = .TRUE.
     1507    ENDIF
    14971508!
    14981509!-- Allocate arrays for start and end index of horizontal surface type for each (j,i)-grid point.
    1499 !-- This is required e.g. in diffion_x, which is called for each (j,i). In order to find the
     1510!-- This is required e.g. in diffusion_x, which is called for each (j,i). In order to find the
    15001511!-- location where the respective flux is store within the surface-type, start- and end-index are
    15011512!-- stored for each (j,i). For example, each (j,i) can have several entries where fluxes for
     
    15031514!-- surfaces might exist for given (j,i). If no surface of respective type exist at current (j,i),
    15041515!-- set indicies such that loop in diffusion routines will not be entered.
    1505     ALLOCATE ( surfaces%start_index(nys_l:nyn_l,nxl_l:nxr_l) )
    1506     ALLOCATE ( surfaces%end_index(nys_l:nyn_l,nxl_l:nxr_l) )
    1507     surfaces%start_index = 0
    1508     surfaces%end_index   = -1
     1516    IF ( allocate_index_arrays )  THEN
     1517       ALLOCATE( surfaces%start_index(nys_l:nyn_l,nxl_l:nxr_l) )
     1518       ALLOCATE( surfaces%end_index(nys_l:nyn_l,nxl_l:nxr_l)   )
     1519       surfaces%start_index = 0
     1520       surfaces%end_index   = -1
     1521    ENDIF
    15091522!
    15101523!-- Indices to locate surface element
     
    20512064!> Allocating memory for vertical surface types.
    20522065!--------------------------------------------------------------------------------------------------!
    2053  SUBROUTINE allocate_surface_attributes_v( surfaces, nys_l, nyn_l, nxl_l, nxr_l )
     2066 SUBROUTINE allocate_surface_attributes_v( surfaces, nys_l, nyn_l, nxl_l, nxr_l,                   &
     2067                                           no_allocate_index_arrays )
    20542068
    20552069    IMPLICIT NONE
     
    20602074    INTEGER(iwp) ::  nxr_l  !< east bound of local 2d array start/end_index, is equal to nyn, except for restart-array
    20612075
     2076    LOGICAL ::  allocate_index_arrays
     2077    LOGICAL, INTENT(IN), OPTIONAL ::  no_allocate_index_arrays
     2078
    20622079    TYPE(surf_type) ::  surfaces !< respective surface type
    20632080
     2081
     2082    IF ( PRESENT( no_allocate_index_arrays ) )  THEN
     2083       allocate_index_arrays = .NOT. no_allocate_index_arrays
     2084    ELSE
     2085       allocate_index_arrays = .TRUE.
     2086    ENDIF
     2087
    20642088!
    20652089!-- Allocate arrays for start and end index of vertical surface type for each (j,i)-grid point. This
    2066 !-- is required in diffion_x, which is called for each (j,i). In order to find the location where
     2090!-- is required in diffusion_x, which is called for each (j,i). In order to find the location where
    20672091!-- the respective flux is store within the surface-type, start- and end-index are stored for each
    20682092!-- (j,i). For example, each (j,i) can have several entries where fluxes for vertical surfaces might
    20692093!-- be stored. In the flat case, where no vertical walls exit, set indicies such that loop in
    20702094!-- diffusion routines will not be entered.
    2071     ALLOCATE ( surfaces%start_index(nys_l:nyn_l,nxl_l:nxr_l) )
    2072     ALLOCATE ( surfaces%end_index(nys_l:nyn_l,nxl_l:nxr_l) )
    2073     surfaces%start_index = 0
    2074     surfaces%end_index   = -1
     2095    IF ( allocate_index_arrays )  THEN
     2096       ALLOCATE( surfaces%start_index(nys_l:nyn_l,nxl_l:nxr_l) )
     2097       ALLOCATE( surfaces%end_index(nys_l:nyn_l,nxl_l:nxr_l)   )
     2098       surfaces%start_index = 0
     2099       surfaces%end_index   = -1
     2100    ENDIF
    20752101!
    20762102!-- Indices to locate surface element.
     
    31413167    INTEGER(iwp), DIMENSION(0:3) ::  start_index_v  !< start index for vertical surface elements on gathered surface array
    31423168
    3143     INTEGER(iwp),DIMENSION(nys:nyn,nxl:nxr) ::  global_start_index  !< index for surface data (MPI-IO)
     3169    INTEGER(iwp),DIMENSION(nys:nyn,nxl:nxr) ::  global_end_index    !< end index for surface data (MPI-IO)
     3170    INTEGER(iwp),DIMENSION(nys:nyn,nxl:nxr) ::  global_start_index  !< start index for surface data (MPI-IO)
    31443171
    31453172    LOGICAL ::  surface_data_to_write  !< switch for MPI-I/O if PE has surface data to write
     
    39884015
    39894016          CALL rd_mpi_io_surface_filetypes( surf_h(l)%start_index, surf_h(l)%end_index,            &
    3990                                             surface_data_to_write, global_start_index )
     4017                                            surface_data_to_write, global_start_index,             &
     4018                                            global_end_index )
    39914019          IF ( .NOT. surface_data_to_write )  CYCLE
    39924020
    39934021          ns_h_on_file(l) = total_number_of_surface_values
    39944022
    3995           CALL wrd_mpi_io( 'surf_h(' // dum // ')%start_index', surf_h(l)%start_index )
    3996           CALL wrd_mpi_io( 'surf_h(' // dum // ')%end_index', surf_h(l)%end_index )
    39974023          CALL wrd_mpi_io( 'global_start_index_h_' // dum, global_start_index )
     4024          CALL wrd_mpi_io( 'global_end_index_h_' // dum, global_end_index )
    39984025
    39994026          IF ( ALLOCATED ( surf_h(l)%us ) )  THEN
     
    41214148
    41224149          CALL rd_mpi_io_surface_filetypes( surf_v(l)%start_index, surf_v(l)%end_index,            &
    4123                                             surface_data_to_write, global_start_index )
     4150                                            surface_data_to_write, global_start_index,             &
     4151                                            global_end_index )
     4152
     4153          IF ( .NOT. surface_data_to_write )  CYCLE
    41244154
    41254155          ns_v_on_file(l) = total_number_of_surface_values
    41264156
    4127           CALL wrd_mpi_io( 'surf_v(' // dum // ')%start_index', surf_v(l)%start_index )
    4128           CALL wrd_mpi_io( 'surf_v(' // dum // ')%end_index', surf_v(l)%end_index )
    41294157          CALL wrd_mpi_io( 'global_start_index_v_' // dum, global_start_index )
     4158          CALL wrd_mpi_io( 'global_end_index_v_' // dum, global_end_index )
    41304159
    41314160          IF ( .NOT. surface_data_to_write )  CYCLE
     
    53815410    INTEGER(iwp) ::  mm !< loop index for surface types - file array
    53825411
    5383     INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  global_start_index  !< index for surface data (MPI-IO)
    5384 
    5385     LOGICAL ::  ldum            !< dummy variable
     5412    INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  global_end_index    !< end index for surface data (MPI-IO)
     5413    INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  global_start_index  !< start index for surface data (MPI-IO)
     5414
     5415    LOGICAL ::  data_to_read    !< cycle in l loop, if no values to read
    53865416    LOGICAL ::  surf_match_def  !< flag indicating that surface element is of default type
    53875417    LOGICAL ::  surf_match_lsm  !< flag indicating that surface element is of natural type
     
    54015431       IF ( ns_h_on_file(l) == 0 )  CYCLE  !< No data of this surface type on file
    54025432
     5433       WRITE( dum, '(I1)')  l
     5434
    54035435       IF ( ALLOCATED( surf_h(l)%start_index ) )  CALL deallocate_surface_attributes_h( surf_h(l) )
    5404        surf_h(l)%ns = ns_h_on_file(l)
    5405        CALL allocate_surface_attributes_h( surf_h(l), nys, nyn, nxl, nxr )
    5406 
    5407        WRITE( dum, '(I1)') l
    5408 
    5409        CALL rrd_mpi_io( 'surf_h(' // dum // ')%start_index',  surf_h(l)%start_index )
    5410        CALL rrd_mpi_io( 'surf_h(' // dum // ')%end_index',  surf_h(l)%end_index )
     5436
     5437       ALLOCATE( surf_h(l)%start_index(nys:nyn,nxl:nxr) )
     5438       ALLOCATE( surf_h(l)%end_index(nys:nyn,nxl:nxr) )
     5439       surf_h(l)%start_index = 0
     5440       surf_h(l)%end_index   = -1
     5441
    54115442       CALL rrd_mpi_io( 'global_start_index_h_' // dum , global_start_index )
    5412 
    5413        CALL rd_mpi_io_surface_filetypes( surf_h(l)%start_index, surf_h(l)%end_index, ldum,         &
    5414                                          global_start_index )
     5443       CALL rrd_mpi_io( 'global_end_index_h_' // dum , global_end_index )
     5444
     5445       CALL rd_mpi_io_surface_filetypes( surf_h(l)%start_index, surf_h(l)%end_index, data_to_read, &
     5446                                         global_start_index, global_end_index )
     5447
     5448       surf_h(l)%ns = MAX( 2, MAXVAL( surf_h(l)%end_index ) )
     5449
     5450       CALL allocate_surface_attributes_h( surf_h(l), nys, nyn, nxl, nxr,                          &
     5451                                           no_allocate_index_arrays = .TRUE. )
     5452       IF ( .NOT. data_to_read )  CYCLE
    54155453
    54165454       IF ( ALLOCATED ( surf_h(l)%us ) )  THEN
     
    55395577
    55405578       IF ( ALLOCATED( surf_v(l)%start_index ) )  CALL deallocate_surface_attributes_v( surf_v(l) )
    5541        surf_v(l)%ns = ns_v_on_file(l)
    5542        CALL allocate_surface_attributes_v( surf_v(l), nys, nyn, nxl, nxr )
    5543 
    5544        WRITE( dum, '(I1)' ) l
    5545 
    5546        CALL rrd_mpi_io( 'surf_v(' // dum // ')%start_index', surf_v(l)%start_index )
    5547        CALL rrd_mpi_io( 'surf_v(' // dum // ')%end_index', surf_v(l)%end_index )
     5579
     5580       ALLOCATE( surf_v(l)%start_index(nys:nyn,nxl:nxr) )
     5581       ALLOCATE( surf_v(l)%end_index(nys:nyn,nxl:nxr) )
     5582       surf_v(l)%start_index = 0
     5583       surf_v(l)%end_index   = -1
     5584
     5585       WRITE( dum, '(I1)' )  l
     5586
    55485587       CALL rrd_mpi_io( 'global_start_index_v_' // dum , global_start_index )
    5549 
    5550        CALL rd_mpi_io_surface_filetypes( surf_v(l)%start_index, surf_v(l)%end_index, ldum,         &
    5551                                          global_start_index )
     5588       CALL rrd_mpi_io( 'global_end_index_v_' // dum , global_end_index )
     5589
     5590       CALL rd_mpi_io_surface_filetypes( surf_v(l)%start_index, surf_v(l)%end_index, data_to_read, &
     5591                                         global_start_index, global_end_index )
     5592       IF ( .NOT. data_to_read )  CYCLE
     5593
     5594       surf_v(l)%ns = MAX( 2, MAXVAL( surf_v(l)%end_index ) )
     5595       CALL allocate_surface_attributes_v( surf_v(l), nys, nyn, nxl, nxr,                          &
     5596                                           no_allocate_index_arrays = .TRUE.  )
    55525597
    55535598       IF ( ALLOCATED ( surf_v(l)%us ) )  THEN
Note: See TracChangeset for help on using the changeset viewer.