PROGRAM FK4FK5 * * Read a B1950 position from I/O unit 5 and reply on I/O unit 6 * with the J2000 equivalent. Enter a period to quit. * IMPLICIT NONE CHARACTER C*80,S INTEGER I,J,IHMSF(4),IDMSF(4) DOUBLE PRECISION R4,D4,R5,D5 LOGICAL BAD * Loop until a period is entered C = ' ' DO WHILE (C(:1).NE.'.') * Read h m s d ' " READ (5,'(A)') C IF (C(:1).NE.'.') THEN BAD = .TRUE. * Decode the RA I = 1 CALL sla_DAFIN(C,I,R4,J) IF (J.EQ.0) THEN R4 = 15D0*R4 * Decode the Dec CALL sla_DAFIN(C,I,D4,J) IF (J.EQ.0) THEN * FK4 to FK5 CALL sla_FK45Z(R4,D4,1950D0,R5,D5) * Format and output the result CALL sla_DR2TF(2,R5,S,IHMSF) CALL sla_DR2AF(1,D5,S,IDMSF) WRITE (6, : '(1X,I2.2,2I3.2,''.'',I2.2,2X,A,I2.2,2I3.2,''.'',I1)') : IHMSF,S,IDMSF BAD = .FALSE. END IF END IF IF (BAD) WRITE (6,'(1X,''?'')') END IF END DO ENDIn this example, SLALIB not only provides the complicated FK4 to FK5 transformation but also simplifies the tedious and error-prone tasks of decoding and formatting angles expressed as hours, minutes etc. The example incorporates range checking, and avoids the notorious ``minus zero'' problem (an often-perpetrated bug where declinations between and lose their minus sign). With a little extra elaboration and a few more calls to SLALIB, defaulting can be provided (enabling unused fields to be replaced with commas to avoid retyping), proper motions can be handled, different epochs can be specified, and so on. See the program COCO (SUN/56) for further ideas.
SLALIB --- Positional Astronomy Library