|
SURFEX v7.3
General documentation of Surfex
|
00001 ! ######### 00002 SUBROUTINE COEF_VER_INTERP_LIN_SURF(PZ1,PZ2,KKLIN,PCOEFLIN) 00003 ! ############################################################### 00004 ! 00005 !!**** *VER_INTERP_LIN* - vertical linear interpolation 00006 !! 00007 !! PURPOSE 00008 !! ------- 00009 ! This function computes the interpolation coefficient XCOEFLIN 00010 ! of the level XKLIN of grid PZ1 which is just under the points of 00011 ! grid PZ2 (respectively called hereafter 'initial' and 'target'), 00012 ! in order to perform linear interpolations between these 2 grids. 00013 ! 00014 ! CAUTION: 00015 ! * The interpolation occurs on the WHOLE grid. Therefore, one must 00016 ! only give as argument to this function the inner points of the domain, 00017 ! particularly for the vertical grid, where there is no physical information 00018 ! under the ground or at and over H. 00019 ! * The level numbers must increase from bottom to top. 00020 !! 00021 !!** METHOD 00022 !! ------ 00023 !! two extrapolations are possible: with the two or four nearest points. 00024 !! 00025 !! Interpolation with 2 points: 00026 !! 00027 !! If there is less than two points on one side, the interpolation is linear. 00028 !! 00029 !! EXTERNAL 00030 !! -------- 00031 !! 00032 !! IMPLICIT ARGUMENTS 00033 !! ------------------ 00034 !! 00035 !! REFERENCE 00036 !! --------- 00037 !! 00038 !! 00039 !! AUTHOR 00040 !! ------ 00041 !! 00042 ! V.Masson Meteo-France 00043 !! 00044 !! MODIFICATIONS 00045 !! ------------- 00046 !! Original 18/07/97 00047 !! 20/01/98 use explicit arguments 00048 !! P Jabouille 20/12/02 no extrapolation under the ground 00049 !! S. Malardel 11/2003 bug of no extrapolation under the ground 00050 !! V. Masson 10/2003 no extrapolation above top 00051 !------------------------------------------------------------------------------- 00052 ! 00053 !* 0. DECLARATIONS 00054 ! ------------ 00055 ! 00056 ! 00057 USE YOMHOOK ,ONLY : LHOOK, DR_HOOK 00058 USE PARKIND1 ,ONLY : JPRB 00059 ! 00060 IMPLICIT NONE 00061 ! 00062 !* 0.1 Declaration of arguments 00063 ! ------------------------ 00064 REAL, DIMENSION(:,:), INTENT(IN) :: PZ1 ! altitudes of the points of the 00065 ! ! initial grid 00066 REAL, DIMENSION(:,:), INTENT(IN) :: PZ2 ! altitudes of the points of the 00067 ! ! target grid 00068 INTEGER, DIMENSION(:,:), INTENT(OUT) :: KKLIN ! number of the level 00069 ! of the data to be interpolated 00070 ! 00071 REAL, DIMENSION(:,:), INTENT(OUT):: PCOEFLIN ! interpolation 00072 ! coefficient 00073 ! 00074 ! 00075 !* 0.2 Declaration of local variables 00076 ! ------------------------------ 00077 ! 00078 LOGICAL,DIMENSION(SIZE(PZ1,1),SIZE(PZ1,2)) :: GLEVEL 00079 INTEGER :: JK2,JI 00080 INTEGER,DIMENSION(SIZE(PZ1,1)) :: ILEVEL 00081 INTEGER,DIMENSION(SIZE(PZ1,1)) :: IUNDER 00082 REAL :: ZEPS ! a small number 00083 REAL(KIND=JPRB) :: ZHOOK_HANDLE 00084 !------------------------------------------------------------------------------- 00085 ! 00086 IF (LHOOK) CALL DR_HOOK('COEF_VER_INTERP_LIN_SURF',0,ZHOOK_HANDLE) 00087 ZEPS=1.E-12 00088 ! 00089 !------------------------------------------------------------------------------- 00090 ! 00091 !* 2. LOOP ON THE TARGET VERTICAL GRID 00092 ! -------------------------------- 00093 ! 00094 DO JK2=1,SIZE(PZ2,2) 00095 ! 00096 !------------------------------------------------------------------------------- 00097 ! 00098 !* 3. Determination of the initial level under the target level JK2 00099 ! ------------------------------------------------------------- 00100 ! 00101 GLEVEL(:,:)=PZ1(:,:)<=SPREAD(PZ2(:,JK2),2,SIZE(PZ1,2)) *(1.-ZEPS) 00102 ILEVEL(:) =COUNT(GLEVEL(:,:),2) 00103 ! 00104 !* linear extrapolation under the ground 00105 IUNDER=ILEVEL 00106 ILEVEL(:)=MAX(ILEVEL(:),1) 00107 ! 00108 !* linear extrapolation above the uppest level 00109 ILEVEL(:)=MIN(ILEVEL(:),SIZE(PZ1,2)-1) 00110 ! 00111 KKLIN(:,JK2)=ILEVEL(:) 00112 00113 !------------------------------------------------------------------------------- 00114 ! 00115 !* 4. Linear interpolation coefficients 00116 ! --------------------------------- 00117 ! 00118 DO JI=1,SIZE(PZ1,1) 00119 IF (PZ1(JI,ILEVEL(JI))==PZ1(JI,ILEVEL(JI)+1)) THEN 00120 PCOEFLIN(JI,JK2)= 0. 00121 ELSE 00122 PCOEFLIN(JI,JK2)=(PZ2(JI,JK2)-PZ1(JI,ILEVEL(JI)+1)) & 00123 /(PZ1(JI,ILEVEL(JI))-PZ1(JI,ILEVEL(JI)+1)) 00124 END IF 00125 IF (IUNDER(JI) < 1 ) PCOEFLIN(JI,JK2)=1. ! no extrapolation 00126 IF (ILEVEL(JI)==SIZE(PZ1,2)-1) PCOEFLIN(JI,JK2)=MAX(PCOEFLIN(JI,JK2),0.) ! no extrapolation 00127 ENDDO 00128 ! 00129 !------------------------------------------------------------------------------- 00130 ! 00131 END DO 00132 IF (LHOOK) CALL DR_HOOK('COEF_VER_INTERP_LIN_SURF',1,ZHOOK_HANDLE) 00133 ! 00134 !------------------------------------------------------------------------------- 00135 ! 00136 END SUBROUTINE COEF_VER_INTERP_LIN_SURF
1.8.0