anchor.diff:          real,intent(in),dimension(nx)::rh,qc
           integer, intent(in) :: nx
           real,dimension(nx)::temporary
  -        
  +
           temporary=((1-rh)*qc)**0.25
           where(temporary >1) temporary=1
           where(temporary <0.0001) temporary=0.0001
  -        
  +
           cloudfrac=qc-qcmin
           where(cloudfrac<0) cloudfrac=0
  -        
  +
           cloudfrac=(rh**0.25) * (1-exp((-2000*(cloudfrac)) / temporary))
           where(cloudfrac<0) cloudfrac=0
           where(cloudfrac>1) cloudfrac=1
  -        
  +
       end function
  -    
  +
       function calc_solar_elevation(date,lon,j,nx,day_frac)
           implicit none
           real, dimension(nx) :: calc_solar_elevation
  
positive.code:         real, intent(in), dimension(nx) :: T_air,cloud_cover
          real, dimension(nx) :: effective_emissivity
          integer, intent(in) :: nx
          
          effective_emissivity = 1 - 0.261 * exp((-7.77e-4) * (273.16-T_air)**2)
          longwave = effective_emissivity * stefan_boltzmann * T_air**4
          
          longwave = longwave * (1+0.2*cloud_cover)
      end function longwave
      
      function cloudfrac(rh,qc,nx)
  !       Calculate the cloud fraction based on cloud water content (qc) and relative humidity
  !       based on equations from Xu and Randal (1996)
  
negative.code:         real,intent(in),dimension(:,:,:)::qv,p
          integer,intent(in)::j,nx
          real,dimension(nx) :: mr, e, es
  
          ! convert sensible humidity to mixing ratio
          mr=qv(:,1,j)/(1-qv(:,1,j))
          ! convert mixing ratio to vapor pressure
  