FE-Project
Loading...
Searching...
No Matches
scale_cubedsphere_coord_cnv Module Reference

Module common / Coordinate conversion with cubed-sphere projection. More...

Data Types

interface  cubedspherecoordcnv_cs2localorthvec_alpha
interface  cubedspherecoordcnv_localorth2csvec_alpha

Functions/Subroutines

subroutine, public cubedspherecoordcnv_cs2lonlatpos (panelid, alpha, beta, gam, np, lon, lat)
 Calculate longitude and latitude coordinates from local coordinates using the central angles in an equiangular gnomonic cubed-sphere projection.
subroutine, public cubedspherecoordcnv_cs2lonlatvec (panelid, alpha, beta, gam, np, vecalpha, vecbeta, veclon, veclat, lat)
 Covert the components of a vector in local coordinates with an equiangular gnomonic cubed-sphere projection to those in longitude and latitude coordinates.
subroutine, public cubedspherecoordcnv_lonlat2cspos (panelid, lon, lat, np, alpha, beta)
 Calculate local coordinates using the central angles in an equiangular gnomonic cubed-sphere projection from longitude and latitude coordinates.
subroutine, public cubedspherecoordcnv_lonlat2csvec (panelid, alpha, beta, gam, np, veclon, veclat, vecalpha, vecbeta, lat)
 Covert the components of a vector in longitude and latitude coordinates to those in local coordinates with an equiangular gnomonic cubed-sphere projection.
subroutine, public cubedspherecoordcnv_cs2cartpos (panelid, alpha, beta, gam, np, x, y, z)
 Calculate Cartesian coordinates from local coordinates using the central angles in an equiangular gnomonic cubed-sphere projection.
subroutine, public cubedspherecoordcnv_cart2csvec (panelid, alpha, beta, gam, np, vec_x, vec_y, vec_z, vecalpha, vecbeta)
 Covert the components of a vector in local coordinates with an equiangular gnomonic cubed-sphere projection to those in the Cartesian coordinates.
subroutine, public cubedspherecoordcnv_getmetric (alpha, beta, np, radius, g_ij, gij, gsqrt)
 Calculate the metrics associated with an equiangular gnomonic cubed-sphere projection to those in longitude and latitude coordinates.

Detailed Description

Module common / Coordinate conversion with cubed-sphere projection.

Description
A module to provide coordinate conversions with an equiangular gnomonic cubed-sphere projection
Reference
  • Nair et al. 2015: A Discontinuous Galerkin Transport Scheme on the Cubed Sphere. Monthly Weather Review, 133, 814–828. (Appendix A)
  • Yin et al. 2017: Parallel numerical simulation of the thermal convection in the Earth’s outer core on the cubed-sphere. Geophysical Journal International, 209, 1934–1954. (Appendix A)
Author
Yuta Kawai, Team SCALE

Function/Subroutine Documentation

◆ cubedspherecoordcnv_cs2lonlatpos()

subroutine, public scale_cubedsphere_coord_cnv::cubedspherecoordcnv_cs2lonlatpos ( integer, intent(in) panelid,
real(rp), dimension(np), intent(in) alpha,
real(rp), dimension (np), intent(in) beta,
real(rp), dimension(np), intent(in) gam,
integer, intent(in) np,
real(rp), dimension(np), intent(out) lon,
real(rp), dimension(np), intent(out) lat )

Calculate longitude and latitude coordinates from local coordinates using the central angles in an equiangular gnomonic cubed-sphere projection.

Parameters
[in]panelidPanel ID of cubed-sphere coordinates
[in]npArray size
[in]alphaLocal coordinate using the central angles [rad]
[in]betaLocal coordinate using the central angles [rad]
[in]gamA factor of r/a
[out]lonLongitude coordinate [rad]
[out]latLatitude coordinate [rad]

Definition at line 85 of file scale_cubedsphere_coord_cnv.F90.

90 implicit none
91
92 integer, intent(in) :: panelID !< Panel ID of cubed-sphere coordinates
93 integer, intent(in) :: Np !< Array size
94 real(RP), intent(in) :: alpha(Np) !< Local coordinate using the central angles [rad]
95 real(RP), intent(in) :: beta (Np) !< Local coordinate using the central angles [rad]
96 real(RP), intent(in) :: gam(Np) !< A factor of r/a
97 real(RP), intent(out) :: lon(Np) !< Longitude coordinate [rad]
98 real(RP), intent(out) :: lat(Np) !< Latitude coordinate [rad]
99
100 real(RP) :: CartPos(Np,3)
101 real(RP) :: GeogPos(Np,3)
102
103 integer :: p
104 !-----------------------------------------------------------------------------
105
106 select case( panelid )
107 case( 1, 2, 3, 4 )
108 !$omp parallel
109 !$omp do
110 do p=1, np
111 lon(p) = alpha(p) + 0.5_rp * pi * dble(panelid - 1)
112 lat(p) = atan( tan( beta(p) ) * cos( alpha(p) ) )
113 end do
114 !$omp workshare
115 where( lon(:) < 0.0_rp )
116 lon(:) = lon(:) + 2.0_rp * pi
117 end where
118 !$omp end workshare
119 !$omp end parallel
120 case(5, 6)
121 call cubedspherecoordcnv_cs2cartpos( panelid, alpha, beta, gam, np, & ! (in)
122 cartpos(:,1), cartpos(:,2), cartpos(:,3) ) ! (out)
123
124 call geographiccoordcnv_orth_to_geo_pos( cartpos(:,:), np, & ! (in)
125 geogpos(:,:) ) ! (out)
126
127 !$omp parallel
128 !$omp do
129 do p=1, np
130 lon(p) = geogpos(p,1)
131 lat(p) = geogpos(p,2)
132 end do
133 !$omp workshare
134 where( alpha < 0.0_rp )
135 lon(:) = lon(:) + 2.0_rp * pi
136 end where
137 !$omp end workshare
138 !$omp end parallel
139 case default
140 log_error("CubedSphereCoordCnv_CS2LonLatPos",'(a,i2,a)') "panelID ", panelid, " is invalid. Check!"
141 call prc_abort
142 end select
143
144 return
Module common / Coordinate conversion with a geographic coordinate.
subroutine, public geographiccoordcnv_orth_to_geo_pos(orth_p, np, geo_p)

References cubedspherecoordcnv_cs2cartpos(), and scale_geographic_coord_cnv::geographiccoordcnv_orth_to_geo_pos().

Referenced by scale_mesh_cubedspheredom2d::meshcubedspheredom2d_setuplocaldom(), scale_mesh_cubedspheredom3d::meshcubedspheredom3d_init(), mod_mkinit_util::mkinitutil_calc_cosinebell_global(), and mod_mkinit_util::mkinitutil_galerkinprojection_global().

◆ cubedspherecoordcnv_cs2lonlatvec()

subroutine, public scale_cubedsphere_coord_cnv::cubedspherecoordcnv_cs2lonlatvec ( integer, intent(in) panelid,
real(rp), dimension(np), intent(in) alpha,
real(rp), dimension (np), intent(in) beta,
real(rp), dimension(np), intent(in) gam,
integer, intent(in) np,
real(dp), dimension(np), intent(in) vecalpha,
real(dp), dimension (np), intent(in) vecbeta,
real(rp), dimension(np), intent(out) veclon,
real(rp), dimension(np), intent(out) veclat,
real(rp), dimension(np), intent(in), optional lat )

Covert the components of a vector in local coordinates with an equiangular gnomonic cubed-sphere projection to those in longitude and latitude coordinates.

Parameters
[in]panelidPanel ID of cubed-sphere coordinates
[in]npArray size
[in]alphaLocal coordinate using the central angles [rad]
[in]betaLocal coordinate using the central angles [rad]
[in]gamA factor of RPlanet / r
[in]vecalphaA component of vector in the alpha-coordinate
[in]vecbetaA component of vector in the beta-coordinate
[out]veclonA component of vector in the longitude-coordinate
[out]veclatA component of vector in the latitude-coordinate
[in]latlatitude [rad]

Definition at line 150 of file scale_cubedsphere_coord_cnv.F90.

155
156 use scale_const, only: &
157 eps => const_eps
158 implicit none
159
160 integer, intent(in) :: panelID !< Panel ID of cubed-sphere coordinates
161 integer, intent(in) :: Np !< Array size
162 real(RP), intent(in) :: alpha(Np) !< Local coordinate using the central angles [rad]
163 real(RP), intent(in) :: beta (Np) !< Local coordinate using the central angles [rad]
164 real(RP), intent(in) :: gam(Np) !< A factor of RPlanet / r
165 real(DP), intent(in) :: VecAlpha(Np) !< A component of vector in the alpha-coordinate
166 real(DP), intent(in) :: VecBeta (Np) !< A component of vector in the beta-coordinate
167 real(RP), intent(out) :: VecLon(Np) !< A component of vector in the longitude-coordinate
168 real(RP), intent(out) :: VecLat(Np) !< A component of vector in the latitude-coordinate
169 real(RP), intent(in), optional :: lat(Np) !< latitude [rad]
170
171 integer :: p
172 real(RP) :: X ,Y, del2
173 real(RP) :: s
174
175 real(RP) :: radius
176 real(RP) :: cos_Lat(Np)
177 !-----------------------------------------------------------------------------
178
179 if (present(lat)) then
180 !$omp parallel do
181 do p=1, np
182 cos_lat(p) = cos(lat(p))
183 end do
184 end if
185
186 select case( panelid )
187 case( 1, 2, 3, 4 )
188 if (.not. present(lat)) then
189 !$omp parallel do
190 do p=1, np
191 cos_lat(p) = cos( atan( tan( beta(p) ) * cos( alpha(p) ) ) )
192 end do
193 end if
194
195 !$omp parallel do private( X, Y, del2, radius )
196 do p=1, np
197 x = tan( alpha(p) )
198 y = tan( beta(p) )
199 del2 = 1.0_rp + x**2 + y**2
200 radius = rplanet * gam(p)
201
202 veclon(p) = vecalpha(p) * cos_lat(p) * radius
203 veclat(p) = ( - x * y * vecalpha(p) + ( 1.0_rp + y**2 ) * vecbeta(p) ) &
204 * radius * sqrt( 1.0_rp + x**2 ) / del2
205 end do
206 case ( 5 )
207 s = 1.0_rp
208 case ( 6 )
209 s = - 1.0_rp
210 case default
211 log_error("CubedSphereCoordCnv_CS2LonLatVec",'(a,i2,a)') "panelID ", panelid, " is invalid. Check!"
212 call prc_abort
213 end select
214
215 select case( panelid )
216 case( 5, 6 )
217 !$omp parallel do private( X, Y, del2, radius )
218 do p=1, np
219 x = tan( alpha(p) )
220 y = tan( beta(p) )
221 del2 = 1.0_rp + x**2 + y**2
222 radius = s * rplanet * gam(p)
223
224 if (.not. present(lat)) then
225 cos_lat(p) = cos( atan( sign(1.0_rp, s) / max( sqrt( x**2 + y**2 ), eps ) ) )
226 end if
227
228 veclon(p) = (- y * ( 1.0_rp + x**2 ) * vecalpha(p) + x * ( 1.0_rp + y**2 ) * vecbeta(p) ) &
229 * radius / max( x**2 + y**2, eps ) * cos_lat(p)
230 veclat(p) = (- x * ( 1.0_rp + x**2 ) * vecalpha(p) - y * ( 1.0_rp + y**2 ) * vecbeta(p) ) &
231 * radius / ( del2 * ( max( sqrt( x**2 + y**2 ), eps ) ) )
232 end do
233 end select
234
235 return

Referenced by scale_atm_phy_tb_dgm_globalsmg::atm_phy_tb_dgm_globalsmg_cal_grad(), and mod_atmos_mesh_gm::atmosmeshgm_init().

◆ cubedspherecoordcnv_lonlat2cspos()

subroutine, public scale_cubedsphere_coord_cnv::cubedspherecoordcnv_lonlat2cspos ( integer, intent(in) panelid,
real(rp), dimension(np), intent(in) lon,
real(rp), dimension(np), intent(in) lat,
integer, intent(in) np,
real(rp), dimension(np), intent(out) alpha,
real(rp), dimension (np), intent(out) beta )

Calculate local coordinates using the central angles in an equiangular gnomonic cubed-sphere projection from longitude and latitude coordinates.

Parameters
[in]panelidPanel ID of cubed-sphere coordinates
[in]npArray size
[in]lonLongitude coordinate [rad]
[in]latLatitude coordinate [rad]
[out]alphaLocal coordinate using the central angles [rad]
[out]betaLocal coordinate using the central angles [rad]

Definition at line 241 of file scale_cubedsphere_coord_cnv.F90.

244
245 implicit none
246
247 integer, intent(in) :: panelID !< Panel ID of cubed-sphere coordinates
248 integer, intent(in) :: Np !< Array size
249 real(RP), intent(in) :: lon(Np) !< Longitude coordinate [rad]
250 real(RP), intent(in) :: lat(Np) !< Latitude coordinate [rad]
251 real(RP), intent(out) ::alpha(Np) !< Local coordinate using the central angles [rad]
252 real(RP), intent(out) ::beta (Np) !< Local coordinate using the central angles [rad]
253
254 integer :: p
255 real(RP) :: tan_lat
256 real(RP) :: lon_(Np)
257 !-----------------------------------------------------------------------------
258
259 select case(panelid)
260 case ( 1, 2, 3, 4 )
261 !$omp parallel
262 if ( panelid == 1 ) then
263 !$omp workshare
264 where (lon(:) >= 2.0_rp * pi - 0.25_rp * pi )
265 lon_(:) = lon(:) - 2.0_rp * pi
266 elsewhere
267 lon_(:) = lon(:)
268 end where
269 !$omp end workshare
270 else
271 !$omp workshare
272 where (lon(:) < 0.0_rp )
273 lon_(:) = lon(:) + 2.0_rp * pi
274 elsewhere
275 lon_(:) = lon(:)
276 end where
277 !$omp end workshare
278 end if
279 !$omp do
280 do p=1, np
281 alpha(p) = lon_(p) - 0.5_rp * pi * ( dble(panelid) - 1.0_rp )
282 beta(p) = atan( tan(lat(p)) / cos(alpha(p)) )
283 end do
284 !$omp end parallel
285 case ( 5 )
286 !$omp parallel private(tan_lat)
287 !$omp do
288 do p=1, np
289 tan_lat = tan(lat(p))
290 alpha(p) = + atan( sin(lon(p)) / tan_lat )
291 beta(p) = - atan( cos(lon(p)) / tan_lat )
292 end do
293 !$omp end parallel
294 case ( 6 )
295 !$omp parallel private(tan_lat)
296 !$omp do
297 do p=1, np
298 tan_lat = tan(lat(p))
299 alpha(p) = - atan( sin(lon(p)) / tan_lat )
300 beta(p) = - atan( cos(lon(p)) / tan_lat )
301 end do
302 !$omp end parallel
303 case default
304 log_error("CubedSphereCoordCnv_LonLat2CSPos",'(a,i2,a)') "panelID ", panelid, " is invalid. Check!"
305 call prc_abort
306 end select
307
308 return

Referenced by scale_meshutil_cubedsphere2d::meshutilcubedsphere2d_getpanelid().

◆ cubedspherecoordcnv_lonlat2csvec()

subroutine, public scale_cubedsphere_coord_cnv::cubedspherecoordcnv_lonlat2csvec ( integer, intent(in) panelid,
real(rp), dimension(np), intent(in) alpha,
real(rp), dimension (np), intent(in) beta,
real(rp), dimension(np), intent(in) gam,
integer, intent(in) np,
real(dp), dimension(np), intent(in) veclon,
real(dp), dimension(np), intent(in) veclat,
real(dp), dimension(np), intent(out) vecalpha,
real(dp), dimension (np), intent(out) vecbeta,
real(rp), dimension(np), intent(in), optional lat )

Covert the components of a vector in longitude and latitude coordinates to those in local coordinates with an equiangular gnomonic cubed-sphere projection.

Parameters
[in]panelidPanel ID of cubed-sphere coordinates
[in]npArray size
[in]alphaLocal coordinate using the central angles [rad]
[in]betaLocal coordinate using the central angles [rad]
[in]gamA factor of RPlanet / r
[in]veclonA component of vector in the longitude-coordinate
[in]veclatA component of vector in the latitude-coordinate
[out]vecalphaA component of vector in the alpha-coordinate
[out]vecbetaA component of vector in the beta-coordinate
[in]latlatitude [rad]

Definition at line 314 of file scale_cubedsphere_coord_cnv.F90.

319
320 implicit none
321
322 integer, intent(in) :: panelID !< Panel ID of cubed-sphere coordinates
323 integer, intent(in) :: Np !< Array size
324 real(RP), intent(in) :: alpha(Np) !< Local coordinate using the central angles [rad]
325 real(RP), intent(in) :: beta (Np) !< Local coordinate using the central angles [rad]
326 real(RP), intent(in) :: gam(Np) !< A factor of RPlanet / r
327 real(DP), intent(in) :: VecLon(Np) !< A component of vector in the longitude-coordinate
328 real(DP), intent(in) :: VecLat(Np) !< A component of vector in the latitude-coordinate
329 real(DP), intent(out) :: VecAlpha(Np) !< A component of vector in the alpha-coordinate
330 real(DP), intent(out) :: VecBeta (Np) !< A component of vector in the beta-coordinate
331 real(RP), intent(in), optional :: lat(Np) !< latitude [rad]
332
333 integer :: p
334 real(RP) :: X ,Y, del2
335 real(RP) :: s
336
337 real(RP) :: radius
338 real(RP) :: cos_Lat(Np)
339 real(RP) :: VecLon_ov_cosLat
340 !-----------------------------------------------------------------------------
341
342 if (present(lat)) then
343 !$omp parallel do
344 do p=1, np
345 cos_lat(p) = cos(lat(p))
346 end do
347 end if
348
349 select case( panelid )
350 case( 1, 2, 3, 4 )
351 if (.not. present(lat)) then
352 !$omp parallel do
353 do p=1, np
354 cos_lat(p) = cos( atan( tan( beta(p) ) * cos( alpha(p) ) ) )
355 end do
356 end if
357
358 !$omp parallel do private( X, Y, del2, radius, VecLon_ov_cosLat )
359 do p=1, np
360 x = tan( alpha(p) )
361 y = tan( beta(p) )
362 del2 = 1.0_rp + x**2 + y**2
363 radius = rplanet * gam(p)
364 veclon_ov_coslat = veclon(p) / cos_lat(p)
365
366 vecalpha(p) = veclon_ov_coslat / radius
367 vecbeta(p) = ( x * y * veclon_ov_coslat + del2 / sqrt( 1.0_rp + x**2 ) * veclat(p) ) &
368 / ( radius * (1.0_rp + y**2) )
369 end do
370 case ( 5 )
371 s = 1.0_rp
372 case ( 6 )
373 s = -1.0_rp
374 case default
375 log_error("CubedSphereCoordCnv_LonLat2CSVec",'(a,i2,a)') "panelID ", panelid, " is invalid. Check!"
376 call prc_abort
377 end select
378
379 select case( panelid )
380 case( 5, 6 )
381 !$omp parallel do private( X, Y, del2, radius, VecLon_ov_cosLat )
382 do p=1, np
383 x = tan( alpha(p) )
384 y = tan( beta(p) )
385 del2 = 1.0_rp + x**2 + y**2
386 radius = s * rplanet * gam(p)
387
388 if (.not. present(lat)) then
389 cos_lat(p) = cos( atan( s / sqrt(max(x**2 + y**2, eps)) ) )
390 end if
391 veclon_ov_coslat = veclon(p) / cos_lat(p)
392
393 vecalpha(p) = (- y * veclon_ov_coslat - del2 * x / sqrt( max(del2 - 1.0_rp,eps)) * veclat(p)) &
394 / ( radius * ( 1.0_rp + x**2 ) )
395 vecbeta(p) = ( x * veclon_ov_coslat - del2 * y / sqrt( max(del2 - 1.0_rp,eps)) * veclat(p)) &
396 / ( radius * ( 1.0_rp + y**2 ) )
397 end do
398 end select
399
400 return

◆ cubedspherecoordcnv_cs2cartpos()

subroutine, public scale_cubedsphere_coord_cnv::cubedspherecoordcnv_cs2cartpos ( integer, intent(in) panelid,
real(rp), dimension(np), intent(in) alpha,
real(rp), dimension (np), intent(in) beta,
real(rp), dimension(np), intent(in) gam,
integer, intent(in) np,
real(rp), dimension(np), intent(out) x,
real(rp), dimension(np), intent(out) y,
real(rp), dimension(np), intent(out) z )

Calculate Cartesian coordinates from local coordinates using the central angles in an equiangular gnomonic cubed-sphere projection.

Parameters
[in]panelidPanel ID of cubed-sphere coordinates
[in]npArray size
[in]alphaLocal coordinate using the central angles [rad]
[in]betaLocal coordinate using the central angles [rad]
[in]gamA factor of r/a
[out]xx-coordinate in the Cartesian coordinate
[out]yy-coordinate in the Cartesian coordinate
[out]zz-coordinate in the Cartesian coordinate

Definition at line 406 of file scale_cubedsphere_coord_cnv.F90.

409
410 implicit none
411 integer, intent(in) :: panelID !< Panel ID of cubed-sphere coordinates
412 integer, intent(in) :: Np !< Array size
413 real(RP), intent(in) :: alpha(Np) !< Local coordinate using the central angles [rad]
414 real(RP), intent(in) :: beta (Np) !< Local coordinate using the central angles [rad]
415 real(RP), intent(in) :: gam(Np) !< A factor of r/a
416 real(RP), intent(out) :: X(Np) !< x-coordinate in the Cartesian coordinate
417 real(RP), intent(out) :: Y(Np) !< y-coordinate in the Cartesian coordinate
418 real(RP), intent(out) :: Z(Np) !< z-coordinate in the Cartesian coordinate
419
420 integer :: p
421 real(RP) :: x1, x2, fac
422
423 !-----------------------------------------------------------------------------
424
425 select case(panelid)
426 case(1)
427 !$omp parallel do private(x1, x2, fac)
428 do p=1, np
429 x1 = tan( alpha(p) )
430 x2 = tan( beta(p) )
431 fac = rplanet * gam(p) / sqrt( 1.0_rp + x1**2 + x2**2 )
432 x(p) = fac
433 y(p) = fac * x1
434 z(p) = fac * x2
435 end do
436 case(2)
437 !$omp parallel do private(x1, x2, fac)
438 do p=1, np
439 x1 = tan( alpha(p) )
440 x2 = tan( beta(p) )
441 fac = rplanet * gam(p) / sqrt( 1.0_rp + x1**2 + x2**2 )
442 x(p) = - fac * x1
443 y(p) = fac
444 z(p) = fac * x2
445 end do
446 case(3)
447 !$omp parallel do private(x1, x2, fac)
448 do p=1, np
449 x1 = tan( alpha(p) )
450 x2 = tan( beta(p) )
451 fac = rplanet * gam(p) / sqrt( 1.0_rp + x1**2 + x2**2 )
452 x(p) = - fac
453 y(p) = - fac * x1
454 z(p) = fac * x2
455 end do
456 case(4)
457 !$omp parallel do private(x1, x2, fac)
458 do p=1, np
459 x1 = tan( alpha(p) )
460 x2 = tan( beta(p) )
461 fac = rplanet * gam(p) / sqrt( 1.0_rp + x1**2 + x2**2 )
462 x(p) = fac * x1
463 y(p) = - fac
464 z(p) = fac * x2
465 end do
466 case(5)
467 !$omp parallel do private(x1, x2, fac)
468 do p=1, np
469 x1 = tan( alpha(p) )
470 x2 = tan( beta(p) )
471 fac = rplanet * gam(p) / sqrt( 1.0_rp + x1**2 + x2**2 )
472 x(p) = - fac * x2
473 y(p) = fac * x1
474 z(p) = fac
475 end do
476 case(6)
477 !$omp parallel do private(x1, x2, fac)
478 do p=1, np
479 x1 = tan( alpha(p) )
480 x2 = tan( beta(p) )
481 fac = rplanet * gam(p) / sqrt( 1.0_rp + x1**2 + x2**2 )
482 x(p) = fac * x2
483 y(p) = fac * x1
484 z(p) = - fac
485 end do
486 case default
487 log_error("CubedSphereCoordCnv_CS2CartPos",'(a,i2,a)') "panelID ", panelid, " is invalid. Check!"
488 call prc_abort
489 end select
490
491 return

Referenced by cubedspherecoordcnv_cs2lonlatpos().

◆ cubedspherecoordcnv_cart2csvec()

subroutine, public scale_cubedsphere_coord_cnv::cubedspherecoordcnv_cart2csvec ( integer, intent(in) panelid,
real(rp), dimension(np), intent(in) alpha,
real(rp), dimension (np), intent(in) beta,
real(rp), dimension(np), intent(in) gam,
integer, intent(in) np,
real(dp), dimension(np), intent(in) vec_x,
real(dp), dimension(np), intent(in) vec_y,
real(dp), dimension(np), intent(in) vec_z,
real(rp), dimension(np), intent(out) vecalpha,
real(rp), dimension (np), intent(out) vecbeta )

Covert the components of a vector in local coordinates with an equiangular gnomonic cubed-sphere projection to those in the Cartesian coordinates.

Parameters
[in]panelidPanel ID of cubed-sphere coordinates
[in]npArray size
[in]alphaLocal coordinate using the central angles [rad]
[in]betaLocal coordinate using the central angles [rad]
[in]gamA factor of RPlanet / r
[in]vec_xA component of vector in the x-coordinate with the Cartesian coordinate
[in]vec_yA component of vector in the y-coordinate with the Cartesian coordinate
[in]vec_zA component of vector in the z-coordinate with the Cartesian coordinate
[out]vecalphaA component of vector in the alpha-coordinate
[out]vecbetaA component of vector in the beta-coordinate

Definition at line 497 of file scale_cubedsphere_coord_cnv.F90.

501
502 implicit none
503
504 integer, intent(in) :: panelID !< Panel ID of cubed-sphere coordinates
505 integer, intent(in) :: Np !< Array size
506 real(RP), intent(in) :: alpha(Np) !< Local coordinate using the central angles [rad]
507 real(RP), intent(in) :: beta (Np) !< Local coordinate using the central angles [rad]
508 real(RP), intent(in) :: gam(Np) !< A factor of RPlanet / r
509 real(DP), intent(in) :: Vec_x(Np) !< A component of vector in the x-coordinate with the Cartesian coordinate
510 real(DP), intent(in) :: Vec_y(Np) !< A component of vector in the y-coordinate with the Cartesian coordinate
511 real(DP), intent(in) :: Vec_z(Np) !< A component of vector in the z-coordinate with the Cartesian coordinate
512 real(RP), intent(out) :: VecAlpha(Np) !< A component of vector in the alpha-coordinate
513 real(RP), intent(out) :: VecBeta (Np) !< A component of vector in the beta-coordinate
514
515 integer :: p
516 real(RP) :: x1, x2, fac
517 real(RP) :: r_sec2_alpha, r_sec2_beta
518 !-----------------------------------------------------------------------------
519
520 select case( panelid )
521 case(1)
522 !$omp parallel do private(x1, x2, r_sec2_alpha, r_sec2_beta, fac)
523 do p=1, np
524 x1 = tan( alpha(p) )
525 x2 = tan( beta(p) )
526 r_sec2_alpha = cos(alpha(p))**2
527 r_sec2_beta = cos(beta(p))**2
528 fac = sqrt( 1.0_rp + x1**2 + x2**2 ) / ( rplanet * gam(p) )
529
530 vecalpha(p) = fac * r_sec2_alpha * ( - x1 * vec_x(p) + vec_y(p) )
531 vecbeta(p) = fac * r_sec2_beta * ( - x2 * vec_x(p) + vec_z(p) )
532 end do
533 case(2)
534 !$omp parallel do private(x1, x2, r_sec2_alpha, r_sec2_beta, fac)
535 do p=1, np
536 x1 = tan( alpha(p) )
537 x2 = tan( beta(p) )
538 r_sec2_alpha = cos(alpha(p))**2
539 r_sec2_beta = cos(beta(p))**2
540 fac = sqrt( 1.0_rp + x1**2 + x2**2 ) / ( rplanet * gam(p) )
541
542 vecalpha(p) = - fac * r_sec2_alpha * ( vec_x(p) + x1 * vec_y(p) )
543 vecbeta(p) = fac * r_sec2_beta * ( - x2 * vec_y(p) + vec_z(p) )
544 end do
545 case(3)
546 !$omp parallel do private(x1, x2, r_sec2_alpha, r_sec2_beta, fac)
547 do p=1, np
548 x1 = tan( alpha(p) )
549 x2 = tan( beta(p) )
550 r_sec2_alpha = cos(alpha(p))**2
551 r_sec2_beta = cos(beta(p))**2
552 fac = sqrt( 1.0_rp + x1**2 + x2**2 ) / ( rplanet * gam(p) )
553
554 vecalpha(p) = fac * r_sec2_alpha * ( x1 * vec_x(p) - vec_y(p) )
555 vecbeta(p) = fac * r_sec2_beta * ( x2 * vec_x(p) + vec_z(p) )
556 end do
557 case(4)
558 !$omp parallel do private(x1, x2, r_sec2_alpha, r_sec2_beta, fac)
559 do p=1, np
560 x1 = tan( alpha(p) )
561 x2 = tan( beta(p) )
562 r_sec2_alpha = cos(alpha(p))**2
563 r_sec2_beta = cos(beta(p))**2
564 fac = sqrt( 1.0_rp + x1**2 + x2**2 ) / ( rplanet * gam(p) )
565
566 vecalpha(p) = fac * r_sec2_alpha * ( vec_x(p) + x1 * vec_y(p) )
567 vecbeta(p) = fac * r_sec2_beta * ( x2 * vec_y(p) + vec_z(p) )
568 end do
569 case ( 5 )
570 !$omp parallel do private(x1, x2, r_sec2_alpha, r_sec2_beta, fac)
571 do p=1, np
572 x1 = tan( alpha(p) )
573 x2 = tan( beta(p) )
574 r_sec2_alpha = cos(alpha(p))**2
575 r_sec2_beta = cos(beta(p))**2
576 fac = sqrt( 1.0_rp + x1**2 + x2**2 ) / ( rplanet * gam(p) )
577
578 vecalpha(p) = fac * r_sec2_alpha * ( vec_y(p) - x1 * vec_z(p) )
579 vecbeta(p) = - fac * r_sec2_beta * ( vec_x(p) + x2 * vec_z(p) )
580 end do
581 case ( 6 )
582 !$omp parallel do private(x1, x2, r_sec2_alpha, r_sec2_beta, fac)
583 do p=1, np
584 x1 = tan( alpha(p) )
585 x2 = tan( beta(p) )
586 r_sec2_alpha = cos(alpha(p))**2
587 r_sec2_beta = cos(beta(p))**2
588 fac = sqrt( 1.0_rp + x1**2 + x2**2 ) / ( rplanet * gam(p) )
589
590 vecalpha(p) = fac * r_sec2_alpha * ( vec_y(p) + x1 * vec_z(p) )
591 vecbeta(p) = fac * r_sec2_beta * ( vec_x(p) + x2 * vec_z(p) )
592 end do
593 case default
594 log_error("CubedSphereCoordCnv_Cart2CSVec",'(a,i2,a)') "panelID ", panelid, " is invalid. Check!"
595 call prc_abort
596 end select
597
598 return

◆ cubedspherecoordcnv_getmetric()

subroutine, public scale_cubedsphere_coord_cnv::cubedspherecoordcnv_getmetric ( real(rp), dimension(np), intent(in) alpha,
real(rp), dimension (np), intent(in) beta,
integer, intent(in) np,
real(rp), intent(in) radius,
real(rp), dimension(np,2,2), intent(out) g_ij,
real(rp), dimension (np,2,2), intent(out) gij,
real(rp), dimension(np), intent(out) gsqrt )

Calculate the metrics associated with an equiangular gnomonic cubed-sphere projection to those in longitude and latitude coordinates.

Parameters
[in]npArray size
[in]alphaLocal coordinate using the central angles [rad]
[in]betaLocal coordinate using the central angles [rad]
[in]radiusPlanetary radius
[out]g_ijHorizontal covariant metric tensor
[out]gijHorizontal contravariant metric tensor
[out]gsqrtHorizontal Jacobian

Definition at line 735 of file scale_cubedsphere_coord_cnv.F90.

738
739 implicit none
740
741 integer, intent(in) :: Np !< Array size
742 real(RP), intent(in) :: alpha(Np) !< Local coordinate using the central angles [rad]
743 real(RP), intent(in) :: beta (Np) !< Local coordinate using the central angles [rad]
744 real(RP), intent(in) :: radius !< Planetary radius
745 real(RP), intent(out) :: G_ij(Np,2,2) !< Horizontal covariant metric tensor
746 real(RP), intent(out) :: GIJ (Np,2,2) !< Horizontal contravariant metric tensor
747 real(RP), intent(out) :: Gsqrt(Np) !< Horizontal Jacobian
748
749 real(RP) :: X, Y
750 real(RP) :: r2
751 real(RP) :: fac
752 real(RP) :: G_ij_(2,2)
753 real(RP) :: GIJ_ (2,2)
754
755 integer :: p
756 real(RP) :: OnePlusX2, OnePlusY2
757 !-----------------------------------------------------------------------------
758
759 !$omp parallel do private( &
760 !$omp X, Y, r2, OnePlusX2, OnePlusY2, fac, &
761 !$omp G_ij_, GIJ_ )
762 do p=1, np
763 x = tan(alpha(p))
764 y = tan(beta(p))
765 r2 = 1.0_rp + x**2 + y**2
766 oneplusx2 = 1.0_rp + x**2
767 oneplusy2 = 1.0_rp + y**2
768
769 fac = oneplusx2 * oneplusy2 * ( radius / r2 )**2
770 g_ij_(1,1) = fac * oneplusx2
771 g_ij_(1,2) = - fac * (x * y)
772 g_ij_(2,1) = - fac * (x * y)
773 g_ij_(2,2) = fac * oneplusy2
774 g_ij(p,:,:) = g_ij_(:,:)
775
776 gsqrt(p) = radius**2 * oneplusx2 * oneplusy2 / ( r2 * sqrt(r2) )
777
778 fac = 1.0_rp / gsqrt(p)**2
779 gij_(1,1) = fac * g_ij_(2,2)
780 gij_(1,2) = - fac * g_ij_(1,2)
781 gij_(2,1) = - fac * g_ij_(2,1)
782 gij_(2,2) = fac * g_ij_(1,1)
783 gij(p,:,:) = gij_(:,:)
784 end do
785
786 return

Referenced by scale_mesh_cubedspheredom2d::meshcubedspheredom2d_setuplocaldom(), and scale_mesh_cubedspheredom3d::meshcubedspheredom3d_init().