Changeset 4259 for palm/trunk/SOURCE


Ignore:
Timestamp:
Oct 9, 2019 10:05:22 AM (5 years ago)
Author:
suehring
Message:

Normalize relative wall-, green- and window fractions so that they sum-up to one. Give an informative message in case normalization is required.

File:
1 edited

Legend:

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

    r4258 r4259  
    2828! -----------------
    2929! $Id$
     30! Instead of terminate the job in case the relative wall fractions do not
     31! sum-up to one, give only an informative message and normalize the fractions.
     32!
     33! 4258 2019-10-07 13:29:08Z suehring
    3034! - Add checks to ensure that relative fractions of walls, windowns and green
    3135!   surfaces sum-up to one.
     
    35123516        INTEGER(iwp) ::  l                   !< loop index surface orientation
    35133517        INTEGER(iwp) ::  m                   !< loop index surface element
    3514         INTEGER(iwp) ::  st                  !< dummy 
     3518        INTEGER(iwp) ::  st                  !< dummy
     3519
     3520        LOGICAL      ::  relative_fractions_corrected !< flag indicating if relative surface fractions require normalization
    35153521
    35163522        REAL(wp)     ::  c, tin, twin
    35173523        REAL(wp)     ::  ground_floor_level_l         !< local height of ground floor level
    3518         REAL(wp)     ::  z_agl                        !< height above ground
     3524        REAL(wp)     ::  sum_frac                     !< sum of the relative material fractions at a surface element
     3525        REAL(wp)     ::  z_agl                        !< height of the surface element above terrain
    35193526
    35203527        IF ( debug_output )  CALL debug_message( 'usm_init', 'start' )
     
    44384445                 surf_usm_h%lambda_surf(m) =                                   &
    44394446                                    building_pars_f%pars_xy(ind_lambda_surf,j,i)
    4440              
    4441               write(9,*) m, SUM( surf_usm_h%frac(:,m) ), "indiv", surf_usm_h%frac(0,m), surf_usm_h%frac(1,m), surf_usm_h%frac(2,m)
    44424447           ENDDO
    4443            flush(9)
    4444 
    4445 
    44464448
    44474449           DO  l = 0, 3
     
    50375039!
    50385040!--     Run further checks to ensure that the respecitve material fractions are
    5039 !--     prescribed properly.
     5041!--     prescribed properly. Start with horizontal surfaces (roofs).
     5042        relative_fractions_corrected = .FALSE.
    50405043        DO  m = 1, surf_usm_h%ns
    5041            IF ( SUM( surf_usm_h%frac(:,m) ) /= 1.0_wp )  THEN
    5042               WRITE(message_string,*) 'The relative material fractions do ' // &
    5043                                       'not sum-up to one at horizotal ' //     &
    5044                                       'surface. (i,j) = ',                     &
    5045                                       surf_usm_h%i(m), surf_usm_h%j(m)
    5046               CALL message( 'urban_surface_model_mod', 'PA0686', 2, 2, myid, 6, 0 )
     5044           sum_frac = SUM( surf_usm_h%frac(:,m) )
     5045           IF ( sum_frac /= 1.0_wp )  THEN
     5046              relative_fractions_corrected = .TRUE.
     5047!
     5048!--           Normalize relative fractions to 1. Deviations from 1 can
     5049!--           arise, e.g. by rounding errors but also by inconsistent
     5050!--           driver creation.
     5051              IF ( sum_frac /= 0.0_wp )  THEN
     5052                 surf_usm_h%frac(:,m) = surf_usm_h%frac(:,m) / sum_frac
     5053!
     5054!--           In case all relative fractions are erroneously set to zero,
     5055!--           set wall fraction to 1.
     5056              ELSE
     5057                 surf_usm_h%frac(ind_veg_wall,m)  = 1.0_wp
     5058                 surf_usm_h%frac(ind_wat_win,m)   = 0.0_wp
     5059                 surf_usm_h%frac(ind_pav_green,m) = 0.0_wp
     5060              ENDIF
    50475061           ENDIF
    50485062        ENDDO
    5049        
     5063!
     5064!--     If fractions were normalized, give an informative message.
     5065#if defined( __parallel )
     5066        CALL MPI_ALLREDUCE( MPI_IN_PLACE, relative_fractions_corrected, 1,     &
     5067                            MPI_LOGICAL, MPI_LOR, comm2d, ierr )
     5068#endif
     5069        IF ( relative_fractions_corrected )  THEN
     5070           message_string = 'At some horizotal surfaces the relative '   //    &
     5071                            'material fractions do not sum-up to one . ' //    &
     5072                            'Hence, the respective fractions were normalized.'
     5073           CALL message( 'urban_surface_model_mod', 'PA0686', 0, 0, 0, 6, 0 )
     5074        ENDIF
     5075!
     5076!--     Check relative fractions at vertical surfaces.
     5077        relative_fractions_corrected = .FALSE.
    50505078        DO  l = 0, 3
    50515079           DO  m = 1, surf_usm_v(l)%ns
    5052               IF ( SUM( surf_usm_v(l)%frac(:,m) ) /= 1.0_wp )  THEN
    5053                  WRITE(message_string,*)                                       &
    5054                                       'The relative material fractions do ' // &
    5055                                       'not sum-up to one at vertical ' //      &
    5056                                       'surface. (i,j) = ',                     &
    5057                                       surf_usm_v(l)%i(m), surf_usm_v(l)%j(m)
    5058                  CALL message( 'urban_surface_model_mod', 'PA0686', 2, 2, myid, 6, 0 )
     5080              sum_frac = SUM( surf_usm_v(l)%frac(:,m) )
     5081              IF ( sum_frac /= 1.0_wp )  THEN
     5082                 relative_fractions_corrected = .TRUE.
     5083!
     5084!--              Normalize relative fractions to 1.
     5085                 IF ( sum_frac /= 0.0_wp )  THEN
     5086                    surf_usm_v(l)%frac(:,m) = surf_usm_v(l)%frac(:,m) / sum_frac
     5087!
     5088!--              In case all relative fractions are erroneously set to zero,
     5089!--              set wall fraction to 1.
     5090                 ELSE
     5091                    surf_usm_v(l)%frac(ind_veg_wall,m)  = 1.0_wp
     5092                    surf_usm_v(l)%frac(ind_wat_win,m)   = 0.0_wp
     5093                    surf_usm_v(l)%frac(ind_pav_green,m) = 0.0_wp
     5094                 ENDIF
    50595095              ENDIF
    50605096           ENDDO
    50615097        ENDDO
    5062 !       
     5098!
     5099!--     Also here, ff fractions were normalized, give an informative message.
     5100#if defined( __parallel )
     5101        CALL MPI_ALLREDUCE( MPI_IN_PLACE, relative_fractions_corrected, 1,     &
     5102                            MPI_LOGICAL, MPI_LOR, comm2d, ierr )
     5103#endif
     5104        IF ( relative_fractions_corrected )  THEN
     5105           message_string = 'At some vertical surfaces the relative '    //    &
     5106                            'material fractions do not sum-up to one . ' //    &
     5107                            'Hence, the respective fractions were normalized.'
     5108           CALL message( 'urban_surface_model_mod', 'PA0686', 0, 0, 0, 6, 0 )
     5109        ENDIF
     5110!
    50635111!--     Read the surface_types array.
    50645112!--     Please note, here also initialization of surface attributes is done as
Note: See TracChangeset for help on using the changeset viewer.