*ID SOLVAR
*/
*/  solvarLBB_1939 sets solar constant to 1930's average. The LBB numbers are
*/	removed from this modset. 
*/	This is based on ....
*/
*/  solvarLBB_right is a corrected version of solvarLBB, which was used in some
*/    experiments at vn4.4.
*/
*/  4.5 modset to include long-term variations of the solar "constant" 
*/    in HadCM3 runs, and minor accompanying changes in spectral file
*/    stuff but no variation in ozone amounts, which is probably more
*/    important. 
*/  The solar variability is as in Lean, Beer & Bradley (1995, GRL, 22,
*/    3195-3198) extended to 1997 (Lean, pers. comm., 1998).  It does 
*/    check the year is in the range covered.
*/  This modset is based on existing modsets that vary it in line with
*/    the Hoyt & Schatten reconstruction.  Note that earlier modsets
*/    just altered the total solar irradiance, as in HadCM2.
*/  There is some discussion on http://www_hc/~hadeb/fcgmenu.html & I
*/    wrote a short report on natural forcings of climate 12/97.     WJI
*/
*DECLARE RAD_CTL1
*/
*B ADB2F404.975
*/

CL  Tweak SCS and SW spectral file to allow for solar variability -
CL    the total output & its spectral distribution:

      CALL SOLVAR (PREVIOUS_TIME(1), SCS, NPD_BAND_SW,
     &     SOLAR_FLUX_BAND_SW,  RAYLEIGH_COEFFICIENT_SW,
     &     W_ESFT_SW(1+2*NPD_ESFT_TERM_SW*NPD_BAND_SW,1,1),
C     !  2* to skip two species & get to ozone, the third - can't put
C     !  W_ESFT_SW(1,1,3) as here it is dimensioned by NPD_ESFT_TERM
C     !  & NPD_BAND, but its contents are arranged as if dimensioned 
C     !  by NPD_ESFT_TERM_SW & NPD_BAND_SW.
     &     CMESSAGE, ICODE)

      IF ( ICODE .GT. 0 ) RETURN

*/
*DECLARE CLDCTL1
*/
*I CLDCTL1.102 
     &       DUMMY,
*I CLDCTL1.327

CL  Tweak SCS to allow for variation in total solar output:

      CALL SOLVAR (PREVIOUS_TIME(1), SCS, DUMMY, DUMMY, DUMMY, DUMMY,
     &     CMESSAGE, ICODE)

*/
*/
*DECK SOLVAR1A

!+   Represent variation of solar output - its total & distribution.
! Subroutine Interface:
      SUBROUTINE SOLVAR (YEAR, SCS, NBANDS, FB, RA, OZWB1,
     &     ErrorMessage, ErrorStatus)
      IMPLICIT NONE
! Description:
!  SOLVAR allows for solar variability: its effects on the total solar 
!   output, and on its distribution with wavelength - or at least some 
!   of those things that depend on the latter, namely spectrally 
!   averaged items in the shortwave spectral file.  It assumes that the 
!   empirical (but theoretically plausible) correlations between total 
!   solar output & its spectral distribution over recent solar cycles 
!   due to Lean et al apply across the board, even down to Maunder 
!   minimum, & the time variation is as in Lean, Beer & Bradley (1995,
!   GRL, 22, 3195-3198) extended to 1997 (Lean, pers. comm., 1998).
!   It is written to work with the HadCM3 SW spectral file (or slight 
!   variations) only.  Only the division of the total energy between 
!   the bands, ozone absorption in band 1 & Rayleigh scattering are 
!   worth bothering with (& the last only because it's so easy).  The 
!   ozone absorption can be done just by tweaking the weights, thanks 
!   to Stephen C.
!
! Method:
!  First time in, save the "standard" values of the quantities 
!   concerned in the spectral file.  
!  Every time the year changes, the quantities to be altered in the 
!   spectral file are varied as functions of the solar "constant".
!  Every call re-set SCS, which is set fresh every timestep by SOLPOS.
!
! Current Code Owner: William Ingram
!                    
! History:
! Version  Date     Comment
! =======  ====     =======
! 4.5     14/6/99  Original version, based on corresponding HS modset
!              with data from HadCM2-style LBB modset.  (William Ingram)
!    
! Code description:
!   FORTRAN 77 + common extensions also in fortran 90.
!   This code is written to UM programming standards version 6
! 
! System component covered:  not applicable
! System task:               not applicable
!
! Declarations: these are of the form:-
!     INTEGER      ExampleVariable  !Description of variable

! 
! Global variables (*CALLed common blocks etc.)

*CALL SWSC

! Subroutine arguments
!   Scalar arguments with intent(in):
      INTEGER YEAR,                !  Current year
     &        NBANDS               !  Number of bands in spectral file
      CHARACTER*80 ErrorMessage    !
!   Scalar arguments with intent(InOut):
      REAL SCS                     
!     Solar constant scaling factor, taking into consideration the
!     changes in solar irradiance & the earth-sun distance.
!   Array  arguments with intent(InOut):
      REAL FB(6),                  ! Fraction of insolation in each band
     &     RA(6),                  ! Rayleigh coefficients for each band
     &     OZWB1(5)                ! Ozone esft weights in band 1
!   ErrorStatus:
      INTEGER      ErrorStatus     !+ve = fatal error    

! Local parameters:
      REAL FC2B1D,                 ! Used to convert FCSC to BAND1D
     &     FBSEN1,                 ! Sensitivity of FB(1) to BAND1D
     &     FBSEN2,                 ! Sensitivity of FB(2) to FCSC
     &     RASEN1,                 ! Sensitivity of RA(1) to BAND1D
     &     RASEN2                  ! Sensitivity of RA(2) to FCSC 
      PARAMETER ( FC2B1D = 213. )
      PARAMETER ( FBSEN1 = 5.212, FBSEN2 = 0.1458 )
      PARAMETER ( RASEN1 = 4.360, RASEN2 = 0.2185 )
! Local scalars:
      REAL SOV                     ! Solar "constant" for the year
      REAL MNFB(6), MNRA(2), MNOZ(5)
      ! Reference values for FB, RA and OZWB1.
      REAL FCSC,                   ! Fractional change in solar constant
     &     BAND1D                  
!     Factor representing the band-1 quantities's quadratic dependence
!     on solar constant (in band 2 they vary linearly).

      REAL OZSEN(5)                ! Sensitivities of OZWB1 to BAND1D
      DATA OZSEN / -3.65009, -3.84821, -2.57906, 2.44108, 12.7060 /

      LOGICAL FIRST                ! First time in ?
      DATA FIRST  / .TRUE. /
      INTEGER LASTYR               ! Year last time through
      DATA LASTYR / -99999 /

      SAVE FIRST, LASTYR, MNRA, MNFB, MNOZ, FCSC
!- End of header  

      IF ( FIRST ) THEN

C  Check only on the number of bands & that there seem to be 5 esft 
C   terms for the first gas in the first band - any more complex test on, 
C   say, the total size of the file, or band limits would be confused by
C   adding more aerosols or re-labelling the (pseudo-)band limits.

        IF ( SUM(OZWB1) .GT. 1.0001 .OR. SUM(OZWB1) .LE. 0.9999 
     &                               .OR. NBANDS .NE. 6 ) THEN
          ErrorMessage = ' SOLVAR: Inappropriate spectral file'
          WRITE (6, *) NBANDS, OZWB1
          WRITE (6, *) ErrorMessage
          ErrorStatus = 8
          RETURN
        ENDIF

C       Store reference values.
        MNFB = FB
        MNRA = RA(1:2)
        MNOZ = OZWB1
        FIRST = .FALSE.

      ENDIF

      IF ( YEAR .LT. 1748 .OR. YEAR .GT. 1997 ) THEN
        ErrorMessage = ' SOLVAR: Only years 1748-1997 covered'
        WRITE (6, *) YEAR
        WRITE (6, *) ErrorMessage
        ErrorStatus = 9
        RETURN
      ENDIF

      IF ( YEAR .NE. LASTYR ) THEN

!       Calculate this year's solar constant & thence FCSC and BAND1D
!	But as using average of 1930's replace LBBSIV(YEAR) by 2.3239
        SOV = 2.3239 + 1363.3718 
!       1363.3718 = SC - mean(LBBSIV)
        FCSC = SOV / SC - 1.
        BAND1D = FCSC * ( 1. + FC2B1D * FCSC )

!       Set FB(1,2) using BAND1D & FCSC and the rest by normalization.
        FB(1) = ( 1. + FBSEN1 * BAND1D ) * MNFB (1)
        FB(2) = ( 1. + FBSEN2 * FCSC )   * MNFB (2)
        FB(3:6) = MNFB(3:6)   *  ( 1. - FB(1) - FB(2) ) / SUM(MNFB(3:6))

!       Set RA(1,2) using BAND1D & FCSC: the rest are insignificant.
        RA(1) = ( 1. + RASEN1 * BAND1D ) * MNRA (1)
        RA(2) = ( 1. + RASEN2 * FCSC )   * MNRA (2)

!       Set OZWB1 using BAND1D but must then re-normalize.
        OZWB1 = ( 1. + OZSEN * BAND1D ) * MNOZ
        OZWB1 = OZWB1 / SUM(OZWB1)

        LASTYR = YEAR

      ENDIF

      SCS = SCS * ( 1. + FCSC )

      RETURN
      END
