<p><b>laura@ucar.edu</b> 2011-09-28 17:30:51 -0600 (Wed, 28 Sep 2011)</p><p>added the CAM radiation code to core_physics<br>
</p><hr noshade><pre><font color="gray">Modified: branches/atmos_physics/src/core_physics/Makefile
===================================================================
--- branches/atmos_physics/src/core_physics/Makefile        2011-09-28 23:26:28 UTC (rev 1039)
+++ branches/atmos_physics/src/core_physics/Makefile        2011-09-28 23:30:51 UTC (rev 1040)
@@ -83,18 +83,22 @@
         ./physics_wrf/module_bl_ysu.o
 
 module_driver_radiation_lw.o: \
+        module_driver_radiation_sw.o          \
         module_physics_constants.o            \
+        module_physics_manager.o              \
+        module_physics_ra_caminit.o           \
         module_physics_rrtmg_lwinit.o         \
-        module_physics_ra_caminit.o           \
         module_physics_vars.o                 \
+        ./physics_wrf/module_ra_cam.o         \
         ./physics_wrf/module_ra_rrtmg_lw.o
 
 module_driver_radiation_sw.o: \
+        module_physics_constants.o            \
         module_physics_manager.o              \
-        module_physics_constants.o            \
         module_physics_ra_caminit.o           \
         module_physics_rrtmg_swinit.o         \
         module_physics_vars.o                 \
+        ./physics_wrf/module_ra_cam.o         \
         ./physics_wrf/module_ra_rrtmg_sw.o
 
 module_driver_sfclayer.o: \

Modified: branches/atmos_physics/src/core_physics/module_driver_radiation_lw.F
===================================================================
--- branches/atmos_physics/src/core_physics/module_driver_radiation_lw.F        2011-09-28 23:26:28 UTC (rev 1039)
+++ branches/atmos_physics/src/core_physics/module_driver_radiation_lw.F        2011-09-28 23:30:51 UTC (rev 1040)
@@ -1,13 +1,17 @@
 !=============================================================================================
  module module_driver_radiation_lw
  use grid_types
+ use timer
 
+ use module_driver_radiation_sw, only: radconst
  use module_physics_constants
+ use module_physics_manager, only: gmt,curr_julday,julday,year
  use module_physics_ra_caminit
  use module_physics_rrtmg_lwinit
  use module_physics_vars
 
 !from wrf physics:
+ use module_ra_cam
  use module_ra_rrtmg_lw
 
  implicit none
@@ -17,7 +21,7 @@
           driver_radiation_lw,     &amp;
           init_radiation_lw
 
- integer,private:: i,j,k
+ integer,private:: i,j,k,n
 
  contains
 
@@ -46,13 +50,59 @@
  if(.not.allocated(lwuptc_p)     ) allocate(lwuptc_p(ims:ime,jms:jme)             )
  if(.not.allocated(olrtoa_p)     ) allocate(olrtoa_p(ims:ime,jms:jme)             )
 
- if(.not.allocated(lwdnflx_p)    ) allocate(lwdnflx_p(ims:ime,kms:kme+1,jms:jme)  )
- if(.not.allocated(lwdnflxc_p)   ) allocate(lwdnflxc_p(ims:ime,kms:kme+1,jms:jme) )
- if(.not.allocated(lwupflx_p)    ) allocate(lwupflx_p(ims:ime,kms:kme+1,jms:jme)  )
- if(.not.allocated(lwupflxc_p)   ) allocate(lwupflxc_p(ims:ime,kms:kme+1,jms:jme) )

  if(.not.allocated(rthratenlw_p) ) allocate(rthratenlw_p(ims:ime,kms:kme,jms:jme) )
 
+ radiation_lw_select: select case (trim(radt_lw_scheme))
+
+    case(&quot;rrtmg_lw&quot;)
+       if(.not.allocated(lwdnflx_p)    ) allocate(lwdnflx_p(ims:ime,kms:kme+1,jms:jme)  )
+       if(.not.allocated(lwdnflxc_p)   ) allocate(lwdnflxc_p(ims:ime,kms:kme+1,jms:jme) )
+       if(.not.allocated(lwupflx_p)    ) allocate(lwupflx_p(ims:ime,kms:kme+1,jms:jme)  )
+       if(.not.allocated(lwupflxc_p)   ) allocate(lwupflxc_p(ims:ime,kms:kme+1,jms:jme) )
+
+    case(&quot;cam_lw&quot;)
+       if(.not.allocated(xlat_p)       ) allocate(xlat_p(ims:ime,jms:jme)               )
+       if(.not.allocated(xlon_p)       ) allocate(xlon_p(ims:ime,jms:jme)               )
+       if(.not.allocated(gsw_p)        ) allocate(gsw_p(ims:ime,jms:jme)                )
+       if(.not.allocated(swcf_p)       ) allocate(swcf_p(ims:ime,jms:jme)               )
+       if(.not.allocated(swdnb_p)      ) allocate(swdnb_p(ims:ime,jms:jme)              )
+       if(.not.allocated(swdnbc_p)     ) allocate(swdnbc_p(ims:ime,jms:jme)             )
+       if(.not.allocated(swdnt_p)      ) allocate(swdnt_p(ims:ime,jms:jme)              )
+       if(.not.allocated(swdntc_p)     ) allocate(swdntc_p(ims:ime,jms:jme)             )
+       if(.not.allocated(swupb_p)      ) allocate(swupb_p(ims:ime,jms:jme)              )
+       if(.not.allocated(swupbc_p)     ) allocate(swupbc_p(ims:ime,jms:jme)             )
+       if(.not.allocated(swupt_p)      ) allocate(swupt_p(ims:ime,jms:jme)              )
+       if(.not.allocated(swuptc_p)     ) allocate(swuptc_p(ims:ime,jms:jme)             )
+       if(.not.allocated(coszr_p)      ) allocate(coszr_p(ims:ime,jms:jme)              )
+       if(.not.allocated(sfc_albedo_p) ) allocate(sfc_albedo_p(ims:ime,jms:jme)         )
+       if(.not.allocated(rthratensw_p) ) allocate(rthratensw_p(ims:ime,kms:kme,jms:jme) )
+
+       if(.not.allocated(cemiss_p)     ) allocate(cemiss_p(ims:ime,kms:kme,jms:jme)     )
+       if(.not.allocated(taucldc_p)    ) allocate(taucldc_p(ims:ime,kms:kme,jms:jme)    )
+       if(.not.allocated(taucldi_p)    ) allocate(taucldi_p(ims:ime,kms:kme,jms:jme)    )
+
+       if(.not.allocated(pin_p)        ) allocate(pin_p(num_oznlevels)                  )
+       if(.not.allocated(ozmixm_p) ) &amp;
+          allocate(ozmixm_p(ims:ime,1:num_oznlevels,jms:jme,num_months) )
+       
+       if(.not.allocated(m_hybi_p)     ) allocate(m_hybi_p(num_aerlevels)               )
+       if(.not.allocated(m_psn_p)      ) allocate(m_psn_p(ims:ime,jms:jme)              )
+       if(.not.allocated(m_psp_p)      ) allocate(m_psp_p(ims:ime,jms:jme)              )
+       if(.not.allocated(aerosolcn_p)  ) &amp;
+          allocate(aerosolcn_p(ims:ime,1:num_aerlevels,jms:jme,num_aerosols) )
+       if(.not.allocated(aerosolcp_p)  ) &amp;
+          allocate(aerosolcp_p(ims:ime,1:num_aerlevels,jms:jme,num_aerosols) )
+
+       if(.not.allocated(emstot_p) ) allocate(emstot_p(ims:ime,kms:kme,jms:jme) )
+       if(.not.allocated(abstot_p) ) &amp;
+          allocate(abstot_p(ims:ime,kms:kme,cam_abs_dim2,jms:jme) )
+       if(.not.allocated(absnxt_p) ) &amp;
+          allocate(absnxt_p(ims:ime,kms:kme,cam_abs_dim1,jms:jme) )
+
+    case default
+
+ end select radiation_lw_select
+
  end subroutine allocate_radiation_lw
 
 !=============================================================================================
@@ -76,21 +126,66 @@
  if(allocated(lwupbc_p)     ) deallocate(lwupbc_p     )
  if(allocated(lwupt_p)      ) deallocate(lwupt_p      )
  if(allocated(lwuptc_p)     ) deallocate(lwuptc_p     )
- if(allocated(lwdnflx_p)    ) deallocate(lwdnflx_p    )
- if(allocated(lwdnflxc_p)   ) deallocate(lwdnflxc_p   )
- if(allocated(lwupflx_p)    ) deallocate(lwupflx_p    )
- if(allocated(lwupflxc_p)   ) deallocate(lwupflxc_p   )
  if(allocated(olrtoa_p)     ) deallocate(olrtoa_p     )
  
  if(allocated(rthratenlw_p) ) deallocate(rthratenlw_p )
 
+ radiation_lw_select: select case (trim(radt_lw_scheme))
+
+    case(&quot;rrtmg_lw&quot;)
+       if(allocated(lwdnflx_p)    ) deallocate(lwdnflx_p    )
+       if(allocated(lwdnflxc_p)   ) deallocate(lwdnflxc_p   )
+       if(allocated(lwupflx_p)    ) deallocate(lwupflx_p    )
+       if(allocated(lwupflxc_p)   ) deallocate(lwupflxc_p   )
+
+    case(&quot;cam_lw&quot;)
+       if(allocated(pin_p)        ) deallocate(pin_p        )
+       if(allocated(m_hybi_p)     ) deallocate(m_hybi_p     )          
+
+       if(allocated(xlat_p)       ) deallocate(xlat_p       )
+       if(allocated(xlon_p)       ) deallocate(xlon_p       )
+
+       if(allocated(gsw_p)        ) deallocate(gsw_p        )
+       if(allocated(swcf_p)       ) deallocate(swcf_p       )
+       if(allocated(swdnb_p)      ) deallocate(swdnb_p      )
+       if(allocated(swdnbc_p)     ) deallocate(swdnbc_p     )
+       if(allocated(swdnt_p)      ) deallocate(swdnt_p      )
+       if(allocated(swdntc_p)     ) deallocate(swdntc_p     )
+       if(allocated(swupb_p)      ) deallocate(swupb_p      )
+       if(allocated(swupbc_p)     ) deallocate(swupbc_p     )
+       if(allocated(swupt_p)      ) deallocate(swupt_p      )
+       if(allocated(swuptc_p)     ) deallocate(swuptc_p     )
+       if(allocated(coszr_p)      ) deallocate(coszr_p      )
+       if(allocated(sfc_albedo_p) ) deallocate(sfc_albedo_p )
+       if(allocated(rthratensw_p) ) deallocate(rthratensw_p )
+
+       if(allocated(cemiss_p)     ) deallocate(cemiss_p     )
+       if(allocated(ozmixm_p)     ) deallocate(ozmixm_p     )
+       if(allocated(taucldc_p)    ) deallocate(taucldc_p    )
+       if(allocated(taucldi_p)    ) deallocate(taucldi_p    )
+       
+       if(allocated(m_psn_p)      ) deallocate(m_psn_p      )
+       if(allocated(m_psp_p)      ) deallocate(m_psp_p      )
+       if(allocated(aerosolcn_p)  ) deallocate(aerosolcn_p  )
+       if(allocated(aerosolcp_p)  ) deallocate(aerosolcp_p  )
+
+       if(allocated(abstot_p)     ) deallocate(abstot_p     )
+       if(allocated(absnxt_p)     ) deallocate(absnxt_p     )
+       if(allocated(emstot_p)     ) deallocate(emstot_p     )
+
+    case default
+
+ end select radiation_lw_select
+
  end subroutine deallocate_radiation_lw
 
 !=============================================================================================
- subroutine radiation_lw_from_MPAS(diag_physics,sfc_input)
+ subroutine radiation_lw_from_MPAS(mesh,state,diag_physics,sfc_input)
 !=============================================================================================
 
 !input arguments:
+ type(mesh_type),intent(in) :: mesh
+ type(state_type),intent(in):: state
  type(sfc_input_type)   ,intent(in):: sfc_input
  type(diag_physics_type),intent(in):: diag_physics
 
@@ -102,7 +197,7 @@
     tsk_p(i,j)       = sfc_input % skintemp % array(i)
     snow_p(i,j)      = sfc_input % snow     % array(i)
     xice_p(i,j)      = sfc_input % xice     % array(i)
-    xland_p(i,j)     = sfc_input % xland     % array(i)
+    xland_p(i,j)     = sfc_input % xland    % array(i)
  enddo
  enddo
  do j = jts,jte
@@ -116,6 +211,13 @@
 !initialization:
  do j = jts,jte
  do i = its,ite
+    f_ice(i,j) = 0.
+    f_rain(i,j) = 0.
+ enddo
+ enddo
+
+ do j = jts,jte
+ do i = its,ite
     glw_p(i,j)      = 0.
     lwcf_p(i,j)     = 0.
     lwdnb_p(i,j)    = 0.
@@ -129,15 +231,6 @@
     olrtoa_p(i,j)   = 0.
  enddo
  
- do k = kts,kte+2
- do i = its,ite
-    lwdnflx_p(i,k,j)  = 0.
-    lwdnflxc_p(i,k,j) = 0.
-    lwupflx_p(i,k,j)  = 0.
-    lwupflxc_p(i,k,j) = 0.
- enddo
- enddo
-
  do k = kts,kte
  do i = its,ite
     rthratenlw_p(i,k,j) = 0.
@@ -145,6 +238,130 @@
  enddo
  enddo
 
+ radiation_lw_select: select case (trim(radt_lw_scheme))
+
+    case(&quot;rrtmg_lw&quot;)
+       do j = jts,jte
+       do k = kts,kte+2
+       do i = its,ite
+          lwdnflx_p(i,k,j)  = 0.
+          lwdnflxc_p(i,k,j) = 0.
+          lwupflx_p(i,k,j)  = 0.
+          lwupflxc_p(i,k,j) = 0.
+       enddo
+       enddo
+       enddo
+
+    case(&quot;cam_lw&quot;)
+       do j = jts,jte
+       do i = its,ite
+          xlat_p(i,j) = (mesh % latCell % array(i)) / degrad
+          xlon_p(i,j) = (mesh % lonCell % array(i)) / degrad
+          sfc_albedo_p(i,j) = diag_physics % sfc_albedo % array(i)
+
+          coszr_p(i,j)      = 0.
+          gsw_p(i,j)        = 0.
+          swcf_p(i,j)       = 0.
+          swdnb_p(i,j)      = 0.
+          swdnbc_p(i,j)     = 0.
+          swdnt_p(i,j)      = 0.
+          swdntc_p(i,j)     = 0.
+          swupb_p(i,j)      = 0.
+          swupbc_p(i,j)     = 0.
+          swupt_p(i,j)      = 0.
+          swuptc_p(i,j)     = 0.
+       enddo
+       do k = kts,kte
+       do i = its,ite
+          rthratensw_p(i,k,j) = 0.
+          cemiss_p(i,k,j)     = 0.
+          taucldc_p(i,k,j)    = 0.
+          taucldi_p(i,k,j)    = 0.
+       enddo
+       enddo
+       enddo
+
+       call timer_start(&quot;CAM lw: read arrays for infrared absorption&quot;)
+       !infrared absorption:
+       do j = jts,jte
+       do n = 1,cam_abs_dim1
+       do k = kts,kte
+       do i = its,ite
+          absnxt_p(i,k,n,j) = diag_physics % absnxt % array(k,n,i)
+       enddo
+       enddo
+       enddo
+       do n = 1,cam_abs_dim2
+       do k = kts,kte+1
+       do i = its,ite
+          abstot_p(i,k,n,j) = diag_physics % abstot % array(k,n,i)
+       enddo
+       enddo
+       enddo
+       do k = kts,kte+1
+       do i = its,ite
+          emstot_p(i,k,j) = diag_physics % emstot % array(k,i)
+       enddo
+       enddo
+       enddo
+       call timer_stop(&quot;CAM lw: read arrays for infrared absorption&quot;)
+!      write(0,*) '--- end radiation_lw_from_MPAS: doabsems=',doabsems
+!      do k = kts,kte+1
+!         write(0,102) k,(maxval(abstot_p(its:ite,k,n,jts:jte)),n=1,10)
+!      enddo
+!      write(0,*)
+!      do k = kts,kte
+!         write(0,102) k,(maxval(absnxt_p(its:ite,k,n,jts:jte)),n=1,cam_abs_dim1)
+!      enddo
+!      write(0,*)
+!      do k = kts,kte+1
+!         write(0,102) k,maxval(emstot_p(its:ite,k,jts:jte))
+!      enddo
+
+       call timer_start(&quot;CAM lw: ozone and aerosols&quot;)
+       !ozone mixing ratio:
+       do k = 1, num_oznlevels
+          pin_p(k) = mesh % pin % array(k,1)
+       enddo
+       do n = 1, num_months
+          do j = jts,jte
+          do k = 1, num_oznlevels
+          do i = its,ite
+             ozmixm_p(i,k,j,n) = mesh % ozmixm % array(n,k,i)
+          enddo
+          enddo
+          enddo
+       enddo
+       !aerosol mixing ratio:
+       do k = 1, num_aerlevels
+          m_hybi_p(k) = mesh % m_hybi % array(k,1)
+       enddo
+       do i = its,ite
+       do j = jts,jte
+          m_psp_p(i,j) = state % m_ps % array(i)
+          m_psn_p(i,j) = state % m_ps % array(i)
+       enddo
+       enddo
+       do n = 1,num_aerosols
+       do j = jts,jte
+       do k = 1, num_aerlevels
+       do i = its,ite
+          aerosolcp_p(i,k,j,n) = state % aerosols % array(n,k,i)
+          aerosolcn_p(i,k,j,n) = state % aerosols % array(n,k,i)
+       enddo
+       enddo
+       enddo
+       enddo
+       call timer_stop(&quot;CAM lw: ozone and aerosols&quot;)
+
+    case default
+
+ end select radiation_lw_select
+
+!format:
+ 101 format(i3,2i6,12(1x,e15.8))
+ 102 format(i6,12(1x,e15.8))
+
  end subroutine radiation_lw_from_MPAS
 
 !=============================================================================================
@@ -188,6 +405,52 @@
  enddo
  enddo
 
+ radiation_lw_select: select case (trim(radt_lw_scheme))
+
+    case(&quot;cam_lw&quot;)
+       !infrared absorption:
+       do j = jts,jte
+       do n = 1,cam_abs_dim1
+       do k = kts,kte
+       do i = its,ite
+          diag_physics % absnxt % array(k,n,i) = absnxt_p(i,k,n,j)
+       enddo
+       enddo
+       enddo
+       do n = 1,cam_abs_dim2
+       do k = kts,kte+1
+       do i = its,ite
+          diag_physics % abstot % array(k,n,i) = abstot_p(i,k,n,j)
+       enddo
+       enddo
+       enddo
+       do k = kts,kte+1
+       do i = its,ite
+          diag_physics % emstot % array(k,i) = emstot_p(i,k,j)
+       enddo
+       enddo
+       enddo
+!      write(0,*) '--- end radiation_lw_to_MPAS: doabsems=',doabsems
+!      do k = kts,kte+1
+!         write(0,102) k,(maxval(abstot_p(its:ite,k,n,jts:jte)),n=1,10)
+!      enddo
+!      write(0,*)
+!      do k = kts,kte
+!        write(0,102) k,(maxval(absnxt_p(its:ite,k,n,jts:jte)),n=1,cam_abs_dim1)
+!      enddo
+!      write(0,*)
+!      do k = kts,kte+1
+!         write(0,102) k,maxval(emstot_p(its:ite,k,jts:jte))
+!      enddo
+
+    case default
+
+ end select radiation_lw_select
+
+!format:
+ 101 format(i3,2i6,12(1x,e15.8))
+ 102 format(i6,12(1x,e15.8))
+
  end subroutine radiation_lw_to_MPAS
 
 !=============================================================================================
@@ -225,18 +488,26 @@
  end subroutine init_radiation_lw
 
 !=============================================================================================
- subroutine driver_radiation_lw(itimestep,diag_physics,sfc_input,tend_physics)
+ subroutine driver_radiation_lw(itimestep,mesh,state,diag_physics,sfc_input, &amp;
+                                tend_physics,xtime_s)
 !=============================================================================================
 
 !input arguments:
  integer,intent(in):: itimestep
+ type(mesh_type),intent(in) :: mesh
+ real(kind=RKIND),intent(in):: xtime_s
 
 !inout arguments:
+ type(state_type)       ,intent(inout):: state
  type(diag_physics_type),intent(inout):: diag_physics
  type(sfc_input_type)   ,intent(inout):: sfc_input
  type(tend_physics_type),intent(inout):: tend_physics
 
+!local variables:
+ real(kind=RKIND):: radt,xtime_m
+
 !---------------------------------------------------------------------------------------------
+ call timer_start(&quot;radiation_lw&quot;)
  write(0,100) itimestep
 
 !formats:
@@ -244,7 +515,7 @@
  101 format(i8,12(1x,e15.8))
 
 !copy all MPAS arrays to rectangular grid:
- call radiation_lw_from_MPAS(diag_physics,sfc_input)
+ call radiation_lw_from_MPAS(mesh,state,diag_physics,sfc_input)
 
 !call to longwave radiation scheme:
  radiation_lw_select: select case (trim(radt_lw_scheme))
@@ -279,6 +550,77 @@
                        )
        write(0,*) '--- exit subroutine rrtmg_lwrad'
 
+    case (&quot;cam_lw&quot;)
+       xtime_m = xtime_s/60.
+
+       !... calculates solar declination:
+       call radconst(declin,solcon,curr_julday,degrad,dpd)
+
+!... convert the radiation time_step to minutes:
+       radt = dt_radtlw/60.
+
+       call timer_start(&quot;camrad&quot;)
+       call camrad( dolw = .true. , dosw = .false. ,                                         &amp;
+                rthratenlw    = rthratenlw_p  , rthratensw    = rthratensw_p  ,              &amp;
+                swupt         = swupt_p       , swuptc        = swuptc_p      ,              &amp;
+                swdnt         = swdnt_p       , swdntc        = swdntc_p      ,              &amp;
+                lwupt         = lwupt_p       , lwuptc        = lwuptc_p      ,              &amp;
+                lwdnt         = lwdnt_p       , lwdntc        = lwdntc_p      ,              &amp;
+                swupb         = swupb_p       , swupbc        = swupbc_p      ,              &amp;
+                swdnb         = swdnb_p       , swdnbc        = swdnbc_p      ,              &amp;
+                lwupb         = lwupb_p       , lwupbc        = lwupbc_p      ,              &amp;
+                lwdnb         = lwdnb_p       , lwdnbc        = lwdnbc_p      ,              &amp;
+                swcf          = swcf_p        , lwcf          = lwcf_p        ,              &amp;
+                gsw           = gsw_p         , glw           = glw_p         ,              &amp;
+                olr           = olrtoa_p      , cemiss        = cemiss_p      ,              &amp;
+                taucldc       = taucldc_p     , taucldi       = taucldi_p     ,              &amp; 
+                coszr         = coszr_p       , albedo        = sfc_albedo_p  ,              &amp; 
+                emiss         = sfc_emiss_p   , tsk           = tsk_p         ,              &amp; 
+                xlat          = xlat_p        , xlong         = xlon_p        ,              &amp;
+                t_phy         = t_p           , pi_phy        = pi_p          ,              &amp;
+                p_phy         = pres_p        , p8w           = pres2_p       ,              &amp;
+                z             = z_p           , dz8w          = dz_p          ,              &amp;            
+                rho_phy       = rho_p         , qv3d          = qv_p          ,              &amp; 
+                qc3d          = qc_p          , qr3d          = qr_p          ,              &amp;
+                qi3d          = qi_p          , qs3d          = qs_p          ,              &amp;
+                qg3d          = qg_p          , f_qv          = f_qv          ,              &amp;
+                f_qc          = f_qc          , f_qr          = f_qr          ,              &amp;
+                f_qi          = f_qi          , f_qs          = f_qs          ,              &amp;
+                f_qg          = f_qg          , f_ice_phy     = f_ice         ,              &amp;
+                f_rain_phy    = f_rain        , cldfra        = cldfrac_p     ,              &amp;
+                xland         = xland_p       , xice          = xice_p        ,              &amp;
+                num_months    = num_months    , levsiz        = num_oznlevels ,              &amp; 
+                pin0          = pin_p         , ozmixm        = ozmixm_p      ,              &amp;
+                paerlev       = num_aerlevels , naer_c        = num_aerosols  ,              &amp;
+                m_psp         = m_psp_p       , m_psn         = m_psn_p       ,              &amp;
+                aerosolcp     = aerosolcp_p   , aerosolcn     = aerosolcn_p   ,              &amp;
+                m_hybi0       = m_hybi_p      , snow          = snow_p        ,              &amp;
+                cam_abs_dim1  = cam_abs_dim1  , cam_abs_dim2  = cam_abs_dim2  ,              &amp;
+                gmt           = gmt           , yr            = year          ,              &amp;
+                julday        = julday        , julian        = curr_julday   ,              &amp;
+                dt            = dt_dyn        , xtime         = xtime_m       ,              &amp;
+                declin        = declin        , solcon        = solcon        ,              &amp;
+                radt          = radt          , degrad        = degrad        ,              &amp;
+                n_cldadv      = 3             , abstot_3d     = abstot_p      ,              &amp;
+                absnxt_3d     = absnxt_p      , emstot_3d     = emstot_p      ,              &amp;
+                doabsems      = doabsems      ,                                              &amp;
+                ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,      &amp;
+                ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,      &amp;
+                its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte        &amp;
+                  )
+       call timer_stop(&quot;camrad&quot;)
+       write(0,*) '--- end subroutince camrad lw: doabsems=',doabsems
+       write(0,*) 'max lwupb      =',maxval(lwupb_p(its:ite,jms:jme))
+       write(0,*) 'min lwupb      =',minval(lwupb_p(its:ite,jms:jme))
+       write(0,*) 'max lwupbc     =',maxval(lwupbc_p(its:ite,jms:jme))
+       write(0,*) 'min lwupbc     =',minval(lwupbc_p(its:ite,jms:jme))
+       write(0,*) 'max lwupt      =',maxval(lwupt_p(its:ite,jms:jme))
+       write(0,*) 'min lwupt      =',minval(lwupt_p(its:ite,jms:jme))
+       write(0,*) 'max lwuptc     =',maxval(lwuptc_p(its:ite,jms:jme))
+       write(0,*) 'min lwuptc     =',minval(lwuptc_p(its:ite,jms:jme))
+       write(0,*) 'max rthratenlw =',maxval(rthratenlw_p(its:ite,kts:kte,jms:jme))
+       write(0,*) 'min rthratenlw =',minval(rthratenlw_p(its:ite,kts:kte,jms:jme))
+
     case default
 
  end select radiation_lw_select
@@ -287,6 +629,7 @@
  call radiation_lw_to_MPAS(diag_physics,tend_physics)
 
  write(0,*) '--- end subroutine driver_radiation_lw:'
+ call timer_stop(&quot;radiation_lw&quot;)
 
  end subroutine driver_radiation_lw
 

Modified: branches/atmos_physics/src/core_physics/module_driver_radiation_sw.F
===================================================================
--- branches/atmos_physics/src/core_physics/module_driver_radiation_sw.F        2011-09-28 23:26:28 UTC (rev 1039)
+++ branches/atmos_physics/src/core_physics/module_driver_radiation_sw.F        2011-09-28 23:30:51 UTC (rev 1040)
@@ -1,14 +1,17 @@
 !=============================================================================================
  module module_driver_radiation_sw
  use grid_types
+ use timer
 
  use module_physics_manager
  use module_physics_constants
+ use module_physics_manager, only: gmt,curr_julday,julday,year
  use module_physics_ra_caminit
  use module_physics_rrtmg_swinit
  use module_physics_vars
  
 !from wrf physics:
+ use module_ra_cam
  use module_ra_rrtmg_sw
 
  implicit none
@@ -16,9 +19,10 @@
  public:: allocate_radiation_sw,   &amp;
           deallocate_radiation_sw, &amp;
           driver_radiation_sw,     &amp;
-          init_radiation_sw
+          init_radiation_sw,       &amp;
+          radconst
 
- integer,private:: i,j,k
+ integer,private:: i,j,k,n
 
  contains
 
@@ -49,14 +53,61 @@
  if(.not.allocated(swupbc_p)     ) allocate(swupbc_p(ims:ime,jms:jme)             )
  if(.not.allocated(swupt_p)      ) allocate(swupt_p(ims:ime,jms:jme)              )
  if(.not.allocated(swuptc_p)     ) allocate(swuptc_p(ims:ime,jms:jme)             )
-
- if(.not.allocated(swdnflx_p)    ) allocate(swdnflx_p(ims:ime,kms:kme+1,jms:jme)  )
- if(.not.allocated(swdnflxc_p)   ) allocate(swdnflxc_p(ims:ime,kms:kme+1,jms:jme) )
- if(.not.allocated(swupflx_p)    ) allocate(swupflx_p(ims:ime,kms:kme+1,jms:jme)  )
- if(.not.allocated(swupflxc_p)   ) allocate(swupflxc_p(ims:ime,kms:kme+1,jms:jme) )
  
  if(.not.allocated(rthratensw_p) ) allocate(rthratensw_p(ims:ime,kms:kme,jms:jme) )
 
+ radiation_sw_select: select case (trim(radt_sw_scheme))
+
+    case(&quot;rrtmg_sw&quot;)
+       if(.not.allocated(swdnflx_p)    ) allocate(swdnflx_p(ims:ime,kms:kme+1,jms:jme)  )
+       if(.not.allocated(swdnflxc_p)   ) allocate(swdnflxc_p(ims:ime,kms:kme+1,jms:jme) )
+       if(.not.allocated(swupflx_p)    ) allocate(swupflx_p(ims:ime,kms:kme+1,jms:jme)  )
+       if(.not.allocated(swupflxc_p)   ) allocate(swupflxc_p(ims:ime,kms:kme+1,jms:jme) )
+
+    case(&quot;cam_sw&quot;)
+       if(.not.allocated(xlat_p)       ) allocate(xlat_p(ims:ime,jms:jme)               )
+       if(.not.allocated(xlon_p)       ) allocate(xlon_p(ims:ime,jms:jme)               )
+
+       if(.not.allocated(glw_p)        ) allocate(glw_p(ims:ime,jms:jme)                )
+       if(.not.allocated(lwcf_p)       ) allocate(lwcf_p(ims:ime,jms:jme)               )
+       if(.not.allocated(lwdnb_p)      ) allocate(lwdnb_p(ims:ime,jms:jme)              )
+       if(.not.allocated(lwdnbc_p)     ) allocate(lwdnbc_p(ims:ime,jms:jme)             )
+       if(.not.allocated(lwdnt_p)      ) allocate(lwdnt_p(ims:ime,jms:jme)              )
+       if(.not.allocated(lwdntc_p)     ) allocate(lwdntc_p(ims:ime,jms:jme)             )
+       if(.not.allocated(lwupb_p)      ) allocate(lwupb_p(ims:ime,jms:jme)              )
+       if(.not.allocated(lwupbc_p)     ) allocate(lwupbc_p(ims:ime,jms:jme)             )
+       if(.not.allocated(lwupt_p)      ) allocate(lwupt_p(ims:ime,jms:jme)              )
+       if(.not.allocated(lwuptc_p)     ) allocate(lwuptc_p(ims:ime,jms:jme)             )
+       if(.not.allocated(olrtoa_p)     ) allocate(olrtoa_p(ims:ime,jms:jme)             )
+       if(.not.allocated(sfc_emiss_p)  ) allocate(sfc_emiss_p(ims:ime,jms:jme)          )
+       if(.not.allocated(rthratenlw_p) ) allocate(rthratenlw_p(ims:ime,kms:kme,jms:jme) )
+
+       if(.not.allocated(cemiss_p)     ) allocate(cemiss_p(ims:ime,kms:kme,jms:jme)     )
+       if(.not.allocated(taucldc_p)    ) allocate(taucldc_p(ims:ime,kms:kme,jms:jme)    )
+       if(.not.allocated(taucldi_p)    ) allocate(taucldi_p(ims:ime,kms:kme,jms:jme)    )
+
+       if(.not.allocated(pin_p)        ) allocate(pin_p(num_oznlevels)                  )
+       if(.not.allocated(ozmixm_p) ) &amp;
+          allocate(ozmixm_p(ims:ime,1:num_oznlevels,jms:jme,num_months) )
+       
+       if(.not.allocated(m_hybi_p)     ) allocate(m_hybi_p(num_aerlevels)               )
+       if(.not.allocated(m_psn_p)      ) allocate(m_psn_p(ims:ime,jms:jme)              )
+       if(.not.allocated(m_psp_p)      ) allocate(m_psp_p(ims:ime,jms:jme)              )
+       if(.not.allocated(aerosolcn_p)  ) &amp;
+          allocate(aerosolcn_p(ims:ime,1:num_aerlevels,jms:jme,num_aerosols) )
+       if(.not.allocated(aerosolcp_p)  ) &amp;
+          allocate(aerosolcp_p(ims:ime,1:num_aerlevels,jms:jme,num_aerosols) )
+
+       if(.not.allocated(emstot_p) ) allocate(emstot_p(ims:ime,kms:kme,jms:jme) )
+       if(.not.allocated(abstot_p) ) &amp;
+          allocate(abstot_p(ims:ime,kms:kme,cam_abs_dim2,jms:jme) )
+       if(.not.allocated(absnxt_p) ) &amp;
+          allocate(absnxt_p(ims:ime,kms:kme,cam_abs_dim1,jms:jme) )
+
+    case default
+
+ end select radiation_sw_select
+
  end subroutine allocate_radiation_sw
 
 !=============================================================================================
@@ -83,23 +134,65 @@
  if(allocated(swupbc_p)     ) deallocate(swupbc_p     )
  if(allocated(swupt_p)      ) deallocate(swupt_p      )
  if(allocated(swuptc_p)     ) deallocate(swuptc_p     )
- if(allocated(swdnflx_p)    ) deallocate(swdnflx_p    )
- if(allocated(swdnflxc_p)   ) deallocate(swdnflxc_p   )
- if(allocated(swupflx_p)    ) deallocate(swupflx_p    )
- if(allocated(swupflxc_p)   ) deallocate(swupflxc_p   )
  
  if(allocated(rthratensw_p) ) deallocate(rthratensw_p )
 
+ radiation_sw_select: select case (trim(radt_sw_scheme))
+
+    case(&quot;rrtmg_sw&quot;)
+       if(allocated(swdnflx_p)    ) deallocate(swdnflx_p    )
+       if(allocated(swdnflxc_p)   ) deallocate(swdnflxc_p   )
+       if(allocated(swupflx_p)    ) deallocate(swupflx_p    )
+       if(allocated(swupflxc_p)   ) deallocate(swupflxc_p   )
+
+    case(&quot;cam_sw&quot;)
+       if(allocated(pin_p)        ) deallocate(pin_p        )
+       if(allocated(m_hybi_p)     ) deallocate(m_hybi_p     )
+
+       if(allocated(xlat_p)       ) deallocate(xlat_p       )
+       if(allocated(xlon_p)       ) deallocate(xlon_p       )
+
+       if(allocated(glw_p)        ) deallocate(glw_p        )
+       if(allocated(lwcf_p)       ) deallocate(lwcf_p       )
+       if(allocated(lwdnb_p)      ) deallocate(lwdnb_p      )
+       if(allocated(lwdnbc_p)     ) deallocate(lwdnbc_p     )
+       if(allocated(lwdnt_p)      ) deallocate(lwdnt_p      )
+       if(allocated(lwdntc_p)     ) deallocate(lwdntc_p     )
+       if(allocated(lwupb_p)      ) deallocate(lwupb_p      )
+       if(allocated(lwupbc_p)     ) deallocate(lwupbc_p     )
+       if(allocated(lwupt_p)      ) deallocate(lwupt_p      )
+       if(allocated(lwuptc_p)     ) deallocate(lwuptc_p     )
+       if(allocated(olrtoa_p)     ) deallocate(olrtoa_p     )
+       if(allocated(sfc_emiss_p)  ) deallocate(sfc_emiss_p  )
+       if(allocated(rthratenlw_p) ) deallocate(rthratenlw_p )
+
+       if(allocated(cemiss_p)     ) deallocate(cemiss_p     )
+       if(allocated(ozmixm_p)     ) deallocate(ozmixm_p     )
+       if(allocated(taucldc_p)    ) deallocate(taucldc_p    )
+       if(allocated(taucldi_p)    ) deallocate(taucldi_p    )
+
+       if(allocated(m_psn_p)      ) deallocate(m_psn_p      )
+       if(allocated(m_psp_p)      ) deallocate(m_psp_p      )
+       if(allocated(aerosolcn_p)  ) deallocate(aerosolcn_p  )
+       if(allocated(aerosolcp_p)  ) deallocate(aerosolcp_p  )
+
+       if(allocated(abstot_p)     ) deallocate(abstot_p     )
+       if(allocated(absnxt_p)     ) deallocate(absnxt_p     )
+       if(allocated(emstot_p)     ) deallocate(emstot_p     )
+
+    case default
+
+ end select radiation_sw_select
+
  end subroutine deallocate_radiation_sw
 
 !=============================================================================================
- subroutine radiation_sw_from_MPAS(mesh,diag_physics,sfc_input)
+ subroutine radiation_sw_from_MPAS(mesh,state,diag_physics,sfc_input)
 !=============================================================================================
 
 !input arguments:
- type(mesh_type),intent(in):: mesh
-
-!inout arguments:
+ type(mesh_type),intent(in) :: mesh
+ type(state_type),intent(in):: state
  type(diag_physics_type),intent(inout):: diag_physics
  type(sfc_input_type)   ,intent(inout):: sfc_input
 
@@ -140,15 +233,6 @@
     swuptc_p(i,j)   = 0.
  enddo
 
- do k = kts,kte+2
- do i = its,ite
-    swdnflx_p(i,k,j)  = 0.
-    swdnflxc_p(i,k,j) = 0.
-    swupflx_p(i,k,j)  = 0.
-    swupflxc_p(i,k,j) = 0.
- enddo
- enddo
-
  do k = kts,kte
  do i = its,ite
     rthratensw_p(i,k,j) = 0.
@@ -156,6 +240,123 @@
  enddo
  enddo
 
+ radiation_sw_select: select case (trim(radt_sw_scheme))
+
+    case(&quot;rrtmg_sw&quot;)
+       do j = jts,jte
+       do k = kts,kte+2
+       do i = its,ite
+          swdnflx_p(i,k,j)  = 0.
+          swdnflxc_p(i,k,j) = 0.
+          swupflx_p(i,k,j)  = 0.
+          swupflxc_p(i,k,j) = 0.
+       enddo
+       enddo
+       enddo
+
+    case(&quot;cam_sw&quot;)
+
+       do j = jts,jte
+       do i = its,ite
+          sfc_emiss_p(i,j) = diag_physics % sfc_emiss % array(i)
+
+          olrtoa_p(i,j)     = 0.
+          glw_p(i,j)        = 0.
+          lwcf_p(i,j)       = 0.
+          lwdnb_p(i,j)      = 0.
+          lwdnbc_p(i,j)     = 0.
+          lwdnt_p(i,j)      = 0.
+          lwdntc_p(i,j)     = 0.
+          lwupb_p(i,j)      = 0.
+          lwupbc_p(i,j)     = 0.
+          lwupt_p(i,j)      = 0.
+          lwuptc_p(i,j)     = 0.
+       enddo
+       do k = kts,kte
+       do i = its,ite
+          rthratenlw_p(i,k,j) = 0.
+          cemiss_p(i,k,j)     = 0.
+          taucldc_p(i,k,j)    = 0.
+          taucldi_p(i,k,j)    = 0.
+       enddo
+       enddo
+       enddo
+       !infrared absorption:
+       do j = jts,jte
+       do n = 1,cam_abs_dim1
+       do k = kts,kte
+       do i = its,ite
+          absnxt_p(i,k,n,j) = diag_physics % absnxt % array(k,n,i)
+       enddo
+       enddo
+       enddo
+       do n = 1,cam_abs_dim2
+       do k = kts,kte+1
+       do i = its,ite
+          abstot_p(i,k,n,j) = diag_physics % abstot % array(k,n,i)
+       enddo
+       enddo
+       enddo
+       do k = kts,kte+1
+       do i = its,ite
+          emstot_p(i,k,j) = diag_physics % emstot % array(k,i)
+       enddo
+       enddo
+       enddo
+!      write(0,*) '--- end radiation_sw_from_MPAS: doabsems=',doabsems
+!      do k = kts,kte+1
+!         write(0,102) k,(maxval(abstot_p(its:ite,k,n,jts:jte)),n=1,10)
+!      enddo
+!      write(0,*)
+!      do k = kts,kte
+!         write(0,102) k,(maxval(absnxt_p(its:ite,k,n,jts:jte)),n=1,cam_abs_dim1)
+!      enddo
+!      write(0,*)
+!      do k = kts,kte+1
+!         write(0,102) k,maxval(emstot_p(its:ite,k,jts:jte))
+!      enddo
+       !ozone mixing ratio:
+       do k = 1, num_oznlevels
+          pin_p(k) = mesh % pin % array(k,1)
+       enddo
+       do n = 1, num_months
+          do j = jts,jte
+          do k = 1, num_oznlevels
+          do i = its,ite
+             ozmixm_p(i,k,j,n) = mesh % ozmixm % array(n,k,i)
+          enddo
+          enddo
+          enddo
+       enddo
+       !aerosol mixing ratio:
+       do k = 1, num_aerlevels
+          m_hybi_p(k) = mesh % m_hybi % array(k,1)
+       enddo
+       do i = its,ite
+       do j = jts,jte
+          m_psp_p(i,j) = state % m_ps % array(i)
+          m_psn_p(i,j) = state % m_ps % array(i)
+       enddo
+       enddo
+       do n = 1,num_aerosols
+       do j = jts,jte
+       do k = 1, num_aerlevels
+       do i = its,ite
+          aerosolcp_p(i,k,j,n) = state % aerosols % array(n,k,i)
+          aerosolcn_p(i,k,j,n) = state % aerosols % array(n,k,i)
+       enddo
+       enddo
+       enddo
+       enddo
+
+    case default
+
+ end select radiation_sw_select
+
+!format:
+ 101 format(i3,2i6,12(1x,e15.8))
+ 102 format(i6,12(1x,e15.8))
+
  end subroutine radiation_sw_from_MPAS
 
 !=============================================================================================
@@ -183,16 +384,16 @@
     diag_physics % swupt      % array(i) = swupt_p(i,j)
     diag_physics % swuptc     % array(i) = swuptc_p(i,j)
  enddo
+!not needed:
+!do k = kts,kte+2
+!do i = its,ite
+!   diag_physics % swdnflx    % array(k,i) = swdnflx_p(i,k,j)
+!   diag_physics % swdnflxc   % array(k,i) = swdnflxc_p(i,k,j)
+!   diag_physics % swupflx    % array(k,i) = swupflx_p(i,k,j)
+!   diag_physics % swupflxc   % array(k,i) = swupflxc_p(i,k,j)
+!enddo
+!enddo
 
- do k = kts,kte+2
- do i = its,ite
-    diag_physics % swdnflx    % array(k,i) = swdnflx_p(i,k,j)
-    diag_physics % swdnflxc   % array(k,i) = swdnflxc_p(i,k,j)
-    diag_physics % swupflx    % array(k,i) = swupflx_p(i,k,j)
-    diag_physics % swupflxc   % array(k,i) = swupflxc_p(i,k,j)
- enddo
- enddo
-
  do k = kts,kte
  do i = its,ite
     tend_physics % rthratensw % array(k,i) = rthratensw_p(i,k,j)
@@ -201,6 +402,35 @@
 
  enddo
 
+ radiation_sw_select: select case (trim(radt_sw_scheme))
+    case(&quot;cam_sw&quot;)
+       !infrared absorption:
+       do j = jts,jte
+       do n = 1,cam_abs_dim1
+       do k = kts,kte
+       do i = its,ite
+          diag_physics % absnxt % array(k,n,i) = absnxt_p(i,k,n,j)
+       enddo
+       enddo
+       enddo
+       do n = 1,cam_abs_dim2
+       do k = kts,kte+1
+       do i = its,ite
+          diag_physics % abstot % array(k,n,i) = abstot_p(i,k,n,j)
+       enddo
+       enddo
+       enddo
+       do k = kts,kte+1
+       do i = its,ite
+          diag_physics % emstot % array(k,i) = emstot_p(i,k,j)
+       enddo
+       enddo
+       enddo
+
+    case default
+
+ end select radiation_sw_select
+
  end subroutine radiation_sw_to_MPAS
 
 !=============================================================================================
@@ -241,16 +471,16 @@
 
 !=============================================================================================
  subroutine driver_radiation_sw(itimestep,mesh,state,diag_physics,sfc_input, &amp;
-                                tend_physics, xtime_s)
+                                tend_physics,xtime_s)
 !=============================================================================================
 
 !input arguments:
  integer,intent(in):: itimestep
  type(mesh_type),intent(in) :: mesh
- type(state_type),intent(in):: state
  real(kind=RKIND),intent(in):: xtime_s
 
 !inout arguments:
+ type(state_type)       ,intent(inout):: state
  type(diag_physics_type),intent(inout):: diag_physics
  type(sfc_input_type)   ,intent(inout):: sfc_input
  type(tend_physics_type),intent(inout):: tend_physics
@@ -274,13 +504,10 @@
             '     SOLCON      =', f16.9,/, &amp;
             '     DECLIN      =', f16.9)
 
- !xtime =&gt; state % xtime % scalar
- !ldf (2011-09-19): change needed until AdvanceClock is corrected by Conrad.
   xtime_m = xtime_s/60.
- !xtime_m = xtime_s/60. - dt_dyn/60. 
 
 !copy all MPAS arrays to rectangular grid:
- call radiation_sw_from_MPAS(mesh,diag_physics,sfc_input)
+ call radiation_sw_from_MPAS(mesh,state,diag_physics,sfc_input)
 
 !... calculates solar declination:
 !call radconst(declin,solcon,julday,degrad,dpd)
@@ -327,6 +554,69 @@
                        )
        write(0,*) '--- exit subroutine rrtmg_swrad'
 
+    case (&quot;cam_sw&quot;)
+       call camrad( dolw = .false. , dosw = .true. ,                                         &amp;
+                rthratenlw    = rthratenlw_p  , rthratensw    = rthratensw_p  ,              &amp;
+                swupt         = swupt_p       , swuptc        = swuptc_p      ,              &amp;
+                swdnt         = swdnt_p       , swdntc        = swdntc_p      ,              &amp;
+                lwupt         = lwupt_p       , lwuptc        = lwuptc_p      ,              &amp;
+                lwdnt         = lwdnt_p       , lwdntc        = lwdntc_p      ,              &amp;
+                swupb         = swupb_p       , swupbc        = swupbc_p      ,              &amp;
+                swdnb         = swdnb_p       , swdnbc        = swdnbc_p      ,              &amp;
+                lwupb         = lwupb_p       , lwupbc        = lwupbc_p      ,              &amp;
+                lwdnb         = lwdnb_p       , lwdnbc        = lwdnbc_p      ,              &amp;
+                swcf          = swcf_p        , lwcf          = lwcf_p        ,              &amp;
+                gsw           = gsw_p         , glw           = glw_p         ,              &amp;
+                olr           = olrtoa_p      , cemiss        = cemiss_p      ,              &amp;
+                taucldc       = taucldc_p     , taucldi       = taucldi_p     ,              &amp; 
+                coszr         = coszr_p       , albedo        = sfc_albedo_p  ,              &amp; 
+                emiss         = sfc_emiss_p   , tsk           = tsk_p         ,              &amp; 
+                xlat          = xlat_p        , xlong         = xlon_p        ,              &amp;
+                t_phy         = t_p           , pi_phy        = pi_p          ,              &amp;
+                p_phy         = pres_p        , p8w           = pres2_p       ,              &amp;
+                z             = z_p           , dz8w          = dz_p          ,              &amp;            
+                rho_phy       = rho_p         , qv3d          = qv_p          ,              &amp; 
+                qc3d          = qc_p          , qr3d          = qr_p          ,              &amp;
+                qi3d          = qi_p          , qs3d          = qs_p          ,              &amp;
+                qg3d          = qg_p          , f_qv          = f_qv          ,              &amp;
+                f_qc          = f_qc          , f_qr          = f_qr          ,              &amp;
+                f_qi          = f_qi          , f_qs          = f_qs          ,              &amp;
+                f_qg          = f_qg          , f_ice_phy     = f_ice         ,              &amp;
+                f_rain_phy    = f_rain        , cldfra        = cldfrac_p     ,              &amp;
+                xland         = xland_p       , xice          = xice_p        ,              &amp;
+                num_months    = num_months    , levsiz        = num_oznlevels ,              &amp; 
+                pin0          = pin_p         , ozmixm        = ozmixm_p      ,              &amp;
+                paerlev       = num_aerlevels , naer_c        = num_aerosols  ,              &amp;
+                m_psp         = m_psp_p       , m_psn         = m_psn_p       ,              &amp;
+                aerosolcp     = aerosolcp_p   , aerosolcn     = aerosolcn_p   ,              &amp;
+                m_hybi0       = m_hybi_p      , snow          = snow_p        ,              &amp;
+                cam_abs_dim1  = cam_abs_dim1  , cam_abs_dim2  = cam_abs_dim2  ,              &amp;
+                gmt           = gmt           , yr            = year          ,              &amp;
+                julday        = julday        , julian        = curr_julday   ,              &amp;
+                dt            = dt_dyn        , xtime         = xtime_m       ,              &amp;
+                declin        = declin        , solcon        = solcon        ,              &amp;
+                radt          = radt          , degrad        = degrad        ,              &amp;
+                n_cldadv      = 3             , abstot_3d     = abstot_p      ,              &amp;
+                absnxt_3d     = absnxt_p      , emstot_3d     = emstot_p      ,              &amp;
+                doabsems      = doabsems      ,                                              &amp;
+                ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,      &amp;
+                ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,      &amp;
+                its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte        &amp;
+                  )
+
+       write(0,*) '--- end subroutine camrad sw'
+       write(0,*) 'doabsems =',doabsems
+       write(0,*) 'max swupb      =',maxval(swupb_p(its:ite,jms:jme))
+       write(0,*) 'min swupb      =',minval(swupb_p(its:ite,jms:jme))
+       write(0,*) 'max swupbc     =',maxval(swupbc_p(its:ite,jms:jme))
+       write(0,*) 'min swupbc     =',minval(swupbc_p(its:ite,jms:jme))
+       write(0,*) 'max swupt      =',maxval(swupt_p(its:ite,jms:jme))
+       write(0,*) 'min swupt      =',minval(swupt_p(its:ite,jms:jme))
+       write(0,*) 'max swuptc     =',maxval(swuptc_p(its:ite,jms:jme))
+       write(0,*) 'min swuptc     =',minval(swuptc_p(its:ite,jms:jme))
+       write(0,*) 'max rthratensw =',maxval(rthratensw_p(its:ite,kts:kte,jms:jme))
+       write(0,*) 'min rthratensw =',minval(rthratensw_p(its:ite,kts:kte,jms:jme))
+
     case default
 
  end select radiation_sw_select

Modified: branches/atmos_physics/src/core_physics/module_physics_driver.F
===================================================================
--- branches/atmos_physics/src/core_physics/module_physics_driver.F        2011-09-28 23:26:28 UTC (rev 1039)
+++ branches/atmos_physics/src/core_physics/module_physics_driver.F        2011-09-28 23:30:51 UTC (rev 1040)
@@ -72,7 +72,7 @@
     !call to short wave radiation scheme:
     if(l_radtsw) then
        call allocate_radiation_sw
-       call driver_radiation_sw(itimestep,block%mesh,block%state%time_levs(1)%state, &amp;
+       call driver_radiation_sw(itimestep,block%mesh,block%state%time_levs(1)%state,  &amp;
                                block%diag_physics,block%sfc_input,block%tend_physics, &amp;
                                xtime_s)
     endif
@@ -80,8 +80,9 @@
     !call to long wave radiation scheme:
     if(l_radtlw) then
        call allocate_radiation_lw
-       call driver_radiation_lw(itimestep,block%diag_physics,block%sfc_input,        &amp;
-                               block%tend_physics)
+       call driver_radiation_lw(itimestep,block%mesh,block%state%time_levs(1)%state,  &amp;
+                               block%diag_physics,block%sfc_input,block%tend_physics, &amp;
+                               xtime_s)
     endif
 
     !deallocate all radiation arrays:

Modified: branches/atmos_physics/src/core_physics/module_physics_manager.F
===================================================================
--- branches/atmos_physics/src/core_physics/module_physics_manager.F        2011-09-28 23:26:28 UTC (rev 1039)
+++ branches/atmos_physics/src/core_physics/module_physics_manager.F        2011-09-28 23:30:51 UTC (rev 1040)
@@ -132,11 +132,12 @@
  end subroutine physics_timetracker
 
 !=============================================================================================
- subroutine physics_run_init(mesh,clock)
+ subroutine physics_run_init(mesh,state,clock)
 !=============================================================================================
 
 !input arguments:
- type(mesh_type),intent(in):: mesh
+ type(mesh_type),intent(in) :: mesh
+ type(state_type),intent(in):: state
  type(MPAS_Clock_type):: clock
 
 !local variables:
@@ -226,6 +227,9 @@
  write(0,*) '    jts= ',jts,' jte=',jte
  write(0,*) '    kts= ',kts,' kte=',kte
 
+!initialization:
+ num_months = mesh % nMonths
+
 !initialization of physics time-steps:
  dt_dyn     = config_dt
  n_physics  = config_n_physics
@@ -234,9 +238,9 @@
  n_pbl      = config_n_pbl
 
  dt_physics = dt_dyn*n_physics        
- dt_microp  = nint(dt_dyn/n_microp) !for now.
- dt_cu      = dt_physics            !for now.
- dt_pbl     = dt_physics            !for now.
+ dt_microp  = dt_dyn/n_microp  !for now.
+ dt_cu      = dt_physics       !for now.
+ dt_pbl     = dt_physics       !for now.
 
 !longwave radiation scheme:
  radt_lw_scheme = trim(config_radt_lw_scheme)
@@ -245,6 +249,25 @@
  radt_sw_scheme = trim(config_radt_sw_scheme)
  dt_radtsw = dt_dyn*config_n_radt_sw
 
+!CAM radiation schemes:
+ if(trim(config_radt_lw_scheme) .eq. &quot;cam_lw&quot; .or. &amp;
+    trim(config_radt_sw_scheme) .eq. &quot;cam_sw&quot; ) then
+
+    !this logical initiates the calculation of &quot;pre-dfined arrays in the longwave
+    !radiation code. these arrays are calculated once if it is the beginning of a
+    !new run or if it is a restart run:
+    doabsems     = .false.
+    cam_abs_dim1 = mesh % cam_dim1
+    cam_abs_dim2 = mesh % nVertLevels + 1
+
+    !initializes the number of aerosols, and the prescribed vertical dimensions for
+    !aerosols and ozone mixing ratios:
+    num_aerosols  = state % num_aerosols
+    num_aerLevels = mesh % naerLevels
+    num_oznLevels = mesh % noznLevels
+
+ endif 
+
 !land-surface scheme:
  lsm_scheme = trim(config_lsm_scheme)
  num_soils  = mesh% nSoilLevels

Modified: branches/atmos_physics/src/core_physics/module_physics_vars.F
===================================================================
--- branches/atmos_physics/src/core_physics/module_physics_vars.F        2011-09-28 23:26:28 UTC (rev 1039)
+++ branches/atmos_physics/src/core_physics/module_physics_vars.F        2011-09-28 23:30:51 UTC (rev 1040)
@@ -26,12 +26,13 @@
  logical:: l_radtlw                   !controls call to longwave radiation parameterization.
  logical:: l_radtsw                   !controls call to shortwave parameterization.
 
-
  integer,public:: ids,ide,jds,jde,kds,kde
  integer,public:: ims,ime,jms,jme,kms,kme
  integer,public:: its,ite,jts,jte,kts,kte
  integer,public:: n_physics,n_microp
 
+ integer,public:: num_months          !number of months                                     [-]
+
  real(kind=RKIND),public:: dt_dyn     !time-step for dynamics
  real(kind=RKIND),public:: dt_physics !time-step for physics.
  real(kind=RKIND),public:: dt_microp  !time-step for cloud microphysics parameterization.
@@ -271,6 +272,43 @@
     rthratenlw_p       !uncoupled theta tendency due to longwave radiation            [K s-1]
 
 !=============================================================================================
+!... variables and arrays related to parameterization of long- and short-wave radiation needed
+!    only by the &quot;CAM&quot; radiation codes:
+!=============================================================================================
+
+ logical:: doabsems
+
+ integer:: cam_abs_dim1
+ integer:: cam_abs_dim2
+ integer:: num_moist
+ integer:: num_aerosols
+ integer:: num_aerlevels
+ integer:: num_oznlevels
+
+ real(kind=RKIND),dimension(:),allocatable:: &amp;
+    pin_p,            &amp;!pressure levels for ozone concentration                           [Pa]
+    m_hybi_p           !hybrid levels for aerosols                                         [-]
+
+ real(kind=RKIND),dimension(:,:),allocatable:: &amp;
+    m_psn_p,          &amp;!
+    m_psp_p            !
+
+ real(kind=RKIND),dimension(:,:,:,:),allocatable:: &amp;
+    aerosolcn_p,      &amp;!
+    aerosolcp_p        !
+
+ real(kind=RKIND),dimension(:,:,:),allocatable:: &amp;
+    emstot_p,         &amp;!total emissivity                                                   [-]
+    cemiss_p,         &amp;!cloud emissivity for ISCCP                                         [-]
+    taucldc_p,        &amp;!cloud water optical depth for ISCCP                                [-]
+    taucldi_p          !cloud ice optical depth for ISCCP                                  [-]    
+
+ real(kind=RKIND),dimension(:,:,:,:),allocatable:: &amp;
+    abstot_p,         &amp;!total layer absorptivity                                           [-]
+    absnxt_p,         &amp;!total nearest layer absorptivity                                   [-]
+    ozmixm_p           !ozone mixing ratio.
+
+!=============================================================================================
 !.. variables and arrays related to cloudiness:
 !=============================================================================================
 

</font>
</pre>