New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 7508 for branches/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90 – NEMO

Ignore:
Timestamp:
2016-12-19T13:15:59+01:00 (8 years ago)
Author:
mocavero
Message:

changes on code duplication and workshare construct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90

    r7037 r7508  
    141141      INTEGER  ::   ifpr     ! dummy loop indice 
    142142      INTEGER  ::   jfld     ! dummy loop arguments 
     143      INTEGER  ::   ji, jj               ! dummy loop indices 
    143144      INTEGER  ::   ios      ! Local integer output status for namelist read 
    144145      ! 
     
    194195         CALL fld_fill( sf, slf_i, cn_dir, 'sbc_blk_core', 'flux formulation for ocean surface boundary condition', 'namsbc_core' ) 
    195196         ! 
    196          sfx(:,:) = 0._wp                          ! salt flux; zero unless ice is present (computed in limsbc(_2).F90) 
    197          ! 
     197!$OMP PARALLEL DO schedule(static) private(jj, ji) 
     198         DO jj = 1, jpj 
     199            DO ji = 1, jpi 
     200               sfx(ji,jj) = 0._wp                          ! salt flux; zero unless ice is present (computed in limsbc(_2).F90) 
     201            END DO 
     202         END DO 
    198203      ENDIF 
    199204 
     
    205210#if defined key_cice 
    206211      IF( MOD( kt - 1, nn_fsbc ) == 0 )   THEN 
    207          qlw_ice(:,:,1)   = sf(jp_qlw)%fnow(:,:,1)  
    208          qsr_ice(:,:,1)   = sf(jp_qsr)%fnow(:,:,1) 
    209          tatm_ice(:,:)    = sf(jp_tair)%fnow(:,:,1)          
    210          qatm_ice(:,:)    = sf(jp_humi)%fnow(:,:,1) 
    211          tprecip(:,:)     = sf(jp_prec)%fnow(:,:,1) * rn_pfac 
    212          sprecip(:,:)     = sf(jp_snow)%fnow(:,:,1) * rn_pfac 
    213          wndi_ice(:,:)    = sf(jp_wndi)%fnow(:,:,1) 
    214          wndj_ice(:,:)    = sf(jp_wndj)%fnow(:,:,1) 
     212!$OMP PARALLEL DO schedule(static) private(jj, ji) 
     213         DO jj = 1, jpj 
     214            DO ji = 1, jpi 
     215                 qlw_ice(ji,jj,1)   = sf(jp_qlw)%fnow(ji,jj,1)  
     216                 qsr_ice(ji,jj,1)   = sf(jp_qsr)%fnow(ji,jj,1) 
     217                 tatm_ice(ji,jj)    = sf(jp_tair)%fnow(ji,jj,1)          
     218                 qatm_ice(ji,jj)    = sf(jp_humi)%fnow(ji,jj,1) 
     219                 tprecip(ji,jj)     = sf(jp_prec)%fnow(ji,jj,1) * rn_pfac 
     220                 sprecip(ji,jj)     = sf(jp_snow)%fnow(ji,jj,1) * rn_pfac 
     221                 wndi_ice(ji,jj)    = sf(jp_wndi)%fnow(ji,jj,1) 
     222                 wndj_ice(ji,jj)    = sf(jp_wndj)%fnow(ji,jj,1) 
     223            END DO 
     224         END DO 
    215225      ENDIF 
    216226#endif 
     
    267277      zcoef_qsatw = 0.98 * 640380. / rhoa 
    268278 
    269 !$OMP PARALLEL WORKSHARE       
    270       zst(:,:) = pst(:,:) + rt0      ! convert SST from Celcius to Kelvin (and set minimum value far above 0 K) 
     279!$OMP PARALLEL DO schedule(static) private(jj, ji) 
     280         DO jj = 1, jpj 
     281            DO ji = 1, jpi 
     282               zst(ji,jj) = pst(ji,jj) + rt0      ! convert SST from Celcius to Kelvin (and set minimum value far above 0 K) 
    271283 
    272284      ! ----------------------------------------------------------------------------- ! 
     
    275287 
    276288      ! ... components ( U10m - U_oce ) at T-point (unmasked) 
    277       zwnd_i(:,:) = 0.e0   
    278       zwnd_j(:,:) = 0.e0 
    279 !$OMP END PARALLEL WORKSHARE 
     289              zwnd_i(ji,jj) = 0.e0   
     290              zwnd_j(ji,jj) = 0.e0 
     291            END DO 
     292         END DO 
    280293#if defined key_cyclone 
    281294      CALL wnd_cyc( kt, zwnd_i, zwnd_j )    ! add analytical tropical cyclone (Vincent et al. JGR 2012) 
     
    312325      ! ocean albedo assumed to be constant + modify now Qsr to include the diurnal cycle                    ! Short Wave 
    313326      zztmp = 1. - albo 
    314       IF( ln_dm2dc ) THEN   ;   qsr(:,:) = zztmp * sbc_dcy( sf(jp_qsr)%fnow(:,:,1) ) * tmask(:,:,1) 
    315       ELSE                  ;   qsr(:,:) = zztmp *          sf(jp_qsr)%fnow(:,:,1)   * tmask(:,:,1) 
     327      IF( ln_dm2dc ) THEN 
     328         qsr(:,:) = zztmp * sbc_dcy( sf(jp_qsr)%fnow(:,:,1) ) * tmask(:,:,1) 
     329      ELSE 
     330         qsr(:,:) = zztmp *          sf(jp_qsr)%fnow(:,:,1)   * tmask(:,:,1) 
    316331      ENDIF 
    317332 
     
    319334      DO jj = 1, jpj 
    320335         DO ji = 1, jpi 
    321       zqlw(ji,jj) = (  sf(jp_qlw)%fnow(ji,jj,1) - Stef * zst(ji,jj)*zst(ji,jj)*zst(ji,jj)*zst(ji,jj)  ) * tmask(ji,jj,1)   ! Long  Wave 
    322       ! ----------------------------------------------------------------------------- ! 
    323       !     II    Turbulent FLUXES                                                    ! 
    324       ! ----------------------------------------------------------------------------- ! 
    325  
    326       ! ... specific humidity at SST and IST 
    327       zqsatw(ji,jj) = zcoef_qsatw * EXP( -5107.4 / zst(ji,jj) ) 
     336            zqlw(ji,jj) = (  sf(jp_qlw)%fnow(ji,jj,1) - Stef * zst(ji,jj)*zst(ji,jj)*zst(ji,jj)*zst(ji,jj)  ) * tmask(ji,jj,1)   ! Long  Wave 
     337            ! ----------------------------------------------------------------------------- ! 
     338            !     II    Turbulent FLUXES                                                    ! 
     339            ! ----------------------------------------------------------------------------- ! 
     340 
     341            ! ... specific humidity at SST and IST 
     342            zqsatw(ji,jj) = zcoef_qsatw * EXP( -5107.4 / zst(ji,jj) ) 
    328343 
    329344         END DO 
     
    346361      ! ... add the HF tau contribution to the wind stress module? 
    347362      IF( lhftau ) THEN 
    348          taum(:,:) = taum(:,:) + sf(jp_tdif)%fnow(:,:,1) 
     363!$OMP PARALLEL DO schedule(static) private(jj, ji) 
     364         DO jj = 1, jpj 
     365            DO ji = 1, jpi 
     366               taum(ji,jj) = taum(ji,jj) + sf(jp_tdif)%fnow(ji,jj,1) 
     367            END DO 
     368         END DO 
    349369      ENDIF 
    350370      CALL iom_put( "taum_oce", taum )   ! output wind stress module 
     
    371391      DO jj = 1, jpj 
    372392         DO ji = 1, jpi 
    373       IF( ABS( rn_zu - rn_zqt) < 0.01_wp ) THEN 
    374          !! q_air and t_air are (or "are almost") given at 10m (wind reference height) 
    375          zevap(ji,jj) = rn_efac*MAX( 0._wp,     rhoa*Ce(ji,jj)*( zqsatw(ji,jj) - sf(jp_humi)%fnow(ji,jj,1) )*wndm(ji,jj) ) ! Evaporation 
    376          zqsb (ji,jj) =                     cpa*rhoa*Ch(ji,jj)*( zst   (ji,jj) - sf(jp_tair)%fnow(ji,jj,1) )*wndm(ji,jj)   ! Sensible Heat 
    377       ELSE 
    378          !! q_air and t_air are not given at 10m (wind reference height) 
    379          ! Values of temp. and hum. adjusted to height of wind during bulk algorithm iteration must be used!!! 
    380          zevap(ji,jj) = rn_efac*MAX( 0._wp,     rhoa*Ce(ji,jj)*( zqsatw(ji,jj) - zq_zu(ji,jj) )*wndm(ji,jj) )   ! Evaporation 
    381          zqsb (ji,jj) =                     cpa*rhoa*Ch(ji,jj)*( zst   (ji,jj) - zt_zu(ji,jj) )*wndm(ji,jj)     ! Sensible Heat 
    382       ENDIF 
    383       zqla (ji,jj) = Lv * zevap(ji,jj)                                                              ! Latent Heat 
    384  
     393            IF( ABS( rn_zu - rn_zqt) < 0.01_wp ) THEN 
     394            !! q_air and t_air are (or "are almost") given at 10m (wind reference height) 
     395               zevap(ji,jj) = rn_efac*MAX( 0._wp,     rhoa*Ce(ji,jj)*( zqsatw(ji,jj) - sf(jp_humi)%fnow(ji,jj,1) )*wndm(ji,jj) ) ! Evaporation 
     396               zqsb (ji,jj) =                     cpa*rhoa*Ch(ji,jj)*( zst   (ji,jj) - sf(jp_tair)%fnow(ji,jj,1) )*wndm(ji,jj)   ! Sensible Heat 
     397            ELSE 
     398            !! q_air and t_air are not given at 10m (wind reference height) 
     399            ! Values of temp. and hum. adjusted to height of wind during bulk algorithm iteration must be used!!! 
     400               zevap(ji,jj) = rn_efac*MAX( 0._wp,     rhoa*Ce(ji,jj)*( zqsatw(ji,jj) - zq_zu(ji,jj) )*wndm(ji,jj) )   ! Evaporation 
     401               zqsb (ji,jj) =                     cpa*rhoa*Ch(ji,jj)*( zst   (ji,jj) - zt_zu(ji,jj) )*wndm(ji,jj)     ! Sensible Heat 
     402            ENDIF 
     403            zqla (ji,jj) = Lv * zevap(ji,jj)                                                              ! Latent Heat 
    385404         END DO 
    386405      END DO 
     
    417436      ! 
    418437#if defined key_lim3 
    419 !$OMP PARALLEL WORKSHARE 
    420       qns_oce(:,:) = zqlw(:,:) - zqsb(:,:) - zqla(:,:)                                ! non solar without emp (only needed by LIM3) 
    421       qsr_oce(:,:) = qsr(:,:) 
    422 !$OMP END PARALLEL WORKSHARE 
     438!$OMP PARALLEL DO schedule(static) private(jj, ji) 
     439      DO jj = 1, jpj 
     440         DO ji = 1, jpi 
     441            qns_oce(ji,jj) = zqlw(ji,jj) - zqsb(ji,jj) - zqla(ji,jj)   ! non solar without emp (only needed by LIM3) 
     442            qsr_oce(ji,jj) = qsr(ji,jj) 
     443         END DO 
     444      END DO 
    423445#endif 
    424446      ! 
     
    431453         CALL iom_put( "qsr_oce" ,   qsr  )                 ! output downward solar heat over the ocean 
    432454         CALL iom_put( "qt_oce"  ,   qns+qsr )              ! output total downward heat over the ocean 
    433          tprecip(:,:) = sf(jp_prec)%fnow(:,:,1) * rn_pfac   ! output total precipitation [kg/m2/s] 
    434          sprecip(:,:) = sf(jp_snow)%fnow(:,:,1) * rn_pfac   ! output solid precipitation [kg/m2/s] 
     455!$OMP PARALLEL DO schedule(static) private(jj, ji) 
     456      DO jj = 1, jpj 
     457         DO ji = 1, jpi 
     458            tprecip(ji,jj) = sf(jp_prec)%fnow(ji,jj,1) * rn_pfac   ! output total precipitation [kg/m2/s] 
     459            sprecip(ji,jj) = sf(jp_snow)%fnow(ji,jj,1) * rn_pfac   ! output solid precipitation [kg/m2/s] 
     460         END DO 
     461      END DO 
    435462         CALL iom_put( 'snowpre', sprecip * 86400. )        ! Snow 
    436463         CALL iom_put( 'precip' , tprecip * 86400. )        ! Total precipitation 
     
    477504 
    478505!!gm brutal.... 
    479 !$OMP PARALLEL WORKSHARE 
    480       utau_ice  (:,:) = 0._wp 
    481       vtau_ice  (:,:) = 0._wp 
    482       wndm_ice  (:,:) = 0._wp 
    483 !$OMP END PARALLEL WORKSHARE 
     506!$OMP PARALLEL DO schedule(static) private(jj, ji) 
     507      DO jj = 1, jpj 
     508         DO ji = 1, jpi 
     509            utau_ice  (ji,jj) = 0._wp 
     510            vtau_ice  (ji,jj) = 0._wp 
     511            wndm_ice  (ji,jj) = 0._wp 
     512         END DO 
     513      END DO 
    484514!!gm end 
    485515 
     
    515545         ! 
    516546      CASE( 'C' )                  ! C-grid ice dynamics :   U & V-points (same as ocean) 
    517 !$OMP PARALLEL DO schedule(static) private(jj,ji,zwndi_t,zwndj_t) 
     547!$OMP PARALLEL 
     548!$OMP DO schedule(static) private(jj,ji,zwndi_t,zwndj_t) 
    518549         DO jj = 2, jpj 
    519550            DO ji = fs_2, jpi   ! vect. opt. 
     
    523554            END DO 
    524555         END DO 
    525 !$OMP PARALLEL DO schedule(static) private(jj,ji) 
     556!$OMP DO schedule(static) private(jj,ji) 
    526557         DO jj = 2, jpjm1 
    527558            DO ji = fs_2, fs_jpim1   ! vect. opt. 
     
    532563            END DO 
    533564         END DO 
     565!$OMP END PARALLEL 
    534566         CALL lbc_lnk( utau_ice, 'U', -1. ) 
    535567         CALL lbc_lnk( vtau_ice, 'V', -1. ) 
     
    637669      END DO 
    638670      ! 
    639 !$OMP WORKSHARE 
    640       tprecip(:,:) = sf(jp_prec)%fnow(:,:,1) * rn_pfac      ! total precipitation [kg/m2/s] 
    641       sprecip(:,:) = sf(jp_snow)%fnow(:,:,1) * rn_pfac      ! solid precipitation [kg/m2/s] 
    642 !$OMP END WORKSHARE 
     671!$OMP DO schedule(static) private(jj, ji) 
     672      DO jj = 1, jpj 
     673         DO ji = 1, jpi 
     674            tprecip(ji,jj) = sf(jp_prec)%fnow(ji,jj,1) * rn_pfac      ! total precipitation [kg/m2/s] 
     675            sprecip(ji,jj) = sf(jp_snow)%fnow(ji,jj,1) * rn_pfac      ! solid precipitation [kg/m2/s] 
     676         END DO 
     677      END DO 
    643678!$OMP END PARALLEL       
    644679      CALL iom_put( 'snowpre', sprecip * 86400. )                  ! Snow precipitation 
     
    650685      ! --- evaporation --- ! 
    651686      z1_lsub = 1._wp / Lsub 
    652 !$OMP PARALLEL WORKSHARE       
    653       evap_ice (:,:,:) = rn_efac * qla_ice (:,:,:) * z1_lsub    ! sublimation 
    654       devap_ice(:,:,:) = rn_efac * dqla_ice(:,:,:) * z1_lsub    ! d(sublimation)/dT 
    655       zevap    (:,:)   = rn_efac * ( emp(:,:) + tprecip(:,:) )  ! evaporation over ocean 
    656  
    657       ! --- evaporation minus precipitation --- ! 
    658       zsnw(:,:) = 0._wp 
    659 !$OMP END PARALLEL WORKSHARE       
     687 
     688!$OMP PARALLEL       
     689!$OMP DO schedule(static) private(jl, jj, ji) 
     690      DO jl = 1, jpl  
     691         DO jj = 1, jpj 
     692            DO ji = 1, jpi 
     693               evap_ice (ji,jj,jl) = rn_efac * qla_ice (ji,jj,jl) * z1_lsub    ! sublimation 
     694               devap_ice(ji,jj,jl) = rn_efac * dqla_ice(ji,jj,jl) * z1_lsub    ! d(sublimation)/dT 
     695            END DO 
     696         END DO 
     697      END DO 
     698!$OMP DO schedule(static) private(jj, ji) 
     699      DO jj = 1, jpj 
     700         DO ji = 1, jpi 
     701            zevap    (ji,jj)   = rn_efac * ( emp(ji,jj) + tprecip(ji,jj) )  ! evaporation over ocean 
     702            ! --- evaporation minus precipitation --- ! 
     703            zsnw(ji,jj) = 0._wp 
     704         END DO 
     705      END DO 
     706!$OMP END PARALLEL 
    660707      CALL lim_thd_snwblow( pfrld, zsnw )  ! snow distribution over ice after wind blowing  
     708    
    661709      emp_oce(:,:) = pfrld(:,:) * zevap(:,:) - ( tprecip(:,:) - sprecip(:,:) ) - sprecip(:,:) * (1._wp - zsnw ) 
    662710      emp_ice(:,:) = SUM( a_i_b(:,:,:) * evap_ice(:,:,:), dim=3 ) - sprecip(:,:) * zsnw 
     
    664712 
    665713      ! --- heat flux associated with emp --- ! 
    666       qemp_oce(:,:) = - pfrld(:,:) * zevap(:,:) * sst_m(:,:) * rcp                               & ! evap at sst 
    667          &          + ( tprecip(:,:) - sprecip(:,:) ) * ( sf(jp_tair)%fnow(:,:,1) - rt0 ) * rcp  & ! liquid precip at Tair 
    668          &          +   sprecip(:,:) * ( 1._wp - zsnw ) *                                        & ! solid precip at min(Tair,Tsnow) 
    669          &              ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus ) 
    670       qemp_ice(:,:) =   sprecip(:,:) * zsnw *                                                    & ! solid precip (only) 
    671          &              ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus ) 
     714      qemp_oce(:,:) = - pfrld(:,:) * zevap(:,:) * sst_m(:,:) * rcp                            & ! evap at sst 
     715      &          + ( tprecip(:,:) - sprecip(:,:) ) * ( sf(jp_tair)%fnow(:,:,1) - rt0 ) * rcp  & ! liquid precip at Tair 
     716      &          +   sprecip(:,:) * ( 1._wp - zsnw ) *                                    & ! solid precip at min(Tair,Tsnow) 
     717      &              ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus ) 
     718      qemp_ice(:,:) =   sprecip(:,:) * zsnw *                                                   & ! solid precip (only) 
     719      &              ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus ) 
    672720 
    673721      ! --- total solar and non solar fluxes --- ! 
     
    675723      qsr_tot(:,:) = pfrld(:,:) * qsr_oce(:,:) + SUM( a_i_b(:,:,:) * qsr_ice(:,:,:), dim=3 ) 
    676724 
    677       ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo) --- ! 
     725      ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo) 
     726      ! --- ! 
    678727      qprec_ice(:,:) = rhosn * ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus ) 
    679728 
     
    684733                                   ! But we do not have Tice => consider it at 0°C => evap=0  
    685734      END DO 
    686  
    687735      CALL wrk_dealloc( jpi,jpj, zevap, zsnw )  
    688736#endif 
     
    693741      ! ( Maykut and Untersteiner, 1971 ; Ebert and Curry, 1993 ) 
    694742      ! 
    695 !$OMP PARALLEL WORKSHARE       
    696       fr1_i0(:,:) = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice ) 
    697       fr2_i0(:,:) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice ) 
    698 !$OMP END PARALLEL WORKSHARE       
     743!$OMP PARALLEL DO schedule(static) private(jj, ji) 
     744      DO jj = 1, jpj 
     745         DO ji = 1, jpi 
     746            fr1_i0(ji,jj) = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice ) 
     747            fr2_i0(ji,jj) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice ) 
     748         END DO 
     749      END DO 
    699750      ! 
    700751      ! 
     
    753804      ! 
    754805      INTEGER ::   j_itt 
     806      INTEGER ::   ji, jj    ! dummy loop indices 
    755807      INTEGER , PARAMETER ::   nb_itt = 5       ! number of itterations 
    756808      LOGICAL ::   l_zt_equal_zu = .FALSE.      ! if q and t are given at different height than U 
     
    787839      !! Neutral coefficients at 10m: 
    788840      IF( ln_cdgw ) THEN      ! wave drag case 
    789 !$OMP PARALLEL WORKSHARE       
    790          cdn_wave(:,:) = cdn_wave(:,:) + rsmall * ( 1._wp - tmask(:,:,1) ) 
    791          ztmp0   (:,:) = cdn_wave(:,:) 
    792 !$OMP END PARALLEL WORKSHARE       
     841!$OMP PARALLEL DO schedule(static) private(jj, ji) 
     842         DO jj = 1, jpj 
     843            DO ji = 1, jpi 
     844               cdn_wave(ji,jj) = cdn_wave(ji,jj) + rsmall * ( 1._wp - tmask(ji,jj,1) ) 
     845               ztmp0   (ji,jj) = cdn_wave(ji,jj) 
     846            END DO 
     847         END DO 
    793848      ELSE 
    794849         ztmp0 = cd_neutral_10m( U_zu ) 
Note: See TracChangeset for help on using the changeset viewer.