PROGRAM DateConversion
   IMPLICIT NONE
   INTERFACE 
      SUBROUTINE Conversion(Number, Year, Month, Day)
         INTEGER, INTENT(IN)    :: Number
         INTEGER, INTENT(OUT)   :: Year, Month, Day
      END SUBROUTINE Conversion
   END INTERFACE
 
   INTEGER :: YYYYMMDD, Y, M, D

   DO 
      WRITE(*,*) 'A YYYYMMDD please (0 to Stop) -> '
      READ(*,*) YYYYMMDD 
      IF (YYYYMMDD == 0) EXIT

      CALL Conversion(YYYYMMDD, Y, M, D)
  
      WRITE(*,*) 'Year   = ' , Y
      WRITE(*,*) 'Month  = ' , M
      WRITE(*,*) 'Day    = ' , D
      WRITE(*,*) 
   END DO
END PROGRAM DateConversion

SUBROUTINE Conversion(Number, Year, Month, Day)
   IMPLICIT NONE
   INTEGER, INTENT(IN)   :: Number
   INTEGER, INTENT(OUT)   :: Year, Month, Day

   Year = Number / 10000
   Month = MOD(Number, 10000) / 100
   Day = MOD(Number, 100)
END SUBROUTINE Conversion   
