      subroutine GOTideharmsys(infl1,infl2,outfl,dods,nstr)
      !infl1,infl2-某一分潮同相幅值（余弦分量）、异相幅值（正弦分量）规格化球谐系数文件
      !dods-分潮的Doodson常数（整数M2-255555）
      !nstr-分潮名称,如M2分潮为'M2'
	character*800::infl1,infl2,outfl
	character*5::nstr
 	real*8::cnm(900000),snm(900000),cab(3000000),sab(3000000),ccd(3000000),scd(3000000)
	real*8::dods,BB(4,4),BPB(4,4),xx(4),x2(4),x0(2),x1(2),LL(4),ae,bias,sinb,cosb,pi,RAD
      integer::n,m,k,i,nn,maxn,maxn1,maxn2
	integer::status=0
      integer tmzn
	real*8::CRS(5)
	character*800::airtddir,otidedir,eop_c04fl,gcenterfl,ierst65fl,loadlovfl,jeph405fl
      common /dirparablk/ airtddir,otidedir,eop_c04fl,gcenterfl,ierst65fl,loadlovfl,jeph405fl
      common /sysparablk/ tmzn,CRS
!---------------------------------------------------------------------
      ae=CRS(2);pi=datan(1.d0)*4.d0;RAD=pi/180.d0
      cab=0.d0;sab=0.d0
      open(unit=8,file=infl1,status="old",iostat=status)
      if(status/=0)goto 906
	do while(.not.eof(8))
	  read(8,*,end=901)n,m,cab(n*(n+1)/2+m),sab(n*(n+1)/2+m)
      enddo
901   close(8)
      maxn1=n
      ccd=0.d0;scd=0.d0
      open(unit=8,file=infl2,status="old",iostat=status)
      if(status/=0)goto 906
	do while(.not.eof(8))
	  read(8,*,end=902)n,m,ccd(n*(n+1)/2+m),scd(n*(n+1)/2+m)
      enddo
902   close(8)
      maxn2=n
      maxn=maxn1;if(maxn<maxn2)maxn=maxn2
      cab=cab*ae;sab=sab*ae 
      ccd=ccd*ae;scd=scd*ae 
      open(unit=10,file=outfl,status="replace")
      do m=0,maxn
 	  do n=1,maxn
          if(m>n)goto 991
          k=n*(n+1)/2+m;x2=0.d0
          LL(1)=cab(k);LL(2)=sab(k);LL(3)=ccd(k);LL(4)=scd(k)
          xx(1)=(LL(1)-LL(4))/2.d0;xx(2)=(LL(2)+LL(3))/2.d0
          xx(3)=LL(4)+xx(1);xx(4)=LL(3)-xx(2)
994       x0(1)=xx(4);x0(2)=xx(3);call ReimtoHg(x0,x1)
          x2(3:4)=x1(1:2)
          x0(1)=xx(2);x0(2)=xx(1);call ReimtoHg(x0,x1)
          x2(1:2)=x1(1:2)
	    write(10,101)dods*1.d-3,adjustr(nstr),n,m,(xx(i),i=1,4),(x2(i),i=1,4)
991       continue
	  enddo
	enddo
      close(10)
906   continue
101   format(f8.3,a5,2I5,4F14.8,F13.8,F10.4,F13.8,F10.4)
      end
