        program abfg
c
c       convert ABFG to omega and Omega
c
        character*114 data
c
        open(10,file='abfg.in',status='UNKNOWN')
        open(11,file='abfg.out',status='UNKNOWN')
c
        degrad=0.0174532925
c
  100   read(10,901,end=999) data,a,b,f,g
  901   format(a114,t87,4f7.3)
c
	bmf=b-f
	bpf=b+f
	amg=a-g
	apg=a+g
	pang  = abs(atan(bmf/apg))/degrad
	xmang = abs(atan(bpf/amg))/degrad
	if (bmf .lt. 0. .and. apg .lt. 0.) pang  = 180. + pang
	if (bmf .lt. 0. .and. apg .gt. 0.) pang  = 360. - pang
	if (bmf .gt. 0. .and. apg .lt. 0.) pang  = 180. - pang
	if (bpf .lt. 0. .and. amg .lt. 0.) xmang = 180. + xmang
	if (bpf .lt. 0. .and. amg .gt. 0.) xmang = 360. - xmang
	if (bpf .gt. 0. .and. amg .lt. 0.) xmang = 180. - xmang
	asc = (pang+xmang)/2.
	if (asc .lt. 0.0) asc=asc+360.
	per = (pang-xmang)/2.
	if (per .lt. 0.0) per=per+360.
	sum1 = a*a + b*b + f*f + g*g
	sum2 = a*g - b*f
	p1 = sum1/sum2
	p2 = sqrt(p1*p1-4.)
	p3 = abs((p1+p2)/2.)
	p4 = abs((p1-p2)/2.)
	if (p3 .gt. 1.) cinc=p4
	if (p4 .gt. 1.) cinc=p3
	sinc = sqrt(1.-cinc*cinc)
	if (cinc .ne.  0.) xinc = atan(abs(sinc/cinc))/degrad
	if (cinc .eq.  0.) xinc =  90.
	if (sum2 .lt.  0.) xinc = 180. - xinc
	if (xinc .ne. 90.) semi = sqrt(abs(sum2/cos(degrad*xinc)))
	if (xinc .eq. 90.) semi = 99.99
c
        write(11,902) data,xinc,asc,per,semi
  902   format(a114,3x,4f8.3)
        go to 100
c
  999   stop
        end

