SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/hor_interpol_cartesian.F90
Go to the documentation of this file.
00001 !     #########
00002 SUBROUTINE HOR_INTERPOL_CARTESIAN(KLUOUT,PFIELDIN,PFIELDOUT)
00003 !     #################################################################################
00004 !
00005 !
00006 USE MODD_PREP,           ONLY : XLAT_OUT, XLON_OUT, XX_OUT, XY_OUT, LINTERP
00007 USE MODD_GRID_CARTESIAN, ONLY : XX, XY, NX, NY
00008 USE MODD_SURF_PAR,   ONLY : XUNDEF
00009 !
00010 USE MODE_GRIDTYPE_CARTESIAN
00011 USE MODI_BILIN
00012 !
00013 !
00014 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00015 USE PARKIND1  ,ONLY : JPRB
00016 !
00017 IMPLICIT NONE
00018 !
00019 !*      0.1    declarations of arguments
00020 !
00021 INTEGER,            INTENT(IN)  :: KLUOUT    ! logical unit of output listing
00022 REAL, DIMENSION(:,:), INTENT(IN)  :: PFIELDIN  ! field to interpolate horizontally
00023 REAL, DIMENSION(:,:), INTENT(OUT) :: PFIELDOUT ! interpolated field
00024 !
00025 !*      0.2    declarations of local variables
00026 !
00027 REAL, DIMENSION(:),   ALLOCATABLE :: ZX       ! X coordinate
00028 REAL, DIMENSION(:),   ALLOCATABLE :: ZY       ! Y coordinate
00029 INTEGER                           :: INO      ! output number of points
00030 REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZFIELDIN ! input field
00031 !
00032 INTEGER                           :: JI       ! loop index
00033 INTEGER                           :: JJ       ! loop index
00034 INTEGER                           :: JL       ! loop index
00035 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00036 
00037 !-------------------------------------------------------------------------------------
00038 !
00039 !*      1.    Allocations
00040 !
00041 IF (LHOOK) CALL DR_HOOK('HOR_INTERPOL_CARTESIAN',0,ZHOOK_HANDLE)
00042 INO = SIZE(XX_OUT)
00043 !
00044 ALLOCATE(ZX      (INO))
00045 ALLOCATE(ZY      (INO))
00046 !
00047 !*      2.    Transformation of latitudes/longitudes into metric coordinates of output grid
00048 !
00049 !* WARNING : here, because the input grid is not geographic, one assumes that
00050 !            coordinates are coherent between input and output grid, but without
00051 !            any way to check it.
00052 !
00053 ZX = XX_OUT
00054 ZY = XY_OUT
00055 !
00056 !
00057 !*      3.    Put input field on its squared grid
00058 !
00059 ALLOCATE(ZFIELDIN(NX,NY,SIZE(PFIELDIN,2)))
00060 !
00061 DO JJ=1,NY
00062   DO JI=1,NX
00063     ZFIELDIN(JI,JJ,:) = PFIELDIN(JI+NX*(JJ-1),:)
00064   END DO
00065 END DO
00066 !
00067 !*      4.    Interpolation with bilinear
00068 !
00069 DO JL=1,SIZE(PFIELDIN,2)
00070   CALL BILIN(KLUOUT,XX,XY,ZFIELDIN(:,:,JL),ZX,ZY,PFIELDOUT(:,JL),LINTERP)
00071 END DO
00072 !
00073 !
00074 !*      5.    Deallocations
00075 !
00076 !
00077 DEALLOCATE(ZX)
00078 DEALLOCATE(ZY)
00079 DEALLOCATE(ZFIELDIN)
00080 IF (LHOOK) CALL DR_HOOK('HOR_INTERPOL_CARTESIAN',1,ZHOOK_HANDLE)
00081 !
00082 !-------------------------------------------------------------------------------------
00083 END SUBROUTINE HOR_INTERPOL_CARTESIAN