C
C			DATODA.FTN
C
C  A SUBROUTINE TO CONVERT MO-DA-YR TO TOTAL DAYS SINCE JAN 1, 1980 OR
C  VICE VERSA
C  IF DIREC = 1 CONVERT THE MO, DA, YR GIVEN TO TOTAL DAYS
C  IF DIREC = 2 CONVERT THE PRESENT MO, DA, YR TO TOTAL DAYS
C  IF DIREC = 3 CONVERT THE TOTAL DAYS SUBMITTED TO MO, DA, YR
	SUBROUTINE DATODA(MO,DA,YR,TOTDA,DIREC)
	INTEGER	MO,DA,YR,TOTDA,DIREC,DAYS
	IF(DIREC.GE.3)GO TO 300
C
C  COME HERE TO CONVERT MO,DA,YR TO TOTAL DAYS
C
	IF(DIREC.EQ.1)TOTDA=DAYS(MO,DA,YR,0)
	IF(DIREC.EQ.2)TOTDA=DAYS(MO,DA,YR,2)
	RETURN
C
C  COME HERE TO CONVERT TOTAL DAYS TO MO,DA,YR
C
300	I=TOTDA
	YR=I/365.24+80
310	I=TOTDA-DAYS(1,1,YR,0)
	IF(I.LT.0)GO TO 400
	IF(I.GT.366)GO TO 410
320	MO=I/29+1
325	I=TOTDA-DAYS(MO,1,YR,0)
	IF(I.LT.0)GO TO 420
	DA=I+1
	RETURN
400	YR=YR-1
	GO TO 310
410	YR=YR+1
	GO TO 310
420	MO=MO-1
	GO TO 325
	END
