Ignore:
Timestamp:
Jul 18, 2016, 9:41:10 PM (8 years ago)
Author:
Laurent Fairhead
Message:

Merged trunk changes r2545:2589 into testing branch

Location:
LMDZ5/branches/testing
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LMDZ5/branches/testing

  • LMDZ5/branches/testing/libf/phylmd/grid_noro_m.F90

    r2408 r2594  
    33!*******************************************************************************
    44
     5  USE print_control_mod, ONLY: lunout
     6  USE assert_eq_m,       ONLY: assert_eq
    57  PRIVATE
    6   PUBLIC :: grid_noro
     8  PUBLIC :: grid_noro, grid_noro0
    79
    810
     
    4547!    on the edge are contained in input cells.
    4648!===============================================================================
    47   USE assert_eq_m, ONLY: assert_eq
    48   USE print_control_mod, ONLY: lunout
    49   IMPLICIT NONE
    50   REAL, PARAMETER :: epsfra = 1.e-5
     49  IMPLICIT NONE
    5150!-------------------------------------------------------------------------------
    5251! Arguments:
     
    315314!-------------------------------------------------------------------------------
    316315!
     316SUBROUTINE grid_noro0(xd,yd,zd,x,y,zphi,mask)
     317!
     318!===============================================================================
     319! Purpose: Extracted from grid_noro to provide geopotential height for dynamics
     320!          without any call to physics subroutines.
     321!===============================================================================
     322  IMPLICIT NONE
     323!-------------------------------------------------------------------------------
     324! Arguments:
     325  REAL, INTENT(IN)   :: xd(:), yd(:) !--- INPUT  COORDINATES     (imdp) (jmdp)
     326  REAL, INTENT(IN)   :: zd(:,:)      !--- INPUT  FIELD           (imdp,jmdp)
     327  REAL, INTENT(IN)   :: x(:), y(:)   !--- OUTPUT COORDINATES     (imar+1) (jmar)
     328  REAL, INTENT(OUT)  :: zphi(:,:)    !--- GEOPOTENTIAL           (imar+1,jmar)
     329  REAL, INTENT(INOUT):: mask(:,:)    !--- MASK                   (imar+1,jmar)
     330!-------------------------------------------------------------------------------
     331! Local variables:
     332  CHARACTER(LEN=256) :: modname="grid_noro0"
     333  REAL, ALLOCATABLE :: xusn(:), yusn(:)           ! dim (imdp+2*iext) (jmdp+2)
     334  REAL, ALLOCATABLE :: zusn(:,:)                  ! dim (imdp+2*iext,jmdp+2)
     335  REAL, ALLOCATABLE :: weight(:,:)                ! dim (imar+1,jmar)
     336  REAL, ALLOCATABLE :: mask_tmp(:,:), zmea(:,:)   ! dim (imar+1,jmar)
     337  REAL, ALLOCATABLE :: num_tot(:,:), num_lan(:,:) ! dim (imax,jmax)
     338  REAL, ALLOCATABLE :: a(:), b(:)                 ! dim (imax)
     339  REAL, ALLOCATABLE :: c(:), d(:)                 ! dim (jmax)
     340  LOGICAL :: masque_lu
     341  INTEGER :: i, ii, imdp, imar, iext
     342  INTEGER :: j, jj, jmdp, jmar, nn
     343  REAL    :: xpi, zlenx, weighx, xincr,  zbordnor, zmeanor, zweinor, zbordest
     344  REAL    :: rad, zleny, weighy, masque, zbordsud, zmeasud, zweisud, zbordoue
     345!-------------------------------------------------------------------------------
     346  imdp=assert_eq(SIZE(xd),SIZE(zd,1),TRIM(modname)//" imdp")
     347  jmdp=assert_eq(SIZE(yd),SIZE(zd,2),TRIM(modname)//" jmdp")
     348  imar=assert_eq(SIZE(x),SIZE(zphi,1),SIZE(mask,1),TRIM(modname)//" imar")-1
     349  jmar=assert_eq(SIZE(y),SIZE(zphi,2),SIZE(mask,2),TRIM(modname)//" jmar")
     350! IF(imar/=iim)   CALL abort_gcm(TRIM(modname),'imar/=iim'  ,1)
     351! IF(jmar/=jjm+1) CALL abort_gcm(TRIM(modname),'jmar/=jjm+1',1)
     352  iext=imdp/10
     353  xpi = ACOS(-1.)
     354  rad = 6371229.
     355
     356!--- ARE WE USING A READ MASK ?
     357  masque_lu=ANY(mask/=-99999.); IF(.NOT.masque_lu) mask=0.0
     358  WRITE(lunout,*)'Masque lu: ',masque_lu
     359
     360!--- EXTENSION OF THE INPUT DATABASE TO PROCEED COMPUTATIONS AT BOUNDARIES:
     361  ALLOCATE(xusn(imdp+2*iext))
     362  xusn(1     +iext:imdp  +iext)=xd(:)
     363  xusn(1          :       iext)=xd(1+imdp-iext:imdp)-2.*xpi
     364  xusn(1+imdp+iext:imdp+2*iext)=xd(1          :iext)+2.*xpi
     365
     366  ALLOCATE(yusn(jmdp+2))
     367  yusn(1       )=yd(1)   +(yd(1)   -yd(2))
     368  yusn(2:jmdp+1)=yd(:)
     369  yusn(  jmdp+2)=yd(jmdp)+(yd(jmdp)-yd(jmdp-1))
     370
     371  ALLOCATE(zusn(imdp+2*iext,jmdp+2))
     372  zusn(1       +iext:imdp  +iext,2:jmdp+1)=zd  (:                   ,     :)
     373  zusn(1            :       iext,2:jmdp+1)=zd  (imdp-iext+1:imdp    ,     :)
     374  zusn(1+imdp  +iext:imdp+2*iext,2:jmdp+1)=zd  (1:iext              ,     :)
     375  zusn(1            :imdp/2+iext,       1)=zusn(1+imdp/2:imdp  +iext,     2)
     376  zusn(1+imdp/2+iext:imdp+2*iext,       1)=zusn(1       :imdp/2+iext,     2)
     377  zusn(1            :imdp/2+iext,  jmdp+2)=zusn(1+imdp/2:imdp  +iext,jmdp+1)
     378  zusn(1+imdp/2+iext:imdp+2*iext,  jmdp+2)=zusn(1       :imdp/2+iext,jmdp+1)
     379
     380!--- COMPUTE LIMITS OF MODEL GRIDPOINT AREA (REGULAR GRID)
     381  ALLOCATE(a(imar+1),b(imar+1))
     382  b(1:imar)=(x(1:imar  )+ x(2:imar+1))/2.0
     383  b(imar+1)= x(  imar+1)+(x(  imar+1)-x(imar))/2.0
     384  a(1)=x(1)-(x(2)-x(1))/2.0
     385  a(2:imar+1)= b(1:imar)
     386
     387  ALLOCATE(c(jmar),d(jmar))
     388  d(1:jmar-1)=(y(1:jmar-1)+ y(2:jmar))/2.0
     389  d(  jmar  )= y(  jmar  )+(y(  jmar)-y(jmar-1))/2.0
     390  c(1)=y(1)-(y(2)-y(1))/2.0
     391  c(2:jmar)=d(1:jmar-1)
     392
     393!--- INITIALIZATIONS:
     394  ALLOCATE(weight(imar+1,jmar)); weight(:,:)= 0.0
     395  ALLOCATE(zmea  (imar+1,jmar)); zmea  (:,:)= 0.0
     396
     397!--- SUMMATION OVER GRIDPOINT AREA
     398  zleny=xpi/REAL(jmdp)*rad
     399  xincr=xpi/REAL(jmdp)/2.
     400  ALLOCATE(num_tot(imar+1,jmar)); num_tot(:,:)=0.
     401  ALLOCATE(num_lan(imar+1,jmar)); num_lan(:,:)=0.
     402  DO ii = 1, imar+1
     403    DO jj = 1, jmar
     404      DO j = 2,jmdp+1
     405        zlenx  =zleny  *COS(yusn(j))
     406        zbordnor=(xincr+c(jj)-yusn(j))*rad
     407        zbordsud=(xincr-d(jj)+yusn(j))*rad
     408        weighy=AMAX1(0.,AMIN1(zbordnor,zbordsud,zleny))
     409        IF(weighy/=0) THEN
     410          DO i = 2, imdp+2*iext-1
     411            zbordest=(xusn(i)-a(ii)+xincr)*rad*COS(yusn(j))
     412            zbordoue=(b(ii)+xincr-xusn(i))*rad*COS(yusn(j))
     413            weighx=AMAX1(0.,AMIN1(zbordest,zbordoue,zlenx))
     414            IF(weighx/=0)THEN
     415              num_tot(ii,jj)=num_tot(ii,jj)+1.0
     416              IF(zusn(i,j)>=1.)num_lan(ii,jj)=num_lan(ii,jj)+1.0
     417              weight(ii,jj)=weight(ii,jj)+weighx*weighy
     418              zmea  (ii,jj)=zmea  (ii,jj)+zusn(i,j)*weighx*weighy !--- MEAN
     419            END IF
     420          END DO
     421        END IF
     422      END DO
     423    END DO
     424  END DO
     425
     426!--- COMPUTE PARAMETERS NEEDED BY LOTT & MILLER (1997) AND LOTT (1999) SSO SCHEME
     427  IF(.NOT.masque_lu) THEN
     428    WHERE(weight(:,1:jmar-1)/=0.0) mask=num_lan(:,:)/num_tot(:,:)
     429  END IF
     430  nn=COUNT(weight(:,1:jmar-1)==0.0)
     431  IF(nn/=0) WRITE(lunout,*)'Problem with weight ; vanishing occurrences: ',nn
     432  WHERE(weight/=0.0) zmea(:,:)=zmea(:,:)/weight(:,:)
     433
     434!--- MASK BASED ON GROUND MAXIMUM, 10% THRESHOLD (<10%: SURF PARAMS MEANINGLESS)
     435  ALLOCATE(mask_tmp(imar+1,jmar)); mask_tmp(:,:)=0.0
     436  WHERE(mask>=0.1) mask_tmp = 1.
     437  WHERE(weight(:,:)/=0.0)
     438    zphi(:,:)=mask_tmp(:,:)*zmea(:,:)
     439    zmea(:,:)=mask_tmp(:,:)*zmea(:,:)
     440  END WHERE
     441  WRITE(lunout,*)'  MEAN ORO:' ,MAXVAL(zmea)
     442
     443!--- Values at poles
     444  zphi(imar+1,:)=zphi(1,:)
     445
     446  zweinor=SUM(weight(1:imar,   1),DIM=1)
     447  zweisud=SUM(weight(1:imar,jmar),DIM=1)
     448  zmeanor=SUM(weight(1:imar,   1)*zmea(1:imar,   1),DIM=1)
     449  zmeasud=SUM(weight(1:imar,jmar)*zmea(1:imar,jmar),DIM=1)
     450  zphi(:,1)=zmeanor/zweinor; zphi(:,jmar)=zmeasud/zweisud
     451
     452END SUBROUTINE grid_noro0
     453!
     454!-------------------------------------------------------------------------------
     455
     456
     457!-------------------------------------------------------------------------------
     458!
    317459SUBROUTINE MVA9(x)
    318460!
Note: See TracChangeset for help on using the changeset viewer.