grid_tools  1.6.0
 All Data Structures Files Functions Variables
pmat5.f90
Go to the documentation of this file.
1 
4 
7 module cstgeo ! Constants for orientation and stretching of map
8 use pkind, only: sp
9 implicit none
10 real(sp),dimension(3,3):: rotm
11 real(sp) :: sc
12 real(sp) :: sci
13 end module cstgeo
14 
17 module dcstgeo ! Constants for orientation and stretching of map
18 use pkind, only: dp
19 implicit none
20 real(dp),dimension(3,3):: rotm
21 real(dp) :: sc
22 real(dp) :: sci
23 end module dcstgeo
24 
27 module pmat5
28 use pkind, only: spi,sp,dp
29 implicit none
30 private
31 public :: ininmap,inivmap,ctogr,grtoc,ctog,gtoc,&
34 interface ininmap; module procedure sininmap,dininmap; end interface
35 interface inivmap; module procedure sinivmap,dinivmap; end interface
36 interface ctogr; module procedure sctogr, dctogr; end interface
37 interface grtoc
38  module procedure sgrtoc,dgrtoc, sgrtocd,dgrtocd, sgrtocdd,dgrtocdd
39  end interface
40 interface ctog; module procedure sctog, dctog; end interface
41 interface gtoc
42  module procedure sgtoc,dgtoc, sgtocd,dgtocd, sgtocdd,dgtocdd; end interface
43 interface gtoframe
44  module procedure sgtoframev,gtoframev,sgtoframem,gtoframem; end interface
45 interface paraframe; module procedure sparaframe,paraframe; end interface
46 interface frametwist;module procedure sframetwist,frametwist; end interface
47 interface ctoc_schm
48  module procedure sctoc,dctoc, sctocd,dctocd, sctocdd,dctocdd; end interface
49 interface plrot; module procedure plrot, dplrot; end interface
50 interface plroti; module procedure plroti,dplroti; end interface
51 interface plctoc; module procedure plctoc; end interface
52 contains
53 
63 subroutine sininmap(alon0,alat0,rot3)! [ininmap]
64 use pietc_s, only: u0,dtor
65 implicit none
66 real(sp), intent(IN ):: alon0,alat0
67 real(sp),dimension(3,3),intent(OUT):: rot3
68 real(sp) :: blon0,blat0,clon0,clat0,slon0,slat0
69 blon0=dtor*alon0; clon0=cos(blon0); slon0=sin(blon0)
70 blat0=dtor*alat0; clat0=cos(blat0); slat0=sin(blat0)
71 rot3(1,1)=slat0*clon0; rot3(1,2)=slat0*slon0; rot3(1,3)=-clat0
72 rot3(2,1)=-slon0; rot3(2,2)=clon0; rot3(2,3)=u0
73 rot3(3,1)=clat0*clon0; rot3(3,2)=clat0*slon0; rot3(3,3)=slat0
74 end subroutine sininmap
75 
85 subroutine dininmap(alon0,alat0,rot3)! [ininmap]
86 use pietc, only: u0,dtor
87 implicit none
88 real(dp), intent(IN ):: alon0,alat0
89 real(dp),dimension(3,3),intent(OUT):: rot3
90 real(dp) :: blon0,blat0,clon0,clat0,slon0,slat0
91 blon0=dtor*alon0; clon0=cos(blon0); slon0=sin(blon0)
92 blat0=dtor*alat0; clat0=cos(blat0); slat0=sin(blat0)
93 rot3(1,1)=slat0*clon0; rot3(1,2)=slat0*slon0; rot3(1,3)=-clat0
94 rot3(2,1)=-slon0; rot3(2,2)=clon0; rot3(2,3)=u0
95 rot3(3,1)=clat0*clon0; rot3(3,2)=clat0*slon0; rot3(3,3)=slat0
96 end subroutine dininmap
97 
107 subroutine sinivmap(alon0,alat0,rot3)! [inivmap]
108 use pietc_s, only: u0,dtor
109 implicit none
110 real(sp), intent(IN ):: alon0,alat0
111 real(sp),dimension(3,3),intent(OUT):: rot3
112 real(sp) :: blon0,blat0,clon0,clat0,slon0,slat0
113 blon0=dtor*alon0
114 blat0=dtor*alat0
115 clon0=cos(blon0)
116 slon0=sin(blon0)
117 clat0=cos(blat0)
118 slat0=sin(blat0)
119 rot3(1,1)=-slon0
120 rot3(1,2)=clon0
121 rot3(1,3)=u0
122 rot3(2,1)=-slat0*clon0
123 rot3(2,2)=-slat0*slon0
124 rot3(2,3)=clat0
125 rot3(3,1)=clat0*clon0
126 rot3(3,2)=clat0*slon0
127 rot3(3,3)=slat0
128 end subroutine sinivmap
129 
139 subroutine dinivmap(alon0,alat0,rot3)! [inivmap]
140 use pietc, only: u0,dtor
141 implicit none
142 real(dp), intent(IN ):: alon0,alat0
143 real(dp),dimension(3,3),intent(OUT):: rot3
144 real(dp) :: blon0,blat0,clon0,clat0,slon0,slat0
145 blon0=dtor*alon0
146 blat0=dtor*alat0
147 clon0=cos(blon0)
148 slon0=sin(blon0)
149 clat0=cos(blat0)
150 slat0=sin(blat0)
151 rot3(1,1)=-slon0
152 rot3(1,2)=clon0
153 rot3(1,3)=u0
154 rot3(2,1)=-slat0*clon0
155 rot3(2,2)=-slat0*slon0
156 rot3(2,3)=clat0
157 rot3(3,1)=clat0*clon0
158 rot3(3,2)=clat0*slon0
159 rot3(3,3)=slat0
160 end subroutine dinivmap
161 
172 subroutine sctogr(xe,rlat,rlon)! [ctogr]
173 use pietc_s, only: u0
174 implicit none
175 real(sp),dimension(3),intent(IN ):: xe
176 real(sp), intent(OUT):: rlat,rlon
177 real(sp) :: r
178 r=sqrt(xe(1)**2+xe(2)**2)
179 rlat=atan2(xe(3),r)
180 if(r==u0)then
181  rlon=u0
182 else
183  rlon=atan2(xe(2),xe(1))
184 endif
185 end subroutine sctogr
186 
197 subroutine dctogr(xe,rlat,rlon)! [ctogr]
198 use pietc, only: u0
199 implicit none
200 real(dp),dimension(3),intent(IN ):: xe
201 real(dp), intent(OUT):: rlat,rlon
202 real(dp) :: r
203 r=sqrt(xe(1)**2+xe(2)**2)
204 rlat=atan2(xe(3),r)
205 if(r==u0)then
206  rlon=u0
207 else
208  rlon=atan2(xe(2),xe(1))
209 endif
210 end subroutine dctogr
211 
219 subroutine sgrtoc(rlat,rlon,xe)! [grtoc]
220 implicit none
221 real(sp), intent(IN ):: rlat,rlon
222 real(sp),dimension(3),intent(OUT):: xe
223 real(sp) :: sla,cla,slo,clo
224 sla=sin(rlat); cla=cos(rlat)
225 slo=sin(rlon); clo=cos(rlon)
226 xe(1)=cla*clo; xe(2)=cla*slo; xe(3)=sla
227 end subroutine sgrtoc
228 
236 subroutine dgrtoc(rlat,rlon,xe)! [grtoc]
237 implicit none
238 real(dp), intent(IN ):: rlat,rlon
239 real(dp),dimension(3),intent(OUT):: xe
240 real(dp) :: sla,cla,slo,clo
241 sla=sin(rlat); cla=cos(rlat)
242 slo=sin(rlon); clo=cos(rlon)
243 xe(1)=cla*clo; xe(2)=cla*slo; xe(3)=sla
244 end subroutine dgrtoc
245 
256 subroutine sgrtocd(rlat,rlon,xe,dxedlat,dxedlon)! [grtoc]
257 implicit none
258 real(sp), intent(IN ):: rlat,rlon
259 real(sp),dimension(3),intent(OUT):: xe,dxedlat,dxedlon
260 real(dp) :: rlat_d,rlon_d
261 real(dp),dimension(3):: xe_d,dxedlat_d,dxedlon_d
262 rlat_d=rlat; rlon_d=rlon
263 call dgrtocd(rlat_d,rlon_d,xe_d,dxedlat_d,dxedlon_d)
264 xe =xe_d
265 dxedlat=dxedlat_d
266 dxedlon=dxedlon_d
267 end subroutine sgrtocd
268 
279 subroutine dgrtocd(rlat,rlon,xe,dxedlat,dxedlon)! [grtoc]
280 use pietc, only: u0
281 implicit none
282 real(dp), intent(IN ):: rlat,rlon
283 real(dp),dimension(3),intent(OUT):: xe,dxedlat,dxedlon
284 real(dp) :: sla,cla,slo,clo
285 sla=sin(rlat); cla=cos(rlat)
286 slo=sin(rlon); clo=cos(rlon)
287 xe(1)=cla*clo; xe(2)=cla*slo; xe(3)=sla
288 dxedlat(1)=-sla*clo; dxedlat(2)=-sla*slo; dxedlat(3)=cla
289 dxedlon(1)=-cla*slo; dxedlon(2)= cla*clo; dxedlon(3)=u0
290 end subroutine dgrtocd
291 
305 subroutine sgrtocdd(rlat,rlon,xe,dxedlat,dxedlon, &! [grtoc]
306  ddxedlatdlat,ddxedlatdlon,ddxedlondlon)
307 implicit none
308 real(sp), intent(IN ):: rlat,rlon
309 real(sp),dimension(3),intent(OUT):: xe,dxedlat,dxedlon, &
310  ddxedlatdlat,ddxedlatdlon,ddxedlondlon
311 real(dp) :: rlat_d,rlon_d
312 real(dp),dimension(3):: xe_d,dxedlat_d,dxedlon_d, &
313  ddxedlatdlat_d,ddxedlatdlon_d,ddxedlondlon_d
314 rlat_d=rlat; rlon_d=rlon
315 call dgtocdd(rlat_d,rlon_d,xe_d,dxedlat_d,dxedlon_d, &
316  ddxedlatdlat_d,ddxedlatdlon_d,ddxedlondlon_d)
317 xe =xe_d
318 dxedlat =dxedlat_d
319 dxedlon =dxedlon_d
320 ddxedlatdlat=ddxedlatdlat_d
321 ddxedlatdlon=ddxedlatdlon_d
322 ddxedlondlon=ddxedlondlon_d
323 end subroutine sgrtocdd
324 
338 subroutine dgrtocdd(rlat,rlon,xe,dxedlat,dxedlon, &! [grtoc]
339  ddxedlatdlat,ddxedlatdlon,ddxedlondlon)
340 use pietc, only: u0
341 implicit none
342 real(dp), intent(IN ):: rlat,rlon
343 real(dp),dimension(3),intent(OUT):: xe,dxedlat,dxedlon, &
344  ddxedlatdlat,ddxedlatdlon,ddxedlondlon
345 real(dp) :: sla,cla,slo,clo
346 sla=sin(rlat); cla=cos(rlat)
347 slo=sin(rlon); clo=cos(rlon)
348 xe(1)=cla*clo; xe(2)=cla*slo; xe(3)=sla
349 dxedlat(1)=-sla*clo; dxedlat(2)=-sla*slo; dxedlat(3)=cla
350 dxedlon(1)=-cla*slo; dxedlon(2)= cla*clo; dxedlon(3)=u0
351 ddxedlatdlat(1)=-cla*clo
352 ddxedlatdlat(2)=-cla*slo
353 ddxedlatdlat(3)=-sla
354 ddxedlatdlon(1)= sla*slo
355 ddxedlatdlon(2)=-sla*clo
356 ddxedlatdlon(3)= u0
357 ddxedlondlon(1)=-cla*clo
358 ddxedlondlon(2)=-cla*slo
359 ddxedlondlon(3)= u0
360 end subroutine dgrtocdd
361 
372 subroutine sctog(xe,dlat,dlon)! [ctog]
373 use pietc_s, only: u0,rtod
374 implicit none
375 real(sp),dimension(3),intent(IN ):: xe
376 real(sp), intent(OUT):: dlat,dlon
377 real(sp) :: r
378 r=sqrt(xe(1)**2+xe(2)**2)
379 dlat=atan2(xe(3),r)*rtod
380 if(r==u0)then
381  dlon=u0
382 else
383  dlon=atan2(xe(2),xe(1))*rtod
384 endif
385 end subroutine sctog
386 
397 subroutine dctog(xe,dlat,dlon)! [ctog]
398 use pietc, only: u0,rtod
399 implicit none
400 real(dp),dimension(3),intent(IN ):: xe
401 real(dp), intent(OUT):: dlat,dlon
402 real(dp) :: r
403 r=sqrt(xe(1)**2+xe(2)**2)
404 dlat=atan2(xe(3),r)*rtod
405 if(r==u0)then
406  dlon=u0
407 else
408  dlon=atan2(xe(2),xe(1))*rtod
409 endif
410 end subroutine dctog
411 
422 subroutine sgtoc(dlat,dlon,xe)! [gtoc]
423 use pietc_s, only: dtor
424 implicit none
425 real(sp), intent(IN ):: dlat,dlon
426 real(sp),dimension(3),intent(OUT):: xe
427 real(sp) :: rlat,rlon,sla,cla,slo,clo
428 rlat=dtor*dlat; rlon=dtor*dlon
429 sla=sin(rlat); cla=cos(rlat)
430 slo=sin(rlon); clo=cos(rlon)
431 xe(1)=cla*clo; xe(2)=cla*slo; xe(3)=sla
432 end subroutine sgtoc
433 
444 subroutine dgtoc(dlat,dlon,xe)! [gtoc]
445 use pietc, only: dtor
446 implicit none
447 real(dp), intent(IN ):: dlat,dlon
448 real(dp),dimension(3),intent(OUT):: xe
449 real(dp) :: rlat,rlon,sla,cla,slo,clo
450 rlat=dtor*dlat; rlon=dtor*dlon
451 sla=sin(rlat); cla=cos(rlat)
452 slo=sin(rlon); clo=cos(rlon)
453 xe(1)=cla*clo; xe(2)=cla*slo; xe(3)=sla
454 end subroutine dgtoc
455 
469 subroutine sgtocd(dlat,dlon,xe,dxedlat,dxedlon)! [gtoc]
470 implicit none
471 real(sp), intent(IN ):: dlat,dlon
472 real(sp),dimension(3),intent(OUT):: xe,dxedlat,dxedlon
473 real(dp) :: dlat_d,dlon_d
474 real(dp),dimension(3):: xe_d,dxedlat_d,dxedlon_d
475 dlat_d=dlat; dlon_d=dlon
476 call dgtocd(dlat_d,dlon_d,xe_d,dxedlat_d,dxedlon_d)
477 xe =xe_d
478 dxedlat=dxedlat_d
479 dxedlon=dxedlon_d
480 end subroutine sgtocd
481 
495 subroutine dgtocd(dlat,dlon,xe,dxedlat,dxedlon)! [gtoc]
496 use pietc, only: u0,dtor
497 implicit none
498 real(dp), intent(IN ):: dlat,dlon
499 real(dp),dimension(3),intent(OUT):: xe,dxedlat,dxedlon
500 real(dp) :: rlat,rlon,sla,cla,slo,clo
501 rlat=dtor*dlat; rlon=dtor*dlon
502 sla=sin(rlat); cla=cos(rlat)
503 slo=sin(rlon); clo=cos(rlon)
504 xe(1)=cla*clo; xe(2)=cla*slo; xe(3)=sla
505 dxedlat(1)=-sla*clo; dxedlat(2)=-sla*slo; dxedlat(3)=cla; dxedlat=dxedlat*dtor
506 dxedlon(1)=-cla*slo; dxedlon(2)= cla*clo; dxedlon(3)=u0 ; dxedlon=dxedlon*dtor
507 end subroutine dgtocd
508 
526 subroutine sgtocdd(dlat,dlon,xe,dxedlat,dxedlon, &
527  ddxedlatdlat,ddxedlatdlon,ddxedlondlon)! [gtoc]
528 implicit none
529 real(sp), intent(IN ):: dlat,dlon
530 real(sp),dimension(3),intent(OUT):: xe,dxedlat,dxedlon, &
531  ddxedlatdlat,ddxedlatdlon,ddxedlondlon
532 real(dp) :: dlat_d,dlon_d
533 real(dp),dimension(3):: xe_d,dxedlat_d,dxedlon_d, &
534  ddxedlatdlat_d,ddxedlatdlon_d,ddxedlondlon_d
535 dlat_d=dlat; dlon_d=dlon
536 call dgtocdd(dlat_d,dlon_d,xe_d,dxedlat_d,dxedlon_d, &
537  ddxedlatdlat_d,ddxedlatdlon_d,ddxedlondlon_d)
538 xe =xe_d
539 dxedlat =dxedlat_d
540 dxedlon =dxedlon_d
541 ddxedlatdlat=ddxedlatdlat_d
542 ddxedlatdlon=ddxedlatdlon_d
543 ddxedlondlon=ddxedlondlon_d
544 end subroutine sgtocdd
545 
563 subroutine dgtocdd(dlat,dlon,xe,dxedlat,dxedlon, &
564  ddxedlatdlat,ddxedlatdlon,ddxedlondlon)! [gtoc]
565 use pietc, only: u0,dtor
566 implicit none
567 real(dp), intent(IN ):: dlat,dlon
568 real(dp),dimension(3),intent(OUT):: xe,dxedlat,dxedlon, &
569  ddxedlatdlat,ddxedlatdlon,ddxedlondlon
570 real(dp) :: rlat,rlon,sla,cla,slo,clo
571 rlat=dtor*dlat; rlon=dtor*dlon
572 sla=sin(rlat); cla=cos(rlat)
573 slo=sin(rlon); clo=cos(rlon)
574 xe(1)=cla*clo; xe(2)=cla*slo; xe(3)=sla
575 dxedlat(1)=-sla*clo; dxedlat(2)=-sla*slo; dxedlat(3)=cla; dxedlat=dxedlat*dtor
576 dxedlon(1)=-cla*slo; dxedlon(2)= cla*clo; dxedlon(3)=u0 ; dxedlon=dxedlon*dtor
577 ddxedlatdlat(1)=-cla*clo
578 ddxedlatdlat(2)=-cla*slo
579 ddxedlatdlat(3)=-sla
580 ddxedlatdlon(1)= sla*slo
581 ddxedlatdlon(2)=-sla*clo
582 ddxedlatdlon(3)= u0
583 ddxedlondlon(1)=-cla*clo
584 ddxedlondlon(2)=-cla*slo
585 ddxedlondlon(3)= u0
586 ddxedlatdlat=ddxedlatdlat*dtor**2
587 ddxedlatdlon=ddxedlatdlon*dtor**2
588 ddxedlondlon=ddxedlondlon*dtor**2
589 end subroutine dgtocdd
590 
599 subroutine sgtoframem(splat,splon,sorth)! [gtoframe]
600 implicit none
601 real(sp), intent(in ):: splat,splon
602 real(sp),dimension(3,3),intent(out):: sorth
603 real(dp):: plat,plon
604 real(dp),dimension(3,3):: orth
605 plat=splat; plon=splon; call gtoframem(plat,plon,orth); sorth=orth
606 end subroutine sgtoframem
607 
616 subroutine gtoframem(plat,plon,orth)! [gtoframe]
617 implicit none
618 real(dp), intent(in ):: plat,plon
619 real(dp),dimension(3,3),intent(out):: orth
620 real(dp),dimension(3):: xp,yp,zp
621 call gtoframev(plat,plon, xp,yp,zp)
622 orth(:,1)=xp; orth(:,2)=yp; orth(:,3)=zp
623 end subroutine gtoframem
624 
636 subroutine sgtoframev(splat,splon,sxp,syp,szp)! [gtoframe]
637 !==============================================================================
638 implicit none
639 real(sp), intent(in ):: splat,splon
640 real(sp),dimension(3),intent(out):: sxp,syp,szp
641 !------------------------------------------------------------------------------
642 real(dp) :: plat,plon
643 real(dp),dimension(3):: xp,yp,zp
644 !==============================================================================
645 plat=splat; plon=splon
646 call gtoframev(plat,plon, xp,yp,zp)
647 sxp=xp; syp=yp; szp=zp
648 end subroutine sgtoframev
649 
661 subroutine gtoframev(plat,plon, xp,yp,zp)! [gtoframe]
662 use pietc, only: u0,u1
663 implicit none
664 real(dp), intent(in ):: plat,plon
665 real(dp),dimension(3),intent(out):: xp,yp,zp
666 real(dp),dimension(3):: dzpdlat,dzpdlon
667 if(plat==90)then ! is this the north pole?
668  xp=(/ u0,u1, u0/) ! Assume the limiting case lat-->90 along the 0-meridian
669  yp=(/-u1,u0, u0/) !
670  zp=(/ u0,u0, u1/)
671 elseif(plat==-90)then
672  xp=(/ u0,u1, u0/) ! Assume the limiting case lat-->90 along the 0-meridian
673  yp=(/ u1,u0, u0/) !
674  zp=(/ u0,u0,-u1/)
675 else
676  call gtoc(plat,plon,zp,dzpdlat,dzpdlon)
677  xp=dzpdlon/sqrt(dot_product(dzpdlon,dzpdlon))
678  yp=dzpdlat/sqrt(dot_product(dzpdlat,dzpdlat))
679 endif
680 end subroutine gtoframev
681 
695 subroutine sparaframe(sxp,syp,szp, sxv,syv,szv)! [paraframe]
696 implicit none
697 real(sp),dimension(3),intent(in ):: sxp,syp,szp, szv
698 real(sp),dimension(3),intent(out):: sxv,syv
699 real(dp),dimension(3):: xp,yp,zp, xv,yv,zv
700 xp=sxp; yp=syp; zp=szp
701 call paraframe(xp,yp,zp, xv,yv,zv)
702 sxv=xv; syv=yv
703 end subroutine sparaframe
704 
718 subroutine paraframe(xp,yp,zp, xv,yv,zv)! [paraframe]
719 use pmat4, only: cross_product,normalized
720 implicit none
721 real(dp),dimension(3),intent(in ):: xp,yp,zp, zv
722 real(dp),dimension(3),intent(out):: xv,yv
723 real(dp) :: xpofv,ypofv,theta,ctheta,stheta
724 real(dp),dimension(3):: xq,yq
725 xpofv=dot_product(xp,zv)
726 ypofv=dot_product(yp,zv)
727 theta=atan2(ypofv,xpofv); ctheta=cos(theta); stheta=sin(theta)
728 xq=zv-zp; xq=xq-zv*dot_product(xq,zv); xq=normalized(xq)
729 yq=cross_product(zv,xq)
730 xv=xq*ctheta-yq*stheta
731 yv=xq*stheta+yq*ctheta
732 end subroutine paraframe
733 
750 subroutine sframetwist(sxp,syp,szp, sxv,syv,szv, stwist)! [frametwist]
751 implicit none
752 real(sp),dimension(3),intent(in ):: sxp,syp,szp, sxv,syv,szv
753 real(sp), intent(out):: stwist
754 real(dp),dimension(3):: xp,yp,zp, xv,yv,zv
755 real(dp) :: twist
756 xp=sxp;yp=syp; zp=szp; xv=sxv; yv=syv; zv=szv
757 call frametwist(xp,yp,zp, xv,yv,zv, twist)
758 stwist=twist
759 end subroutine sframetwist
760 
777 subroutine frametwist(xp,yp,zp, xv,yv,zv, twist)! [frametwist]
778 implicit none
779 real(dp),dimension(3),intent(in ):: xp,yp,zp, xv,yv,zv
780 real(dp), intent(out):: twist
781 real(dp),dimension(3):: xxv,yyv
782 real(dp) :: c,s
783 call paraframe(xp,yp,zp, xxv,yyv,zv)
784 c=dot_product(xv,xxv); s=dot_product(xv,yyv)
785 twist=atan2(s,c)
786 end subroutine frametwist
787 
794 subroutine sctoc(s,xc1,xc2)! [ctoc_schm]
795 use pietc_s, only: u1,u2
796 implicit none
797 real(sp), intent(IN ):: s
798 real(sp),dimension(3),intent(INOUT):: xc1,xc2
799 real(sp) :: x,y,z,a,b,d,e,ab2,aa,bb,di,aapbb,aambb
800 x=xc1(1); y=xc1(2); z=xc1(3)
801 a=s+u1
802 b=s-u1
803 ab2=a*b*u2
804 aa=a*a
805 bb=b*b
806 aapbb=aa+bb
807 aambb=aa-bb
808 d=aapbb-ab2*z
809 e=aapbb*z-ab2
810 di=u1/d
811 xc2(1)=(aambb*x)*di
812 xc2(2)=(aambb*y)*di
813 xc2(3)=e*di
814 end subroutine sctoc
815 
824 subroutine sctocd(s,xc1,xc2,dxc2)! [ctoc_schm]
825 use pietc_s, only: u0,u1,u2
826 implicit none
827 real(sp),intent(IN) :: s
828 real(sp),dimension(3), intent(INOUT):: xc1,xc2
829 real(sp),dimension(3,3),intent( OUT):: dxc2
830 real(sp) :: x,y,z,a,b,d,e, &
831  ab2,aa,bb,di,ddi,aapbb,aambb
832 x=xc1(1); y=xc1(2); z=xc1(3)
833 a=s+u1
834 b=s-u1
835 ab2=a*b*u2
836 aa=a*a
837 bb=b*b
838 aapbb=aa+bb
839 aambb=aa-bb
840 d=aapbb-ab2*z
841 e=aapbb*z-ab2
842 di=u1/d
843 xc2(1)=(aambb*x)*di
844 xc2(2)=(aambb*y)*di
845 xc2(3)=e*di
846 ddi=di*di
847 
848 dxc2=u0
849 dxc2(1,1)=aambb*di
850 dxc2(1,3)=ab2*aambb*x*ddi
851 dxc2(2,2)=aambb*di
852 dxc2(2,3)=ab2*aambb*y*ddi
853 dxc2(3,3)=aapbb*di +ab2*e*ddi
854 end subroutine sctocd
855 
865 subroutine sctocdd(s,xc1,xc2,dxc2,ddxc2)! [ctoc_schm]
866 use pietc_s, only: u0,u1,u2
867 implicit none
868 real(sp), intent(IN ):: s
869 real(sp),dimension(3), intent(INOUT):: xc1,xc2
870 real(sp),dimension(3,3), intent( OUT):: dxc2
871 real(sp),dimension(3,3,3),intent( OUT):: ddxc2
872 real(sp) :: x,y,z,a,b,d,e, &
873  ab2,aa,bb,di,ddi,dddi, &
874  aapbb,aambb
875 x=xc1(1); y=xc1(2); z=xc1(3)
876 a=s+u1
877 b=s-u1
878 ab2=a*b*u2
879 aa=a*a
880 bb=b*b
881 aapbb=aa+bb
882 aambb=aa-bb
883 d=aapbb-ab2*z
884 e=aapbb*z-ab2
885 di=u1/d
886 xc2(1)=(aambb*x)*di
887 xc2(2)=(aambb*y)*di
888 xc2(3)=e*di
889 ddi=di*di
890 dddi=ddi*di
891 
892 dxc2=u0
893 dxc2(1,1)=aambb*di
894 dxc2(1,3)=ab2*aambb*x*ddi
895 dxc2(2,2)=aambb*di
896 dxc2(2,3)=ab2*aambb*y*ddi
897 dxc2(3,3)=aapbb*di +ab2*e*ddi
898 
899 ddxc2=u0
900 ddxc2(1,1,3)=ab2*aambb*ddi
901 ddxc2(1,3,1)=ddxc2(1,1,3)
902 ddxc2(1,3,3)=u2*ab2**2*aambb*x*dddi
903 ddxc2(2,2,3)=ab2*aambb*ddi
904 ddxc2(2,3,2)=ddxc2(2,2,3)
905 ddxc2(2,3,3)=u2*ab2**2*aambb*y*dddi
906 ddxc2(3,3,3)=u2*ab2*(aapbb*ddi+ab2*e*dddi)
907 end subroutine sctocdd
908 
915 subroutine dctoc(s,xc1,xc2)! [ctoc_schm]
916 use pietc, only: u1,u2
917 implicit none
918 real(dp), intent(IN ):: s
919 real(dp),dimension(3),intent(INOUT):: xc1,xc2
920 real(dp) :: x,y,z,a,b,d,e, &
921  ab2,aa,bb,di,aapbb,aambb
922 x=xc1(1); y=xc1(2); z=xc1(3)
923 a=s+u1
924 b=s-u1
925 ab2=a*b*u2
926 aa=a*a
927 bb=b*b
928 aapbb=aa+bb
929 aambb=aa-bb
930 d=aapbb-ab2*z
931 e=aapbb*z-ab2
932 di=u1/d
933 xc2(1)=(aambb*x)*di
934 xc2(2)=(aambb*y)*di
935 xc2(3)=e*di
936 end subroutine dctoc
937 
946 subroutine dctocd(s,xc1,xc2,dxc2)! [ctoc_schm]
947 use pietc, only: u0,u1,u2
948 implicit none
949 real(dp), intent(IN ):: s
950 real(dp),dimension(3), intent(INOUT):: xc1,xc2
951 real(dp),dimension(3,3),intent( OUT):: dxc2
952 real(dp) :: x,y,z,a,b,d,e, &
953  ab2,aa,bb,di,ddi,aapbb,aambb
954 x=xc1(1); y=xc1(2); z=xc1(3)
955 a=s+u1
956 b=s-u1
957 ab2=a*b*u2
958 aa=a*a
959 bb=b*b
960 aapbb=aa+bb
961 aambb=aa-bb
962 d=aapbb-ab2*z
963 e=aapbb*z-ab2
964 di=u1/d
965 xc2(1)=(aambb*x)*di
966 xc2(2)=(aambb*y)*di
967 xc2(3)=e*di
968 ddi=di*di
969 
970 dxc2=u0
971 dxc2(1,1)=aambb*di
972 dxc2(1,3)=ab2*aambb*x*ddi
973 dxc2(2,2)=aambb*di
974 dxc2(2,3)=ab2*aambb*y*ddi
975 dxc2(3,3)=aapbb*di +ab2*e*ddi
976 end subroutine dctocd
977 
987 subroutine dctocdd(s,xc1,xc2,dxc2,ddxc2)! [ctoc_schm]
988 use pietc, only: u0,u1,u2
989 implicit none
990 real(dp),intent(IN) :: s
991 real(dp),dimension(3), intent(INOUT):: xc1,xc2
992 real(dp),dimension(3,3), intent(OUT ):: dxc2
993 real(dp),dimension(3,3,3),intent(OUT ):: ddxc2
994 real(dp) :: x,y,z,a,b,d,e, &
995  ab2,aa,bb,di,ddi,dddi, &
996  aapbb,aambb
997 x=xc1(1); y=xc1(2); z=xc1(3)
998 a=s+u1
999 b=s-u1
1000 ab2=a*b*u2
1001 aa=a*a
1002 bb=b*b
1003 aapbb=aa+bb
1004 aambb=aa-bb
1005 d=aapbb-ab2*z
1006 e=aapbb*z-ab2
1007 di=u1/d
1008 xc2(1)=(aambb*x)*di
1009 xc2(2)=(aambb*y)*di
1010 xc2(3)=e*di
1011 ddi=di*di
1012 dddi=ddi*di
1013 
1014 dxc2=u0
1015 dxc2(1,1)=aambb*di
1016 dxc2(1,3)=ab2*aambb*x*ddi
1017 dxc2(2,2)=aambb*di
1018 dxc2(2,3)=ab2*aambb*y*ddi
1019 dxc2(3,3)=aapbb*di +ab2*e*ddi
1020 
1021 ddxc2=u0
1022 ddxc2(1,1,3)=ab2*aambb*ddi
1023 ddxc2(1,3,1)=ddxc2(1,1,3)
1024 ddxc2(1,3,3)=u2*ab2**2*aambb*x*dddi
1025 ddxc2(2,2,3)=ab2*aambb*ddi
1026 ddxc2(2,3,2)=ddxc2(2,2,3)
1027 ddxc2(2,3,3)=u2*ab2**2*aambb*y*dddi
1028 ddxc2(3,3,3)=u2*ab2*(aapbb*ddi+ab2*e*dddi)
1029 end subroutine dctocdd
1030 
1039 subroutine plrot(rot3,n,x,y,z)! [plrot]
1040 implicit none
1041 integer, intent(IN ):: n
1042 real(sp),dimension(3,3),intent(IN ):: rot3
1043 real(sp),dimension(n), intent(INOUT):: x,y,z
1044 real(sp),dimension(3) :: t
1045 integer :: k
1046 do k=1,n
1047  t(1)=x(k); t(2)=y(k); t(3)=z(k)
1048  t=matmul(rot3,t)
1049  x(k)=t(1); y(k)=t(2); z(k)=t(3)
1050 enddo
1051 end subroutine plrot
1052 
1061 subroutine plroti(rot3,n,x,y,z)! [plroti]
1062 implicit none
1063 integer, intent(IN ):: n
1064 real(sp),dimension(3,3),intent(IN ):: rot3
1065 real(sp),dimension(n), intent(INOUT):: x,y,z
1066 real(sp),dimension(3) :: t
1067 integer :: k
1068 do k=1,n
1069  t(1)=x(k); t(2)=y(k); t(3)=z(k)
1070  t=matmul(t,rot3)
1071  x(k)=t(1); y(k)=t(2); z(k)=t(3)
1072 enddo
1073 end subroutine plroti
1074 
1083 subroutine dplrot(rot3,n,x,y,z)! [plrot]
1084 implicit none
1085 integer, intent(IN ):: n
1086 real(dP),dimension(3,3),intent(IN ):: rot3
1087 real(dP),dimension(n), intent(INOUT):: x,y,z
1088 real(dP),dimension(3) :: t
1089 integer :: k
1090 do k=1,n
1091  t(1)=x(k); t(2)=y(k); t(3)=z(k)
1092  t=matmul(rot3,t)
1093  x(k)=t(1); y(k)=t(2); z(k)=t(3)
1094 enddo
1095 end subroutine dplrot
1096 
1105 subroutine dplroti(rot3,n,x,y,z)! [plroti]
1106 implicit none
1107 integer, intent(IN ):: n
1108 real(dP),dimension(3,3),intent(IN ):: rot3
1109 real(dP),dimension(n), intent(INOUT):: x,y,z
1110 real(dP),dimension(3) :: t
1111 integer :: k
1112 do k=1,n
1113  t(1)=x(k); t(2)=y(k); t(3)=z(k)
1114  t=matmul(t,rot3)
1115  x(k)=t(1); y(k)=t(2); z(k)=t(3)
1116 enddo
1117 end subroutine dplroti
1118 
1127 subroutine plctoc(s,n,x,y,z)! [plctoc]
1128 use pietc_s, only: u1
1129 implicit none
1130 integer, intent(IN ):: n
1131 real(sp), intent(IN ):: s
1132 real(sp),dimension(n),intent(INOUT):: x,y,z
1133 real(sp) :: a,b,d,e,ab2,aa,bb,di,aapbb,aambb
1134 integer :: i
1135 a=s+u1
1136 b=s-u1
1137 ab2=a*b*2
1138 aa=a*a
1139 bb=b*b
1140 aapbb=aa+bb
1141 aambb=aa-bb
1142 do i=1,n
1143  d=aapbb-ab2*z(i)
1144  e=aapbb*z(i)-ab2
1145  di=1/d
1146  x(i)=(aambb*x(i))*di
1147  y(i)=(aambb*y(i))*di
1148  z(i)=e*di
1149 enddo
1150 end subroutine plctoc
1151 
1152 end module pmat5
1153 
1154 
1155 
subroutine sgtocdd(dlat, dlon, xe, dxedlat, dxedlon, ddxedlatdlat, ddxedlatdlon, ddxedlondlon)
Transform "Geographical" to "Cartesian" coordinates, where the geographical coordinates refer to lati...
Definition: pmat5.f90:526
Constants for orientation and stretching of map.
Definition: pmat5.f90:17
subroutine dgtoc(dlat, dlon, xe)
Transform "Geographical" to "Cartesian" coordinates, where the geographical coordinates refer to lati...
Definition: pmat5.f90:444
subroutine sctocd(s, xc1, xc2, dxc2)
Evaluate Schmidt transformation, xc1 –> xc2, with scaling parameter s, and its jacobian, dxc2.
Definition: pmat5.f90:824
subroutine sctocdd(s, xc1, xc2, dxc2, ddxc2)
Evaluate Schmidt transformation, xc1 –> xc2, with scaling parameter s, its jacobian, dxc2, and its 2nd derivative, ddxc2.
Definition: pmat5.f90:865
subroutine gtoframev(plat, plon, xp, yp, zp)
Given a geographical point by its degrees lat and lon, plat and plon, return its standard orthogonal ...
Definition: pmat5.f90:661
subroutine sgrtoc(rlat, rlon, xe)
Transform "Geographical" to "Cartesian" coordinates.
Definition: pmat5.f90:219
Utility routines for orienting the globe and basic geographical mappings.
Definition: pmat5.f90:27
subroutine dinivmap(alon0, alat0, rot3)
Initialize the rotation matrix ROT3 needed to transform standard earth-centered cartesian components ...
Definition: pmat5.f90:139
subroutine dininmap(alon0, alat0, rot3)
Initialize the rotation matrix ROT3 needed to transform standard earth-centered cartesian components ...
Definition: pmat5.f90:85
subroutine dgrtocdd(rlat, rlon, xe, dxedlat, dxedlon, ddxedlatdlat, ddxedlatdlon, ddxedlondlon)
Transform "Geographical" to "Cartesian" coordinates, together with the 1st and 2nd partial derivative...
Definition: pmat5.f90:338
subroutine gtoframem(plat, plon, orth)
From the degree lat and lon (plat and plon) return the standard orthogonal 3D frame at this location ...
Definition: pmat5.f90:616
subroutine sgrtocdd(rlat, rlon, xe, dxedlat, dxedlon, ddxedlatdlat, ddxedlatdlon, ddxedlondlon)
Transform "Geographical" to "Cartesian" coordinates, together with the 1st and 2nd partial derivative...
Definition: pmat5.f90:305
subroutine sinivmap(alon0, alat0, rot3)
Initialize the rotation matrix ROT3 needed to transform standard earth-centered cartesian components ...
Definition: pmat5.f90:107
subroutine sctog(xe, dlat, dlon)
Transform "Cartesian" to "Geographical" coordinates, where the geographical coordinates refer to lati...
Definition: pmat5.f90:372
subroutine dplroti(rot3, n, x, y, z)
Invert the rotation of a three-dimensional polyline.
Definition: pmat5.f90:1105
subroutine dgrtocd(rlat, rlon, xe, dxedlat, dxedlon)
Transform "Geographical" to "Cartesian" coordinates, together with the partial derivatives of cartesi...
Definition: pmat5.f90:279
subroutine sctogr(xe, rlat, rlon)
Transform "Cartesian" to "Geographical" coordinates, where the geographical coordinates refer to lati...
Definition: pmat5.f90:172
subroutine dctocdd(s, xc1, xc2, dxc2, ddxc2)
Evaluate Schmidt transformation, xc1 –> xc2, with scaling parameter s, its jacobian, dxc2, and its 2nd derivative, ddxc2.
Definition: pmat5.f90:987
subroutine dctogr(xe, rlat, rlon)
Transform "Cartesian" to "Geographical" coordinates, where the geographical coordinates refer to lati...
Definition: pmat5.f90:197
Module for handy vector and matrix operations in Euclidean geometry.
Definition: pmat4.f90:45
subroutine dgtocd(dlat, dlon, xe, dxedlat, dxedlon)
Transform "Geographical" to "Cartesian" coordinates, where the geographical coordinates refer to lati...
Definition: pmat5.f90:495
subroutine dplrot(rot3, n, x, y, z)
Apply a constant rotation to a three dimensional polyline.
Definition: pmat5.f90:1083
subroutine dgrtoc(rlat, rlon, xe)
Transform "Geographical" to "Cartesian" coordinates.
Definition: pmat5.f90:236
subroutine dctocd(s, xc1, xc2, dxc2)
Evaluate Schmidt transformation, xc1 –> xc2, with scaling parameter s, and its jacobian, dxc2.
Definition: pmat5.f90:946
Standard integer, real, and complex single and double precision kinds.
Definition: pkind.f90:7
subroutine sgtoframev(splat, splon, sxp, syp, szp)
Given a geographical point by its degrees lat and lon, plat and plon, return its standard orthogonal ...
Definition: pmat5.f90:636
Constants for orientation and stretching of map.
Definition: pmat5.f90:7
subroutine dctog(xe, dlat, dlon)
Transform "Cartesian" to "Geographical" coordinates, where the geographical coordinates refer to lati...
Definition: pmat5.f90:397
Some of the commonly used constants (pi etc) mainly for double-precision subroutines.
Definition: pietc.f90:14
subroutine sctoc(s, xc1, xc2)
Evaluate Schmidt transformation, xc1 –> xc2, with scaling parameter s.
Definition: pmat5.f90:794
subroutine sgtoc(dlat, dlon, xe)
Transform "Geographical" to "Cartesian" coordinates, where the geographical coordinates refer to lati...
Definition: pmat5.f90:422
subroutine sframetwist(sxp, syp, szp, sxv, syv, szv, stwist)
Given a principal cartesian orthonormal frame, {xp,yp,zp} (i.e., at P with Earth-centered cartesians...
Definition: pmat5.f90:750
subroutine sininmap(alon0, alat0, rot3)
Initialize the rotation matrix ROT3 needed to transform standard earth-centered cartesian components ...
Definition: pmat5.f90:63
subroutine sparaframe(sxp, syp, szp, sxv, syv, szv)
Take a principal reference orthonormal frame, {xp,yp,zp} and a dependent point defined by unit vector...
Definition: pmat5.f90:695
subroutine sgrtocd(rlat, rlon, xe, dxedlat, dxedlon)
Transform "Geographical" to "Cartesian" coordinates, together with the partial derivatives of cartesi...
Definition: pmat5.f90:256
subroutine sgtoframem(splat, splon, sorth)
From the degree lat and lon (plat and plon) return the standard orthogonal 3D frame at this location ...
Definition: pmat5.f90:599
subroutine sgtocd(dlat, dlon, xe, dxedlat, dxedlon)
Transform "Geographical" to "Cartesian" coordinates, where the geographical coordinates refer to lati...
Definition: pmat5.f90:469
subroutine dgtocdd(dlat, dlon, xe, dxedlat, dxedlon, ddxedlatdlat, ddxedlatdlon, ddxedlondlon)
Transform "Geographical" to "Cartesian" coordinates, where the geographical coordinates refer to lati...
Definition: pmat5.f90:563
subroutine dctoc(s, xc1, xc2)
Evaluate Schmidt transformation, xc1 –> xc2, with scaling parameter s.
Definition: pmat5.f90:915