SUBROUTINE gradfs(sigl,kcco2,nfile)
  !
  ! $Author: CPTEC $
  ! $Date: 2000/02/24 13:15:43 $
  ! $Revision: 1.0 $
  !

  IMPLICIT NONE

  INCLUDE "parmeta.f90"
  INCLUDE "rdparm.f90"

  INTEGER,PARAMETER :: lngth=37*l
  REAL, PARAMETER :: pi=3.1415927
  REAL :: q19001=19.001,hp98=0.98,h3m6=3.0e-6
  REAL :: hp537=0.537,h74e1=74.0,h15e1=15.0,q14330=1.43306e-6 !zhao h3m6=3.0#e-6
  REAL :: hp2=0.2,twenty=20.0,hnine=9.0,degrad=180.0/pi !zhao q14330=1.43306#e-6
  REAL :: hsigma=5.673e-5,daysec=1.1574e-5,rco2=3.3e-4
  REAL :: emisp,emist,xlatt,xlatp, avg, a1, b1, b2, hp75, h6m2
  REAL, DIMENSION(5) :: cao3sw,cah2sw,cbsw
  REAL, DIMENSION(37,l) :: dduo3n, ddo3n2, ddo3n3, ddo3n4

  COMMON /rdfsav/ emisp,emist,xlatt,xlatp,q19001,hp98,h3m6,  &
       hp75,h6m2,hp537,h74e1,h15e1,q14330,hp2,twenty,hnine,  &
       degrad,hsigma,daysec,rco2, cao3sw,cah2sw,cbsw

  !seasonal climatologies of o3 (obtained from a previously run
  !code which interpolates o3 to user vertical coordinate).
  !defined as 5 deg lat means n.p.->s.p.
  COMMON /savmem/ dduo3n, ddo3n2, ddo3n3, ddo3n4
  !-              winter spring summer  fall

  REAL, DIMENSION(lp1), INTENT(inout) :: sigl
  INTEGER, INTENT(in) :: nfile
  INTEGER, INTENT(in) :: kcco2
  REAL,DIMENSION(lngth) :: rad1, rad2, rad3, rad4
  EQUIVALENCE (rad1(1),dduo3n(1,1)),(rad2(1),ddo3n2(1,1))
  EQUIVALENCE (rad3(1),ddo3n3(1,1)),(rad4(1),ddo3n4(1,1))
  REAL,DIMENSION(5) ::  xao3sw,xah2sw,xbsw !zhao dimension sigl(l)
  INTEGER :: i, lv
  DATA xao3sw / 0., .690, .480, .210, 0./ ,  &
       xah2sw / 0., .690, .480, .210, 0./ ,  &
       xbsw   / 0., .035, .020, .005, 0./
  CALL hconst

  !interpolate climo o3 to the current vertical coordinate...
  !need layer sigma, get from psfc and layer p for i=1.....
  DO  i = 1 , 5
     cao3sw(i) = xao3sw(i)
     cah2sw(i) = xah2sw(i)
     cbsw(i) = xbsw(i)
  END DO
  !convert sigl from pa to mb to be used in o3int
  DO  lv=1,lp1
     sigl(lv)=0.01*sigl(lv)
  END DO
  CALL o3int(sigl)
  CALL conrad(nfile)
  !average climatological valus of o3 from 5 deg lat means, so that
  !time and space interpolation will work (done elsewhere in radfs)
  DO  i=1,lngth
     avg=.25e0*(rad1(i)+rad2(i)+rad3(i)+rad4(i))
     a1=.5e0*(rad2(i)-rad4(i))
     b1=.5e0*(rad1(i)-rad3(i))
     b2=.25e0*((rad1(i)+rad3(i))-(rad2(i)+rad4(i)))
     rad1(i)=avg
     rad2(i)=a1
     rad3(i)=b1
     rad4(i)=b2
  END DO
  emist = .6e0
  emisp = .3e0
  xlatp = 60.e0
  xlatt = 30.e0
END SUBROUTINE gradfs
