SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
latlontoxy1d.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 latlontoxy1d(PLAT0,PLON0,PRPK,PBETA,PLATOR,PLONOR, &
7  pxhatm,pyhatm,plat,plon,kn,pradius)
8 ! ################################################
9 !
10 !!**** *SM_LATLONTOXY1D * - Routine to compute conformal coordinates
11 !!
12 !!
13 !! PURPOSE
14 !! -------
15 ! This routine computes the cartesian conformal coordinates
16 ! of an array given in latitude-longitude coordinates
17 ! Three map projections are available:
18 ! - polar-stereographic (PRPK=1),
19 ! - lambert conformal (0<PRPK<1),
20 ! - mercator (PRPK=0).
21 !
22 !
23 !!** METHOD
24 !! ------
25 !! Spherical earth approximation is used. Longitude origin is
26 !! set in Greenwich, and is positive eastwards. An anticlockwise
27 !! rotation of XBETA degrees is applied to the conformal frame
28 !! with respect to the geographical directions.
29 !!
30 !! WARNING: ALL INPUT AND OUTPUT ANGLES ARE IN DEGREES...
31 !!
32 !! EXTERNAL
33 !! --------
34 !! None
35 !!
36 !! EXPLICIT ARGUMENTS
37 !! ------------------
38 !! PXHAT,PYHAT(:) : 1D arrays of the "velocity" gridpoints
39 !! cartesian conformal coordinates (meters,input).
40 !! PLATOR : Latitude of the (1,1) point of the "mass" grid
41 !! (degrees,input);
42 !! PLONOR : Longitude of the (1,1) point of the "mass" grid
43 !! (degrees,input);
44 !! PXHATM : conformal coordinate x (meters, mass-grid, input)
45 !! PYHATM : conformal coordinate y (meters, mass-grid, input)
46 !! PLAT : latitude (degrees, mass-grid, output)
47 !! PLON : longitude (degrees, mass-grid, output)
48 !!
49 !! IMPLICIT ARGUMENTS
50 !! ------------------
51 !! Module MODD_CST : contains Physical constants
52 !! XPI : Pi;
53 !! XRADIUS : Earth radius (meters);
54 !!
55 !!
56 !! REFERENCE
57 !! ---------
58 !! Asencio N. et al., 1994, "Le projet de modele non-hydrostatique
59 !! commun CNRM-LA, specifications techniques",
60 !! Note CNRM/GMME, 26, 139p, (Chapter 2).
61 !! Ducrocq V., 1994, "Generation de la grille dans le modele",
62 !! Note interne MNH, 5 mai, 3p.
63 !! Joly A., 1992, "Geographic parameters for ARPEGE/ALADIN",
64 !! Internal note ARPEGE/ALADIN, february 27,28p.
65 !! Levallois J., 1970, "Geodesie generale", Tome 2, Collection
66 !! de l'IGN, Eyrolles, Paris, 408p.
67 !!
68 !! AUTHOR
69 !! ------
70 !! P.M. *LA*
71 !!
72 !! MODIFICATION
73 !! ------------
74 !! Original PM 24/05/94
75 !! Updated PM 27/07/94
76 !! Updated VD 23/08/94
77 !! Updated VM 24/10/95 projection from north pole (PRPK<0) and
78 !! longitudes set between PLON0-180. and PLON0+180.
79 !!
80 !-------------------------------------------------------------------------------
81 !
82 !* 0. DECLARATIONS
83 ! ------------
84 !
85 USE modd_csts
86 !
87 !
88 USE yomhook ,ONLY : lhook, dr_hook
89 USE parkind1 ,ONLY : jprb
90 !
91 IMPLICIT NONE
92 !
93 !* 0.1 Declarations of arguments and results
94 !
95 INTEGER, INTENT(IN) :: kn
96 REAL, INTENT(IN) :: plat0
97 REAL, INTENT(IN) :: plon0
98 REAL, INTENT(IN) :: prpk
99 REAL, INTENT(IN) :: pbeta
100 REAL, INTENT(IN) :: plator ! Latitude of the origine point
101 REAL, INTENT(IN) :: plonor ! Longitude of the origine point
102 REAL, DIMENSION(KN), INTENT(IN) :: plat,plon
103 REAL, DIMENSION(KN), INTENT(OUT):: pxhatm,pyhatm
104 REAL, OPTIONAL, INTENT(IN) :: pradius
105 !
106 !* 0.2 Declarations of local variables
107 !
108 REAL,DIMENSION(KN) :: zlat,zlon
109 REAL :: zrpk,zlat0,zlon0,zlator,zlonor
110 REAL :: zrdsdg,zclat0,zslat0,zclator,zslator
111 REAL :: zro0,zga0,zbeta,zcgam,zsgam
112 REAL :: zxp,zyp,zraclat0,zxe,zye
113 REAL :: zradius
114 !
115 REAL,DIMENSION(KN) :: zclat,zslat,zro,zga,zxpr,zypr
116 REAL(KIND=JPRB) :: zhook_handle
117 !
118 !
119 !-------------------------------------------------------------------------------
120 !
121 !* 1. PRELIMINARY CALCULATION FOR ALL PROJECTIONS
122 ! -------------------------------------------
123 !
124 IF (lhook) CALL dr_hook('LATLONTOXY1D',0,zhook_handle)
125 zrdsdg = xpi/180. ! Degree to radian conversion factor
126 !
127 ! By definition, (PLONOR,PLATOR) are the geographical
128 ! coordinates, and (ZXBM0,ZYBM0) the conformal cartesian
129 ! coordinates of the (1,1) point of the "mass" grid.
130 !
131 !
132 zlon(:)=plon(:)
133 zlon(:)=zlon(:)+nint((plon0-zlon(:))/360.)*360.
134 !
135 zlonor=plonor
136 zlonor=zlonor+nint((plon0-zlonor)/360.)*360.
137 !
138 zradius = xradius
139 IF (present(pradius)) zradius = pradius
140 !
141 !------------------------------------------------------------------------------
142 !
143 !* 2. POLAR SEREOGRAPHIC AND LAMBERT CONFORMAL CASES
144 ! ----------------------------------------------
145 ! (PRPK=1 P-stereo, 0<PRPK<1 Lambert)
146 !
147 IF(prpk /= 0.) THEN
148 !
149  IF (prpk<0.) THEN ! projection from north pole
150  zrpk=-prpk
151  zbeta=-pbeta
152  zlat0=-plat0
153  zlon0=plon0+180.
154  zlator=-plator
155  zlonor=zlonor+180.
156  zlat(:)=-plat(:)
157  zlon(:)=zlon(:)+180.
158  ELSE ! projection from south pole
159  zrpk=prpk
160  zbeta=pbeta
161  zlat0=plat0
162  zlon0=plon0
163  zlator=plator
164  zlonor=zlonor
165  zlat(:)=plat(:)
166  zlon(:)=zlon(:)
167  ENDIF
168 !
169 !* 2.1 Preliminary calculations
170 !
171  zclat0 = cos(zrdsdg*zlat0)
172  zslat0 = sin(zrdsdg*zlat0)
173  zclator = cos(zrdsdg*zlator)
174  zslator = sin(zrdsdg*zlator)
175  zro0 = (zradius/zrpk)*(abs(zclat0))**(1.-zrpk) &
176  * ((1.+zslat0)*abs(zclator)/(1.+zslator))**zrpk
177  zga0 = (zrpk*(zlonor-zlon0)-zbeta)*zrdsdg
178  zxp = -zro0*sin(zga0)
179  zyp = zro0*cos(zga0)
180 !
181 !* 2.2 Conformal coordinates in meters
182 !
183  zclat(:) = cos(zrdsdg*zlat(:))
184  zslat(:) = sin(zrdsdg*zlat(:))
185  zro(:) = (zradius/zrpk)*(abs(zclat0))**(1.-zrpk) &
186  * ((1.+zslat0)*abs(zclat(:))/(1.+zslat(:)))**zrpk
187  zga(:) = (zrpk*(zlon(:)-zlon0)-zbeta)*zrdsdg
188 !
189  pxhatm(:) = zxp+zro(:)*sin(zga(:))
190  pyhatm(:) = zyp-zro(:)*cos(zga(:))
191 !
192  IF (prpk<0.) THEN ! projection from north pole
193  pyhatm(:)=-pyhatm(:)
194  ENDIF
195 !
196 !-------------------------------------------------------------------------------
197 !
198 !* 3. MERCATOR PROJECTION WITH ROTATION
199 ! ---------------------------------
200 ! (PRPK=0)
201 !
202 ELSE
203 !
204 !* 3.1 Preliminary calculations
205 !
206  zcgam = cos(-zrdsdg*pbeta)
207  zsgam = sin(-zrdsdg*pbeta)
208  zraclat0 = zradius*cos(zrdsdg*plat0)
209  zxe = - zraclat0*(plonor-plon0)*zrdsdg
210  zye = - zraclat0*log(tan(xpi/4.+plator*zrdsdg/2.))
211 !
212 !* 3.2 Conformal coordinates
213 !
214  zxpr(:) = zraclat0*(zlon(:)-plon0)*zrdsdg+zxe
215  zypr(:) = zraclat0*log(tan(xpi/4.+plat(:)*zrdsdg/2.))+zye
216  !
217  pxhatm = zxpr(:)*zcgam-zypr(:)*zsgam
218  pyhatm = zxpr(:)*zsgam+zypr(:)*zcgam
219 !
220 !-------------------------------------------------------------------------------
221 !
222 !* 4. EXIT
223 ! ----
224 !
225 END IF
226 IF (lhook) CALL dr_hook('LATLONTOXY1D',1,zhook_handle)
227 !-------------------------------------------------------------------------------
228 END SUBROUTINE latlontoxy1d
subroutine latlontoxy1d(PLAT0, PLON0, PRPK, PBETA, PLATOR, PLONOR, PXHATM, PYHATM, PLAT, PLON, KN, PRADIUS)
Definition: latlontoxy1d.F90:6