
      IMPLICIT REAL*8(A-H,O-Z)
      CHARACTER ISD,NDE(3)
      CHARACTER*13 FILEC,FILEa
      character*40 teste
      INTEGER*4 COOR(2),JD
      INTEGER*2 MAG(3),ERCO,CEM
      INTEGER*1 ERMG(3)
      CEM=100
      IAH=12
      IAM=24
      AS=48.123D0
      ISD="-"
      IDG=23
      IDM=46
      DS=54.321D0
      ARG=15.0D0*(DFLOAT(IAH)+DFLOAT(IAM)/6.0D1+AS/3.6D3)
      arg=261.236352
      IAR=IDINT(ARG)
      JAR=IAR+1
      write(*,*)arg,iar,jar
      IF(ISD.EQ."-")THEN
      ISD="m"
      ELSE
      ISD="p"
      ENDIF
      DEC=DFLOAT(IDG)+DFLOAT(IDM)/6.0D1+DS/3.6D3
      dec=22.431105
      isd="p"
      IDE=IDINT(DEC*10.0D0)
      write(*,*)isd,dec,ide
      I=MOD(IDE,10)
      NDE(3)=CHAR(I+48)
      IDE=IDE/10
      I=MOD(IDE,10)
      NDE(2)=CHAR(I+48)
      I=IDE/10
      NDE(1)=CHAR(I+48)
      write(*,*)nde(1),nde(2),nde(3)
      FILEc=ISD//NDE(1)//NDE(2)//NDE(3)//"TMASS.ast"
      FILEa=ISD//NDE(1)//NDE(2)//NDE(3)//"TMASS.acc"
      write(*,*)filec,filea
      CLOSE (1)
      CLOSE (2)
      OPEN(1,FILE=FILEc,ACCESS="DIRECT",FORM="UNFORMATTED",RECL=23)
      OPEN(2,FILE=FILEa,ACCESS="DIRECT",FORM="FORMATTED",RECL=39)
      READ(2,1000,REC=JAR)IAC,JAC,IRC,JRC,NRC
      write(*,*)IAC,JAC,IRC,JRC,NRC
 1000 FORMAT(1X,I3,9X,I3,3(1X,I6))
      DO 1 I=IRC,JRC
      READ(1,REC=I)(COOR(J),J=1,2),ERCO,
     ?             MAG(1),ERMG(1),MAG(2),ERMG(2),MAG(3),ERMG(3),JD
      WRITE(*,*)(COOR(J),J=1,2),ERCO,
     ?             MAG(1),ERMG(1),MAG(2),ERMG(2),MAG(3),ERMG(3),JD
      AR=DFLOAT(COOR(1))/1.0D6
      DE=DFLOAT(COOR(2))/1.0D6
      ERDE=DFLOAT(MOD(ERCO,CEM))/100.0
      ERRA=(DFLOAT(ERCO)-ERDE)/10000.0
      ZMGJ=DFLOAT(MAG(1))/1000.0
      EMGJ=DFLOAT(ERMG(1))/100.0
      ZMGH=DFLOAT(MAG(2))/1000.0
      EMGH=DFLOAT(ERMG(2))/100.0
      ZMGK=DFLOAT(MAG(3))/1000.0
      EMGK=DFLOAT(ERMG(3))/100.0

c
c     a linha abaixo estava errada
c
c     DJ=DFLOAT(JD)/1.0D4+2451.0D4
c

      DJ=DFLOAT(JD)/1.0D4+2451.0D3
      WRITE(*,*)RA,DE,ERRA,ERDE,ZMGJ,EMGJ,ZMGH,EMGH,ZMGK,EMGK,DJ
      if(coor(1).gt.261236350)pause
      
   1  continue
      STOP
      END

