SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
pack_grid_lonlatval.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! ##############################################################
6  SUBROUTINE pack_grid_lonlatval(KMASK_SIZE,KMASK,KGRID_PAR1,PGRID_PAR1,KGRID_PAR2,OPACK,PGRID_PAR2)
7 ! ##############################################################
8 !
9 !!**** *PACK_GRID_IGN* packs the grid definition vector
10 !!
11 !! PURPOSE
12 !! -------
13 !!
14 !! METHOD
15 !! ------
16 !!
17 !! REFERENCE
18 !! ---------
19 !!
20 !! AUTHOR
21 !! ------
22 !!
23 !! E. Martin Meteo-France
24 !!
25 !! MODIFICATION
26 !! ------------
27 !!
28 !! Original 10/2007
29 !!
30 !----------------------------------------------------------------------------
31 !
32 !* 0. DECLARATION
33 ! -----------
34 !
37 !
38 !
39 USE yomhook ,ONLY : lhook, dr_hook
40 USE parkind1 ,ONLY : jprb
41 !
42 IMPLICIT NONE
43 !
44 !* 0.1 Declaration of arguments
45 ! ------------------------
46 !
47 INTEGER, INTENT(IN) :: kmask_size ! size of mask
48 INTEGER, DIMENSION(KMASK_SIZE), INTENT(IN) :: kmask ! mask used
49 INTEGER, INTENT(IN) :: kgrid_par1 ! size of input grid vector
50 REAL, DIMENSION(KGRID_PAR1), INTENT(IN) :: pgrid_par1 ! parameters of input grid
51 INTEGER, INTENT(INOUT) :: kgrid_par2 ! size of output grid vector
52 LOGICAL, INTENT(IN) :: opack ! flag to pack the grid vector
53 REAL, DIMENSION(KGRID_PAR2), INTENT(OUT) :: pgrid_par2 ! parameters of output grid
54 !
55 !* 0.2 Declaration of other local variables
56 ! ------------------------------------
57 !
58 REAL, DIMENSION(:), ALLOCATABLE :: zx1 ! X conformal coordinate of grid mesh
59 REAL, DIMENSION(:), ALLOCATABLE :: zy1 ! Y conformal coordinate of grid mesh
60 REAL, DIMENSION(:), ALLOCATABLE :: zdx1 ! X grid mesh size
61 REAL, DIMENSION(:), ALLOCATABLE :: zdy1 ! Y grid mesh size
62 REAL, DIMENSION(:), ALLOCATABLE :: zx2 ! X conformal coordinate of grid mesh
63 REAL, DIMENSION(:), ALLOCATABLE :: zy2 ! Y conformal coordinate of grid mesh
64 REAL, DIMENSION(:), ALLOCATABLE :: zdx2 ! X grid mesh size
65 REAL, DIMENSION(:), ALLOCATABLE :: zdy2 ! Y grid mesh size
66 
67 INTEGER :: il1 ! number of points of input grid
68 REAL, DIMENSION(:), POINTER :: zgrid_par2 ! parameters of output grid
69 REAL(KIND=JPRB) :: zhook_handle
70 !----------------------------------------------------------------------------
71 !
72 !* 2. Computes grid parameters
73 ! ------------------------
74 !
75 IF (lhook) CALL dr_hook('PACK_GRID_LONLATVAL',0,zhook_handle)
76  CALL get_gridtype_lonlatval(pgrid_par1,kl=il1)
77 !
78 ALLOCATE(zx1(il1))
79 ALLOCATE(zy1(il1))
80 ALLOCATE(zdx1(il1))
81 ALLOCATE(zdy1(il1))
82 !
83  CALL get_gridtype_lonlatval(pgrid_par1,px=zx1,py=zy1,pdx=zdx1,pdy=zdy1)
84 !
85 ALLOCATE(zx2(kmask_size))
86 ALLOCATE(zy2(kmask_size))
87 ALLOCATE(zdx2(kmask_size))
88 ALLOCATE(zdy2(kmask_size))
89 !
90  CALL pack_same_rank(kmask,zx1 ,zx2 )
91  CALL pack_same_rank(kmask,zy1 ,zy2 )
92  CALL pack_same_rank(kmask,zdx1,zdx2)
93  CALL pack_same_rank(kmask,zdy1,zdy2)
94 !
95 DEALLOCATE(zx1 )
96 DEALLOCATE(zy1 )
97 DEALLOCATE(zdx1)
98 DEALLOCATE(zdy1)
99 !
100  CALL put_gridtype_lonlatval(zgrid_par2,zx2,zy2,zdx2,zdy2)
101 !
102 IF (opack) THEN
103  pgrid_par2(:) = zgrid_par2(:)
104 ELSE
105  kgrid_par2 = SIZE(zgrid_par2(:))
106 END IF
107 !
108 DEALLOCATE(zgrid_par2)
109 DEALLOCATE(zx2 )
110 DEALLOCATE(zy2 )
111 DEALLOCATE(zdx2)
112 DEALLOCATE(zdy2)
113 IF (lhook) CALL dr_hook('PACK_GRID_LONLATVAL',1,zhook_handle)
114 !-------------------------------------------------------------------------------
115 !
116 END SUBROUTINE pack_grid_lonlatval
subroutine put_gridtype_lonlatval(PGRID_PAR, PX, PY, PDX, PDY)
subroutine pack_grid_lonlatval(KMASK_SIZE, KMASK, KGRID_PAR1, PGRID_PAR1, KGRID_PAR2, OPACK, PGRID_PAR2)
subroutine get_gridtype_lonlatval(PGRID_PAR, KL, PX, PY, PDX, PDY)