18use pietc,
only:
f,
t,
u0,
u1,
u2,
o2,
rtod,
dtor,
pih,
pi2
69real(dp),
dimension(3),
intent(in ):: xc
70real(dp),
dimension(2),
intent(out):: xs
72zp=
u1+xc(3); xs=xc(1:2)/zp
87real(dp),
dimension(2),
intent(in ):: xs
88real(dp),
dimension(3),
intent(out):: xc
89real(dp),
dimension(3,2),
intent(out):: xcd
91zp=
u2/(
u1+dot_product(xs,xs)); xc(1:2)=xs*zp; xc(3)=zp
92xcd=-
outer_product(xc,xs)*zp; xcd(1,1)=xcd(1,1)+zp; xcd(2,2)=xcd(2,2)+zp
109real(dp),
dimension(2),
intent(in ):: xs
110real(dp),
dimension(3),
intent(out):: xc
111real(dp),
dimension(3,2),
intent(out):: xcd
112real(dp),
dimension(3,2,2),
intent(out):: xcdd
113real(dp),
dimension(3,2):: zpxcdxs
114real(dp),
dimension(3) :: zpxc
117zp=
u2/(
u1+dot_product(xs,xs)); xc(1:2)=xs*zp; xc(3)=zp
119zpxc=zp*xc; xc(3)=xc(3)-
u1; xcdd=
u0
122 xcdd(:,i,i)=xcdd(:,i,i)-zpxc
123 xcdd(:,i,:)=xcdd(:,i,:)-zpxcdxs
124 xcdd(:,:,i)=xcdd(:,:,i)-zpxcdxs
125 xcdd(i,:,i)=xcdd(i,:,i)-zpxc(1:2)
126 xcdd(i,i,:)=xcdd(i,i,:)-zpxc(1:2)
128do i=1,2; xcd(i,i)=xcd(i,i)+zp;
enddo
140real(dp),
intent(in ):: k
141real(dp),
dimension(2),
intent(in ):: xs
142real(dp),
dimension(2),
intent(out):: xt
143logical,
intent(out):: ff
145s=k*(xs(1)*xs(1)+xs(2)*xs(2)); sc=
u1-s
146ff=abs(s)>=
u1;
if(ff)
return
161real(dp),
intent(in ):: k
162real(dp),
dimension(2),
intent(in ):: xt
163real(dp),
dimension(2),
intent(out):: xs
164real(dp),
dimension(2,2),
intent(out):: xsd
165logical,
intent(out):: ff
166real(dp),
dimension(2):: rspd
167real(dp) :: s,sp,rsp,rsppi,rsppis
169s=k*dot_product(xt,xt); sp=
u1+s
170ff=(sp<=
u0);
if(ff)
return
177do i=1,2; xsd(i,i)=xsd(i,i)+rsppi;
enddo
192subroutine xttoxs1(k,xt,xs,xsd,xsdd,xs1,xsd1,ff)
195real(dp),
intent(in ):: k
196real(dp),
dimension(2),
intent(in ):: xt
197real(dp),
dimension(2),
intent(out):: xs ,xs1
198real(dp),
dimension(2,2),
intent(out):: xsd,xsd1
199real(dp),
dimension(2,2,2),
intent(out):: xsdd
200logical,
intent(out):: ff
201real(dp),
dimension(2,2):: rspdd
202real(dp),
dimension(2) :: rspd,rspd1,rsppid
203real(dp) :: s,sp,rsp,rsppi,rsppis,s1,rsp1
205s1=dot_product(xt,xt); s=k*s1; sp=
u1+s
206ff=(sp<=
u0);
if(ff)
return
207rsp=sqrt(sp); rsp1=
o2*s1/rsp
208rsppi=
u1/(
u1+rsp); rsppis=rsppi**2
209xs=xt*rsppi; xs1=-xt*rsp1*rsppis
210rspd=k*xt/rsp; rspd1=(xt*rsp-k*xt*rsp1)/sp
213do i=1,2; xsd1(i,i)=xsd1(i,i)-rsp1; enddo; xsd1=xsd1*rsppis
216do i=1,2; xsd(i,i)=xsd(i,i)+rsppi;
enddo
220do i=1,2; xsdd(i,:,i)= rsppid;
enddo
221do i=1,2; xsdd(i,i,:)=xsdd(i,i,:)+rsppid;
enddo
222do i=1,2; xsdd(:,:,i)=xsdd(:,:,i)+
u2*rspdd*rsppid(i);
enddo
223do i=1,2; rspdd(i,i)=rspdd(i,i)+rsp*rsppi;
enddo
224do i=1,2; xsdd(i,:,:)=xsdd(i,:,:)-xt(i)*rspdd*rsppi*k/sp;
enddo
236real(dp),
intent(in ):: a
237real(dp),
dimension(2),
intent(in ):: xt
238real(dp),
dimension(2),
intent(out):: xm
239logical ,
intent(out):: ff
241do i=1,2;
call zttozm(a,xt(i),xm(i),ff);
if(ff)return;
enddo
255real(dp),
intent(in ):: a
256real(dp),
dimension(2),
intent(in ):: xm
257real(dp),
dimension(2),
intent(out):: xt
258real(dp),
dimension(2,2),
intent(out):: xtd
259logical,
intent(out):: ff
261xtd=
u0;
do i=1,2;
call zmtozt(a,xm(i),xt(i),xtd(i,i),ff);
if(ff)return;
enddo
277real(dp),
intent(in ):: a
278real(dp),
dimension(2),
intent(in ):: xm
279real(dp),
dimension(2),
intent(out):: xt,xt1
280real(dp),
dimension(2,2),
intent(out):: xtd,xtd1
281logical,
intent(out):: ff
286 call zmtozt1(a,xm(i),xt(i),xtd(i,i),xt1(i),xtd1(i,i),ff)
300real(dp),
intent(in ):: a,zt
301real(dp),
intent(out):: zm
302logical,
intent(out):: ff
305if (a>
u0)then; ra=sqrt( a); razt=ra*zt; zm=atan(razt)/ra
306elseif(a<
u0)then; ra=sqrt(-a); razt=ra*zt; ff=abs(razt)>=
u1;
if(ff)
return
324real(dp),
intent(in ):: a,zm
325real(dp),
intent(out):: zt,ztd
326logical,
intent(out):: ff
329if (a>
u0)then; ra=sqrt( a); zt=tan(ra*zm)/ra; ff=abs(ra*zm)>=
pih
330elseif(a<
u0)then; ra=sqrt(-a); zt=tanh(ra*zm)/ra
351real(dp),
intent(in ):: a,zm
352real(dp),
intent(out):: zt,ztd,zt1,ztd1
353logical,
intent(out):: ff
354real(dp):: ra,rad,razm
356if (a>
u0)then;ra=sqrt( a);razm=ra*zm; zt=tan(razm)/ra; ff=abs(razm)>=
pih
358zt1=(rad*zm/ra)*((-
u2*sin(razm*
o2)**2-
sinoxm(razm))/cos(razm)+(tan(razm))**2)
359elseif(a<
u0)then;ra=sqrt(-a);razm=ra*zm; zt=tanh(razm)/ra
361zt1=(rad*zm/ra)*((
u2*sinh(razm*
o2)**2-
sinhoxm(razm))/cosh(razm)-(tanh(razm))**2)
362else ;zt=zm; zt1=zm**3*
o3
365ztd1=zt*zt +
u2*a*zt*zt1
382real(dp),
dimension(2),
intent(in ):: ak,xm
383real(dp),
dimension(3),
intent(out):: xc
384real(dp),
dimension(3,2),
intent(out):: xcd
385logical,
intent(out):: ff
401real(dp),
dimension(2),
intent(in ):: ak,xm
402real(dp),
dimension(3),
intent(out):: xc
403real(dp),
dimension(3,2),
intent(out):: xcd
404real(dp),
dimension(3,2),
intent(out):: xc1
405real(dp),
dimension(3,2,2),
intent(out):: xcd1
406logical,
intent(out):: ff
407real(dp),
dimension(3,2,2):: xcdd
408real(dp),
dimension(2,2,2):: xsd1,xsdd
409real(dp),
dimension(2,2) :: xtd,xsd,xs1,xtd1,xsdk,mat22
410real(dp),
dimension(2) :: xt,xt1,xs,xsk
412call xmtoxt1(ak(1),xm,xt,xtd,xt1,xtd1,ff);
if(ff)
return
413call xttoxs1(ak(2),xt,xs,xsd,xsdd,xsk,xsdk,ff);
if(ff)
return
414xs1(:,2)=xsk; xs1(:,1)=matmul(xsd,xt1)
415mat22=xsdd(:,:,1)*xt1(1)+xsdd(:,:,2)*xt1(2)
416xsd1(:,:,1)=matmul(xsd,xtd1)+matmul(mat22,xtd)
417xsd1(:,:,2)=matmul(xsdk,xtd)
419call xstoxc(xs,xc,xcd,xcdd)
421do i=1,3; xcd1(i,:,:)=matmul(transpose(xsd),matmul(xcdd(i,:,:),xs1));
enddo
422do i=1,2; xcd1(:,:,i)=xcd1(:,:,i)+matmul(xcd,xsd1(:,:,i));
enddo
441real(dp),
intent(in ):: a,k
442real(dp),
dimension(2),
intent(in ):: xm
443real(dp),
dimension(3),
intent(out):: xc
444real(dp),
dimension(3,2),
intent(out):: xcd
445logical,
intent(out):: ff
446real(dp),
dimension(2,2):: xtd,xsd
447real(dp),
dimension(2) :: xt,xs
448call xmtoxt(a,xm,xt,xtd,ff);
if(ff)
return
449call xttoxs(k,xt,xs,xsd,ff);
if(ff)
return
467real(dp),
intent(in ):: a,k
468real(dp),
dimension(3),
intent(in ):: xc
469real(dp),
dimension(2),
intent(out):: xm
470logical,
intent(out):: ff
471real(dp),
dimension(2):: xs,xt
474call xstoxt(k,xs,xt,ff);
if(ff)
return
490real(dp),
intent(in ):: arcx,arcy
491real(dp),
dimension(3),
intent(out):: edgex,edgey
492real(dp):: cx,sx,cy,sy,rarcx,rarcy
493rarcx=arcx*dtor; rarcy=arcy*dtor
494cx=cos(rarcx); sx=sin(rarcx)
495cy=cos(rarcy); sy=sin(rarcy)
496edgex=(/sx,u0,cx/); edgey=(/u0,sy,cy/)
514real(dp),
dimension(3,2),
intent(in ):: j0
515real(dp),
intent(out):: v1,v2,v3,v4
516real(dp),
dimension(2,2):: el,g
517g=matmul(transpose(j0),j0)
519v1=el(1,1)**2+u2*el(1,2)**2+el(2,2)**2
522v4=(el(1,1)+el(2,2))**2
541subroutine get_qxd(j0,j0d, v1,v2,v3,v4,v1d,v2d,v3d,v4d)
544real(dp),
dimension(3,2),
intent(in ):: j0
545real(dp),
dimension(3,2,2),
intent(in ):: j0d
546real(dp),
intent(out):: v1,v2,v3,v4
547real(dp),
dimension(2),
intent(out):: v1d,v2d,v3d,v4d
548real(dp),
dimension(2,2,2,2):: deldg
549real(dp),
dimension(2,2,2) :: eld,gd
550real(dp),
dimension(2,2) :: el,g
552g=matmul(transpose(j0),j0)
554 gd(:,:,i)=matmul(transpose(j0d(:,:,i)),j0)+matmul(transpose(j0),j0d(:,:,i))
556call logsym2(g,el,deldg); el=el*o2; deldg=deldg*o2
558do i=1,2;
do j=1,2;
do k=1,2
559 eld(:,:,k)=eld(:,:,k)+deldg(:,:,i,j)*gd(i,j,k)
561v1=el(1,1)**2+u2*el(1,2)**2+el(2,2)**2
564v4=(el(1,1)+el(2,2))**2
565v1d=u2*(el(1,1)*eld(1,1,:)+u2*el(1,2)*eld(1,2,:)+el(2,2)*eld(2,2,:))
568v4d=u2*(el(1,1)+el(2,2))*(eld(1,1,:)+eld(2,2,:))
602subroutine get_meanqd(ngh,lam,xg,wg,ak,ma, q,qdak,qdma, & ! [get_meanq]
605integer(spi),
intent(in ):: ngh
606real(dp),
intent(in ):: lam
607real(dp),
dimension(ngh),
intent(in ):: xg,wg
608real(dp),
dimension(2) ,
intent(in ):: ak,ma
609real(dp),
intent(out):: q
610real(dp),
dimension(2),
intent(out):: qdak,qdma
611real(dp),
dimension(2),
intent(out):: ga
612real(dp),
dimension(2,2),
intent(out):: gadak,gadma
613logical,
intent(out):: ff
614real(dp),
dimension(3,2,2):: xcd1
615real(dp),
dimension(3,2) :: xcd,xc1
616real(dp),
dimension(3) :: xc
617real(dp),
dimension(2) :: xm, v1dxy,v2dxy,v3dxy,v4dxy, &
618 v1dL,v2dL,v3dL,v4dL, v1d,v2d,v3d,v4d
620 v1xy,v2xy,v3xy,v4xy, v1L,v2L,v3L,v4L, v1,v2,v3,v4
621integer(spi) :: i,ic,ix,iy
622v1 =u0; v2 =u0; v3 =u0; v4 =u0
623v1d=u0; v2d=u0; v3d=u0; v4d=u0
627 v1l =u0; v2l =u0; v3l =u0; v4l =u0
628 v1dl=u0; v2dl=u0; v3dl=u0; v4dl=u0
632 call xmtoxc_ak(ak,xm,xc,xcd,xc1,xcd1,ff);
if(ff)
return
633 call get_qx(xcd,xcd1, v1xy,v2xy,v3xy,v4xy, v1dxy,v2dxy,v3dxy,v4dxy)
634 v1l =v1l +wx*v1xy; v2l =v2l +wx*v2xy
635 v3l =v3l +wx*v3xy; v4l =v4l +wx*v4xy
636 v1dl=v1dl+wx*v1dxy;v2dl=v2dl+wx*v2dxy
637 v3dl=v3dl+wx*v3dxy;v4dl=v4dl+wx*v4dxy
639 v1 =v1 +wy*v1l; v2 =v2 +wy*v2l; v3 =v3 +wy*v3l; v4 =v4 +wy*v4l
640 v1d=v1d+wy*v1dl; v2d=v2d+wy*v2dl; v3d=v3d+wy*v3dl; v4d=v4d+wy*v4dl
643call get_qofv(lam,v2,v3, v1d,v2d,v3d,v4d, qdak)
649 call xmtoxc_ak(ak,xm,xc,xcd,xc1,xcd1,ff);
if(ff)
return
650 ga(i)=atan2(xc(i),xc(3))*rtod
651 gadak(i,:)=(xc(3)*xc1(i,:)-xc(i)*xc1(3,:))*rtod
652 gadma(i,i)=(xc(3)*xcd(i,i)-xc(i)*xcd(3,i))*rtod
654 v1l=u0; v2l=u0; v3l=u0; v4l=u0
658 call xmtoxc_ak(ak,xm,xc,xcd,ff);
if(ff)
return
659 call get_qx(xcd, v1xy,v2xy,v3xy,v4xy)
660 v1l=v1l+wy*v1xy; v2l=v2l+wy*v2xy; v3l=v3l+wy*v3xy; v4l=v4l+wy*v4xy
662 v1d(i)=(v1l-v1)/ma(i); v2d(i)=(v2l-v2)/ma(i)
663 v3d(i)=(v3l-v3)/ma(i); v4d(i)=(v4l-v4)/ma(i)
665call get_qofv(lam,v2,v3, v1d,v2d,v3d,v4d, qdma)
683integer(spi),
intent(in ):: n,ngh
684real(dp),
dimension(ngh),
intent(in ):: xg,wg
685real(dp),
intent(in ):: lam
686real(dp),
dimension(2,n),
intent(in ):: aks,mas
687real(dp),
dimension(n),
intent(out):: qs
688logical,
intent(out):: ff
689real(dp),
dimension(n) :: v1s,v2s,v3s,v4s
690real(dp),
dimension(n) :: v1sL,v2sL,v3sL,v4sL
691real(dp),
dimension(3,2):: xcd
692real(dp),
dimension(3) :: xc
693real(dp),
dimension(2) :: xm,xgs
694real(dp) :: wx,wy, v1xy,v2xy,v3xy,v4xy
695integer(spi) :: i,ix,iy
696v1s=u0; v2s=u0; v3s=u0; v4s=u0
699 v1sl=u0; v2sl=u0; v3sl=u0; v4sl=u0
702 xgs=(/xg(ix),xg(iy)/)
705 call xmtoxc_ak(aks(:,i),xm,xc,xcd,ff);
if(ff)
return
706 call get_qx(xcd,v1xy,v2xy,v3xy,v4xy)
707 v1sl(i)=v1sl(i)+wx*v1xy; v2sl(i)=v2sl(i)+wx*v2xy
708 v3sl(i)=v3sl(i)+wx*v3xy; v4sl(i)=v4sl(i)+wx*v4xy
711 v1s=v1s+wy*v1sl; v2s=v2s+wy*v2sl; v3s=v3s+wy*v3sl; v4s=v4s+wy*v4sl
713call get_qofv(n,lam,v1s,v2s,v3s,v4s, qs)
730real(dp),
intent(in ):: lam,v1,v2,v3,v4
731real(dp),
intent(out):: q
734q=lamc*(v1-(v2**2+v3**2)) +lam*(v4 -(v2+v3)**2)
752real(dp),
intent(in ):: lam,v2,v3
753real(dp),
dimension(2),
intent(in ):: v1d,v2d,v3d,v4d
754real(dp),
dimension(2),
intent(out):: qd
757qd=lamc*(v1d-u2*(v2d*v2+v3d*v3))+lam*(v4d-u2*(v2d+v3d)*(v2+v3))
772integer(spi),
intent(in ):: n
773real(dp),
intent(in ):: lam
774real(dp),
dimension(n),
intent(in ):: v1s,v2s,v3s,v4s
775real(dp),
dimension(n),
intent(out):: qs
778qs=lamc*(v1s-(v2s**2+v3s**2)) +lam*(v4s -(v2s+v3s)**2)
792real(dp),
intent(in ):: asp,tmarcx
793real(dp),
dimension(2),
intent(out):: ak
810real(dp),
intent(in ):: asp,arc
811real(dp),
dimension(2),
intent(out):: ak
812integer(spi),
parameter :: narc=11,nasp=10
813real(dp),
parameter :: eps=1.e-7_dp,darc=10._dp+eps,dasp=.1_dp+eps
814real(dp),
dimension(nasp,0:narc):: adarc,kdarc
815real(dp) :: sasp,sarc,wx0,wx1,wa0,wa1
816integer(spi) :: iasp0,iasp1,iarc0,iarc1
826-.450_dp,-.328_dp,-.185_dp,-.059_dp,0.038_dp,0.107_dp,0.153_dp,0.180_dp,0.195_dp,0.199_dp,&
827-.452_dp,-.327_dp,-.184_dp,-.058_dp,0.039_dp,0.108_dp,0.154_dp,0.182_dp,0.196_dp,0.200_dp,&
828-.457_dp,-.327_dp,-.180_dp,-.054_dp,0.043_dp,0.112_dp,0.158_dp,0.186_dp,0.200_dp,0.205_dp,&
829-.464_dp,-.323_dp,-.173_dp,-.047_dp,0.050_dp,0.118_dp,0.164_dp,0.192_dp,0.208_dp,0.213_dp,&
830-.465_dp,-.313_dp,-.160_dp,-.035_dp,0.060_dp,0.127_dp,0.173_dp,0.202_dp,0.217_dp,0.224_dp,&
831-.448_dp,-.288_dp,-.138_dp,-.017_dp,0.074_dp,0.140_dp,0.184_dp,0.213_dp,0.230_dp,0.237_dp,&
832-.395_dp,-.244_dp,-.104_dp,0.008_dp,0.093_dp,0.156_dp,0.199_dp,0.227_dp,0.244_dp,0.252_dp,&
833-.301_dp,-.177_dp,-.057_dp,0.042_dp,0.119_dp,0.175_dp,0.215_dp,0.242_dp,0.259_dp,0.269_dp,&
834-.185_dp,-.094_dp,0.001_dp,0.084_dp,0.150_dp,0.199_dp,0.235_dp,0.260_dp,0.277_dp,0.287_dp,&
835-.069_dp,-.006_dp,0.066_dp,0.132_dp,0.186_dp,0.227_dp,0.257_dp,0.280_dp,0.296_dp,0.308_dp,&
8360.038_dp,0.081_dp,0.134_dp,0.185_dp,0.226_dp,0.258_dp,0.283_dp,0.303_dp,0.319_dp,0.333_dp,&
8370.038_dp,0.081_dp,0.134_dp,0.185_dp,0.226_dp,0.258_dp,0.283_dp,0.303_dp,0.319_dp,0.333_dp/
840-.947_dp,-.818_dp,-.668_dp,-.535_dp,-.433_dp,-.361_dp,-.313_dp,-.284_dp,-.269_dp,-.264_dp,&
841-.946_dp,-.816_dp,-.665_dp,-.533_dp,-.431_dp,-.359_dp,-.311_dp,-.282_dp,-.267_dp,-.262_dp,&
842-.942_dp,-.806_dp,-.655_dp,-.524_dp,-.424_dp,-.353_dp,-.305_dp,-.276_dp,-.261_dp,-.255_dp,&
843-.932_dp,-.789_dp,-.637_dp,-.509_dp,-.412_dp,-.343_dp,-.296_dp,-.266_dp,-.250_dp,-.244_dp,&
844-.909_dp,-.759_dp,-.609_dp,-.486_dp,-.394_dp,-.328_dp,-.283_dp,-.254_dp,-.237_dp,-.230_dp,&
845-.863_dp,-.711_dp,-.569_dp,-.456_dp,-.372_dp,-.310_dp,-.266_dp,-.238_dp,-.220_dp,-.212_dp,&
846-.779_dp,-.642_dp,-.518_dp,-.419_dp,-.343_dp,-.287_dp,-.247_dp,-.220_dp,-.202_dp,-.192_dp,&
847-.661_dp,-.556_dp,-.456_dp,-.374_dp,-.310_dp,-.262_dp,-.226_dp,-.200_dp,-.182_dp,-.171_dp,&
848-.533_dp,-.462_dp,-.388_dp,-.325_dp,-.274_dp,-.234_dp,-.203_dp,-.179_dp,-.161_dp,-.150_dp,&
849-.418_dp,-.373_dp,-.322_dp,-.275_dp,-.236_dp,-.204_dp,-.178_dp,-.156_dp,-.139_dp,-.127_dp,&
850-.324_dp,-.296_dp,-.261_dp,-.229_dp,-.200_dp,-.174_dp,-.152_dp,-.133_dp,-.117_dp,-.104_dp,&
851-.324_dp,-.296_dp,-.261_dp,-.229_dp,-.200_dp,-.174_dp,-.152_dp,-.133_dp,-.117_dp,-.104_dp/
854iasp0=floor(sasp); wa1=sasp-iasp0
855iasp1=iasp0+1; wa0=iasp1-sasp
857iarc0=floor(sarc); wx1=sarc-iarc0
858iarc1=iarc0+1; wx0=iarc1-sarc
859if(iasp0<1 .or. iasp1>nasp)stop
'Guessak_geo; Aspect ratio out of range'
860if(iarc0<0 .or. iarc1>narc)stop
'Guessak_geo; Major semi-arc is out of range'
863ak=(/wx0*(wa0*adarc(iasp0,iarc0)+wa1*adarc(iasp1,iarc0))+ &
864 wx1*(wa0*adarc(iasp0,iarc1)+wa1*adarc(iasp1,iarc1)), &
865 wx0*(wa0*kdarc(iasp0,iarc0)+wa1*kdarc(iasp1,iarc0))+ &
866 wx1*(wa0*kdarc(iasp0,iarc1)+wa1*kdarc(iasp1,iarc1))/)
903use pietc,
only:
u5,
o5,
s18,
s36,
s54,
s72,
ms18,
ms36,
ms54,
ms72
907real(dp),
intent(in ):: lam,garcx,garcy
908real(dp),
intent(out):: a,k,marcx,marcy,q
909logical ,
intent(out):: FF
910integer(spi),
parameter :: nit=200,mit=20,ngh=25
911real(dp) ,
parameter :: u2o5=
u2*
o5,&
913 f72=u2o5*
s72,mf18=-f18,mf36=-f36,mf54=-f54,&
915 r=0.001_dp,rr=r*r,dang=
pi2*
o5,crit=1.e-14_dp
916real(dp),
dimension(ngh) :: wg,xg
917real(dp),
dimension(0:4,0:4):: em5
918real(dp),
dimension(0:4) :: qs
919real(dp),
dimension(2,0:4) :: aks,mas
920real(dp),
dimension(2,2) :: basis0,basis,hess,el,gadak,gadma,madga,madak
921real(dp),
dimension(2) :: ak,dak,dma,vec2,grad,qdak,qdma,ga,ma,gat
922real(dp) :: s,tgarcx,tgarcy,asp,ang
925data em5/
o5,u2o5,
u0,u2o5,
u0,&
926 o5, f18, f72,mf54, f36,&
927 o5,mf54, f36, f18,mf72,&
928 o5,mf54,mf36, f18, f72,&
929 o5, f18,mf72,mf54,mf36/
932data basis0/0.1_dp,
u0, 0.3_dp,0.3_dp/
933ff=lam<
u0 .or. lam>=
u1
934if(ff)then; print
'("In bestesg_geo; lam out of range")';return;
endif
935ff= garcx<=
u0 .or. garcy<=
u0
937 print
'("In bestesg_geo; a nonpositive domain parameter, garcx or garcy")'
942if(flip)then; tgarcx=garcy; tgarcy=garcx
943else ; tgarcx=garcx; tgarcy=garcy
966 call get_meanq(ngh,lam,xg,wg,ak,ma,q,qdak,qdma,gat,gadak,gadma,ff)
968 madga=gadma;
call inv(madga)
969 madak=-matmul(madga,gadak)
970 qdak=qdak+matmul(qdma,madak)
975 vec2=(/cos(ang),sin(ang)/)*r
976 dak=matmul(basis,vec2)
977 dma=matmul(madak,dak)
981 call get_meanq(5,ngh,lam,xg,wg,aks,mas, qs,ff)
983 grad=matmul(qdak,basis)/q
996 hess(1,1)=qs(0)+qs(3)
999 hess(2,2)=qs(0)-qs(3)
1003 call chol2(hess,el,ff)
1005 print
'(" In bestESG_geo, Hessian is not positive; cholesky fails")'
1009 el(1,1)=
u1/el(1,1); el(2,2)=
u1/el(2,2); el(2,1)=-el(2,1)*el(1,1)*el(2,2)
1012 vec2=-matmul(transpose(el),matmul(el,grad))
1013 dak=matmul(basis,vec2)
1014 gat=gat+matmul(gadak,dak)
1016 dma=-matmul(madga,gat-ga)
1023 if(it<mit)basis=matmul(basis,transpose(el))
1025 s=sqrt(dot_product(dak,dak))
1028if(it>nit)print
'("WARNING; Relatively inferior convergence in bestesg_geo")'
1031if(flip)then; marcx=ma(2); marcy=ma(1)
1032else ; marcx=ma(1); marcy=ma(2)
1073use pietc,
only:
u5,
o5,
s18,
s36,
s54,
s72,
ms18,
ms36,
ms54,
ms72
1076real(dp),
intent(in ):: lam,marcx,marcy
1077real(dp),
intent(out):: a,k,garcx,garcy,q
1078logical ,
intent(out):: FF
1079integer(spi),
parameter :: nit=25,mit=7,ngh=25
1080real(dp),
parameter :: u2o5=
u2*
o5, &
1081 f18=u2o5*
s18,f36=u2o5*
s36,f54=u2o5*
s54, &
1082 f72=u2o5*
s72,mf18=-f18,mf36=-f36,mf54=-f54,&
1084 r=0.001_dp,rr=r*r,dang=
pi2*
o5,crit=1.e-12_dp
1085real(dp),
dimension(ngh) :: wg,xg
1086real(dp),
dimension(0:4,0:4):: em5
1087real(dp),
dimension(0:4) :: qs
1088real(dp),
dimension(2,0:4) :: aks,mas
1089real(dp),
dimension(2,2) :: basis0,basis,hess,el,gadak,gadma
1090real(dp),
dimension(2) :: ak,dak,vec2,grad,qdak,qdma,ga,ma
1091real(dp) :: s,tmarcx,tmarcy,asp,ang
1094data em5/
o5,u2o5,
u0,u2o5,
u0,&
1095 o5, f18, f72,mf54, f36,&
1096 o5,mf54, f36, f18,mf72,&
1097 o5,mf54,mf36, f18, f72,&
1098 o5, f18,mf72,mf54,mf36/
1101data basis0/0.1_dp,
u0, 0.3_dp,0.3_dp/
1102ff=lam<
u0 .or. lam>=
u1
1103if(ff)then; print
'("In bestesg_map; lam out of range")';return;
endif
1104ff= marcx<=
u0 .or. marcy<=
u0
1106 print
'("In bestesg_map; a nonpositive domain parameter, marcx or marcy")'
1111if(flip)then; tmarcx=marcy; tmarcy=marcx
1112else ; tmarcx=marcx; tmarcy=marcy
1114ma=(/tmarcx,tmarcy/);
do i=0,4; mas(:,i)=ma;
enddo
1121 call get_meanq(ngh,lam,xg,wg,ak,ma,q,qdak,qdma,ga,gadak,gadma,ff)
1127 vec2=(/cos(ang),sin(ang)/)*r
1128 aks(:,i)=ak+matmul(basis,vec2)
1130 call get_meanq(5,ngh,lam,xg,wg,aks,mas, qs,ff)
1132 grad=matmul(qdak,basis)/q
1144 hess(1,1)=qs(0)+qs(3)
1147 hess(2,2)=qs(0)-qs(3)
1151 call chol2(hess,el,ff)
1153 print
'(" In bestESG_map, hessian is not positive; cholesky fails")'
1157 el(1,1)=
u1/el(1,1); el(2,2)=
u1/el(2,2); el(2,1)=-el(2,1)*el(1,1)*el(2,2)
1160 vec2=-matmul(transpose(el),matmul(el,grad))
1161 dak=matmul(basis,vec2)
1162 ga=ga+matmul(gadak,dak)
1169 if(it<mit)basis=matmul(basis,transpose(el))
1171 s=sqrt(dot_product(dak,dak))
1174if(it>nit)print
'("WARNING; Relatively inferior convergence in bestesg_map")'
1177if(flip)then; garcx=ga(2); garcy=ga(1)
1178else ; garcx=ga(1); garcy=ga(2)
1219subroutine hgrid_ak_rr(lx,ly,nx,ny,A,K,plat,plon,pazi, & ! [hgrid_ak_rr]
1220 delx,dely, glat,glon,garea, ff)
1224integer(spi),
intent(in ):: lx,ly,nx,ny
1225real(dp),
intent(in ):: a,k,plat,plon,pazi, &
1227real(dp),
dimension(lx:lx+nx ,ly:ly+ny ),
intent(out):: glat,glon
1228real(dp),
dimension(lx:lx+nx-1,ly:ly+ny-1),
intent(out):: garea
1229logical,
intent(out):: ff
1230real(dp),
dimension(3,3):: prot,azirot
1231real(dp),
dimension(3,2):: xcd
1232real(dp),
dimension(3) :: xc
1233real(dp),
dimension(2) :: xm
1234real(dp) :: clat,slat,clon,slon,cazi,sazi,&
1235 rlat,drlata,drlatb,drlatc, &
1236 rlon,drlona,drlonb,drlonc
1237integer(spi) :: ix,iy,mx,my
1238clat=cos(plat); slat=sin(plat)
1239clon=cos(plon); slon=sin(plon)
1240cazi=cos(pazi); sazi=sin(pazi)
1242azirot(:,1)=(/ cazi, sazi, u0/)
1243azirot(:,2)=(/-sazi, cazi, u0/)
1244azirot(:,3)=(/ u0, u0, u1/)
1246prot(:,1)=(/ -slon, clon, u0/)
1247prot(:,2)=(/-slat*clon, -slat*slon, clat/)
1248prot(:,3)=(/ clat*clon, clat*slon, slat/)
1249prot=matmul(prot,azirot)
1258 xcd=matmul(prot,xcd)
1259 xc =matmul(prot,xc )
1260 call ctogr(xc,glat(ix,iy),glon(ix,iy))
1268 drlata=glat(ix+1,iy )-rlat
1269 drlatb=glat(ix+1,iy+1)-rlat
1270 drlatc=glat(ix ,iy+1)-rlat
1272 drlona=glon(ix+1,iy )-rlon
1273 drlonb=glon(ix+1,iy+1)-rlon
1274 drlonc=glon(ix ,iy+1)-rlon
1279 garea(ix,iy)=
sarea(rlat, drlata,drlona, drlatb,drlonb) &
1280 -
sarea(rlat, drlatc,drlonc, drlatb,drlonb)
1337 delx,dely, glat,glon,garea,dx,dy,angle_dx,angle_dy, ff)
1341integer(spi),
intent(in ):: lx,ly,nx,ny
1342real(dp),
intent(in ):: a,k,plat,plon,pazi, &
1344real(dp),
dimension(lx:lx+nx ,ly:ly+ny ),
intent(out):: glat,glon
1345real(dp),
dimension(lx:lx+nx-1,ly:ly+ny-1),
intent(out):: garea
1346real(dp),
dimension(lx:lx+nx-1,ly:ly+ny ),
intent(out):: dx
1347real(dp),
dimension(lx:lx+nx ,ly:ly+ny-1),
intent(out):: dy
1348real(dp),
dimension(lx:lx+nx ,ly:ly+ny ),
intent(out):: angle_dx,angle_dy
1349logical,
intent(out):: ff
1350real(dp),
dimension(lx-1:lx+nx+1,ly-1:ly+ny+1):: gat
1351real(dp),
dimension(lx-1:lx+nx+1,ly :ly+ny ):: dxt
1352real(dp),
dimension(lx :lx+nx ,ly-1:ly+ny+1):: dyt
1353real(dp),
dimension(3,3):: prot,azirot
1354real(dp),
dimension(3,2):: xcd,eano
1355real(dp),
dimension(2,2):: xcd2
1356real(dp),
dimension(3) :: xc,east,north
1357real(dp),
dimension(2) :: xm
1358real(dp) :: clat,slat,clon,slon,cazi,sazi,delxy
1359integer(spi) :: ix,iy,mx,my,lxm,lym,mxp,myp
1361clat=cos(plat); slat=sin(plat)
1362clon=cos(plon); slon=sin(plon)
1363cazi=cos(pazi); sazi=sin(pazi)
1365azirot(:,1)=(/ cazi, sazi, u0/)
1366azirot(:,2)=(/-sazi, cazi, u0/)
1367azirot(:,3)=(/ u0, u0, u1/)
1369prot(:,1)=(/ -slon, clon, u0/)
1370prot(:,2)=(/-slat*clon, -slat*slon, clat/)
1371prot(:,3)=(/ clat*clon, clat*slon, slat/)
1372prot=matmul(prot,azirot)
1384 call xmtoxc_ak(a,k,xm,xc,xcd,ff);
if(ff)
return
1385 xcd=matmul(prot,xcd)
1386 xc =matmul(prot,xc )
1387 call ctogr(xc,glat(ix,iy),glon(ix,iy))
1388 east=(/-xc(2),xc(1),u0/); east=east/sqrt(dot_product(east,east))
1390 eano(:,1)=east; eano(:,2)=north
1391 xcd2=matmul(transpose(eano),xcd)
1392 angle_dx(ix,iy)=atan2( xcd2(2,1),xcd2(1,1))
1393 angle_dy(ix,iy)=atan2(-xcd2(1,2),xcd2(2,2))
1394 dxt(ix,iy)=sqrt(dot_product(xcd2(:,1),xcd2(:,1)))*delx
1395 dyt(ix,iy)=sqrt(dot_product(xcd2(:,2),xcd2(:,2)))*dely
1404 call xmtoxc_ak(a,k,xm,xc,xcd,ff);
if(ff)
return
1405 xcd=matmul(prot,xcd)
1406 xc =matmul(prot,xc )
1407 east=(/-xc(2),xc(1),u0/); east=east/sqrt(dot_product(east,east))
1409 eano(:,1)=east; eano(:,2)=north
1410 xcd2=matmul(transpose(eano),xcd)
1411 dxt(lxm,iy)=sqrt(dot_product(xcd2(:,1),xcd2(:,1)))*delx
1419 call xmtoxc_ak(a,k,xm,xc,xcd,ff);
if(ff)
return
1420 xcd=matmul(prot,xcd)
1421 xc =matmul(prot,xc )
1422 east=(/-xc(2),xc(1),u0/); east=east/sqrt(dot_product(east,east))
1424 eano(:,1)=east; eano(:,2)=north
1425 xcd2=matmul(transpose(eano),xcd)
1426 dxt(mxp,iy)=sqrt(dot_product(xcd2(:,1),xcd2(:,1)))*delx
1434 call xmtoxc_ak(a,k,xm,xc,xcd,ff);
if(ff)
return
1435 xcd=matmul(prot,xcd)
1436 xc =matmul(prot,xc )
1437 east=(/-xc(2),xc(1),u0/); east=east/sqrt(dot_product(east,east))
1439 eano(:,1)=east; eano(:,2)=north
1440 xcd2=matmul(transpose(eano),xcd)
1441 dyt(ix,lym)=sqrt(dot_product(xcd2(:,2),xcd2(:,2)))*dely
1449 call xmtoxc_ak(a,k,xm,xc,xcd,ff);
if(ff)
return
1450 xcd=matmul(prot,xcd)
1451 xc =matmul(prot,xc )
1452 east=(/-xc(2),xc(1),u0/); east=east/sqrt(dot_product(east,east))
1454 eano(:,1)=east; eano(:,2)=north
1455 xcd2=matmul(transpose(eano),xcd)
1456 dyt(ix,myp)=sqrt(dot_product(xcd2(:,2),xcd2(:,2)))*dely
1464call xmtoxc_ak(a,k,xm,xc,xcd,ff);
if(ff)
return
1471call xmtoxc_ak(a,k,xm,xc,xcd,ff);
if(ff)
return
1479call xmtoxc_ak(a,k,xm,xc,xcd,ff);
if(ff)
return
1486call xmtoxc_ak(a,k,xm,xc,xcd,ff);
if(ff)
return
1492dx =(13_dp*(dxt(lx :mx-1,:)+dxt(lx+1:mx ,:)) &
1493 -(dxt(lxm:mx-2,:)+dxt(lx+2:mxp,:)))/24_dp
1494dy =(13_dp*(dyt(:,ly :my-1)+dyt(:,ly+1:my )) &
1495 -(dyt(:,lym:my-2)+dyt(:,ly+2:myp)))/24_dp
1496gat(lx:mx-1,:)=(13_dp*(gat(lx :mx-1,:)+gat(lx+1:mx ,:)) &
1497 -(gat(lxm:mx-2,:)+gat(lx+2:mxp,:)))/24_dp
1498garea =(13_dp*(gat(lx:mx-1,ly :my-1)+gat(lx:mx-1,ly+1:my )) &
1499 -(gat(lx:mx-1,lym:my-2)+gat(lx:mx-1,ly+2:myp)))/24_dp
1539subroutine hgrid_ak_rc(lx,ly,nx,ny,A,K,plat,plon,pazi, & ! [hgrid_ak_rc]
1540 delx,dely, xc,xcd,garea, ff)
1544integer(spi),
intent(in ):: lx,ly,nx,ny
1545real(dp),
intent(in ):: a,k,plat,plon,pazi,delx,dely
1546real(dp),
dimension(3, lx:lx+nx ,ly:ly+ny ),
intent(out):: xc
1547real(dp),
dimension(3,2,lx:lx+nx ,ly:ly+ny ),
intent(out):: xcd
1548real(dp),
dimension( lx:lx+nx-1,ly:ly+ny-1),
intent(out):: garea
1549logical,
intent(out):: ff
1550real(dp),
dimension(3,3):: prot,azirot
1551real(dp),
dimension(2) :: xm
1552real(dp) :: clat,slat,clon,slon,cazi,sazi, &
1553 rlat,rlata,rlatb,rlatc,drlata,drlatb,drlatc, &
1554 rlon,rlona,rlonb,rlonc,drlona,drlonb,drlonc
1555integer(spi) :: ix,iy,mx,my
1556clat=cos(plat); slat=sin(plat)
1557clon=cos(plon); slon=sin(plon)
1558cazi=cos(pazi); sazi=sin(pazi)
1560azirot(:,1)=(/ cazi, sazi, u0/)
1561azirot(:,2)=(/-sazi, cazi, u0/)
1562azirot(:,3)=(/ u0, u0, u1/)
1564prot(:,1)=(/ -slon, clon, u0/)
1565prot(:,2)=(/-slat*clon, -slat*slon, clat/)
1566prot(:,3)=(/ clat*clon, clat*slon, slat/)
1567prot=matmul(prot,azirot)
1574 call xmtoxc_ak(a,k,xm,xc(:,ix,iy),xcd(:,:,ix,iy),ff)
1576 xcd(:,:,ix,iy)=matmul(prot,xcd(:,:,ix,iy))
1577 xc(:, ix,iy)=matmul(prot,xc(:, ix,iy))
1584 call ctogr(xc(:,ix ,iy ),rlat ,rlon )
1585 call ctogr(xc(:,ix+1,iy ),rlata,rlona)
1586 call ctogr(xc(:,ix+1,iy+1),rlatb,rlonb)
1587 call ctogr(xc(:,ix ,iy+1),rlatc,rlonc)
1588 drlata=rlata-rlat; drlona=rlona-rlon
1589 drlatb=rlatb-rlat; drlonb=rlonb-rlon
1590 drlatc=rlatc-rlat; drlonc=rlonc-rlon
1596 garea(ix,iy)=
sarea(rlat, drlata,drlona, drlatb,drlonb) &
1597 -
sarea(rlat, drlatc,drlonc, drlatb,drlonb)
1628subroutine hgrid_ak_dd(lx,ly,nx,ny,a,k,pdlat,pdlon,pdazi, & ! [hgrid_ak_dd]
1629 delx,dely, gdlat,gdlon,garea, ff)
1631integer(spi),
intent(in ):: lx,ly,nx,ny
1632real(dp),
intent(in ):: A,K,pdlat,pdlon,&
1634real(dp),
dimension(lx:lx+nx ,ly:ly+ny ),
intent(out):: gdlat,gdlon
1635real(dp),
dimension(lx:lx+nx-1,ly:ly+ny-1),
intent(out):: garea
1636logical,
intent(out):: ff
1637real(dp):: plat,plon,pazi
1642 delx,dely, gdlat,gdlon,garea, ff)
1672 delx,dely, gdlat,gdlon,garea,dx,dy,dangle_dx,dangle_dy, ff)
1674integer(spi),
intent(in ):: lx,ly,nx,ny
1675real(dp),
intent(in ):: a,k,pdlat,pdlon,&
1677real(dp),
dimension(lx:lx+nx ,ly:ly+ny ),
intent(out):: gdlat,gdlon
1678real(dp),
dimension(lx:lx+nx-1,ly:ly+ny-1),
intent(out):: garea
1679real(dp),
dimension(lx:lx+nx-1,ly:ly+ny ),
intent(out):: dx
1680real(dp),
dimension(lx:lx+nx ,ly:ly+ny-1),
intent(out):: dy
1681real(dp),
dimension(lx:lx+nx ,ly:ly+ny ),
intent(out):: dangle_dx,dangle_dy
1682logical,
intent(out):: ff
1683real(dp):: plat,plon,pazi
1688 delx,dely, gdlat,gdlon,garea,dx,dy,dangle_dx,dangle_dy, ff)
1692dangle_dx=dangle_dx*rtod
1693dangle_dy=dangle_dy*rtod
1722subroutine hgrid_ak_dc(lx,ly,nx,ny,a,k,pdlat,pdlon,pdazi, & ! [hgrid_ak_dc]
1723 delx,dely, xc,xcd,garea, ff)
1725integer(spi),
intent(in ):: lx,ly,nx,ny
1726real(dp),
intent(in ):: A,K,pdlat,pdlon,pdazi,delx,dely
1727real(dp),
dimension(3, lx:lx+nx ,ly:ly+ny ),
intent(out):: xc
1728real(dp),
dimension(3,2,lx:lx+nx ,ly:ly+ny ),
intent(out):: xcd
1729real(dp),
dimension( lx:lx+nx-1,ly:ly+ny-1),
intent(out):: garea
1730logical,
intent(out):: ff
1731real(dp):: plat,plon,pazi
1736 delx,dely, xc,xcd,garea, ff)
1764subroutine hgrid_ak(lx,ly,nx,ny,a,k,plat,plon,pazi, & ! [hgrid_ak]
1765 re,delxre,delyre, glat,glon,garea, ff)
1767integer(spi),
intent(in ):: lx,ly,nx,ny
1768real(dp),
intent(in ):: a,k,plat,plon,pazi, &
1770real(dp),
dimension(lx:lx+nx ,ly:ly+ny ),
intent(out):: glat,glon
1771real(dp),
dimension(lx:lx+nx-1,ly:ly+ny-1),
intent(out):: garea
1772logical,
intent(out):: ff
1773real(dp):: delx,dely,rere
1777 delx,dely, glat,glon,garea, ff)
1816subroutine hgrid_ak_c(lx,ly,nx,ny,a,k,plat,plon,pazi, & ! [hgrid_ak]
1817 re,delxre,delyre, glat,glon,garea,dx,dy,dangle_dx,dangle_dy, ff)
1819integer(spi),
intent(in ):: lx,ly,nx,ny
1820real(dp),
intent(in ):: a,k,plat,plon,pazi, &
1822real(dp),
dimension(lx:lx+nx ,ly:ly+ny ),
intent(out):: glat,glon
1823real(dp),
dimension(lx:lx+nx-1,ly:ly+ny-1),
intent(out):: garea
1824real(dp),
dimension(lx:lx+nx-1,ly:ly+ny ),
intent(out):: dx
1825real(dp),
dimension(lx:lx+nx ,ly:ly+ny-1),
intent(out):: dy
1826real(dp),
dimension(lx:lx+nx ,ly:ly+ny ),
intent(out):: dangle_dx,dangle_dy
1827logical,
intent(out):: ff
1828real(dp):: delx,dely,rere
1832 delx,dely, glat,glon,garea,dx,dy,dangle_dx,dangle_dy, ff)
1838dangle_dx=dangle_dx*rtod
1839dangle_dy=dangle_dy*rtod
1853integer(spi),
intent(IN ):: m
1854real(dp),
dimension(m),
intent(OUT):: x,w
1855integer(spi),
parameter:: nit=8
1856real(dp),
parameter:: eps=3.e-14_dp
1857integer(spi) :: i,ic,j,jm,it,m2,m4p,m4p3
1858real(dp) :: z,zzm,p1,p2,p3,pp,z1
1859m2=m*2; m4p=m*4+1; m4p3=m4p+2
1860do i=1,m; ic=m4p3-4*i
1861 z=cos(pih*ic/m4p); zzm=z*z-u1
1864 do j=1,m2; jm=j-1; p3=p2; p2=p1; p1=((j+jm)*z*p2-jm*p3)/j;
enddo
1865 pp=m2*(z*p1-p2)/zzm; z1=z; z=z1-p1/pp; zzm=z*z-u1
1866 if(abs(z-z1) <= eps)
exit
1868 x(i)=z; w(i)=-u2/(zzm*pp*pp)
1890real(dp),
intent(in ):: a,k,plat,plon,pazi,lat,lon
1891real(dp),
dimension(2),
intent(out):: xm
1892logical,
intent(out):: ff
1893real(dp),
dimension(3,3):: prot,azirot
1894real(dp) :: clat,slat,clon,slon,cazi,sazi
1895real(dp),
dimension(3) :: xc
1896clat=cos(plat); slat=sin(plat)
1897clon=cos(plon); slon=sin(plon)
1898cazi=cos(pazi); sazi=sin(pazi)
1900azirot(:,1)=(/ cazi, sazi, u0/)
1901azirot(:,2)=(/-sazi, cazi, u0/)
1902azirot(:,3)=(/ u0, u0, u1/)
1904prot(:,1)=(/ -slon, clon, u0/)
1905prot(:,2)=(/-slat*clon, -slat*slon, clat/)
1906prot(:,3)=(/ clat*clon, clat*slon, slat/)
1907prot=matmul(prot,azirot)
1909call grtoc(lat,lon,xc)
1910xc=matmul(transpose(prot),xc)
1934real(dp),
intent(in ):: a,k,plat,plon,pazi,delx,dely,lat,lon
1935real(dp),
dimension(2),
intent(out):: xm
1936logical,
intent(out):: ff
1937call gtoxm_ak_rr_m(a,k,plat,plon,pazi,lat,lon,xm,ff);
if(ff)
return
1938xm(1)=xm(1)/delx; xm(2)=xm(2)/dely
1956real(dp),
intent(in ):: a,k,pdlat,pdlon,pdazi,dlat,dlon
1957real(dp),
dimension(2),
intent(out):: xm
1958logical,
intent(out):: ff
1959real(dp):: plat,plon,pazi,lat,lon
1985real(dp),
intent(in ):: a,k,pdlat,pdlon,pdazi,delx,dely,dlat,dlon
1986real(dp),
dimension(2),
intent(out):: xm
1987logical,
intent(out):: ff
1988real(dp):: plat,plon,pazi,lat,lon
1994call gtoxm_ak_rr_g(a,k,plat,plon,pazi,delx,dely,lat,lon,xm,ff)
2017real(dp),
intent(in ):: a,k,plat,plon,pazi
2018real(dp),
dimension(2),
intent(in ):: xm
2019real(dp),
intent(out):: lat,lon
2020logical,
intent(out):: ff
2021real(dp),
dimension(3,2):: xcd
2022real(dp),
dimension(3,3):: prot,azirot
2023real(dp) :: clat,slat,clon,slon,cazi,sazi
2024real(dp),
dimension(3) :: xc
2025clat=cos(plat); slat=sin(plat)
2026clon=cos(plon); slon=sin(plon)
2027cazi=cos(pazi); sazi=sin(pazi)
2029azirot(:,1)=(/ cazi, sazi, u0/)
2030azirot(:,2)=(/-sazi, cazi, u0/)
2031azirot(:,3)=(/ u0, u0, u1/)
2033prot(:,1)=(/ -slon, clon, u0/)
2034prot(:,2)=(/-slat*clon, -slat*slon, clat/)
2035prot(:,3)=(/ clat*clon, clat*slon, slat/)
2036prot=matmul(prot,azirot)
2037call xmtoxc_ak(a,k,xm,xc,xcd,ff);
if(ff)
return
2039call ctogr(xc,lat,lon)
2064real(dp),
intent(in ):: a,k,plat,plon,pazi,delx,dely
2065real(dp),
dimension(2),
intent(in ):: xm
2066real(dp),
intent(out):: lat,lon
2067logical,
intent(out):: ff
2068real(dp),
dimension(2):: xmt
2089real(dp),
intent(in ):: a,k,pdlat,pdlon,pdazi
2090real(dp),
dimension(2),
intent(in ):: xm
2091real(dp),
intent(out):: dlat,dlon
2092logical,
intent(out):: ff
2093real(dp):: plat,plon,pazi,lat,lon
2119real(dp),
intent(in ):: a,k,pdlat,pdlon,pdazi,delx,dely
2120real(dp),
dimension(2),
intent(in ):: xm
2121real(dp),
intent(out):: dlat,dlon
2122logical,
intent(out):: ff
2123real(dp),
dimension(2):: xmt
2124real(dp) :: plat,plon,pazi,lat,lon
Suite of routines to perform the 2-parameter family of Extended Schmidt Gnomonic (ESG) regional grid ...
subroutine get_meanqd(ngh, lam, xg, wg, ak, ma, q, qdak, qdma, ga, gadak, gadma, ff)
For a parameter vector, ak and a map-space domain-parameter vector, ma, return the lambda-parameteriz...
subroutine xmtog_ak_rr_g(a, k, plat, plon, pazi, delx, dely, xm, lat, lon, ff)
For an ESG map with parameters, (A,K), and geographical orientation, given by plon,...
subroutine get_qsofvs(n, lam, v1s, v2s, v3s, v4s, qs)
General util to convert value.
subroutine gtoxm_ak_dd_g(a, k, pdlat, pdlon, pdazi, delx, dely, dlat, dlon, xm, ff)
Like gtoxm_ak_rr_g, except lat, lon, azimuth, are expressed in degrees.
subroutine hgrid_ak_rr_c(lx, ly, nx, ny, a, k, plat, plon, pazi, delx, dely, glat, glon, garea, dx, dy, angle_dx, angle_dy, ff)
Use a and k as the parameters of an extended Schmidt-transformed gnomonic (ESG) mapping centered at (...
subroutine xmtog_ak_dd_g(a, k, pdlat, pdlon, pdazi, delx, dely, xm, dlat, dlon, ff)
Like xmtog_ak_rr_g, except lat, lon, azimuth, are expressed in degrees.
subroutine xstoxc1(xs, xc, xcd, xcdd)
Standard transformation from polar stereographic map coordinates, xs, to cartesian,...
subroutine get_qxd(j0, j0d, v1, v2, v3, v4, v1d, v2d, v3d, v4d)
From a jacobian matrix, j0, and its derivative, j0d, get a sufficient set of v.
subroutine hgrid_ak_dd_c(lx, ly, nx, ny, a, k, pdlat, pdlon, pdazi, delx, dely, gdlat, gdlon, garea, dx, dy, dangle_dx, dangle_dy, ff)
Like hgrid_ak_rr_c, except all the angle arguments (but not delx,dely) are in degrees instead of radi...
subroutine gtoxm_ak_dd_m(a, k, pdlat, pdlon, pdazi, dlat, dlon, xm, ff)
Like gtoxm_ak_rr_m, except lat, lon, azimuth, are expressed in degrees.
subroutine xmtoxc_vak(ak, xm, xc, xcd, ff)
Assuming the vector AK parameterization of the Extended Schmidt-transformed Gnomonic (ESG) mapping wi...
subroutine xttoxs1(k, xt, xs, xsd, xsdd, xs1, xsd1, ff)
Like xttoxs, but also, return the derivatives, wrt K, of xs and xsd.
subroutine xmtoxc_vak1(ak, xm, xc, xcd, xc1, xcd1, ff)
Like xmtoxc_vak, _ak, but also return derivatives wrt ak.
subroutine get_qofvd(lam, v2, v3, v1d, v2d, v3d, v4d, qd)
Like get_qofv, but for (only) the 2-vector derivatives of Q.
subroutine gtoxm_ak_rr_g(a, k, plat, plon, pazi, delx, dely, lat, lon, xm, ff)
Given the map specification (angles in radians), the grid spacing (in map-space units) and the sample...
subroutine gtoxm_ak_rr_m(a, k, plat, plon, pazi, lat, lon, xm, ff)
Given the map specification (angles in radians), the grid spacing (in map-space units) and the sample...
subroutine hgrid_ak_c(lx, ly, nx, ny, a, k, plat, plon, pazi, re, delxre, delyre, glat, glon, garea, dx, dy, dangle_dx, dangle_dy, ff)
Like hgrid_ak_rr_c except the argument list includes the earth radius, re, and this is used to expres...
subroutine zmtozt1(a, zm, zt, ztd, zt1, ztd1, ff)
Like zmtozt, but also, get the derivative with respect to a, zt1 of zt, and ztd1 of ztd.
subroutine xmtog_ak_dd_m(a, k, pdlat, pdlon, pdazi, xm, dlat, dlon, ff)
Like xmtog_ak_rr_m, except lat, lon, azimuth, are expressed in degrees.
subroutine xmtog_ak_rr_m(a, k, plat, plon, pazi, xm, lat, lon, ff)
Given the ESG map specified by parameters (A,K) and geographical center and orientation,...
subroutine get_meanqs(n, ngh, lam, xg, wg, aks, mas, qs, ff)
Like getmeanqd, except for n different values, aks, of ak and n different values, mas of ma,...
subroutine xmtoxt1(a, xm, xt, xtd, xt1, xtd1, ff)
Like zmtozt1, but for 2-vector xm and xt, and 2*2 diagonal Jacobian xtd Also, the derivatives,...
This module is for evaluating several useful real-valued functions that are not always available in F...
Some of the commonly used constants (pi etc) mainly for double-precision subroutines.
real(dp), parameter dtor
Degrees to radians.
logical, parameter f
for pain-relief in logical ops
real(dp), parameter o5
fifth
real(dp), parameter u1
one
real(dp), parameter o2
half
real(dp), parameter s54
sine(54 deg)
real(dp), parameter rtod
radians to degrees
real(dp), parameter s18
sine(18 deg)
real(dp), parameter o3
third
real(dp), parameter ms54
minus-sine(54 deg)
real(dp), parameter s36
sine(36 deg)
real(dp), parameter pih
pi*half
real(dp), parameter u5
five
real(dp), parameter s72
sine(72 deg)
real(dp), parameter ms18
minus-sine(18 deg)
real(dp), parameter ms72
minus-sine(72 deg)
real(dp), parameter ms36
minus-sine(36 deg)
logical, parameter t
for pain-relief in logical ops
real(dp), parameter u0
zero
real(dp), parameter u2
two
real(dp), parameter pi2
Pi*2.
Standard integer, real, and complex single and double precision kinds.
integer, parameter dp
Double precision real kind.
integer, parameter spi
Single precision integer kind.
Module for handy vector and matrix operations in Euclidean geometry.
Utility routines for orienting the globe and basic geographical mappings.
A suite of routines to perform the eigen-decomposition of symmetric 2*2 matrices and to deliver basic...