!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
    SUBROUTINE SOLARD(R1)
!     ******************************************************************
!$$$  SUBPROGRAM DOCUMENTATION BLOCK
!                .      .    .                               .
! SUBPROGRAM:    SOLARD      COMPUTE THE SOLAR-EARTH DISTANCE
!   PRGRMMR: Q.ZHAO           ORG: W/NMC2     DATE: 96-7-23

! ABSTRACT:
!     SOLARD CALCULATES THE SOLAR-EARTH DISTANCE ON EACH DAY
!     FOR USE IN SHORT-WAVE RADIATION.

! PROGRAM HISTORY LOG:
!   96-07-23  Q.ZHAO      - ORIGINATOR
!   98-10-09  Q.ZHAO      - CHANGED TO USE IW3JDN IN W3LIB TO
!                           CALCULATE JD.

! USAGE: CALL SOLARD FROM SUBROUTINE INIT

!   INPUT ARGUMENT LIST:
!       NONE

!   OUTPUT ARGUMENT LIST:
!       R1   - THE NON-DIMENSIONAL DISTANCE BETWEEN SUN AND THE EARTH
!              (LESS THAN 1.0 IN SUMMER AND LARGER THAN 1.0 IN WINTER).

!   INPUT FILES:
!     NONE

!   OUTPUT FILES:
!     NONE

!   SUBPROGRAMS CALLED:

!     UNIQUE: NONE

!     LIBRARY: IW3JDN

!   COMMON BLOCKS: CTLBLK

! ATTRIBUTES:
!   LANGUAGE: FORTRAN 90
!   MACHINE : IBM SP
!$$$
#include "sp.h"
!***********************************************************************
    PARAMETER &
    (PI=3.1415926,PI2=2.*PI)
!-----------------------------------------------------------------------
    LOGICAL :: &
    RUN,FIRST,RESTRT,SIGMA,LEAP
!-----------------------------------------------------------------------
    INCLUDE "COMM_CTLBLK.f90"
!-----------------------------------------------------------------------
    DIMENSION &
    NDM (12)
!-----------------------------------------------------------------------
    DATA &
    JYR19/1900/,     JMN/0/,  CCR/1.3E-6/

    DATA &
    NDM/0,31,59,90,120,151,181,212,243,273,304,334/

!.....TPP = DAYS BETWEEN EPOCH AND PERIHELION PASSAGE OF 1900
!.....JDOR1 = JD OF DECEMBER 30, 1899 AT 12 HOURS UT
!.....JDOR2 = JD OF EPOCH WHICH IS JANUARY 0, 1990 AT 12 HOURS UT

    DATA &
    TPP/1.55/,    JDOR1/2415019/,     JDOR2/2415020/

!    *******************************************************************
!     COMPUTES JULIAN DAY AND FRACTION FROM YEAR, MONTH, DAY AND TIME UT
!     ACCURATE ONLY BETWEEN MARCH 1, 1900 AND FEBRUARY 28, 2100
!     BASED ON JULIAN CALENDAR CORRECTED TO CORRESPOND TO GREGORIAN
!        CALENDAR DURING THIS PERIOD
!    *******************************************************************
    JYR=IDAT(3)
    JMNTH=IDAT(1)
    JDAY=IDAT(2)
    JHR=IHRST

    JD=IW3JDN(JYR,JMNTH,JDAY)
    IF(JHR >= 12) THEN
        JD=JD-1
        FJD=.5E0+.041666667E0*FLOAT(JHR)+.00069444444E0*FLOAT(JMN)
    ELSE
        7 FJD=.041666667E0*FLOAT(JHR-12)+.00069444444E0*FLOAT(JMN)
    END IF
    DAYINC=JHR/24.0
    JD=JD+FJD+DAYINC
    FJD=JD+FJD+DAYINC-JD
!***
!*** CALCULATE THE SOLAR-EARTH DISTANCE
!***
    DAT=FLOAT(JD-JDOR2)-TPP+FJD
!***
!    COMPUTES TIME IN JULIAN CENTURIES AFTER EPOCH
!***
    T=FLOAT(JD-JDOR2)/36525.E0
!***
!    COMPUTES LENGTH OF ANOMALISTIC AND TROPICAL YEARS (MINUS 365 DAYS)
!***
    YEAR=.25964134E0+.304E-5*T
!***
!    COMPUTES ORBIT ECCENTRICITY  FROM T
!***
    EC=.01675104E0-(.418E-4+.126E-6*T)*T
    YEAR=YEAR+365.E0
!***
!    DATE=DAYS SINCE LAST PERIHELION PASSAGE
!***
    DATE = MOD(DAT,YEAR)
!***
!    SOLVE ORBIT EQUATIONS BY NEWTONs METHOD
!***
    EM=PI2*DATE/YEAR
    E=1.E0
    ITER = 0
    31 EP=E-(E-EC*SIN(E)-EM)/(1.E0-EC*COS(E))
    CR=ABS(E-EP)
    E=EP
    ITER = ITER + 1
    IF(ITER > 10) GOTO 1031
    IF(CR > CCR) GO TO 31
    1031 CONTINUE
    R1=1.E0-EC*COS(E)

    WRITE(6,1000)JYR,JMNTH,JDAY,JHR,R1
    1000 FORMAT('SUN-EARTH DISTANCE CALCULATION FINISHED IN SOLARD'/ &
    'YEAR=',I5,'  MONTH=',I3,'  DAY=',I3,' HOUR=' &
    ,      I3,' R1=',F9.4)
!***
!    RETURN TO RADTN
!***
    RETURN
    END SUBROUTINE SOLARD
