SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
pack_grid_cartesian.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_cartesian(KMASK_SIZE,KMASK,KGRID_PAR1,PGRID_PAR1,KGRID_PAR2,OPACK,PGRID_PAR2)
7 ! ##############################################################
8 !
9 !!**** *PACK_GRID_CARTESIAN* packs the grid definition vector
10 !!
11 !! PURPOSE
12 !! -------
13 !!
14 !! METHOD
15 !! ------
16 !!
17 !! REFERENCE
18 !! ---------
19 !!
20 !! AUTHOR
21 !! ------
22 !!
23 !! V. Masson Meteo-France
24 !!
25 !! MODIFICATION
26 !! ------------
27 !!
28 !! Original 03/2004
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 :: zlat0 ! reference latitude
59 REAL :: zlon0 ! reference longitude
60 INTEGER :: iimax ! number of points in I direction
61 INTEGER :: ijmax ! number of points in J direction
62 REAL, DIMENSION(:), ALLOCATABLE :: zx1 ! X conformal coordinate of grid mesh
63 REAL, DIMENSION(:), ALLOCATABLE :: zy1 ! Y conformal coordinate of grid mesh
64 REAL, DIMENSION(:), ALLOCATABLE :: zdx1 ! X grid mesh size
65 REAL, DIMENSION(:), ALLOCATABLE :: zdy1 ! Y grid mesh size
66 REAL, DIMENSION(:), ALLOCATABLE :: zx2 ! X conformal coordinate of grid mesh
67 REAL, DIMENSION(:), ALLOCATABLE :: zy2 ! Y conformal coordinate of grid mesh
68 REAL, DIMENSION(:), ALLOCATABLE :: zdx2 ! X grid mesh size
69 REAL, DIMENSION(:), ALLOCATABLE :: zdy2 ! Y grid mesh size
70 
71 INTEGER :: il1 ! number of points of input grid
72 REAL, DIMENSION(:), POINTER :: zgrid_par2 ! parameters of output grid
73 REAL(KIND=JPRB) :: zhook_handle
74 !----------------------------------------------------------------------------
75 !
76 !* 2. Computes grid parameters
77 ! ------------------------
78 !
79 IF (lhook) CALL dr_hook('PACK_GRID_CARTESIAN',0,zhook_handle)
80  CALL get_gridtype_cartesian(pgrid_par1,kl=il1)
81 !
82 ALLOCATE(zx1(il1))
83 ALLOCATE(zy1(il1))
84 ALLOCATE(zdx1(il1))
85 ALLOCATE(zdy1(il1))
86 !
87  CALL get_gridtype_cartesian(pgrid_par1,zlat0,zlon0, &
88  iimax,ijmax, &
89  zx1,zy1,zdx1,zdy1 )
90 !
91 ALLOCATE(zx2(kmask_size))
92 ALLOCATE(zy2(kmask_size))
93 ALLOCATE(zdx2(kmask_size))
94 ALLOCATE(zdy2(kmask_size))
95 !
96  CALL pack_same_rank(kmask,zx1 ,zx2 )
97  CALL pack_same_rank(kmask,zy1 ,zy2 )
98  CALL pack_same_rank(kmask,zdx1,zdx2)
99  CALL pack_same_rank(kmask,zdy1,zdy2)
100 !
101 DEALLOCATE(zx1 )
102 DEALLOCATE(zy1 )
103 DEALLOCATE(zdx1)
104 DEALLOCATE(zdy1)
105 !
106  CALL put_gridtype_cartesian(zgrid_par2,zlat0,zlon0, &
107  iimax,ijmax, &
108  zx2,zy2,zdx2,zdy2 )
109 !
110 IF (opack) THEN
111  pgrid_par2(:) = zgrid_par2(:)
112 ELSE
113  kgrid_par2 = SIZE(zgrid_par2(:))
114 END IF
115 !
116 DEALLOCATE(zgrid_par2)
117 DEALLOCATE(zx2 )
118 DEALLOCATE(zy2 )
119 DEALLOCATE(zdx2)
120 DEALLOCATE(zdy2)
121 IF (lhook) CALL dr_hook('PACK_GRID_CARTESIAN',1,zhook_handle)
122 !-------------------------------------------------------------------------------
123 !
124 END SUBROUTINE pack_grid_cartesian
subroutine put_gridtype_cartesian(PGRID_PAR, PLAT0, PLON0, KIMAX, KJMAX, PX, PY, PDX, PDY)
subroutine get_gridtype_cartesian(PGRID_PAR, PLAT0, PLON0, KIMAX, KJMAX, PX, PY, PDX, PDY, KL)
subroutine pack_grid_cartesian(KMASK_SIZE, KMASK, KGRID_PAR1, PGRID_PAR1, KGRID_PAR2, OPACK, PGRID_PAR2)