SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/interpol_sbl.F90
Go to the documentation of this file.
00001 !     #########
00002        SUBROUTINE INTERPOL_SBL( PZ, PIN, PH, POUT)
00003 !     #####################################################################
00004 !
00005 !!
00006 !!    PURPOSE
00007 !!    -------
00008 !     This routine do interpolation of field from canopy levels to a defined
00009 !     height. Interpolation is linear.
00010 !         
00011 !     
00012 !!**  METHOD
00013 !!    ------
00014 !     We search for the levels aroud the specified height of interpolation and
00015 !     then perform a linear interpolation. If height of interpolation isn't
00016 !     between two canopy levels, we send the value XUNDEF.
00017 !
00018 !!    EXTERNAL
00019 !!    --------
00020 !!
00021 !!    none
00022 !!
00023 !!    IMPLICIT ARGUMENTS
00024 !!    ------------------ 
00025 !!
00026 !!      
00027 !!    REFERENCE
00028 !!    ---------
00029 !!
00030 !!      
00031 !!    AUTHOR
00032 !!    ------
00033 !     Sebastien Riette
00034 !!
00035 !!
00036 !!    MODIFICATIONS
00037 !!    -------------
00038 !!
00039 !!      Original    14/01/2010
00040 !-------------------------------------------------------------------------------
00041 !
00042 !*       0.     DECLARATIONS
00043 !               ------------
00044 !
00045 USE MODD_SURF_PAR, ONLY : XUNDEF
00046 !
00047 !
00048 !
00049 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00050 USE PARKIND1  ,ONLY : JPRB
00051 !
00052 IMPLICIT NONE
00053 !
00054 !*      0.1    declarations of arguments
00055 !
00056 !
00057 !
00058 REAL, DIMENSION(:,:), INTENT(IN)       :: PZ     ! Height of canopy levels
00059 REAL, DIMENSION(:,:), INTENT(IN)       :: PIN    ! Filed values on canopy levels
00060 REAL,                 INTENT(IN)       :: PH     ! Height of interpolation
00061 !
00062 REAL, DIMENSION(:)  , INTENT(OUT)      :: POUT   ! Interpolated value
00063 !
00064 !*      0.2    declarations of local variables
00065 !
00066 INTEGER :: ILEVEL
00067 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00068 !
00069 !-------------------------------------------------------------------------------
00070 !
00071 ! Starting from the bottom, we look for the canopy level just below 10m and
00072 ! we interpolate linearly the canopy wind field if we're not on last level. If
00073 ! we are on last level, we do nothing and XUNDEF is left in POUT.
00074 IF (LHOOK) CALL DR_HOOK('INTERPOL_SBL',0,ZHOOK_HANDLE)
00075 POUT(:) = XUNDEF
00076 ILEVEL=1
00077 
00078 !While there are XUNDEF values and we aren't at canopy's top
00079 DO WHILE(ANY(POUT(:)==XUNDEF) .AND. ILEVEL/=SIZE(PZ,2))
00080 
00081   !Where interpolation is needed and possible
00082   !(10m is between ILEVEL and ILEVEL+1)
00083   WHERE(POUT(:)==XUNDEF .AND. PZ(:,ILEVEL+1)>=10.)
00084 
00085     !Interpolation between ILEVEL and ILEVEL+1
00086     POUT(:)=PIN(:,ILEVEL) + &
00087               (PIN(:,ILEVEL+1)-PIN(:,ILEVEL)) * &
00088               (PH-PZ(:,ILEVEL)) / (PZ(:,ILEVEL+1)-PZ(:,ILEVEL))  
00089 
00090   END WHERE
00091   ILEVEL=ILEVEL+1
00092 END DO
00093 IF (LHOOK) CALL DR_HOOK('INTERPOL_SBL',1,ZHOOK_HANDLE)
00094 !
00095 !-------------------------------------------------------------------------------
00096 !
00097 END SUBROUTINE INTERPOL_SBL