      module coolref_init_module
      use params_module,only: nlat,nlon,nlonp2,nlonp4,nlevp1
      use addfld_module,only: addfld
      implicit none
!     -------------------------------------------------------------
!     Routine to initialize cooling reference quantities from Roldan et al
!     Initial vectors tm1,tm2,xnod,xnco2d,xnon,xnco2n,cool1,cool2 (nlevp1)
!    -------------------------------------------------------------
      real,dimension(nlevp1) :: tm1,tm2,xnod,xnco2d,xnon,xnco2n,
     |  cool1,cool2
!
! Fields derived for use in sub lincoeff and sub cool:
      real,dimension(nlevp1) ::
     |  tm1a,tm2a, ! tm1,tm2 shifted 1/2 dz         
     |  cool1a,cool2a, ! cool1,cool2 shifted 1/2 dz  
     |  aday,      ! formerly AD(ZKMXP)
     |  anight     ! formerly AN(ZKMXP)
!
! Change cooling constant, as per Bougher, 9/29/06:
!     real,parameter :: coolk = 1.1550e-13  ! old value
      real,parameter :: coolk = 1.7321e-13  ! new value
!
      contains
!-----------------------------------------------------------------------
      subroutine coolref_init
!
! ----------------------------------------------------------------------
!     DRIVER TO extract cooling reference quantities
!     -- from Roldan et al., (2000)
!     -- Tref, COOLref, OMIXref, CO2MIXref (dayside and nigthside mean)
! ----------------------------------------------------------------------
!** Bottom of code FACTORS are used for coooling**
! ----------------------------------------------------------------------
      use params_module,only: nlat,nlon,nlonp2,nlonp4,nlevp1
      use addfld_module,only: addfld
      implicit none
!
! Local arrays:
!
!
!
#include<defs.h>
!
! --------------------------------------------------------------------------
!  *  data statements  (all from Miguel Vopez-Valerde, p.c. 2007)
!  *  Dayside (4) and Nightside (4) vectors (nlevp1) column per data statement 
!     -- nlevp1 = 47
! --------------------------------------------------------------------------
! Dayside Reference Cooling Quantities: T(K), OMIX, CO2MIX, COOLREF(K/day)
! -- Direct from Miguel in tables and interpolated to our nlevp1 pressure grid
! -- Self consistency in T, OMIX, CO2MIX, cool (DAY AND NIGHT)
! -- Self consistency (total compatibility) with Qnir from Roldan et al.,(2000)
! -- Quantities obtained on interfaces (nlevp1) but needed on mid-levels for dt.F 
! --------------------------------------------------------------------------
! **Only took values up to zp=11 on nightside and zp=5.5 on dayside and then held
!   constant due to the lack of data above those pressures
! --------------------------------------------------------------------------
!
#if (NLEV==68)
!  Tref (dayside) corresponding to COOL(DY), OMIX(DY), CO2MIX(DY)
!
! 12/7/08 btf: nlevp1=69 (-16 to +18): pad with top value
!
!     WRITE(*,*)'NLEV',NLEV
      tm1(:) = (/
!    | 242.84,242.84,242.84,242.84,242.84,242.84,242.84,242.84,242.84,
!    | 242.84,242.84,242.84,242.84,242.84,242.84,242.84,242.84,242.84,
!    | 242.84,242.84,242.84,242.84,
!
     | 242.84,232.78,223.58,214.6,206.07,199.92,195.49,
     | 191.44,187.59,184.97,183.53,182.32,181.15,
     | 179.98,178.81,177.89,177.65,178.15,178.94,179.75,
     | 180.64,181.83,183.38,185.14,187.12,189.36,192.03,
     | 195.15,198.9,203.57,209.21,216.4,225.25,236.53,
     | 249.39,262.1,273.17,282.38,289.57,295.24,299.52,
     | 302.24,304.98,306.02,306.02,306.02,306.02,306.02,
     | 306.02,306.02,306.02,306.02,306.02,306.02,306.02,
     | 306.02,306.02,306.02,306.02,306.02,306.02,306.02,
     | 306.02,306.02,306.02,306.02,306.02,306.02,306.02/)

!
!    | 202.13,197.16,193.03,189.11,185.99,184.08,182.79,
!    | 181.61,180.44,179.27,178.17,177.54,177.84,178.63,
!    | 179.42,180.25,181.26,182.71,184.41,186.3,188.44,
!    | 190.9,193.89,197.38,201.67,206.73,213.42,221.56,
!    | 231.99,244.11,257.2,269.02,279.,286.98,293.16,298.08,
!    | 301.15,303.98,305.9,306.61,306.61,306.61,306.61,
!    | 306.61,306.61,306.61,306.61,306.61,306.61,306.61,
!    | 306.61,306.61,306.61,306.61,306.61,306.61,306.61,
!    | 306.61,306.61,306.61,306.61,306.61,306.61,306.61,
!    | 306.61,306.61,306.61,306.61,306.61/)
!
!     WRITE(*,*)'tm1',tm1
!
!  Dayside Atomic oxygen volume mixing ratio (log10 units)
!  -- Code needs straight units. Conversion needed.
!  -- From Hedin et al., (1983)
!
      xnod(:) = (/
!    | -8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,
!    | -8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,
!    | -8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,

     | -8.5591,-8.2617,-8.1181,-7.9751,-7.8613,-7.957,
     | -8.1172,-7.8282,-7.2736,-6.7164,-6.1698,-5.6429,
     | -5.1205,-4.7247,-4.4326,-4.1739,-3.9682,-3.7991,
     | -3.6344,-3.464,-3.2899,-3.1131,-2.9316,-2.7484,
     | -2.5614,-2.3719,-2.1819,-1.9906,-1.8039,-1.6141,
     | -1.4261,-1.2474,-1.0778,-0.91263,-0.76714,-0.63512,
     | -0.51831,-0.41878,-0.33088,-0.25872,-0.19698,
     | -0.14877,-0.11124,-0.081914,-0.081914,-0.081914,
     | -0.081914,-0.081914,-0.081914,-0.081914,-0.081914,-0.081914,
     | -0.081914,-0.081914,-0.081914,-0.081914,-0.081914,
     | -0.081914,-0.081914,-0.081914,-0.081914,-0.081914,-0.081914,
     | -0.081914,-0.081914,-0.081914,-0.081914,-0.081914,
     | -0.081914/)
!
!    | -7.8956,-8.0496,-7.9388,-7.4286,-6.865,-6.3185,
!    | -5.801,-5.2909,-4.8673,-4.5427,-4.283,-4.0446,
!    | -3.8695,-3.7068,-3.5403,-3.3652,-3.1916,-3.0099,
!    | -2.8266,-2.6405,-2.449,-2.2575,-2.0634,-1.8723,
!    | -1.6858,-1.4998,-1.3199,-1.1418,-0.98003,-0.82218,
!    | -0.68432,-0.56295,-0.45727,-0.36506,-0.28626,
!    | -0.21993,-0.16614,-0.12497,-0.09316,-0.06946,-0.06946,
!    | -0.06946,-0.06946,-0.06946,-0.06946,-0.06946,-0.06946,
!    | -0.06946,-0.06946,-0.06946,-0.06946,-0.06946,-0.06946,
!    | -0.06946,-0.06946,-0.06946,-0.06946,-0.06946,-0.06946,
!    | -0.06946,-0.06946,-0.06946,-0.06946,-0.06946,-0.06946,
!    | -0.06946,-0.06946,-0.06946,-0.06946/)
!
!
!  Dayside CO2 volume mmixing ratio (log10 units)
!  -- Code needs straight units. Conversion needed.
!  -- From Hedin et al., (1983)
!
      xnco2d(:) = (/
!    | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
!    | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
!    | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
!    | -0.015473,-0.015473,-0.015473,-0.015473,

     | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
     | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
     | -0.016269,-0.016738,-0.017155,-0.017571,-0.01799,
     | -0.018409,-0.018634,-0.018834,-0.019283,-0.02013,
     | -0.021509,-0.022276,-0.022494,-0.023662,-0.026359,
     | -0.029799,-0.034682,-0.040447,-0.048243,-0.059146,
     | -0.072705,-0.094077,-0.12127,-0.15909,-0.21118,
     | -0.2755,-0.35518,-0.45734,-0.5755,-0.72568,-0.89628,
     | -1.1064,-1.3474,-1.6145,-1.6145,-1.6145,
     | -1.6145,-1.6145,-1.6145,-1.6145,-1.6145,-1.6145,-1.6145,
     | -1.6145,-1.6145,-1.6145,-1.6145,
     | -1.6145,-1.6145,-1.6145,-1.6145,-1.6145,-1.6145,-1.6145,
     | -1.6145,-1.6145,-1.6145,-1.6145,
     | -1.6145/)
!
!    | -0.01547,-0.01547,0.01547,-0.01547,-0.01547,-0.01594,
!    | -0.01657,-0.01699,-0.01741,-0.01782,-0.01824,-0.01863,
!    | -0.01866,-0.01911,-0.01958,-0.02097,-0.02228,-0.02231,
!    | -0.02291,-0.02501,-0.02844,-0.03243,-0.03816,-0.04499,
!    | -0.05479,-0.06563,-0.08578,-0.1095,-0.14425,-0.18809,
!    | -0.24806,-0.32313,-0.41564,-0.5278,-0.66541,-0.82473,
!    | -1.0179,-1.2497,-1.507,-1.7954,-1.7954,-1.7954,-1.7954,
!    | -1.7954,-1.7954,-1.7954,-1.7954,-1.7954,-1.7954,-1.7954,
!    | -1.7954,-1.7954,-1.7954,-1.7954,-1.7954,-1.7954,-1.7954,
!    | -1.7954,-1.7954,-1.7954,-1.7954,-1.7954,-1.7954,-1.7954,
!    | -1.7954,-1.7954,-1.7954,-1.7954,-1.7954/)
!
!  Dayside Exact CO2 15-micron cooling rate (K/day)
!  -- Code needs K/sec for simulation. Conversion needed.
!  -- What sign is needed for application in sub cool?
!
      cool1(:) = (/
!    | -23.436,-23.436,-23.436,-23.436,-23.436,-23.436,-23.436,-23.436,
!    | -23.436,-23.436,-23.436,-23.436,-23.436,-23.436,-23.436,-23.436,
!    | -23.436,-23.436,-23.436,-23.436,-23.436,-23.436,
!
     | -23.436,-26.476,-27.365,-25.171,-24.222,-29.777,
     | -36.191,-38.373,-39.069,-43.076,-47.527,-49.25,
     | -49.351,-48.22,-46.274,-46.086,-50.584,-61.021,-75.251,
     | -93.126,-122.46,-177.74,-277.44,-442.4,-705.83,
     | -1122.4,-1759.7,-2614.6,-3642.,-4736.4,-5883.7,
     | -7163.1,-8534.6,-9663.8,-9991.3,-9057.4,-7189.4,
     | -5079.3,-3244.9,-1863.4,-973.1,-450.96,-189.35,
     | -71.065,-71.065,-71.065,-71.065,-71.065,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065,-71.065,-71.065,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065,-71.065/)
!
!    | -27.047,-33.694,-37.705,-38.822,-41.465,-45.764,
!    | -48.726,-49.438,-48.816,-47.147,-45.49,-47.42,
!    | -55.709,-69.231,-84.664,-106.91,-147.9,-227.06,
!    | -361.9,-580.35,-929.88,-1474.5,-2258.,-3226.3,-4303.6,
!    | -5398.5, -6663.8,-7979.1,-9347.4,-9975.7,-9582.2,
!    | -7984.5,-5894.4,-3909.3,-2349.4,-1277.8,-620.85,
!    | -269.85,-105.33,-36.036,-36.036,-36.036,-36.036,
!    | -36.036,-36.036,-36.036,-36.036,-36.036,-36.036,
!    | -36.036,-36.036,-36.036,-36.036,-36.036,-36.036,
!    | -36.036,-36.036,-36.036,-36.036,-36.036,-36.036,
!    | -36.036,-36.036,-36.036,-36.036,-36.036,-36.036,
!    | -36.036,-36.036/)
!
! --------------------------------------------------------------------------
! Nightside Reference Cooling Quantities: T(K), OMIX, CO2MIX, COOLREF(K/day)
! --------------------------------------------------------------------------
!
!  Tref (nightside) corresponding to COOL(NT), OMIX(NT), CO2MIX(NT)
!
      tm2(:) = (/
!    | 242.84,242.84,242.84,242.84,242.84,242.84,242.84,242.84,242.84,
!    | 242.84,242.84,242.84,242.84,242.84,242.84,242.84,242.84,242.84,
!    | 242.84,242.84,242.84,242.84,
!
! ** Corrected for upper altitudes **
     | 242.84,232.79,223.79,214.6,205.97,199.23,193.95,
     | 188.94,184.02,179.61,175.84,172.14,168.45,164.78,
     | 161.1,157.88,155.91,154.38,152.91,151.34,149.68,
     | 147.99,146.35,144.71,143.09,141.49,139.91,138.25,
     | 136.5,134.71,132.92,131.25,129.69,128.2,126.78,
     | 125.45,124.18,122.86,121.48,120.15,119.08,118.43,
     | 118.1,118.,118.25,118.92,120.12,121.91,124.05,
     | 125.75,127.46,128.68,130.34,131.77,132.21,
     | 132.21,132.21,132.21,132.21,132.21,132.21,132.21,
     | 132.21,132.21,132.21,132.21,132.21,132.21,132.21/)
! ** Before correction at upper alt. **
!    | 242.84,232.79,223.79,214.6,205.97,199.23,193.95,
!    | 188.94,184.02,179.61,175.84,172.14,168.45,164.78,
!    | 161.1,157.88,155.91,154.38,152.91,151.34,149.68,
!    | 147.99,146.35,144.71,143.09,141.49,139.91,138.25,
!    | 136.5,134.71,132.92,131.25,129.69,128.2,126.78,
!    | 125.45,124.18,122.86,121.48,120.15,119.08,118.43,
!    | 118.1,118.,118.25,118.92,120.12,121.91,124.05,
!    | 125.75,127.46,128.68,130.34,131.77,132.21,
!    | 131.77,131.77,131.77,131.77,131.77,131.77,131.77,
!    | 131.77,131.77,131.77,131.77,131.77,131.77,131.77/)

!
!    | 201.71,195.97,190.91,185.96,181.34,177.33,173.6,
!    | 169.91,166.23,162.55,159.13,156.63,154.94,153.51,
!    | 151.99, 150.34,148.66,146.99,145.36,143.73,142.12,
!    | 140.54, 138.9,137.2,135.43,133.62,131.91,130.3,128.78,
!    | 127.33,125.97,124.68,123.39,122.04,120.61,119.44,
!    | 118.6,118.2,118.02,118.09,118.61,118.58,121.08,123.26,
!    | 125.11,126.79,128.27,128.27,128.27,128.27,128.27,128.27,
!    | 128.27,128.27,128.27,128.27,128.27,128.27,128.27,128.27,
!    | 128.27,128.27,128.27,128.27,128.27,128.27,128.27,128.27,
!    | 128.27/)
!     WRITE(*,*)'tm2',tm2
!
!  Nightside Atomic oxygen volume mixing ratio (log10 units)
!  -- Code needs straight units. Conversion needed.
!  -- From Hedin et al., (1983)
!
      xnon(:) = (/
!    | -8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,
!    | -8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,
!    | -8.5591,-8.5591,-8.5591,-8.5591,-8.5591,-8.5591,
!
! ** Corrected for upper altitudes **
     | -8.5591,-8.2617,-8.1181,-7.9751,-7.8638,-7.9925,
     | -8.1663,-7.7754,-7.2404,-6.7054,-6.176,-5.6499,
     | -5.1266,-4.7454,-4.4764,-4.2161,-4.0141,-3.8636,
     | -3.7195,-3.5741,-3.4297,-3.2841,-3.1244,-2.9653,
     | -2.8063,-2.649,-2.496,-2.3307,-2.1625,-1.9994,
     | -1.8435,-1.6863,-1.5196,-1.3585,-1.2062,-1.0603,
     | -0.90226,-0.75835,-0.62492,-0.49534,-0.3779,
     | -0.28087,-0.19523,-0.13466,-0.089473,-0.063896,
     | -0.05062,-0.04586,-0.05032,-0.06160,-0.08602,
     | -0.12311,-0.1797,-0.26820,-0.40809,-0.40809,
     | -0.40809,-0.40809,-0.40809,-0.40809,-0.40809,
     | -0.40809,-0.40809,-0.40809,-0.40809,-0.40809,
     | -0.40809,-0.40809,-0.40809/)
! ** Before correction at upper alt. **
!    | -8.5591,-8.2617,-8.1181,-7.9751,-7.8638,-7.9925,
!    | -8.1663,-7.7754,-7.2404,-6.7054,-6.176,-5.6499,
!    | -5.1266,-4.7454,-4.4764,-4.2161,-4.0141,-3.8636,
!    | -3.7195,-3.5741,-3.4297,-3.2841,-3.1244,-2.9653,
!    | -2.8063,-2.649,-2.496,-2.3307,-2.1625,-1.9994,
!    | -1.8435,-1.6863,-1.5196,-1.3585,-1.2062,-1.0603,
!    | -0.90226,-0.75835,-0.62492,-0.49534,-0.3779,
!    | -0.28087,-0.19523,-0.13466,-0.089473,-0.063896,
!    | -0.05062,-0.04586,-0.05032,-0.06160,-0.08602,
!    | -0.12311,-0.1797,-0.26820,-0.40809,-0.26820,
!    | -0.26820,-0.26820,-0.26820,-0.26820,-0.26820,
!    | -0.26820,-0.26820,-0.26820,-0.26820,-0.26820,
!    | -0.26820,-0.26820,-0.26820/)

!
!    | -7.9124,-8.0958,-7.9121,-7.3912,-6.8505,-6.3176,
!    | -5.7936,-5.2718,-4.863,-4.5662,-4.3054,-4.0849,
!    | -3.9187,-3.7808,-3.6396,-3.489,-3.3363,-3.1806,
!    | 3.0263,-2.874,-2.7195,-2.553,-2.3887,-2.227,
!    | -2.0718,-1.9076,-1.7418,-1.5813,-1.428,-1.2699,
!    | -1.1123,-0.95877,-0.81473,-0.67993,-0.55218,
!    | -0.42011,-0.32063,-0.22654,-0.15602,-0.10217,
!    | -0.07342,-0.05409,-0.04493,-0.04755,-0.05682,
!    | -0.07556,-0.10656,-0.10656,-0.10656,-0.10656,
!    | -0.10656,-0.10656,-0.10656,-0.10656,-0.10656,
!    | -0.10656,-0.10656,-0.10656,-0.10656,-0.10656,
!    | -0.10656,-0.10656,-0.10656,-0.10656,-0.10656,
!    | -0.10656,-0.10656,-0.10656,-0.10656/)
!
!  Nightside CO2 volume mixing ratio (log10 units)
!  -- Code needs straight units. Conversion needed.
!  -- From Hedin et al., (1983)
!
      xnco2n(:) = (/
!    | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
!    | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
!    | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
!    | -0.015473,-0.015473,-0.015473,-0.015473,
!
! ** Corrected for upper altitudes **
     | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
     | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
     | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
     | -0.015473,-0.016161,-0.016936,-0.017708,-0.018472,
     | -0.019233,-0.020006,-0.021125,-0.022245,-0.023357,
     | -0.024574,-0.02603,-0.02749,-0.031759,-0.036627,
     | -0.041938,-0.050038,-0.060203,-0.070949,-0.085723,
     | -0.11362,-0.1417,-0.18342,-0.24263,-0.31451,-0.40667,
     | -0.56087,-0.73734,-0.9799,-1.2389,-1.5637,-1.9104,
     | -2.2742,-2.6635,-3.0706,-3.5169,-3.9939,-4.5233,
     | -5.14328,-5.91040,-5.91040,-5.91040,-5.91040,
     | -5.91040,-5.91040,-5.91040,-5.91040,-5.91040,
     | -5.91040,-5.91040,-5.91040,-5.91040,-5.91040,
     | -5.91040/)
! ** Before correction at upper alt. **
!    | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
!    | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
!    | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
!    | -0.015473,-0.016161,-0.016936,-0.017708,-0.018472,
!    | -0.019233,-0.020006,-0.021125,-0.022245,-0.023357,
!    | -0.024574,-0.02603,-0.02749,-0.031759,-0.036627,
!    | -0.041938,-0.050038,-0.060203,-0.070949,-0.085723,
!    | -0.11362,-0.1417,-0.18342,-0.24263,-0.31451,-0.40667,
!    | -0.56087,-0.73734,-0.9799,-1.2389,-1.5637,-1.9104,
!    | -2.2742,-2.6635,-3.0706,-3.5169,-3.9939,-4.5233,
!    | -5.1433,-5.1433,-5.1433,-5.1433,-5.1433,-5.1433,
!    | -5.1433,-5.1433,-5.1433,-5.1433,-5.1433,-5.1433,
!    | -5.1433,-5.1433,-5.1433,-5.1433/)

!
!    | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
!    | -0.015473,-0.015473,-0.015473,-0.015473,-0.015473,
!    | -0.015473,-0.01586,-0.01663,-0.01741,-0.01817,
!    | -0.01893,-0.0197,-0.02068,-0.0218,-0.02292,-0.02403,
!    | -0.02545,-0.02691,-0.02978,-0.03478,-0.03948,-0.04682,
!    | -0.05605,-0.06666,-0.07761,-0.10239,-0.13042,-0.16449,
!    | -0.21563,-0.28756,-0.35919,-0.50433,-0.66256,-0.87275,
!    | -1.1266,-1.431,-1.7667,-2.1296,-2.5139,-2.9147,-3.3453,
!    | -3.8003,-3.8003,-3.8003,-3.8003,-3.8003,-3.8003,-3.8003,
!    | -3.8003,-3.8003,-3.8003,-3.8003,-3.8003,-3.8003,-3.8003,
!    | -3.8003,-3.8003,-3.8003,-3.8003,-3.8003,-3.8003,-3.8003,
!    | -3.8003,-3.8003/)
!
!  Nightside Exact CO2 15-micron cooling rate (K/day)
!  -- Code needs K/sec for simulation. Conversion needed.
!  -- What sign is needed for application in sub cool?
!
      cool2(:) = (/
!    | -20.632,-20.632,-20.632,-20.632,-20.632,-20.632,-20.632,-20.632,
!    | -20.632,-20.632,-20.632,-20.632,-20.632,-20.632,-20.632,-20.632,
!    | -20.632,-20.632,-20.632,-20.632,-20.632,-20.632,
!
! ** Corrected for upper altitudes **
     | -20.632,-26.5,-27.496,-25.621,-24.483,-28.322,
     | -32.292,-32.633,-30.786,-29.299,-27.683,-24.71,
     | -21.216,-17.708,-14.272,-12.966,-14.631,-16.704,
     | -18.593,-20.985,-25.173,-32.521,-44.678,-59.96,
     | -76.631,-93.266,-108.67,-119.69,-127.24,-131.13,
     | -132.04,-132.32,-131.03,-127.27,-121.24,-113.8,
     | -99.155,-81.321,-61.725,-42.997,-27.468,-16.141,
     | -8.3774,-3.6067,-1.4796,-0.49863,-0.1546,-0.0483,
     | -0.0135,-0.0034,-7.4905e-4,-1.4070e-4,-2.1318e-5,
     | -2.8926e-4,-5.5778e-4,-5.5778e-4,-5.5778e-4,
     | -5.5778e-4,-5.5778e-4,-5.5778e-4,-5.5778e-4,
     | -5.5778e-4,-5.5778e-4,-5.5778e-4,-5.5778e-4,
     | -5.5778e-4,-5.5778e-4,-5.5778e-4,-5.5778e-4/)
! ** Before correction at upper alt. **
!    | -20.632,-26.5,-27.496,-25.621,-24.483,-28.322,
!    | -32.292,-32.633,-30.786,-29.299,-27.683,-24.71,
!    | -21.216,-17.708,-14.272,-12.966,-14.631,-16.704,
!    | -18.593,-20.985,-25.173,-32.521,-44.678,-59.96,
!    | -76.631,-93.266,-108.67,-119.69,-127.24,-131.13,
!    | -132.04,-132.32,-131.03,-127.27,-121.24,-113.8,
!    | -99.155,-81.321,-61.725,-42.997,-27.468,-16.141,
!    | -8.3774,-3.6067,-1.4796,-0.49863,-0.1546,-0.0483,
!    | -0.0135,-0.0034,-7.4905e-4,-1.4070e-4,-2.1318e-5,
!    | -2.8926e-4,-5.5778e-4,-2.8926e-4,-2.8926e-4,
!    | -2.8926e-4,-2.8926e-4,-2.8926e-4,-2.8926e-4,
!    | -2.8926e-4,-2.8926e-4,-2.8926e-4,-2.8926e-4,
!    | -2.8926e-4,-2.8926e-4,-2.8926e-4,-2.8926e-4/)

!
!    | -26.389,-30.785,-32.659,-31.563,-29.882,-28.321,
!    | -25.896,-22.603,-19.093,-15.627,-13.393,-13.842,
!    | -15.875,-17.912,-19.636,-23.08,-29.596,-39.878,
!    | -53.594,-69.882,-86.976,-102.74,-115.34,-124.62,
!    | -130.71,-131.77,-132.21,-131.63,-129.48,-123.88,
!    | -116.74,-105.04,-88.867,-69.649,-49.58,-32.95,
!    | -19.776,-10.909,-5.222,-2.1407,-0.78523,-0.26248,
!    | -0.07676,-0.02189,-0.00576,-0.00132,-0.00028,
!    | -0.00028,-0.00028,-0.00028,-0.00028,-0.00028,
!    | -0.00028,-0.00028,-0.00028,-0.00028,-0.00028,
!    | -0.00028,-0.00028,-0.00028,-0.00028,-0.00028,
!    | -0.00028,-0.00028,-0.00028,-0.00028,-0.00028,
!    | -0.00028,-0.00028/)
!
!
!********************************************************
! Double Res. Data 
!********************************************************
!
#elif (NLEV==136)
!
! --------------------------------------------------------------------------
!  Tref (dayside) corresponding to COOL(DY), OMIX(DY), CO2MIX(DY)
! --------------------------------------------------------------------------
       tm1(:) = (/
     | 242.84,237.74,232.79,228.12,223.58,219.09,
     | 214.6,210.2,206.07,202.72,199.92,197.6,195.49,
     | 193.46,191.44,189.51,187.59,186.27,184.97,
     | 184.23,183.53,182.91,182.32,181.74,181.15,
     | 180.57,179.98,179.4,178.81,178.24,177.89,
     | 177.55,177.65,177.78,178.15,178.55,178.94,
     | 179.34,179.75,180.15,180.64,181.14,181.83,
     | 182.55,183.38,184.21,185.14,186.08,187.12,
     | 188.19,189.36,190.6,192.03,193.55,195.15,
     | 196.97,198.9,201.18,203.57,206.18,209.21,
     | 212.62,216.4,220.59,225.25,230.82,236.53,
     | 242.69,249.39,255.89,262.1,267.91,273.17,
     | 278.05,282.38,286.21,289.57,292.58,295.24,
     | 297.65,299.52,300.87,302.24,303.68,304.98,
     | 305.78,306.02,306.02,306.02,306.02,306.02,
     | 306.02,306.02,306.02,306.02,306.02,306.02,
     | 306.02,306.02,306.02,306.02,306.02,306.02,
     | 306.02,306.02,306.02,306.02,306.02,306.02,
     | 306.02,306.02,306.02,306.02,306.02,306.02,
     | 306.02,306.02,306.02,306.02,306.02,306.02,
     | 306.02,306.02,306.02,306.02,306.02,306.02,
     | 306.02,306.02,306.02,306.02,306.02,306.02,
     | 306.02,306.02,306.02,306.02/)

       xnod(:) = (/
     | -8.5591,-8.3779,-8.2617,-8.1916,-8.1181,
     | -8.0506,-7.9751,-7.9124,-7.8613,-7.8807,
     | -7.9570,-8.0332,-8.1172,-7.9737,-7.8282,
     | -7.4812,-7.2736,-6.9149,-6.7164,-6.3685,
     | -6.1698,-5.8550,-5.6429,-5.3504,-5.1205,
     | -4.9148,-4.7248,-4.5775,-4.4326,-4.3174,
     | -4.1739,-4.0661,-3.9686,-3.8874,-3.7991,
     | -3.7237,-3.6344,-3.5572,-3.4640,-3.3834,
     | -3.2899,-3.2101,-3.1131,-3.0305,-2.9316,
     | -2.8492,-2.7484,-2.6643,-2.5614,-2.4720,
     | -2.3719,-2.2801,-2.1819,-2.0851,-1.9907,
     | -1.8924,-1.8039,-1.7046,-1.6141,-1.5176,
     | -1.4261,-1.3414,-1.2474,-1.1602,-1.0778,
     | -0.9955,-0.9126,-0.8370,-0.7671,-0.6983,
     | -0.6351,-0.5757,-0.5183,-0.4680,-0.4188,
     | -0.3739,-0.3309,-0.2940,-0.2587,-0.2267,
     | -0.1970,-0.1710,-0.1488,-0.1288,-0.1112,
     | -0.0964,-0.0819,-0.0819,-0.0819,-0.0819,
     | -0.0819,-0.0819,-0.0819,-0.0819,-0.0819,
     | -0.0819,-0.0819,-0.0819,-0.0819,-0.0819,
     | -0.0819,-0.0819,-0.0819,-0.0819,-0.0819,
     | -0.0819,-0.0819,-0.0819,-0.0819,-0.0819,
     | -0.0819,-0.0819,-0.0819,-0.0819,-0.0819,
     | -0.0819,-0.0819,-0.0819,-0.0819,-0.0819,
     | -0.0819,-0.0819,-0.0819,-0.0819,-0.0819,
     | -0.0819,-0.0819,-0.0819,-0.0819,-0.0819,
     | -0.0819,-0.0819,-0.0819,-0.0819,-0.0819,
     | -0.0819,-0.0819/)

       xnco2d(:) = (/
     | -0.01547,-0.01547,-0.01547,-0.01547,-0.01547,
     | -0.01547,-0.01547,-0.01547,-0.01547,-0.01547,
     | -0.01547,-0.01547,-0.01547,-0.01547,-0.01547,
     | -0.01547,-0.01547,-0.01547,-0.01547,-0.01586,
     | -0.01627,-0.01657,-0.01674,-0.01695,-0.01715,
     | -0.01736,-0.01757,-0.01778,-0.01799,-0.01820,
     | -0.01841,-0.01862,-0.01863,-0.01863,-0.01883,
     | -0.01906,-0.01928,-0.01951,-0.02013,-0.02082,
     | -0.02151,-0.02219,-0.02228,-0.02228,-0.02249,
     | -0.02273,-0.02366,-0.02465,-0.02636,-0.02808,
     | -0.02980,-0.03183,-0.03468,-0.03755,-0.04045,
     | -0.04411,-0.04824,-0.05362,-0.05915,-0.06449,
     | -0.07271,-0.08360,-0.09408,-0.10647,-0.12127,
     | -0.14017,-0.15909,-0.18199,-0.21118,-0.24108,
     | -0.27550,-0.31516,-0.35518,-0.40504,-0.45734,
     | -0.51483,-0.57550,-0.64976,-0.72568,-0.80790,
     | -0.89628,-0.99570,-1.10636,-1.22421,-1.34740,
     | -1.47823,-1.61450,-1.61450,-1.61450,-1.61450,
     | -1.61450,-1.61450,-1.61450,-1.61450,-1.61450,
     | -1.61450,-1.61450,-1.61450,-1.61450,-1.61450,
     | -1.61450,-1.61450,-1.61450,-1.61450,-1.61450,
     | -1.61450,-1.61450,-1.61450,-1.61450,-1.61450,
     | -1.61450,-1.61450,-1.61450,-1.61450,-1.61450,
     | -1.61450,-1.61450,-1.61450,-1.61450,-1.61450,
     | -1.61450,-1.61450,-1.61450,-1.61450,-1.61450,
     | -1.61450,-1.61450,-1.61450,-1.61450,-1.61450,
     | -1.61450,-1.61450,-1.61450,-1.61450,-1.61450,
     | -1.61450,-1.61450/)

       cool1(:) = (/
     | -23.436,-25.102,-26.476,-27.446,-27.365,-26.837,
     | -25.171,-24.029,-24.222,-26.319,-29.777,-33.029,
     | -36.191,-37.527,-38.373,-38.756,-39.069,-41.036,
     | -43.076,-45.295,-47.527,-48.587,-49.250,-49.461,
     | -49.351,-48.974,-48.220,-47.379,-46.274,-45.331,
     | -46.086,-46.841,-50.584,-54.591,-61.021,-67.748,
     | -75.251,-82.875,-93.126,-103.843,-122.456,-142.147,
     | -177.745,-215.543,-277.437,-341.234,-442.396,
     | -546.922,
     | -705.833,-878.602,-1122.390,-1398.570,-1759.736,
     | -2162.997,-2614.603,-3115.552,-3641.958,-4188.221,
     | -4736.412,-5283.461,-5883.715,-6530.739,-7163.111,
     | -7830.653,-8534.639,-9206.159,-9663.753,-9945.460,
     | -9991.340,-9717.658,-9057.421,-8193.955,-7189.370,
     | -6118.662,-5079.329,-4108.968,-3244.927,-2492.443,
     | -1863.387,-1365.513,-973.097,-672.534,-450.961,
     | -295.586,-189.354,-117.555,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065,-71.065,-71.065,
     | -71.065,-71.065,-71.065/)
!
! --------------------------------------------------------------------------
! Nightside Reference Cooling Quantities: T(K), OMIX, CO2MIX, COOLREF(K/day)
! --------------------------------------------------------------------------
       tm2(:) = (/
     | 242.84,237.74,232.79,228.12,223.58,219.09,
     | 214.6,210.18,205.97,202.37,199.23,196.51,
     | 193.95,191.44,188.94,186.47,184.02,181.81,
     | 179.61,177.73,175.84,173.99,172.14,170.3,
     | 168.45,166.62,164.78,162.94,161.1,159.47,
     | 157.88,156.82,155.91,155.09,154.38,153.68,
     | 152.91,152.15,151.34,150.51,149.68,148.83,
     | 147.99,147.17,146.35,145.53,144.71,143.9,
     | 143.09,142.29,141.49,140.7,139.91,139.08,
     | 138.25,137.39,136.5,135.62,134.71,133.81,
     | 132.92,132.09,131.25,130.46,129.69,128.93,
     | 128.2,127.48,126.78,126.11,125.45,124.81,
     | 124.18,123.54,122.86,122.19,121.48,120.76,
     | 120.15,119.56,119.08,118.68,118.43,118.23,
     | 118.1,118.02,118.,118.07,118.25,118.54,118.92,
     | 119.43,120.12,120.91,121.91,123.02,124.05,
     | 124.93,125.75,126.6,127.46,128.16,128.68,
     | 129.37,130.34,131.21,131.77,132.,132.21,132.21,
     | 132.21,132.21,132.21,132.21,132.21,132.21,132.21,
     | 132.21,132.21,132.21,132.21,132.21,132.21,132.21,
     | 132.21,132.21,132.21,132.21,132.21,132.21,132.21,
     | 132.21,132.21,132.21,132.21,132.21,132.21/)

       xnon(:) = (/
     | -8.5591,-8.3779,-8.2617,-8.1916,-8.1181,
     | -8.0506,-7.9751,-7.9130,-7.8638,-7.8933,
     | -7.9925,-8.0788,-8.1663,-7.9571,-7.7754,
     | -7.4420,-7.2404,-6.8990,-6.7054,-6.3646,
     | -6.1760,-5.8414,-5.6500,-5.3203,-5.1266,
     | -4.9006,-4.7454,-4.5936,-4.4764,-4.3327,
     | -4.2161,-4.1059,-4.0141,-3.9346,-3.8636,
     | -3.7987,-3.7195,-3.6525,-3.5741,-3.5027,
     | -3.4297,-3.3517,-3.2841,-3.1969,-3.1244,
     | -3.0440,-2.9653,-2.8940,-2.8063,-2.7334,
     | -2.6490,-2.5683,-2.4960,-2.4055,-2.3307,
     | -2.2459,-2.1625,-2.0926,-1.9994,-1.9222,
     | -1.8435,-1.7579,-1.6863,-1.5993,-1.5196,
     | -1.4485,-1.3585,-1.2840,-1.2062,-1.1272,
     | -1.0603,-0.9751,-0.9023,-0.8311,-0.7583,
     | -0.6958,-0.6249,-0.5640,-0.4953,-0.4323,
     | -0.3779,-0.3301,-0.2809,-0.2353,-0.1952,
     | -0.1619,-0.1347,-0.1076,-0.0895,-0.0762,
     | -0.0639,-0.0550,-0.0506,-0.0459,-0.0459,
     | -0.0473,-0.0503,-0.0556,-0.0616,-0.0727,
     | -0.0860,-0.1022,-0.1231,-0.1473,-0.1797,
     | -0.2190,-0.2682,-0.3308,-0.4081,-0.4081,
     | -0.4081,-0.4081,-0.4081,-0.4081,-0.4081,
     | -0.4081,-0.4081,-0.4081,-0.4081,-0.4081,
     | -0.4081,-0.4081,-0.4081,-0.4081,-0.4081,
     | -0.4081,-0.4081,-0.4081,-0.4081,-0.4081,
     | -0.4081,-0.4081,-0.4081,-0.4081,-0.4081,
     | -0.4081,-0.4081/)

       xnco2n(:) = (/
     | -0.01547,-0.01547,-0.01547,-0.01547,-0.01547,
     | -0.01547,-0.01547,-0.01547,-0.01547,-0.01547,
     | -0.01547,-0.01547,-0.01547,-0.01547,-0.01547,
     | -0.01547,-0.01547,-0.01547,-0.01547,-0.01547,
     | -0.01547,-0.01547,-0.01547,-0.01547,-0.01547,
     | -0.01547,-0.01547,-0.01547,-0.01547,-0.01547,
     | -0.01547,-0.01577,-0.01616,-0.01655,-0.01694,
     | -0.01732,-0.01771,-0.01809,-0.01847,-0.01885,
     | -0.01923,-0.01962,-0.02001,-0.02057,-0.02113,
     | -0.02169,-0.02224,-0.02280,-0.02336,-0.02391,
     | -0.02457,-0.02530,-0.02603,-0.02676,-0.02749,
     | -0.02925,-0.03176,-0.03429,-0.03663,-0.03898,
     | -0.04194,-0.04597,-0.05004,-0.05495,-0.06020,
     | -0.06552,-0.07095,-0.07644,-0.08572,-0.09945,
     | -0.11362,-0.12746,-0.14170,-0.15958,-0.18342,
     | -0.20872,-0.24263,-0.27941,-0.31451,-0.35109,
     | -0.40667,-0.48570,-0.56087,-0.64464,-0.73734,
     | -0.84762,-0.97990,-1.09726,-1.23890,-1.39921,
     | -1.56372,-1.73525,-1.91039,-2.08506,-2.27421,
     | -2.46746,-2.66354,-2.86609,-3.07063,-3.28939,
     | -3.51691,-3.75724,-3.99388,-4.24399,-4.52334,
     | -4.82841,-5.14328,-5.50916,-5.91040,-5.91040,
     | -5.91040,-5.91040,-5.91040,-5.91040,-5.91040,
     | -5.91040,-5.91040,-5.91040,-5.91040,-5.91040,
     | -5.91040,-5.91040,-5.91040,-5.91040,-5.91040,
     | -5.91040,-5.91040,-5.91040,-5.91040,-5.91040,
     | -5.91040,-5.91040,-5.91040,-5.91040,-5.91040,
     | -5.91040,-5.91040/)

       cool2(:) = (/
     | -20.632,-23.647,-26.500,-27.490,-27.496,-27.083,
     | -25.621,-24.551,-24.483,-25.875,-28.322,-30.384,
     | -32.292,-32.665,-32.633,-31.770,-30.786,-30.037,
     | -29.299,-28.491,-27.683,-26.212,-24.710,-22.973,
     | -21.216,-19.462,-17.708,-15.987,-14.272,-13.507,
     | -12.966,-13.632,-14.631,-15.654,-16.704,-17.731,
     | -18.593,-19.455,-20.985,-22.716,-25.173,-28.828,
     | -32.521,-38.600,-44.678,-51.898,-59.960,-68.084,
     | -76.631,-85.178,-93.266,-101.096,-108.669,-114.179,
     | -119.688,-123.924,-127.239,-130.554,-131.128,-131.655,
     | -132.041,-132.182,-132.323,-131.794,-131.029,-130.066,
     | -127.268,-124.470,-121.235,-117.518,-113.801,-106.610,
     | -99.155,-90.877,-81.321,-71.759,-61.725,-51.691,
     | -42.997,-34.696,-27.468,-21.113,-16.141,-11.584,-8.377,
     | -5.664,-3.607,-2.395,-1.480,-0.871,-0.499,-0.291,
     | -0.155,-0.089,-0.048,-0.026,-0.014,-0.007,-0.003,-0.002,
     | -7.49E-04,-3.23E-04,-1.41E-04,-6.00E-05,-2.13E-05,
     | -7.99E-06,-2.89E-04,-1.09E-03,-5.58E-04,
     | -5.58E-04,-5.58E-04,-5.58E-04,-5.58E-04,-5.58E-04,
     | -5.58E-04,-5.58E-04,-5.58E-04,-5.58E-04,-5.58E-04,
     | -5.58E-04,-5.58E-04,-5.58E-04,-5.58E-04,-5.58E-04,
     | -5.58E-04,-5.58E-04,-5.58E-04,-5.58E-04,-5.58E-04,
     | -5.58E-04,-5.58E-04,-5.58E-04,-5.58E-04,-5.58E-04,
     | -5.58E-04,-5.58E-04,-5.58E-04/)



#else
 write(6,"('ERROR: unsupported NLEV = ',i6)") nlev
#endif

!*************************************************************
! Check for dres or res; if dres then interpolate
!
!#if (NLEV==68)
!      do j = 1,9
!        tm1(:) = tm1(:)
!        xnod(:) = xnod(:)
!        xnco2d(:) = xnco2d(:)
!        cool1(:) = cool1(:)
!        tm2(:) = tm2(:)
!        xnon(:) = xnon(:)
!        xnco2n(:) = xnco2n(:)
!        cool2(:) = cool2(:)
!      enddo
!#elif (NLEV==136)
!      count = 1
!      tm1(1) = tm1(1)
!      xnod(1) = xnod(1)
!      xnco2d(1) = xnco2d(1)
!      cool1(1) = cool1(1)
!      tm2(1) = tm2(1)
!      xnon(1) = xnon(1)
!      xnco2n(1) = xnco2n(1)
!      cool2(1) = cool2(1)
!      do i = 2,69
!        count = count+1
!        tm1(count) = (tm1(i-1)+tm1(i))/2.
!        tm1(count+1) = tm1(i)
!        xnod(count) = (xnod(i-1)+xnod(i))/2.
!        xnod(count+1) = xnod(i)
!        xnco2d(count) = (xnco2d(i-1)+xnco2d(i))/2.
!        xnco2d(count+1) = xnco2d(i)
!        cool1(count) = (cool1(i-1)+cool1(i))/2.
!        cool1(count+1) = cool1(i)
!        tm2(count) = (tm2(i-1)+tm2(i))/2.
!        tm2(count+1) = tm2(i)
!        xnon(count) = (xnon(i-1)+xnon(i))/2.
!        xnon(count+1) = xnon(i)
!        xnco2n(count) = (xnco2n(i-1)+xnco2n(i))/2.
!        xnco2n(count+1) = xnco2n(i)
!        cool2(count) = (cool2(i-1)+cool2(i))/2.
!        cool2(count+1) = cool2(i)
!        count = count+1
!      enddo
!#else
! write(6,"('ERROR: unsupported NLEV = ',i6)") nlev
!#endif
!*************************************************************
!
! Calculate aday, anight and mid-level reference quantities:
      call lincoeff
!
      end subroutine coolref_init
!-----------------------------------------------------------------------
      subroutine lincoeff
      use params_module,only: dz,zibot
      implicit none
!
! Local:
      integer :: k
      real :: roco2,roco2m,xxx,efd,efn,gee,efnm,facm,fden,stm,drate2
      real :: szp(nlevp1)
! ------------------------------------------------------------------------
! Shift tm1,tm2, cool1, cool2 and all VMR by 1/2 level: midlevels for dt.F
! -- Convert cool from Roldan K/day to K/sec (dayside & nightside)
! -- Convert VMR from Roldan log10 to straight units 
! -- What sign should cool1a and cool2a be to fit the sub cool usage?
! -- Scale cool1a rates to force thermal balance near z = -8.5 to -4.0
!    (step prior to refinement of coolexp formulation)
! ------------------------------------------------------------------------
      do k=1,nlevp1-1
        tm1a(k) = .5*(tm1(k)+tm1(k+1))
        tm2a(k) = .5*(tm2(k)+tm2(k+1))
	cool1a(k) = 0.5*(cool1(k)+cool1(k+1))/86400.
	cool2a(k) = 0.5*(cool2(k)+cool2(k+1))/86400.
        xnod(k) = .5*(xnod(k)+xnod(k+1))
        xnon(k) = .5*(xnon(k)+xnon(k+1))
        xnco2d(k) = .5*(xnco2d(k)+xnco2d(k+1))
        xnco2n(k) = .5*(xnco2n(k)+xnco2n(k+1))
      enddo
      tm1a(nlevp1) = tm1a(nlevp1-1)
      tm2a(nlevp1) = tm2a(nlevp1-1)
      cool1a(nlevp1) =  cool1a(nlevp1-1)
      cool2a(nlevp1) =  cool2a(nlevp1-1)
      xnod(nlevp1) = xnod(nlevp1-1)
      xnon(nlevp1) = xnon(nlevp1-1)
      xnco2d(nlevp1) = xnco2d(nlevp1-1)
      xnco2n(nlevp1) = xnco2n(nlevp1-1)
      do k=1,nlevp1
        szp(k) = zibot + .5*dz + (k-1)*dz
	xnod(k) = 10.**(xnod(K))
	xnon(k) = 10.**(xnon(K))
	xnco2d(k) = 10.**(xnco2d(K))
	xnco2n(k) = 10.**(xnco2n(K))
      enddo
! ---------------------------------------------------------------------------
! Modify cool1a (day) to provide 20-90% enhancement over z = -10 to -2 to force
!     stronger CO2 cooling in region of enhanced 4.3 um QIR heating
!     after Roldan et al., (2000).  Temporary fix to heat balance problem
!     near 110-130 km (SZA = 60). Best to date (8/19/07). S. W. Bougher
! (07/27/11) Correction factor(1.3) applied in dt.F for calculated 
!     O depletion compared to reference O [provides 30% enhancement]
!     ZP = -10.0 to -8.5
!      cool1a(13) = cool1a(13)*1.25
!      cool1a(14) = cool1a(14)*1.70
!!     cool1a(14) = cool1a(70)*5.70
!      cool1a(15) = cool1a(15)*1.85
!!     cool1a(15) = cool1a(70)*5.85
!!     ZP = -8.5 to -4
!      do k=16,25
!!	    cool1a(k) = cool1a(k)*1.90
!!	    cool1a(k) = cool1a(k)*1.95
!!	    cool1a(k) = cool1a(k)*2.05
!!	    cool1a(k) = cool1a(k)*2.15
!!!	    cool1a(k) = cool1a(k)*2.45
!  	    cool1a(k) = cool1a(k)*1.30
!! 	    cool1a(k) = cool1a(k)*6.45
!      enddo
!!     ZP = -3.5 to -2
!!     cool1a(26) = cool1a(26)*1.65
!!     cool1a(26) = cool1a(26)*1.75
!!     cool1a(26) = cool1a(26)*1.95
!!     cool1a(26) = cool1a(26)*2.05
!!     cool1a(26) = cool1a(26)*2.35
!!!    cool1a(26) = cool1a(26)*2.25
!      cool1a(26) = cool1a(26)*1.30
!!     cool1a(26) = cool1a(26)*2.40
!!!    cool1a(27) = cool1a(26)*1.50
!      cool1a(27) = cool1a(27)*1.30
!!!    cool1a(28) = cool1a(26)*1.35
!      cool1a(28) = cool1a(28)*1.30
!!!    cool1a(29) = cool1a(26)*1.20
!      cool1a(29) = cool1a(29)*1.30
!********************************************************
#if (NLEV==68)
       cool1a(20) = cool1a(20)*1.10
!!     ZP = -6 to -3.5
       do k=21,25
   	    cool1a(k) = cool1a(k)*1.40
       enddo
!!     ZP = -3.5 to -2
       cool1a(26) = cool1a(26)*1.20
       cool1a(27) = cool1a(27)*1.10

!********************************************************
! Double Res. Data 
!********************************************************
#elif (NLEV==136)
       cool1a(20) = cool1a(20)*1.10
!!     ZP = -6 to -3.5
       do k=21,25
   	    cool1a(k) = cool1a(k)*1.40
       enddo
!!     ZP = -3.5 to -2
       cool1a(26) = cool1a(26)*1.20
       cool1a(27) = cool1a(27)*1.10
!********************************************************
!!     ZP = -8.5 to -4
       do k=31,49
   	    cool1a(k) = cool1a(k)*2.45
       enddo
!!     ZP = -3.5 to -2
       cool1a(51) = cool1a(51)*2.25
       cool1a(52) = cool1a(51)*1.50
       cool1a(53) = cool1a(51)*1.35
       cool1a(54) = cool1a(51)*1.20
       cool1a(55) = cool1a(51)*1.20
       cool1a(56) = cool1a(51)*1.20
       cool1a(57) = cool1a(51)*1.20
#else
 write(6,"('ERROR: unsupported NLEV = ',i6)") nlev
#endif
! ---------------------------------------------------------------------------
! 9/20/06 btf: The next 2 k-loops are taken from old vtgcm code
!              (/home/tgcm/vtgcm/src.1996/start.f) 
! 10/31/06 swb:  Checked new code with vtgcm2 code. Looks fine.
!
C     ***************************************************************
C     DAYSIDE LIN COEFF CALC
C     ***************************************************************
      do k=1,nlevp1                                  ! DO 261 in start.f
        roco2m = coolk*sqrt(tm1a(k))/(5.2e-15*(1.+2.e-3*
     |    (tm1a(k)-220.))*(tm1a(k)/273.3))
        efd = exp(szp(k)+1.5)*((xnco2d(k)+xnod(k))/(xnco2d(k)+xnod(k)*
     |    roco2m))
        efnm = efd
        facm = (1.+efd)/(1.+efnm)
        fden = ((1.+2.e-3*(tm1a(k)-220.))*(tm1a(k)/273.3))
        stm = sqrt(tm1a(k))
        drate2 = (coolk/5.2e-15)*(1./(2.*stm*fden)-(stm/273.3)*
     |    (1.+2.e-3*(2.*tm1a(k)-220.))/fden**2.)
        aday(k) = facm*cool1a(k)*((960./tm1a(k)**2)-     ! AD(K))
     |    (efnm/(1.+efnm))*(40.6/(3.*tm1a(k)**4./3.)+
     |    xnod(k)/(xnco2d(k)+xnod(k)*roco2m)*drate2))
      enddo ! k=1,nlevp1
      write(6,"('lincoeff: aday=',/,(6e12.4))") aday
C     ***************************************************************
C     NIGHTSIDE LIN C0EFF
C     ***************************************************************
      do k=1,nlevp1                                  ! DO 263 in start.f
        roco2m = coolk*sqrt(tm2a(k))/(5.2e-15*(1.+2.e-3*
     |    (tm2a(k)-220.))*(tm2a(k)/273.3))
        efd = exp(szp(k)+1.5)*((xnco2n(k)+xnon(k))/(xnco2n(k)+xnon(k)*
     |    roco2m))
        efnm = efd
        facm = (1.+efd)/(1.+efnm)
        fden = ((1.+2.e-3*(tm2a(k)-220.))*(tm2a(k)/273.3))
        stm = sqrt(tm2a(k))
        drate2 = (coolk/5.2e-15)*(1./(2.*stm*fden)-(stm/273.3)*
     |    (1.+2.e-3*(2.*tm2a(k)-220.))/fden**2.)
        anight(k) = facm*cool2a(k)*((960./tm2a(k)**2)-   ! AN(K))
     |    (efnm/(1.+efnm))*(40.6/(3.*tm2a(k)**4./3.)+
     |    xnon(k)/(xnco2n(k)+xnon(k)*roco2m)*drate2))
      enddo ! k=1,nlevp1
      write(6,"('lincoeff: anight=',/,(6e12.4))") anight
      end subroutine lincoeff
!-----------------------------------------------------------------------
      end module coolref_init_module
! -------------------------------------------------------------
