28 public :: mapprojection_xy2lonlat
29 public :: mapprojection_lonlat2xy
34 interface mapprojection_xy2lonlat
36 module procedure mapprojection_xy2lonlat_2d
38 interface mapprojection_lonlat2xy
39 module procedure mapprojection_lonlat2xy_0d
40 module procedure mapprojection_lonlat2xy_2d
53 private :: mapprojection_none_setup
54 private :: mapprojection_lambertconformal_setup
55 private :: mapprojection_polarstereographic_setup
56 private :: mapprojection_mercator_setup
57 private :: mapprojection_equidistantcylindrical_setup
59 private :: mapprojection_none_xy2lonlat
60 private :: mapprojection_lambertconformal_xy2lonlat
61 private :: mapprojection_polarstereographic_xy2lonlat
62 private :: mapprojection_mercator_xy2lonlat
63 private :: mapprojection_equidistantcylindrical_xy2lonlat
65 private :: mapprojection_none_lonlat2xy
66 private :: mapprojection_lambertconformal_lonlat2xy
67 private :: mapprojection_polarstereographic_lonlat2xy
68 private :: mapprojection_mercator_lonlat2xy
69 private :: mapprojection_equidistantcylindrical_lonlat2xy
71 private :: mapprojection_none_mapfactor
72 private :: mapprojection_lambertconformal_mapfactor
73 private :: mapprojection_polarstereographic_mapfactor
74 private :: mapprojection_mercator_mapfactor
75 private :: mapprojection_equidistantcylindrical_mapfactor
77 private :: mapprojection_none_rotcoef
78 private :: mapprojection_lambertconformal_rotcoef
79 private :: mapprojection_polarstereographic_rotcoef
80 private :: mapprojection_mercator_rotcoef
81 private :: mapprojection_equidistantcylindrical_rotcoef
87 character(len=H_SHORT),
private :: mapprojection_type =
'NONE' 94 real(DP),
private :: mapprojection_hemisphere
96 real(DP),
private :: mapprojection_basepoint_x
97 real(DP),
private :: mapprojection_basepoint_y
99 real(DP),
private :: mapprojection_pole_x
100 real(DP),
private :: mapprojection_pole_y
101 real(DP),
private :: mapprojection_eq_x
102 real(DP),
private :: mapprojection_eq_y
104 real(DP),
private :: mapprojection_rotation = 0.0_dp
105 real(DP),
private :: mapprojection_rot_fact_sin
106 real(DP),
private :: mapprojection_rot_fact_cos
108 real(DP),
private :: mapprojection_lc_lat1 = 30.0_dp
109 real(DP),
private :: mapprojection_lc_lat2 = 60.0_dp
110 real(DP),
private :: mapprojection_lc_c
111 real(DP),
private :: mapprojection_lc_fact
113 real(DP),
private :: mapprojection_ps_lat
114 real(DP),
private :: mapprojection_ps_fact
116 real(DP),
private :: mapprojection_m_lat = 0.0_dp
117 real(DP),
private :: mapprojection_m_fact
119 real(DP),
private :: mapprojection_ec_lat = 0.0_dp
120 real(DP),
private :: mapprojection_ec_fact
122 real(DP),
private :: pi
123 real(DP),
private :: d2r
124 real(DP),
private :: radius
126 character(len=H_SHORT) :: mapprojection_mapping =
"" 127 real(DP),
private :: mapprojection_false_easting
128 real(DP),
private :: mapprojection_false_northing
129 real(DP),
private :: mapprojection_longitude_of_central_meridian
130 real(DP),
private :: mapprojection_longitude_of_projection_origin
131 real(DP),
private :: mapprojection_latitude_of_projection_origin
132 real(DP),
private :: mapprojection_straight_vertical_longitude_from_pole
133 real(DP),
private :: mapprojection_standard_parallel(2)
136 subroutine xy2lonlat_s( x, y, lon, lat )
138 real(DP),
intent(in) :: x, y
139 real(RP),
intent(out) :: lon, lat
140 end subroutine xy2lonlat_s
143 real(RP),
intent(in) :: lon, lat
144 real(DP),
intent(out) :: x, y
148 real(RP),
intent(in) :: lat
149 real(RP),
intent(out) :: m1, m2
153 real(RP),
intent(in) :: lon, lat
154 real(RP),
intent(out) :: rotc_cos, rotc_sin
158 procedure(
lonlat2xy_s),
pointer :: lonlat2xy => null()
159 procedure(
mapfactor_s),
pointer :: mapfactor => null()
160 procedure(
rotcoef_s),
pointer :: rotcoef => null()
176 real(RP),
intent(in) :: DOMAIN_CENTER_X
177 real(RP),
intent(in) :: DOMAIN_CENTER_Y
179 namelist / param_mapprojection / &
182 mapprojection_basepoint_x, &
183 mapprojection_basepoint_y, &
184 mapprojection_type, &
185 mapprojection_rotation, &
186 mapprojection_lc_lat1, &
187 mapprojection_lc_lat2, &
188 mapprojection_ps_lat, &
189 mapprojection_m_lat, &
196 log_info(
"MAPPROJECTION_setup",*)
'Setup' 198 pi =
real(pi_rp, kind=
dp)
199 d2r =
real(d2r_rp, kind=
dp)
200 radius =
real(radius_rp, kind=
dp)
202 mapprojection_basepoint_x = undef
203 mapprojection_basepoint_y = undef
204 mapprojection_ps_lat = undef
206 mapprojection_basepoint_x = domain_center_x
207 mapprojection_basepoint_y = domain_center_y
211 read(
io_fid_conf,nml=param_mapprojection,iostat=ierr)
214 log_info(
"MAPPROJECTION_setup",*)
'Not found namelist. Default used.' 215 elseif( ierr > 0 )
then 216 log_error(
"MAPPROJECTION_setup",*)
'Not appropriate names in namelist PARAM_MAPPROJECTION. Check!' 219 log_nml(param_mapprojection)
222 log_info(
"MAPPROJECTION_setup",*)
'Map projection information' 223 log_info_cont(
'(1x,A,F15.3)')
'Basepoint(x) [m] : ', mapprojection_basepoint_x
224 log_info_cont(
'(1x,A,F15.3)')
'Basepoint(y) [m] : ', mapprojection_basepoint_y
225 log_info_cont(*)
'Map projection type : ', trim(mapprojection_type)
227 mapprojection_mapping =
"" 228 mapprojection_false_easting = undef
229 mapprojection_false_northing = undef
230 mapprojection_longitude_of_central_meridian = undef
231 mapprojection_longitude_of_projection_origin = undef
232 mapprojection_latitude_of_projection_origin = undef
233 mapprojection_straight_vertical_longitude_from_pole = undef
234 mapprojection_standard_parallel(:) = undef
238 select case(trim(mapprojection_type))
240 log_info_cont(*)
'=> NO map projection' 241 call mapprojection_none_setup
242 xy2lonlat => mapprojection_none_xy2lonlat
243 lonlat2xy => mapprojection_none_lonlat2xy
244 mapfactor => mapprojection_none_mapfactor
245 rotcoef => mapprojection_none_rotcoef
247 log_info_cont(*)
'=> Lambert Conformal projection' 248 call mapprojection_lambertconformal_setup
249 xy2lonlat => mapprojection_lambertconformal_xy2lonlat
250 lonlat2xy => mapprojection_lambertconformal_lonlat2xy
251 mapfactor => mapprojection_lambertconformal_mapfactor
252 rotcoef => mapprojection_lambertconformal_rotcoef
254 log_info_cont(*)
'=> Polar Stereographic projection' 255 call mapprojection_polarstereographic_setup
256 xy2lonlat => mapprojection_polarstereographic_xy2lonlat
257 lonlat2xy => mapprojection_polarstereographic_lonlat2xy
258 mapfactor => mapprojection_polarstereographic_mapfactor
259 rotcoef => mapprojection_polarstereographic_rotcoef
261 log_info_cont(*)
'=> Mercator projection' 262 call mapprojection_mercator_setup
263 xy2lonlat => mapprojection_mercator_xy2lonlat
264 lonlat2xy => mapprojection_mercator_lonlat2xy
265 mapfactor => mapprojection_mercator_mapfactor
266 rotcoef => mapprojection_mercator_rotcoef
268 log_info_cont(*)
'=> Equidistant Cylindrical projection' 269 call mapprojection_equidistantcylindrical_setup
270 xy2lonlat => mapprojection_equidistantcylindrical_xy2lonlat
271 lonlat2xy => mapprojection_equidistantcylindrical_lonlat2xy
272 mapfactor => mapprojection_equidistantcylindrical_mapfactor
273 rotcoef => mapprojection_equidistantcylindrical_rotcoef
275 log_error(
"MAPPROJECTION_setup",*)
'Unsupported MAPPROJECTION_type. STOP' 279 mapprojection_rotation = mapprojection_rotation * d2r
280 mapprojection_rot_fact_sin = sin(mapprojection_rotation)
281 mapprojection_rot_fact_cos = cos(mapprojection_rotation)
292 real(RP),
intent(in) :: x
293 real(RP),
intent(in) :: y
294 real(RP),
intent(out) :: lon
295 real(RP),
intent(out) :: lat
300 xx = mapprojection_basepoint_x &
301 + ( x - mapprojection_basepoint_x ) * mapprojection_rot_fact_cos &
302 - ( y - mapprojection_basepoint_y ) * mapprojection_rot_fact_sin
303 yy = mapprojection_basepoint_y &
304 + ( y - mapprojection_basepoint_y ) * mapprojection_rot_fact_cos &
305 + ( x - mapprojection_basepoint_x ) * mapprojection_rot_fact_sin
312 subroutine mapprojection_xy2lonlat_2d( &
313 IA, IS, IE, JA, JS, JE, &
317 integer,
intent(in) :: IA, IS, IE
318 integer,
intent(in) :: JA, JS, JE
320 real(RP),
intent(in) :: x(ia,ja)
321 real(RP),
intent(in) :: y(ia,ja)
322 real(RP),
intent(out) :: lon(ia,ja)
323 real(RP),
intent(out) :: lat(ia,ja)
336 end subroutine mapprojection_xy2lonlat_2d
340 subroutine mapprojection_lonlat2xy_0d( &
344 real(RP),
intent(in) :: lon
345 real(RP),
intent(in) :: lat
346 real(RP),
intent(out) :: x
347 real(RP),
intent(out) :: y
352 call lonlat2xy( lon, lat, xx, yy )
354 xx = xx - mapprojection_basepoint_x
355 yy = yy - mapprojection_basepoint_y
357 x = mapprojection_basepoint_x + ( xx * mapprojection_rot_fact_cos &
358 + yy * mapprojection_rot_fact_sin )
359 y = mapprojection_basepoint_y + ( yy * mapprojection_rot_fact_cos &
360 - xx * mapprojection_rot_fact_sin )
363 end subroutine mapprojection_lonlat2xy_0d
365 subroutine mapprojection_lonlat2xy_2d( &
366 IA, IS, IE, JA, JS, JE, &
370 integer,
intent(in) :: IA, IS, IE
371 integer,
intent(in) :: JA, JS, JE
373 real(RP),
intent(in) :: lon(ia,ja)
374 real(RP),
intent(in) :: lat(ia,ja)
375 real(RP),
intent(out) :: x(ia,ja)
376 real(RP),
intent(out) :: y(ia,ja)
384 call mapprojection_lonlat2xy_0d( lon(i,j), lat(i,j), x(i,j), y(i,j) )
389 end subroutine mapprojection_lonlat2xy_2d
394 IA, IS, IE, JA, JS, JE, &
398 integer,
intent(in) :: IA, IS, IE
399 integer,
intent(in) :: JA, JS, JE
401 real(RP),
intent(in) :: lat(ia,ja)
402 real(RP),
intent(out) :: m1 (ia,ja)
403 real(RP),
intent(out) :: m2 (ia,ja)
412 call mapfactor( lat(i,j), m1(i,j), m2(i,j) )
426 IA, IS, IE, JA, JS, JE, &
430 integer,
intent(in) :: IA, IS, IE
431 integer,
intent(in) :: JA, JS, JE
433 real(RP),
intent(in) :: lon(ia,ja)
434 real(RP),
intent(in) :: lat(ia,ja)
435 real(RP),
intent(out) :: rotc(ia,ja,2)
443 call rotcoef( lon(i,j), lat(i,j), rotc(i,j,1), rotc(i,j,2) )
456 longitude_of_central_meridian, &
457 longitude_of_projection_origin, &
458 latitude_of_projection_origin, &
459 straight_vertical_longitude_from_pole, &
463 character(len=*),
intent(out) :: mapping
465 real(DP),
intent(out),
optional :: false_easting
466 real(DP),
intent(out),
optional :: false_northing
467 real(DP),
intent(out),
optional :: longitude_of_central_meridian
468 real(DP),
intent(out),
optional :: longitude_of_projection_origin
469 real(DP),
intent(out),
optional :: latitude_of_projection_origin
470 real(DP),
intent(out),
optional :: straight_vertical_longitude_from_pole
471 real(DP),
intent(out),
optional :: standard_parallel(2)
474 mapping = mapprojection_mapping
476 if (
present(false_easting) ) &
477 false_easting = mapprojection_false_easting
478 if (
present(false_northing) ) &
479 false_northing = mapprojection_false_northing
480 if (
present(longitude_of_central_meridian) ) &
481 longitude_of_central_meridian = mapprojection_longitude_of_central_meridian
482 if (
present(longitude_of_projection_origin) ) &
483 longitude_of_projection_origin = mapprojection_longitude_of_projection_origin
484 if (
present(latitude_of_projection_origin) ) &
485 latitude_of_projection_origin = mapprojection_latitude_of_projection_origin
486 if (
present(straight_vertical_longitude_from_pole) ) &
487 straight_vertical_longitude_from_pole = mapprojection_straight_vertical_longitude_from_pole
488 if (
present(standard_parallel) ) &
489 standard_parallel(:) = mapprojection_standard_parallel(:)
496 subroutine mapprojection_none_setup
501 log_info(
"MAPPROJECTION_None_setup",*)
'MAPPROJECTION_rotation = ', mapprojection_rotation
503 mapprojection_mapping =
"" 506 end subroutine mapprojection_none_setup
510 subroutine mapprojection_none_xy2lonlat( &
517 real(DP),
intent(in) :: x
518 real(DP),
intent(in) :: y
519 real(RP),
intent(out) :: lon
520 real(RP),
intent(out) :: lat
526 gno(1) = ( x - mapprojection_basepoint_x ) / radius
527 gno(2) = ( y - mapprojection_basepoint_y ) / radius
529 rho = sqrt( gno(1) * gno(1) + gno(2) * gno(2) )
532 if ( rho == 0.0_dp )
then 544 end subroutine mapprojection_none_xy2lonlat
548 subroutine mapprojection_none_lonlat2xy( &
557 real(RP),
intent(in) :: lon
558 real(RP),
intent(in) :: lat
559 real(DP),
intent(out) :: x
560 real(DP),
intent(out) :: y
562 real(DP) :: lat_d, lat0_d, dlon
568 lat_d =
real(lat,kind=
dp)
573 cos_gmm = sin(lat0_d) * sin(lat_d) &
574 + cos(lat0_d) * cos(lat_d) * cos(dlon)
576 gno(1) = ( cos(lat_d) * sin(dlon) ) / cos_gmm
577 gno(2) = ( cos(lat0_d) * sin(lat_d) &
578 - sin(lat0_d) * cos(lat_d) * cos(dlon) ) / cos_gmm
580 x = gno(1) * radius + mapprojection_basepoint_x
581 y = gno(2) * radius + mapprojection_basepoint_y
584 end subroutine mapprojection_none_lonlat2xy
588 subroutine mapprojection_none_mapfactor( &
593 real(RP),
intent(in) :: lat
594 real(RP),
intent(out) :: m1
595 real(RP),
intent(out) :: m2
602 end subroutine mapprojection_none_mapfactor
606 subroutine mapprojection_none_rotcoef( &
610 real(RP),
intent(in) :: lon, lat
611 real(RP),
intent(out) :: rotc_cos, rotc_sin
614 rotc_cos = mapprojection_rot_fact_cos
615 rotc_sin = mapprojection_rot_fact_sin
618 end subroutine mapprojection_none_rotcoef
622 subroutine mapprojection_lambertconformal_setup
627 real(DP) :: lat1rot, lat2rot
628 real(DP) :: dlon, latrot, dist
631 if ( mapprojection_lc_lat1 >= mapprojection_lc_lat2 )
then 632 log_error(
"MAPPROJECTION_LambertConformal_setup",*)
'Please set MAPPROJECTION_LC_lat1 < MAPPROJECTION_LC_lat2 in degree. STOP' 637 mapprojection_hemisphere = sign(1.0_dp,mapprojection_lc_lat1+mapprojection_lc_lat2)
639 lat1rot = 0.5_dp*pi - mapprojection_hemisphere * mapprojection_lc_lat1 * d2r
640 lat2rot = 0.5_dp*pi - mapprojection_hemisphere * mapprojection_lc_lat2 * d2r
643 mapprojection_lc_c = ( log( sin(lat1rot) ) - log( sin(lat2rot) ) ) &
644 / ( log( tan(0.5_dp*lat1rot) ) - log( tan(0.5_dp*lat2rot) ) )
647 mapprojection_lc_fact = sin(lat1rot) / mapprojection_lc_c / tan(0.5_dp*lat1rot)**mapprojection_lc_c
654 dist = mapprojection_lc_fact * radius * tan(0.5_dp*latrot)**mapprojection_lc_c
656 mapprojection_pole_x = mapprojection_basepoint_x - dist * sin(mapprojection_lc_c*dlon)
657 mapprojection_pole_y = mapprojection_basepoint_y + mapprojection_hemisphere * dist * cos(mapprojection_lc_c*dlon)
660 log_info(
"MAPPROJECTION_LambertConformal_setup",*)
'Input parameters' 661 log_info_cont(*)
'MAPPROJECTION_LC_lat1 = ', mapprojection_lc_lat1
662 log_info_cont(*)
'MAPPROJECTION_LC_lat2 = ', mapprojection_lc_lat2
663 log_info_cont(*)
'MAPPROJECTION_hemisphere = ', mapprojection_hemisphere
664 log_info_cont(*)
'MAPPROJECTION_LC_c = ', mapprojection_lc_c
665 log_info_cont(*)
'MAPPROJECTION_LC_fact = ', mapprojection_lc_fact
666 log_info_cont(*)
'MAPPROJECTION_pole_x = ', mapprojection_pole_x
667 log_info_cont(*)
'MAPPROJECTION_pole_y = ', mapprojection_pole_y
668 log_info_cont(*)
'MAPPROJECTION_pole_y = ', mapprojection_pole_y
669 log_info_cont(*)
'MAPPROJECTION_rotation = ', mapprojection_rotation
671 mapprojection_mapping =
"lambert_conformal_conic" 672 mapprojection_standard_parallel(:) = (/ mapprojection_lc_lat1, mapprojection_lc_lat2 /)
675 mapprojection_false_easting = mapprojection_basepoint_x
676 mapprojection_false_northing = mapprojection_basepoint_y
679 end subroutine mapprojection_lambertconformal_setup
683 subroutine mapprojection_lambertconformal_xy2lonlat( &
690 real(DP),
intent(in) :: x
691 real(DP),
intent(in) :: y
692 real(RP),
intent(out) :: lon
693 real(RP),
intent(out) :: lat
695 real(DP) :: xx, yy, dist
698 xx = ( x - mapprojection_pole_x ) / radius / mapprojection_lc_fact
699 yy = -mapprojection_hemisphere * ( y - mapprojection_pole_y ) / radius / mapprojection_lc_fact
701 dist = sqrt( xx*xx + yy*yy )
706 lat = mapprojection_hemisphere * ( 0.5_dp*pi - 2.0_dp*atan( dist**(1.0_dp/mapprojection_lc_c) ) )
709 end subroutine mapprojection_lambertconformal_xy2lonlat
713 subroutine mapprojection_lambertconformal_lonlat2xy( &
720 real(RP),
intent(in) :: lon
721 real(RP),
intent(in) :: lat
722 real(DP),
intent(out) :: x
723 real(DP),
intent(out) :: y
725 real(DP) :: dlon, latrot, dist
729 if ( dlon > pi ) dlon = dlon - pi*2.0_dp
730 if ( dlon < -pi ) dlon = dlon + pi*2.0_dp
732 latrot = 0.5_dp*pi - mapprojection_hemisphere * lat
734 dist = mapprojection_lc_fact * radius * tan(0.5_dp*latrot)**mapprojection_lc_c
736 x = mapprojection_pole_x + dist * sin(mapprojection_lc_c*dlon)
737 y = mapprojection_pole_y - mapprojection_hemisphere * dist * cos(mapprojection_lc_c*dlon)
740 end subroutine mapprojection_lambertconformal_lonlat2xy
744 subroutine mapprojection_lambertconformal_mapfactor( &
749 real(RP),
intent(in) :: lat
750 real(RP),
intent(out) :: m1
751 real(RP),
intent(out) :: m2
756 latrot = 0.5_dp*pi - mapprojection_hemisphere * lat
758 m1 = mapprojection_lc_fact / sin(latrot) * mapprojection_lc_c * tan(0.5_dp*latrot)**mapprojection_lc_c
762 end subroutine mapprojection_lambertconformal_mapfactor
765 subroutine mapprojection_lambertconformal_rotcoef( &
769 real(RP),
intent(in) :: lon, lat
770 real(RP),
intent(out) :: rotc_cos, rotc_sin
777 if ( dlon > pi ) dlon = dlon - pi*2.0_dp
778 if ( dlon < -pi ) dlon = dlon + pi*2.0_dp
780 alpha = - mapprojection_lc_c * dlon * mapprojection_hemisphere &
781 + mapprojection_rotation
783 rotc_cos = cos( alpha )
784 rotc_sin = sin( alpha )
787 end subroutine mapprojection_lambertconformal_rotcoef
791 subroutine mapprojection_polarstereographic_setup
795 real(DP) :: dlon, latrot, dist
799 mapprojection_hemisphere = sign(1.0_dp,mapprojection_ps_lat)
801 lat0 = mapprojection_hemisphere * mapprojection_ps_lat * d2r
804 mapprojection_ps_fact = 1.0_dp + sin(lat0)
811 dist = mapprojection_ps_fact * radius * tan(0.5_dp*latrot)
813 mapprojection_pole_x = mapprojection_basepoint_x - dist * sin(dlon)
814 mapprojection_pole_y = mapprojection_basepoint_y + mapprojection_hemisphere * dist * cos(dlon)
817 log_info(
"MAPPROJECTION_PolarStereographic_setup",*)
'MAPPROJECTION_PS_lat1 = ', mapprojection_ps_lat
818 log_info(
"MAPPROJECTION_PolarStereographic_setup",*)
'MAPPROJECTION_hemisphere = ', mapprojection_hemisphere
819 log_info(
"MAPPROJECTION_PolarStereographic_setup",*)
'MAPPROJECTION_PS_fact = ', mapprojection_ps_fact
820 log_info(
"MAPPROJECTION_PolarStereographic_setup",*)
'MAPPROJECTION_pole_x = ', mapprojection_pole_x
821 log_info(
"MAPPROJECTION_PolarStereographic_setup",*)
'MAPPROJECTION_pole_y = ', mapprojection_pole_y
823 mapprojection_mapping =
"polar_stereographic" 826 mapprojection_standard_parallel(1) = mapprojection_ps_lat
827 mapprojection_false_easting = mapprojection_basepoint_x
828 mapprojection_false_northing = mapprojection_basepoint_y
831 end subroutine mapprojection_polarstereographic_setup
835 subroutine mapprojection_polarstereographic_xy2lonlat( &
842 real(DP),
intent(in) :: x
843 real(DP),
intent(in) :: y
844 real(RP),
intent(out) :: lon
845 real(RP),
intent(out) :: lat
847 real(DP) :: xx, yy, dist
850 xx = ( x - mapprojection_pole_x ) / radius / mapprojection_ps_fact
851 yy = -mapprojection_hemisphere * ( y - mapprojection_pole_y ) / radius / mapprojection_ps_fact
853 dist = sqrt( xx*xx + yy*yy )
857 lat = mapprojection_hemisphere * ( 0.5_dp*pi - 2.0_dp*atan(dist) )
860 end subroutine mapprojection_polarstereographic_xy2lonlat
864 subroutine mapprojection_polarstereographic_lonlat2xy( &
871 real(RP),
intent(in) :: lon
872 real(RP),
intent(in) :: lat
873 real(DP),
intent(out) :: x
874 real(DP),
intent(out) :: y
876 real(DP) :: dlon, latrot, dist
881 latrot = 0.5_dp*pi - mapprojection_hemisphere * lat
883 dist = mapprojection_ps_fact * radius * tan(0.5_dp*latrot)
885 x = mapprojection_pole_x + dist * sin(dlon)
886 y = mapprojection_pole_y - mapprojection_hemisphere * dist * cos(dlon)
889 end subroutine mapprojection_polarstereographic_lonlat2xy
893 subroutine mapprojection_polarstereographic_mapfactor( &
898 real(RP),
intent(in) :: lat
899 real(RP),
intent(out) :: m1
900 real(RP),
intent(out) :: m2
903 m1 = mapprojection_ps_fact / ( 1.0_dp + sin(mapprojection_hemisphere*lat) )
907 end subroutine mapprojection_polarstereographic_mapfactor
910 subroutine mapprojection_polarstereographic_rotcoef( &
914 real(RP),
intent(in) :: lon, lat
915 real(RP),
intent(out) :: rotc_cos, rotc_sin
922 if ( dlon > pi ) dlon = dlon - pi*2.0_dp
923 if ( dlon < -pi ) dlon = dlon + pi*2.0_dp
925 alpha = - dlon * mapprojection_hemisphere &
926 + mapprojection_rotation
928 rotc_cos = cos( alpha )
929 rotc_sin = sin( alpha )
932 end subroutine mapprojection_polarstereographic_rotcoef
936 subroutine mapprojection_mercator_setup
942 real(DP) :: latrot, dist
945 lat0 = mapprojection_m_lat * d2r
948 mapprojection_m_fact = cos(lat0)
950 if ( mapprojection_m_fact == 0.0_dp )
then 951 log_error(
"MAPPROJECTION_Mercator_setup",*)
'MAPPROJECTION_M_lat cannot be set to pole point! value=', mapprojection_m_lat
958 dist = 1.0_dp / tan(0.5_dp*latrot)
960 mapprojection_eq_x = mapprojection_basepoint_x
961 mapprojection_eq_y = mapprojection_basepoint_y - radius * mapprojection_m_fact * log(dist)
964 log_info(
"MAPPROJECTION_Mercator_setup",*)
'MAPPROJECTION_M_lat = ', mapprojection_m_lat
965 log_info(
"MAPPROJECTION_Mercator_setup",*)
'MAPPROJECTION_M_fact = ', mapprojection_m_fact
966 log_info(
"MAPPROJECTION_Mercator_setup",*)
'MAPPROJECTION_eq_x = ', mapprojection_eq_x
967 log_info(
"MAPPROJECTION_Mercator_setup",*)
'MAPPROJECTION_eq_y = ', mapprojection_eq_y
969 mapprojection_mapping =
"mercator" 971 mapprojection_standard_parallel(1) = mapprojection_m_lat
972 mapprojection_false_easting = mapprojection_basepoint_x
973 mapprojection_false_northing = mapprojection_basepoint_y
976 end subroutine mapprojection_mercator_setup
980 subroutine mapprojection_mercator_xy2lonlat( &
987 real(DP),
intent(in) :: x
988 real(DP),
intent(in) :: y
989 real(RP),
intent(out) :: lon
990 real(RP),
intent(out) :: lat
995 xx = ( x - mapprojection_eq_x ) / radius / mapprojection_m_fact
996 yy = ( y - mapprojection_eq_y ) / radius / mapprojection_m_fact
1000 lat = 0.5_dp*pi - 2.0_dp*atan( 1.0_dp/exp(yy) )
1003 end subroutine mapprojection_mercator_xy2lonlat
1007 subroutine mapprojection_mercator_lonlat2xy( &
1014 real(RP),
intent(in) :: lon
1015 real(RP),
intent(in) :: lat
1016 real(DP),
intent(out) :: x
1017 real(DP),
intent(out) :: y
1019 real(DP) :: dlon, latrot, dist
1024 latrot = 0.5_dp*pi - lat
1026 dist = 1.0_dp / tan(0.5_dp*latrot)
1028 x = mapprojection_eq_x + radius * mapprojection_m_fact * dlon
1029 y = mapprojection_eq_y + radius * mapprojection_m_fact * log(dist)
1032 end subroutine mapprojection_mercator_lonlat2xy
1036 subroutine mapprojection_mercator_mapfactor( &
1041 real(RP),
intent(in) :: lat
1042 real(RP),
intent(out) :: m1
1043 real(RP),
intent(out) :: m2
1046 m1 = mapprojection_m_fact / cos(
real(lat,kind=
dp))
1050 end subroutine mapprojection_mercator_mapfactor
1053 subroutine mapprojection_mercator_rotcoef( &
1055 rotc_cos, rotc_sin )
1057 real(RP),
intent(in) :: lon, lat
1058 real(RP),
intent(out) :: rotc_cos, rotc_sin
1061 rotc_cos = mapprojection_rot_fact_cos
1062 rotc_sin = mapprojection_rot_fact_sin
1065 end subroutine mapprojection_mercator_rotcoef
1069 subroutine mapprojection_equidistantcylindrical_setup
1077 lat0 = mapprojection_ec_lat * d2r
1080 mapprojection_ec_fact = cos(lat0)
1082 if ( mapprojection_ec_fact == 0.0_dp )
then 1083 log_error(
"MAPPROJECTION_EquidistantCylindrical_setup",*)
'MAPPROJECTION_EC_lat cannot be set to pole point! value=', mapprojection_ec_lat
1087 mapprojection_eq_x = mapprojection_basepoint_x
1091 log_info(
"MAPPROJECTION_EquidistantCylindrical_setup",*)
'MAPPROJECTION_EC_lat = ', mapprojection_ec_lat
1092 log_info(
"MAPPROJECTION_EquidistantCylindrical_setup",*)
'MAPPROJECTION_EC_fact = ', mapprojection_ec_fact
1093 log_info(
"MAPPROJECTION_EquidistantCylindrical_setup",*)
'MAPPROJECTION_eq_x = ', mapprojection_eq_x
1094 log_info(
"MAPPROJECTION_EquidistantCylindrical_setup",*)
'MAPPROJECTION_eq_y = ', mapprojection_eq_y
1096 mapprojection_mapping =
"equirectangular" 1097 mapprojection_standard_parallel(1) = mapprojection_ec_lat
1099 mapprojection_false_easting = mapprojection_basepoint_x
1100 mapprojection_false_northing = mapprojection_basepoint_y
1103 end subroutine mapprojection_equidistantcylindrical_setup
1107 subroutine mapprojection_equidistantcylindrical_xy2lonlat( &
1116 real(DP),
intent(in) :: x
1117 real(DP),
intent(in) :: y
1118 real(RP),
intent(out) :: lon
1119 real(RP),
intent(out) :: lat
1124 xx = ( x - mapprojection_eq_x ) / radius / mapprojection_ec_fact
1125 yy = ( y - mapprojection_eq_y ) / radius
1131 if ( abs(lat) > 0.5_dp*pi )
then 1132 log_error(
"MAPPROJECTION_EquidistantCylindrical_xy2lonlat",*)
'Invalid latitude range! value=', lat
1137 end subroutine mapprojection_equidistantcylindrical_xy2lonlat
1141 subroutine mapprojection_equidistantcylindrical_lonlat2xy( &
1148 real(RP),
intent(in) :: lon
1149 real(RP),
intent(in) :: lat
1150 real(DP),
intent(out) :: x
1151 real(DP),
intent(out) :: y
1158 x = mapprojection_eq_x + radius * mapprojection_ec_fact * dlon
1159 y = mapprojection_eq_y + radius * lat
1162 end subroutine mapprojection_equidistantcylindrical_lonlat2xy
1166 subroutine mapprojection_equidistantcylindrical_mapfactor( &
1171 real(RP),
intent(in) :: lat
1172 real(RP),
intent(out) :: m1
1173 real(RP),
intent(out) :: m2
1174 real(DP) :: mm1, mm2
1177 mm1 = mapprojection_ec_fact / cos(
real(lat,kind=
dp))
1180 m1 = sqrt( (mapprojection_rot_fact_cos * mm1)**2 + (mapprojection_rot_fact_sin * mm2)**2 )
1181 m2 = sqrt( (mapprojection_rot_fact_cos * mm2)**2 + (mapprojection_rot_fact_sin * mm1)**2 )
1184 end subroutine mapprojection_equidistantcylindrical_mapfactor
1187 subroutine mapprojection_equidistantcylindrical_rotcoef( &
1189 rotc_cos, rotc_sin )
1191 real(RP),
intent(in) :: lon, lat
1192 real(RP),
intent(out) :: rotc_cos, rotc_sin
1195 rotc_cos = mapprojection_rot_fact_cos
1196 rotc_sin = mapprojection_rot_fact_sin
1199 end subroutine mapprojection_equidistantcylindrical_rotcoef
subroutine, public mapprojection_get_attributes(mapping, false_easting, false_northing, longitude_of_central_meridian, longitude_of_projection_origin, latitude_of_projection_origin, straight_vertical_longitude_from_pole, standard_parallel)
Get mapping attributes.
subroutine, public mapprojection_setup(DOMAIN_CENTER_X, DOMAIN_CENTER_Y)
Setup.
subroutine, public mapprojection_rotcoef(IA, IS, IE, JA, JS, JE, lon, lat, rotc)
u(lat,lon) = cos u(x,y) - sin v(x,y) v(lat,lon) = sin u(x,y) + cos v(x,y)
real(rp), public const_radius
radius of the planet [m]
integer, public io_fid_conf
Config file ID.
real(rp), public const_d2r
degree to radian
real(rp), public const_undef
subroutine, public prc_abort
Abort Process.
subroutine, public mapprojection_mapfactor(IA, IS, IE, JA, JS, JE, lat, m1, m2)
(x,y) -> (lon,lat)
real(rp), public mapprojection_basepoint_lon
procedure(xy2lonlat_s), pointer xy2lonlat
real(rp), public const_pi
pi
subroutine mapprojection_xy2lonlat_0d(x, y, lon, lat)
(x,y) -> (lon,lat)
real(rp), public mapprojection_basepoint_lat
integer, parameter, public dp