SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/subscale_aos.F90
Go to the documentation of this file.
00001 !     #########
00002       SUBROUTINE SUBSCALE_AOS(OZ0EFFI,OZ0EFFJ,PSEA)
00003 !     #############################################
00004 !
00005 !!*SUBSCALE_AOS  computes the sum of the ratio: (h'-h)/L when  h'/L >h/L  
00006 !!                  the ' is for subgrid scale orography
00007 !!
00008 !!
00009 !!    METHOD
00010 !!    ------
00011 !!    See M.Georgelin and al. July 1994, Monthly Weather Review.
00012 !!   
00013 !!    EXTERNAL
00014 !!    --------
00015 !!
00016 !!    AUTHOR
00017 !!    ------
00018 !!
00019 !!    M. Georgelin      Laboratoire d'Aerologie
00020 !!
00021 !!    MODIFICATION
00022 !!    ------------
00023 !!
00024 !!    Original    18/12/95
00025 !!    (V. Masson) 10/03/97 rewrites the routine in doctor norm.
00026 !!                         computations are made even if a only a few subsquares
00027 !!                         contains data points.
00028 !!                         returns to the calling routine the localization of
00029 !!                         the points where the z0 coefficients are available.
00030 !!    (V. Masson) 03/2004  externalization
00031 !!
00032 !----------------------------------------------------------------------------
00033 !
00034 !*    0.     DECLARATION
00035 !            -----------
00036 !
00037 USE MODD_PGDWORK,        ONLY : NSSO, XSSQO, LSSQO
00038 USE MODD_PGD_GRID,       ONLY : NL, CGRID, XGRID_PAR, NGRID_PAR
00039 USE MODD_SURF_ATM_GRID_n, ONLY : XMESH_SIZE
00040 USE MODD_SURF_ATM_SSO_n,  ONLY : XAOSIP, XAOSIM, XAOSJP, XAOSJM, &
00041                                   XHO2IP, XHO2IM, XHO2JP, XHO2JM, &
00042                                   XAVG_ZS  
00043 !
00044 USE MODI_GET_ADJACENT_MESHES
00045 !
00046 !
00047 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00048 USE PARKIND1  ,ONLY : JPRB
00049 !
00050 USE MODI_GET_MESH_DIM
00051 IMPLICIT NONE
00052 !
00053 !*    0.1    Declaration of dummy arguments
00054 !            ------------------------------
00055 !
00056 LOGICAL, DIMENSION(:), INTENT(OUT) :: OZ0EFFI! .T. : the z0eff coefficients
00057 !                                            ! are computed at grid point
00058 !                                            ! .F. : not enough sub-grid
00059 !                                            ! information avalaible to
00060 !                                            ! compute the coefficients
00061 LOGICAL, DIMENSION(:), INTENT(OUT) :: OZ0EFFJ! .T. : the z0eff coefficients
00062 !                                            ! are computed at grid point
00063 !                                            ! .F. : not enough sub-grid
00064 !                                            ! information avalaible to
00065 !                                            ! compute the coefficients
00066 REAL,    DIMENSION(:), INTENT(IN)  :: PSEA   ! sea fraction
00067 
00068 !
00069 !*    0.2    Declaration of indexes
00070 !            ----------------------
00071 !
00072 !
00073 INTEGER :: JL          ! loop index on grid meshs
00074 INTEGER :: IL          ! grid mesh index of second subgrid point used
00075 INTEGER :: JISS, JJSS  ! loop indexes for subsquares arrays
00076 INTEGER :: JNEXT       ! loop index on subgrid meshes
00077 INTEGER :: INEXT       ! index to add to JISS or JJSS to obtain the following
00078 !                      ! point containing a data in a segment
00079 INTEGER, DIMENSION(NL) :: ILEFT   ! index of left   grid mesh 
00080 INTEGER, DIMENSION(NL) :: IRIGHT  ! index of right  grid mesh 
00081 INTEGER, DIMENSION(NL) :: ITOP    ! index of top    grid mesh 
00082 INTEGER, DIMENSION(NL) :: IBOTTOM ! index of bottom grid mesh
00083 !
00084 !*    0.3    Declaration of counters inside a grid (JL)
00085 !            -----------------------
00086 !
00087 INTEGER :: IHO2COUNTERJP ! number of times where h/2 has been summed for JP coef
00088 INTEGER :: IHO2COUNTERJM ! number of times where h/2 has been summed for JM coef
00089 INTEGER :: IHO2COUNTERIP ! number of times where h/2 has been summed for IP coef
00090 INTEGER :: IHO2COUNTERIM ! number of times where h/2 has been summed for IM coef
00091 INTEGER :: IAOSCOUNTER   ! number of segments where A/S has been summed
00092 INTEGER :: IAOSDIST ! distance between first and last subsquares used in
00093 !                   ! computation of A/S in a subsegment of the grid
00094 LOGICAL :: GFIRST   ! T indicates the first point has been found for this segment.
00095 !
00096 !*    0.4    Declaration of working arrays inside a grid (JL)
00097 !            -----------------------------
00098 !
00099 REAL, DIMENSION(NSSO) :: ZAOSIP ! A/S in each subsegment for IP coef.
00100 REAL, DIMENSION(NSSO) :: ZAOSIM ! A/S in each subsegment for IM coef.
00101 REAL, DIMENSION(NSSO) :: ZAOSJP ! A/S in each subsegment for JP coef.
00102 REAL, DIMENSION(NSSO) :: ZAOSJM ! A/S in each subsegment for JM coef.
00103 REAL :: ZAIP      ! Area in a subsegment for IP coef.
00104 REAL :: ZAIM      ! Area in a subsegment for IM coef.
00105 REAL :: ZAJP      ! Area in a subsegment for JP coef.
00106 REAL :: ZAJM      ! Area in a subsegment for JM coef.
00107 REAL :: ZSUMHO2IP ! sum of h/2 in the grid for IP coef.
00108 REAL :: ZSUMHO2IM ! sum of h/2 in the grid for IM coef.
00109 REAL :: ZSUMHO2JP ! sum of h/2 in the grid for JP coef.
00110 REAL :: ZSUMHO2JM ! sum of h/2 in the grid for JM coef.
00111 REAL :: ZSSAOS    ! A/S between 2 following points along a subsegment
00112 REAL :: ZSLOPE    ! slope between 2 following points along a subsegment
00113 REAL :: ZDXEFF    ! width of a subsquare along I axis
00114 REAL :: ZDYEFF    ! width of a subsquare along J axis
00115 !
00116 !*    0.5    Declaration of other local variables
00117 !            ------------------------------------
00118 !
00119 REAL, DIMENSION(NL)   :: ZDX      ! grid mesh size in x direction
00120 REAL, DIMENSION(NL)   :: ZDY      ! grid mesh size in y direction
00121 REAL, DIMENSION(0:NL) :: ZSLOPEIP ! x mean slope
00122 REAL, DIMENSION(0:NL) :: ZSLOPEJP ! y mean slope
00123 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00124 !----------------------------------------------------------------------------
00125 !
00126 !*    1.     Initializations
00127 !            ---------------
00128 !
00129 !*    1.1    Occurence of computation of the coefficients
00130 !            --------------------------------------------
00131 !
00132 IF (LHOOK) CALL DR_HOOK('SUBSCALE_AOS',0,ZHOOK_HANDLE)
00133 OZ0EFFI(:)=.FALSE.
00134 OZ0EFFJ(:)=.FALSE.
00135 !
00136 !*    1.2    Grid dimension (meters)
00137 !            -----------------------
00138 !
00139  CALL GET_MESH_DIM(CGRID,NGRID_PAR,NL,XGRID_PAR,ZDX,ZDY,XMESH_SIZE)
00140 !
00141 !
00142 !*    1.3    Left, top, right and bottom adjacent gris meshes
00143 !            ------------------------------------------------
00144 !
00145  CALL GET_ADJACENT_MESHES(CGRID,NGRID_PAR,NL,XGRID_PAR,ILEFT,IRIGHT,ITOP,IBOTTOM)
00146 !
00147 !
00148 !*    1.4    Mean slopes between 2 grid meshes
00149 !            -----------
00150 !
00151 ZSLOPEIP(0) = 0.
00152 ZSLOPEJP(0) = 0.
00153 !
00154 DO JL=1,NL
00155   IF (IRIGHT(JL)/=0 .AND. ILEFT(JL)/=0) THEN
00156     ZSLOPEIP(JL) =  0.5 * ( XAVG_ZS(IRIGHT(JL)) - XAVG_ZS(JL) ) &
00157                           / ( 0.5 * (ZDX(IRIGHT(JL)) + ZDX(JL)) ) &
00158                     + 0.5 * ( XAVG_ZS(JL) - XAVG_ZS(ILEFT (JL)) ) &
00159                           / ( 0.5 * (ZDX(JL)  + ZDX(ILEFT(JL))) )  
00160   ELSE
00161     ZSLOPEIP(JL) = 0.
00162   END IF
00163   IF (ITOP(JL)/=0 .AND. IBOTTOM(JL)/=0) THEN
00164     ZSLOPEJP(JL) =  0.5 * ( XAVG_ZS(ITOP(JL))     - XAVG_ZS(JL) ) &
00165                           / ( 0.5 * (ZDY(ITOP(JL))     + ZDY(JL)) ) &
00166                     + 0.5 * ( XAVG_ZS(JL) - XAVG_ZS(IBOTTOM (JL)) ) &
00167                           / ( 0.5 * (ZDY(JL)  + ZDY(IBOTTOM(JL))) )  
00168   ELSE
00169     ZSLOPEJP(JL) = 0.
00170   END IF
00171 END DO
00172 !
00173 !----------------------------------------------------------------------------
00174 !
00175 !*    2.     Loop on grid points
00176 !            -------------------
00177 !
00178 DO JL=1,NL
00179 !
00180 !*    2.1    No land in grid mesh
00181 !            --------------------
00182 !
00183     IF (PSEA(JL)==1.) CYCLE
00184 !
00185 !*    2.2    Index Initializations
00186 !            ---------------------
00187 !
00188     ZDXEFF=ZDX(JL)/FLOAT(NSSO)
00189     ZDYEFF=ZDY(JL)/FLOAT(NSSO)
00190 !
00191 !----------------------------------------------------------------------------
00192 !
00193 !*    3.     Computations for IP and IM fields
00194 !            ---------------------------------
00195 !
00196     ZAOSIP(:)=0.
00197     ZAOSIM(:)=0.
00198     ZSUMHO2IP=0.
00199     ZSUMHO2IM=0.
00200     IHO2COUNTERIP=0
00201     IHO2COUNTERIM=0
00202     IAOSCOUNTER=0
00203 !
00204 !*    3.1    loop on jss index (there is no specific computation along j)
00205 !            -----------------
00206 !
00207     DO JJSS=1,NSSO
00208 !
00209 !*    3.1.1  initializes counters for the A/S subscale segment computation
00210 !
00211       GFIRST = .TRUE.
00212       IAOSDIST=0
00213       ZAIP=0.
00214       ZAIM=0.
00215 !
00216 !*    3.2    loop on iss index
00217 !            -----------------
00218 !
00219       DO JISS=1,NSSO
00220 !
00221 !*    3.3    search for two consecutive grid points
00222 !            --------------------------------------
00223 !
00224 !*    3.3.1 first one
00225 !
00226         IF (.NOT. LSSQO(JISS,JJSS,JL) ) CYCLE
00227 !
00228 !*    3.3.2  second one (up to one grid mesh further)
00229 !
00230         DO JNEXT=1,NSSO
00231           IF (JISS+JNEXT>NSSO) THEN
00232             IL    = IRIGHT(JL)
00233             INEXT = JISS+JNEXT-NSSO
00234           ELSE
00235             IL    = JL
00236             INEXT = JISS+JNEXT
00237           END IF
00238           ! no right point
00239           IF (IL==0) EXIT
00240           ! subgrid data found
00241           IF (LSSQO(INEXT,JJSS,IL)) EXIT
00242         END DO
00243 !
00244 !*    3.3.3  none found: end of loop along jss
00245 !                        ---------------------
00246 !
00247         IF (JNEXT>=NSSO+1) EXIT
00248 !
00249 !*    3.3.4  second point outside of the domain: end of loop along iss
00250 !                                                ---------------------
00251 !
00252         IF (IL==0) EXIT
00253 !
00254 !*    3.4    add terms to sums of A/S and h/2
00255 !            --------------------------------
00256 !
00257         IF (GFIRST) IAOSCOUNTER=IAOSCOUNTER+1
00258         GFIRST = .FALSE.
00259         IAOSDIST   =IAOSDIST+JNEXT
00260 !
00261 !*    3.4.1  mean slope
00262 !
00263         ZSLOPE=ZSLOPEIP(JL)
00264 !
00265 !*    3.4.2  A/S term
00266 !
00267         ZSSAOS =  XSSQO(INEXT,JJSS,IL) - XSSQO(JISS,JJSS,JL) &
00268                   - ZSLOPE * ZDXEFF * JNEXT  
00269         IF (ZSSAOS>0.) ZAIP=ZAIP+ZSSAOS
00270         IF (ZSSAOS<0.) ZAIM=ZAIM-ZSSAOS
00271 !
00272 !*    3.4.3  h/2 term
00273 !
00274         IF (ZSSAOS>0.) THEN
00275           ZSUMHO2IP = ZSUMHO2IP + 0.5 * ZSSAOS
00276           IHO2COUNTERIP=IHO2COUNTERIP+1
00277         END IF
00278         IF (ZSSAOS<0.) THEN
00279           ZSUMHO2IM = ZSUMHO2IM - 0.5 * ZSSAOS
00280           IHO2COUNTERIM=IHO2COUNTERIM+1
00281         END IF
00282 !
00283 !*    3.5    end of loop on iss index
00284 !            ------------------------
00285 !
00286       END DO
00287       IF (IAOSDIST>0) THEN
00288         ZAOSIP(JJSS)=ZAIP/(ZDXEFF*IAOSDIST)
00289         ZAOSIM(JJSS)=ZAIM/(ZDXEFF*IAOSDIST)
00290       END IF
00291 !
00292 !*    3.6    end of loop on jss index
00293 !            ------------------------
00294 !
00295     END DO
00296 !
00297 !*    3.7    end of IP and IM coefficients
00298 !            -----------------------------
00299 !
00300     IF (IAOSCOUNTER>0) THEN
00301       XAOSIP(JL)=SUM(ZAOSIP) / IAOSCOUNTER
00302       XAOSIM(JL)=SUM(ZAOSIM) / IAOSCOUNTER
00303       IF (IHO2COUNTERIP>0) THEN
00304         XHO2IP(JL)=ZSUMHO2IP   / IHO2COUNTERIP
00305       ELSE
00306         XHO2IP(JL)=0.
00307       END IF
00308       IF (IHO2COUNTERIM>0) THEN
00309         XHO2IM(JL)=ZSUMHO2IM   / IHO2COUNTERIM
00310       ELSE
00311         XHO2IM(JL)=0.
00312       END IF
00313       OZ0EFFI(JL)=.TRUE.
00314     END IF
00315 !
00316 !----------------------------------------------------------------------------
00317 !
00318 !*    4.     Computations for JP and JM fields
00319 !            ---------------------------------
00320 !
00321     ZAOSJP(:)=0.
00322     ZAOSJM(:)=0.
00323     ZSUMHO2JP=0.
00324     ZSUMHO2JM=0.
00325     IHO2COUNTERJP=0
00326     IHO2COUNTERJM=0
00327     IAOSCOUNTER=0
00328 !
00329 !*    4.1    loop on iss index (there is no specific computation along i)
00330 !            -----------------
00331 !
00332     DO JISS=1,NSSO
00333 !
00334 !*    4.1.1  initializes counters for the A/S subscale segment computation
00335 !
00336       GFIRST = .TRUE.
00337       IAOSDIST=0
00338       ZAJP=0.
00339       ZAJM=0.
00340 !
00341 !*    4.2    loop on jss index
00342 !            -----------------
00343 !
00344       DO JJSS=1,NSSO
00345 !
00346 !*    4.3    search for two consecutive grid points
00347 !            --------------------------------------
00348 !
00349 !*    4.3.1 first one
00350 !
00351         IF (.NOT. LSSQO(JISS,JJSS,JL) ) CYCLE
00352 !
00353 !*    4.3.2  second one (up to one grid mesh further)
00354 !
00355         DO JNEXT=1,NSSO
00356           IF (JJSS+JNEXT>NSSO) THEN
00357             IL    = ITOP(JL)
00358             INEXT = JJSS+JNEXT-NSSO
00359           ELSE
00360             IL    = JL
00361             INEXT = JJSS+JNEXT
00362           END IF
00363           ! no right point
00364           IF (IL==0) EXIT
00365           ! subgrid data found
00366           IF (LSSQO(JISS,INEXT,IL)) EXIT
00367         END DO
00368 !
00369 !*    4.3.3  none found: end of loop along jss
00370 !                        ---------------------
00371 !
00372         IF (JNEXT>=NSSO+1) EXIT
00373 !
00374 !*    4.3.4  second point outside of the domain: end of loop along iss
00375 !                                                ---------------------
00376 !
00377         IF (IL==0) EXIT
00378 !
00379 !
00380 !*    4.4    add terms to sums of A/S and h/2
00381 !            --------------------------------
00382 !
00383         IF (GFIRST) IAOSCOUNTER=IAOSCOUNTER+1
00384         GFIRST = .FALSE.
00385         IAOSDIST   =IAOSDIST+JNEXT
00386 !
00387 !*    4.4.1  mean slope
00388 !
00389         ZSLOPE=ZSLOPEJP(JL)
00390 !
00391 !*    4.4.2  A/S term
00392 !
00393         ZSSAOS =  XSSQO(JISS,INEXT,IL) - XSSQO(JISS,JJSS,JL) &
00394                   - ZSLOPE * ZDYEFF * JNEXT  
00395         IF (ZSSAOS>0.) ZAJP=ZAJP+ZSSAOS
00396         IF (ZSSAOS<0.) ZAJM=ZAJM-ZSSAOS
00397 !
00398 !*    4.4.3  h/2 term
00399 !
00400         IF (ZSSAOS>0.) THEN
00401           ZSUMHO2JP = ZSUMHO2JP + 0.5 * ZSSAOS
00402           IHO2COUNTERJP=IHO2COUNTERJP+1
00403         END IF
00404         IF (ZSSAOS<0.) THEN
00405           ZSUMHO2JM = ZSUMHO2JM - 0.5 * ZSSAOS
00406           IHO2COUNTERJM=IHO2COUNTERJM+1
00407         END IF
00408 !
00409 !*    4.5    end of loop on jss index
00410 !            ------------------------
00411 !
00412       END DO
00413       IF (IAOSDIST>0) THEN
00414         ZAOSJP(JISS)=ZAJP/(ZDYEFF*IAOSDIST)
00415         ZAOSJM(JISS)=ZAJM/(ZDYEFF*IAOSDIST)
00416       END IF
00417 !
00418 !*    4.6    end of loop on iss index
00419 !            ------------------------
00420 !
00421     END DO
00422 !
00423 !*    4.7    end of JP and JM coefficients
00424 !            -----------------------------
00425 !
00426     IF (IAOSCOUNTER>0) THEN
00427       XAOSJP(JL)=SUM(ZAOSJP) /IAOSCOUNTER
00428       XAOSJM(JL)=SUM(ZAOSJM) /IAOSCOUNTER
00429       IF (IHO2COUNTERJP>0) THEN
00430         XHO2JP(JL)=ZSUMHO2JP   /IHO2COUNTERJP
00431       ELSE
00432         XHO2JP(JL)=0.
00433       END IF
00434       IF (IHO2COUNTERJM>0) THEN
00435         XHO2JM(JL)=ZSUMHO2JM   /IHO2COUNTERJM
00436       ELSE
00437         XHO2JM(JL)=0.
00438       END IF
00439       OZ0EFFJ(JL)=.TRUE.
00440     END IF
00441 !
00442 !-------------------------------------------------------------------------------
00443 !
00444 !*    5.     Next grid point
00445 !            ---------------
00446 !
00447 END DO
00448 IF (LHOOK) CALL DR_HOOK('SUBSCALE_AOS',1,ZHOOK_HANDLE)
00449 !
00450 !-------------------------------------------------------------------------------
00451 !
00452 END SUBROUTINE SUBSCALE_AOS