Changeset 1908 for palm


Ignore:
Timestamp:
May 25, 2016 5:22:32 PM (9 years ago)
Author:
suehring
Message:

Calculate new divergence only at last Runge-Kutta step

File:
1 edited

Legend:

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

    r1846 r1908  
    1919! Current revisions:
    2020! ------------------
    21 !
     21! New divergence for output into RUN_CONTROL file is calculated only at last
     22! Runge-Kutta step
    2223!
    2324! Former revisions:
     
    107108        ONLY:  bc_lr_cyc, bc_ns_cyc, conserve_volume_flow, dt_3d,              &
    108109               gathered_size, ibc_p_b, ibc_p_t, intermediate_timestep_count,   &
    109                mg_switch_to_pe0_level, nest_domain, nest_bound_l,              &
    110                nest_bound_n, nest_bound_r, nest_bound_s, on_device, outflow_l, &
    111                outflow_n, outflow_r, outflow_s, psolver, simulated_time,       &
    112                subdomain_size, topography, volume_flow, volume_flow_area,      &
    113                volume_flow_initial
     110               intermediate_timestep_count_max, mg_switch_to_pe0_level,        &
     111               nest_domain, nest_bound_l, nest_bound_n, nest_bound_r,          &
     112               nest_bound_s, on_device, outflow_l, outflow_n, outflow_r,       &
     113               outflow_s, psolver, simulated_time, subdomain_size, topography, &
     114               volume_flow, volume_flow_area, volume_flow_initial
    114115
    115116    USE cpulog,                                                                &
     
    359360    ENDDO
    360361
    361     localsum = localsum + threadsum * dt_3d * &
    362                           weight_pres(intermediate_timestep_count)
    363 
     362    IF ( intermediate_timestep_count == intermediate_timestep_count_max )  THEN
     363       localsum = localsum + threadsum * dt_3d * &
     364                             weight_pres(intermediate_timestep_count)
     365    ENDIF
    364366    !$OMP END PARALLEL
    365367#else
     
    383385
    384386!
    385 !-- Compute possible PE-sum of divergences for flow_statistics
    386     !$OMP PARALLEL PRIVATE (i,j,k) FIRSTPRIVATE(threadsum) REDUCTION(+:localsum)
    387     !$OMP DO SCHEDULE( STATIC )
    388     !$acc parallel loop collapse(3) present( d ) reduction(+:threadsum)
    389     DO  i = nxl, nxr
    390        DO  j = nys, nyn
    391           DO  k = nzb+1, nzt
    392              threadsum = threadsum + ABS( d(k,j,i) )
    393           ENDDO
    394        ENDDO
    395     ENDDO
    396     !$acc end parallel loop
    397     localsum = localsum + threadsum * dt_3d * &
    398                           weight_pres(intermediate_timestep_count)
    399     !$OMP END PARALLEL
     387!-- Compute possible PE-sum of divergences for flow_statistics. Carry out
     388!-- computation only at last Runge-Kutta substep.
     389    IF ( intermediate_timestep_count == intermediate_timestep_count_max )  THEN
     390       !$OMP PARALLEL PRIVATE (i,j,k) FIRSTPRIVATE(threadsum) REDUCTION(+:localsum)
     391       !$OMP DO SCHEDULE( STATIC )
     392       !$acc parallel loop collapse(3) present( d ) reduction(+:threadsum)
     393       DO  i = nxl, nxr
     394          DO  j = nys, nyn
     395             DO  k = nzb+1, nzt
     396                threadsum = threadsum + ABS( d(k,j,i) )
     397             ENDDO
     398          ENDDO
     399       ENDDO
     400       !$acc end parallel loop
     401       localsum = localsum + threadsum * dt_3d * &
     402                             weight_pres(intermediate_timestep_count)
     403       !$OMP END PARALLEL
     404    ENDIF
    400405#endif
    401406
     
    403408!-- For completeness, set the divergence sum of all statistic regions to those
    404409!-- of the total domain
    405     sums_divold_l(0:statistic_regions) = localsum
     410    IF ( intermediate_timestep_count == intermediate_timestep_count_max )      &
     411       sums_divold_l(0:statistic_regions) = localsum
    406412
    407413    CALL cpu_log( log_point_s(1), 'divergence', 'stop' )
     
    726732!
    727733!-- Compute the divergence of the corrected velocity field,
    728 !-- a possible PE-sum is computed in flow_statistics
    729     CALL cpu_log( log_point_s(1), 'divergence', 'start' )
    730     sums_divnew_l = 0.0_wp
    731 
    732 !
    733 !-- d must be reset to zero because it can contain nonzero values below the
    734 !-- topography
    735     IF ( topography /= 'flat' )  d = 0.0_wp
    736 
    737     localsum  = 0.0_wp
    738     threadsum = 0.0_wp
    739 
    740     !$OMP PARALLEL PRIVATE (i,j,k) FIRSTPRIVATE(threadsum) REDUCTION(+:localsum)
    741     !$OMP DO SCHEDULE( STATIC )
     734!-- A possible PE-sum is computed in flow_statistics. Carry out computation
     735!-- only at last Runge-Kutta step.
     736    IF ( intermediate_timestep_count == intermediate_timestep_count_max )  THEN
     737       CALL cpu_log( log_point_s(1), 'divergence', 'start' )
     738       sums_divnew_l = 0.0_wp
     739
     740!
     741!--    d must be reset to zero because it can contain nonzero values below the
     742!--    topography
     743       IF ( topography /= 'flat' )  d = 0.0_wp
     744
     745       localsum  = 0.0_wp
     746       threadsum = 0.0_wp
     747
     748       !$OMP PARALLEL PRIVATE (i,j,k) FIRSTPRIVATE(threadsum) REDUCTION(+:localsum)
     749       !$OMP DO SCHEDULE( STATIC )
    742750#if defined( __ibm )
    743     DO  i = nxl, nxr
    744        DO  j = nys, nyn
    745           DO  k = nzb_s_inner(j,i)+1, nzt
    746              d(k,j,i) = ( u(k,j,i+1) - u(k,j,i) ) * ddx + &
    747                         ( v(k,j+1,i) - v(k,j,i) ) * ddy + &
    748                         ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k)
    749           ENDDO
    750           DO  k = nzb+1, nzt
    751              threadsum = threadsum + ABS( d(k,j,i) )
    752           ENDDO
    753        ENDDO
    754     ENDDO
     751       DO  i = nxl, nxr
     752          DO  j = nys, nyn
     753             DO  k = nzb_s_inner(j,i)+1, nzt
     754                d(k,j,i) = ( u(k,j,i+1) - u(k,j,i) ) * ddx +                  &
     755                           ( v(k,j+1,i) - v(k,j,i) ) * ddy +                  &
     756                           ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k)
     757             ENDDO
     758             DO  k = nzb+1, nzt
     759                threadsum = threadsum + ABS( d(k,j,i) )
     760             ENDDO
     761          ENDDO
     762       ENDDO
    755763#else
    756     !$acc kernels present( d, ddzw, rflags_s_inner, u, v, w )
    757     !$acc loop collapse( 3 )
    758     DO  i = nxl, nxr
    759        DO  j = nys, nyn
    760           DO  k = 1, nzt
    761                 d(k,j,i) = ( ( u(k,j,i+1) - u(k,j,i) ) * ddx +   &
    762                              ( v(k,j+1,i) - v(k,j,i) ) * ddy +   &
    763                              ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) &
    764                            ) * rflags_s_inner(k,j,i)
    765           ENDDO
    766        ENDDO
    767     ENDDO
    768     !$acc end kernels
    769 !
    770 !-- Compute possible PE-sum of divergences for flow_statistics
    771     !$acc parallel loop collapse(3) present( d ) reduction(+:threadsum)
    772     DO  i = nxl, nxr
    773        DO  j = nys, nyn
    774           DO  k = nzb+1, nzt
    775              threadsum = threadsum + ABS( d(k,j,i) )
    776           ENDDO
    777        ENDDO
    778     ENDDO
    779     !$acc end parallel loop
     764       !$acc kernels present( d, ddzw, rflags_s_inner, u, v, w )
     765       !$acc loop collapse( 3 )
     766       DO  i = nxl, nxr
     767          DO  j = nys, nyn
     768             DO  k = 1, nzt
     769                   d(k,j,i) = ( ( u(k,j,i+1) - u(k,j,i) ) * ddx +              &
     770                                ( v(k,j+1,i) - v(k,j,i) ) * ddy +              &
     771                                ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k)            &
     772                              ) * rflags_s_inner(k,j,i)
     773             ENDDO
     774          ENDDO
     775       ENDDO
     776       !$acc end kernels
     777!
     778!--    Compute possible PE-sum of divergences for flow_statistics
     779       !$acc parallel loop collapse(3) present( d ) reduction(+:threadsum)
     780       DO  i = nxl, nxr
     781          DO  j = nys, nyn
     782             DO  k = nzb+1, nzt
     783                threadsum = threadsum + ABS( d(k,j,i) )
     784             ENDDO
     785          ENDDO
     786       ENDDO
     787       !$acc end parallel loop
    780788#endif
    781789
    782     localsum = localsum + threadsum
    783     !$OMP END PARALLEL
    784 
    785 !
    786 !-- For completeness, set the divergence sum of all statistic regions to those
    787 !-- of the total domain
    788     sums_divnew_l(0:statistic_regions) = localsum
    789 
    790     CALL cpu_log( log_point_s(1), 'divergence', 'stop' )
     790       localsum = localsum + threadsum
     791       !$OMP END PARALLEL
     792
     793!
     794!--    For completeness, set the divergence sum of all statistic regions to those
     795!--    of the total domain
     796       sums_divnew_l(0:statistic_regions) = localsum
     797
     798       CALL cpu_log( log_point_s(1), 'divergence', 'stop' )
     799
     800    ENDIF
    791801
    792802    CALL cpu_log( log_point(8), 'pres', 'stop' )
Note: See TracChangeset for help on using the changeset viewer.