Ignore:
Timestamp:
Oct 3, 2017, 8:18:41 AM (7 years ago)
Author:
Ehouarn Millour
Message:

Improved slab routines.
FC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ5/trunk/libf/phylmd/ocean_slab_mod.F90

    r2656 r3002  
    1 !
     1!Completed
    22MODULE ocean_slab_mod
    33!
     
    4040  REAL, ALLOCATABLE, DIMENSION(:,:), PUBLIC, SAVE   :: dt_hdiff
    4141  !$OMP THREADPRIVATE(dt_hdiff)
     42  ! heat flux convergence due to GM eddy advection
     43  REAL, ALLOCATABLE, DIMENSION(:,:), PUBLIC, SAVE   :: dt_gm
     44  !$OMP THREADPRIVATE(dt_gm)
     45  ! Heat Flux correction
     46  REAL, ALLOCATABLE, DIMENSION(:,:), PUBLIC, SAVE   :: dt_qflux
     47  !$OMP THREADPRIVATE(dt_qflux)
    4248  ! fraction of ocean covered by sea ice (sic / (oce+sic))
    4349  REAL, ALLOCATABLE, DIMENSION(:), PUBLIC, SAVE  :: fsic
     
    5056  !$OMP THREADPRIVATE(seaice)
    5157  ! net surface heat flux, weighted by open ocean fraction
    52   REAL, ALLOCATABLE, DIMENSION(:), PUBLIC, SAVE  :: slab_bils
    53   !$OMP THREADPRIVATE(slab_bils)
    5458  ! slab_bils accumulated over cpl_pas timesteps
    5559  REAL, ALLOCATABLE, DIMENSION(:), PRIVATE, SAVE  :: bils_cum
     
    108112   LOGICAL, PUBLIC, SAVE :: slab_hdiff
    109113   !$OMP THREADPRIVATE(slab_hdiff)
     114   LOGICAL, PUBLIC, SAVE :: slab_gm
     115   !$OMP THREADPRIVATE(slab_gm)
    110116   REAL, PRIVATE, SAVE    :: coef_hdiff ! coefficient for horizontal diffusion
    111117   !$OMP THREADPRIVATE(coef_hdiff)
     
    155161    ENDIF
    156162    slabh(1)=50.
     163    CALL getin_p('slab_depth',slabh(1))
    157164    IF (nslay.GT.1) THEN
    158165        slabh(2)=150.
     
    176183    slab_ekman=0
    177184    CALL getin_p('slab_ekman',slab_ekman)
     185! GM eddy advection (2-layers only)
     186    slab_gm=.FALSE.
     187    CALL getin_p('slab_gm',slab_gm)
     188    IF (slab_ekman.LT.2) THEN
     189       slab_gm=.FALSE.
     190    ENDIF
    178191! Convective adjustment
    179192    IF (nslay.EQ.1) THEN
     
    205218         (modname,'pb allocation tslab', 1)
    206219
    207     ALLOCATE(slab_bils(klon), stat = error)
    208     IF (error /= 0) THEN
    209        abort_message='Pb allocation slab_bils'
    210        CALL abort_physic(modname,abort_message,1)
    211     ENDIF
    212     slab_bils(:) = 0.0   
    213220    ALLOCATE(bils_cum(klon), stat = error)
    214221    IF (error /= 0) THEN
     
    252259    ENDIF
    253260
     261    ALLOCATE(dt_qflux(klon,nslay), stat = error)
     262    IF (error /= 0) THEN
     263       abort_message='Pb allocation dt_qflux'
     264       CALL abort_physic(modname,abort_message,1)
     265    ENDIF
     266    dt_qflux(:,:) = 0.0   
     267
     268    IF (slab_gm) THEN !GM advection
     269        ALLOCATE(dt_gm(klon,nslay), stat = error)
     270        IF (error /= 0) THEN
     271           abort_message='Pb allocation dt_gm'
     272           CALL abort_physic(modname,abort_message,1)
     273        ENDIF
     274        dt_gm(:,:) = 0.0   
     275    ENDIF
     276
    254277    IF (slab_ekman.GT.0) THEN ! ekman transport
    255278        ALLOCATE(dt_ekman(klon,nslay), stat = error)
     
    276299    IF (slab_hdiff.OR.(slab_ekman.GT.0)) THEN
    277300      CALL gather(zmasq,zmasq_glo)
    278 !$OMP MASTER  ! Only master thread
     301! Master thread/process only
     302!$OMP MASTER 
    279303      IF (is_mpi_root) THEN
    280304          CALL ini_slab_transp(zmasq_glo)
     
    317341       radsol, snow, &
    318342       qsurf, evap, fluxsens, fluxlat, flux_u1, flux_v1, &
    319        tsurf_new, dflux_s, dflux_l, qflux)
     343       tsurf_new, dflux_s, dflux_l, slab_bils)
    320344   
    321345    USE calcul_fluxs_mod
    322     USE slab_heat_transp_mod, ONLY: divgrad_phy, slab_ekman1, slab_ekman2
     346    USE slab_heat_transp_mod, ONLY: divgrad_phy,slab_ekman1,slab_ekman2,slab_gmdiff
    323347    USE mod_phys_lmdz_para
    324348
     
    369393    REAL, DIMENSION(klon), INTENT(OUT)   :: tsurf_new ! new surface tempearture
    370394    REAL, DIMENSION(klon), INTENT(OUT)   :: dflux_s, dflux_l     
    371     REAL, DIMENSION(klon), INTENT(OUT)   :: qflux
     395    REAL, DIMENSION(klon), INTENT(OUT)   :: slab_bils
    372396
    373397! Local variables
     
    378402    REAL, DIMENSION(klon) :: cal, beta, dif_grnd
    379403    ! for Q-Flux computation: d/dt SST, d/dt ice volume (kg/m2), surf fluxes
    380     REAL, DIMENSION(klon) :: diff_sst, diff_siv, lmt_bils
     404    REAL, DIMENSION(klon) :: diff_sst, diff_siv
     405    REAL, DIMENSION(klon,nslay) :: lmt_bils
    381406    ! for surface wind stress
    382407    REAL, DIMENSION(klon) :: u0, v0
     
    386411    ! horizontal diffusion and Ekman local vars
    387412    ! dimension = global domain (klon_glo) instead of // subdomains
    388     REAL, DIMENSION(klon_glo,nslay) :: dt_hdiff_glo, dt_ekman_glo
     413    REAL, DIMENSION(klon_glo,nslay) :: dt_hdiff_glo,dt_ekman_glo,dt_gm_glo
    389414    ! dt_ekman_glo saved for diagnostic, dt_ekman_tmp used for time loop
    390415    REAL, DIMENSION(klon_glo,nslay) :: dt_hdiff_tmp, dt_ekman_tmp
     
    444469!
    445470!****************************************************************************************
    446     lmt_bils(:)=0.
    447471    CALL limit_slab(itime, dtime, jour, lmt_bils, diff_sst, diff_siv)
    448472    ! lmt_bils and diff_sst,siv saved by limit_slab
    449     qflux(:)=lmt_bils(:)+diff_sst(:)/cyang/86400.-diff_siv(:)*ice_den*ice_lat/86400.
    450473    ! qflux = total QFlux correction (in W/m2)
     474    dt_qflux(:,1)=lmt_bils(:,1)+diff_sst(:)/cyang/86400.-diff_siv(:)*ice_den*ice_lat/86400.
     475    IF (nslay.GT.1) THEN
     476       dt_qflux(:,2:nslay)=lmt_bils(:,2:nslay)
     477    END IF
    451478
    452479!****************************************************************************************
     
    469496        CALL gather(tslab,tslab_glo)
    470497      ! Compute horiz transport on one process only
    471 !$OMP MASTER  ! Only master thread
    472         IF (is_mpi_root) THEN ! Only master processus         
     498        IF (is_mpi_root .AND. is_omp_root) THEN ! Only master processus         
    473499          IF (slab_hdiff) THEN
    474500              dt_hdiff_glo(:,:)=0.
     
    476502          IF (slab_ekman.GT.0) THEN
    477503              dt_ekman_glo(:,:)=0.
     504          END IF
     505          IF (slab_gm) THEN
     506              dt_gm_glo(:,:)=0.
    478507          END IF
    479508          DO i=1,cpl_pas ! time splitting for numerical stability
     
    483512                  CALL slab_ekman1(taux_glo,tauy_glo,tslab_glo,dt_ekman_tmp)
    484513                CASE (2)
    485                   CALL slab_ekman2(taux_glo,tauy_glo,tslab_glo,dt_ekman_tmp)
     514                  CALL slab_ekman2(taux_glo,tauy_glo,tslab_glo,dt_ekman_tmp,dt_hdiff_tmp,slab_gm)
    486515                CASE DEFAULT
    487516                  dt_ekman_tmp(:,:)=0.
     
    493522              ENDDO
    494523              tslab_glo=tslab_glo+dt_ekman_tmp*dtime
     524              IF (slab_gm) THEN ! Gent-McWilliams eddy advection
     525                dt_gm_glo(:,:)=dt_gm_glo(:,:)+ dt_hdiff_tmp(:,:)
     526                ! convert dt from K.s-1.(kg.m-2) to K.s-1   
     527                DO k=1,nslay
     528                  dt_hdiff_tmp(:,k)=dt_hdiff_tmp(:,k)/(slabh(k)*sea_den)
     529                END DO
     530                tslab_glo=tslab_glo+dt_hdiff_tmp*dtime
     531              END IF
    495532            ENDIF
     533! GM included in Ekman_2
     534!            IF (slab_gm) THEN ! Gent-McWilliams eddy advection
     535!              CALL slab_gmdiff(tslab_glo,dt_hdiff_tmp)
     536!              ! convert dt_gm from K.m.s-1 to K.s-1   
     537!              DO k=1,nslay
     538!                dt_hdiff_tmp(:,k)=dt_hdiff_tmp(:,k)/slabh(k)
     539!              END DO
     540!              tslab_glo=tslab_glo+dt_hdiff_tmp*dtime
     541!              dt_gm_glo(:,:)=dt_gm_glo(:,:)+ dt_hdiff_tmp(:,:)
     542!            END IF
    496543            IF (slab_hdiff) THEN ! horizontal diffusion
    497544              ! laplacian of slab T
     
    509556            END DO
    510557          END IF
     558          IF (slab_gm) THEN
     559            !dt_hdiff_glo saved in W/m2
     560            dt_gm_glo(:,:)=dt_gm_glo(:,:)*sea_cap/cpl_pas
     561          END IF
    511562          IF (slab_ekman.GT.0) THEN
    512563            ! dt_ekman_glo saved in W/m2
    513564            dt_ekman_glo(:,:)=dt_ekman_glo(:,:)*sea_cap/cpl_pas
    514565          END IF
    515         END IF ! is_mpi_root
    516 !$OMP END MASTER
     566        END IF ! master process
    517567!$OMP BARRIER
    518568        ! Send new fields back to all processes
     
    520570        IF (slab_hdiff) THEN
    521571          CALL Scatter(dt_hdiff_glo,dt_hdiff)
     572        END IF
     573        IF (slab_gm) THEN
     574          CALL Scatter(dt_gm_glo,dt_gm)
    522575        END IF
    523576        IF (slab_ekman.GT.0) THEN
     
    533586! ***********************************
    534587      ! Add read QFlux
    535       tslab(:,1)=tslab(:,1)+qflux(:)*cyang*dtime*cpl_pas
     588      DO k=1,nslay
     589        tslab(:,k)=tslab(:,k)+dt_qflux(:,k)*cyang*dtime*cpl_pas &
     590                   *slabh(1)/slabh(k)
     591      END DO
    536592      ! Add cumulated surface fluxes
    537593      tslab(:,1)=tslab(:,1)+bils_cum(:)*cyang*dtime
     
    913969    IF (ALLOCATED(tice)) DEALLOCATE(tice)
    914970    IF (ALLOCATED(seaice)) DEALLOCATE(seaice)
    915     IF (ALLOCATED(slab_bils)) DEALLOCATE(slab_bils)
    916971    IF (ALLOCATED(slab_bilg)) DEALLOCATE(slab_bilg)
    917972    IF (ALLOCATED(bilg_cum)) DEALLOCATE(bilg_cum)
     
    921976    IF (ALLOCATED(dt_ekman)) DEALLOCATE(dt_ekman)
    922977    IF (ALLOCATED(dt_hdiff)) DEALLOCATE(dt_hdiff)
     978    IF (ALLOCATED(dt_gm)) DEALLOCATE(dt_gm)
     979    IF (ALLOCATED(dt_qflux)) DEALLOCATE(dt_qflux)
    923980
    924981  END SUBROUTINE ocean_slab_final
Note: See TracChangeset for help on using the changeset viewer.