GFS Operational Physics Documentation  gsm/branches/DTC/phys-doc-all phys-doc-all R82971
grrad.f
Go to the documentation of this file.
1 
3 
129 ! ========================================================== !!!!!
130 ! 'module_radiation_driver' descriptions !!!!!
131 ! ========================================================== !!!!!
132 ! !
133 ! this is the radiation driver module. it prepares atmospheric !
134 ! profiles and invokes main radiation calculations. !
135 ! !
136 ! in module 'module_radiation_driver' there are twe externally !
137 ! callable subroutine: !
138 ! !
139 ! 'radinit' -- initialization routine !
140 ! input: !
141 ! ( si, NLAY, me ) !
142 ! output: !
143 ! ( none ) !
144 ! !
145 ! 'radupdate' -- update time sensitive data used by radiations !
146 ! input: !
147 ! ( idate,jdate,deltsw,deltim,lsswr, me ) !
148 ! output: !
149 ! ( slag,sdec,cdec,solcon ) !
150 ! !
151 ! 'grrad' -- setup and invoke main radiation calls !
152 ! input: !
153 ! ( prsi,prsl,prslk,tgrs,qgrs,tracer,vvl,slmsk, !
154 ! xlon,xlat,tsfc,snowd,sncovr,snoalb,zorl,hprim, !
155 ! alvsf,alnsf,alvwf,alnwf,facsf,facwf,fice,tisfc, !
156 ! sinlat,coslat,solhr,jdate,solcon, !
157 ! cv,cvt,cvb,fcice,frain,rrime,flgmin, !
158 ! icsdsw,icsdlw, ntcw,ncld,ntoz, NTRAC,NFXR, !
159 ! dtlw,dtsw, lsswr,lslwr,lssav, !
160 ! IX, IM, LM, me, lprnt, ipt, kdt,deltaq,sup,cnvw,cnvc, !
161 ! output: !
162 ! htrsw,topfsw,sfcfsw,dswcmp,uswcmp,sfalb,coszen,coszdg, !
163 ! htrlw,topflw,sfcflw,tsflw,semis,cldcov, !
164 ! input/output: !
165 ! fluxr !
166 ! optional output: !
167 ! htrlw0,htrsw0,htrswb,htrlwb !
168 ! !
169 ! !
170 ! external modules referenced: !
171 ! 'module physparam' in 'physparam.f' !
172 ! 'module funcphys' in 'funcphys.f' !
173 ! 'module physcons' in 'physcons.f' !
174 ! !
175 ! 'module module_radiation_gases' in 'radiation_gases.f' !
176 ! 'module module_radiation_aerosols' in 'radiation_aerosols.f' !
177 ! 'module module_radiation_surface' in 'radiation_surface.f' !
178 ! 'module module_radiation_clouds' in 'radiation_clouds.f' !
179 ! !
180 ! 'module module_radsw_cntr_para' in 'radsw_xxxx_param.f' !
181 ! 'module module_radsw_parameters' in 'radsw_xxxx_param.f' !
182 ! 'module module_radsw_main' in 'radsw_xxxx_main.f' !
183 ! !
184 ! 'module module_radlw_cntr_para' in 'radlw_xxxx_param.f' !
185 ! 'module module_radlw_parameters' in 'radlw_xxxx_param.f' !
186 ! 'module module_radlw_main' in 'radlw_xxxx_main.f' !
187 ! !
188 ! where xxxx may vary according to different scheme selection !
189 ! !
190 ! !
191 ! program history log: !
192 ! mm-dd-yy ncep - created program grrad !
193 ! 08-12-03 yu-tai hou - re-written for modulized radiations !
194 ! 11-06-03 yu-tai hou - modified !
195 ! 01-18-05 s. moorthi - NOAH/ICE model changes added !
196 ! 05-10-05 yu-tai hou - modified module structure !
197 ! 12-xx-05 s. moorthi - sfc lw flux adj by mean temperature !
198 ! 02-20-06 yu-tai hou - add time variation for co2 data, and !
199 ! solar const. add sfc emiss change !
200 ! 03-21-06 s. Moorthi - added surface temp over ice !
201 ! 07-28-06 yu-tai hou - add stratospheric vocanic aerosols !
202 ! 03-14-07 yu-tai hou - add generalized spectral band interp !
203 ! for aerosol optical prop. (sw and lw) !
204 ! 04-10-07 yu-tai hou - spectral band sw/lw heating rates !
205 ! 05-04-07 yu-tai hou - make options for clim based and modis !
206 ! based (h. wei and c. marshall) albedo !
207 ! 09-05-08 yu-tai hou - add the initial date and time 'idate' !
208 ! and control param 'ICTM' to the passing param list!
209 ! to handel different time/date requirements for !
210 ! external data (co2, aeros, solcon, ...) !
211 ! 10-10-08 yu-tai hou - add the ICTM=-2 option for combining !
212 ! initial condition data with seasonal cycle from !
213 ! climatology. !
214 ! 03-12-09 yu-tai hou - use two time stamps to keep tracking !
215 ! dates for init cond and fcst time. remove volcanic!
216 ! aerosols data in climate hindcast (ICTM=-2). !
217 ! 03-16-09 yu-tai hou - included sub-column clouds approx. !
218 ! control flags isubcsw/isubclw in initialization !
219 ! subroutine. passed auxiliary cloud control arrays !
220 ! icsdsw/icsdlw (if isubcsw/isubclw =2, it will be !
221 ! the user provided permutation seeds) to the sw/lw !
222 ! radiation calculation programs. also moved cloud !
223 ! overlapping control flags iovrsw/iovrlw from main !
224 ! radiation routines to the initialization routines.!
225 ! 04-02-09 yu-tai hou - modified surface control flag iems to !
226 ! have additional function of if the surface-air !
227 ! interface have the same or different temperature !
228 ! for radiation calculations. !
229 ! 04-03-09 yu-tai hou - modified to add lw surface emissivity !
230 ! as output variable. changed the sign of sfcnsw to !
231 ! be positive value denote solar flux goes into the !
232 ! ground (this is needed to reduce sign confusion !
233 ! in other part of model) !
234 ! 09-09-09 fanglin yang (thru s.moorthi) added QME5 QME6 to E-20!
235 ! 01-09-10 sarah lu - added gocart option, revised grrad for!
236 ! gocart coupling. calling argument modifed: ldiag3 !
237 ! removed; cldcov/fluxr sequence changed; cldcov is !
238 ! changed from accumulative to instant field and !
239 ! from input/output to output field !
240 ! 01-24-10 sarah lu - added aod to fluxr, added prslk and !
241 ! oz to setaer input argument (for gocart coupling),!
242 ! added tau_gocart to setaer output argument (for, !
243 ! aerosol diag by index of nv_aod) !
244 ! 07-08-10 s.moorthi - updated the NEMS version for new physics !
245 ! 07-28-10 yu-tai hou - changed grrad interface to allow all !
246 ! components of sw/lw toa/sfc instantaneous values !
247 ! being passed to the calling program. moved the !
248 ! computaion of sfc net sw flux (sfcnsw) to the !
249 ! calling program. merged carlos' nmmb modification.!
250 ! 07-30-10 s. moorthi - corrected some errors associated with !
251 ! unit changes !
252 ! 12-02-10 s. moorthi/y. hou - removed the use of aerosol flags !
253 ! 'iaersw' 'iaerlw' from radiations and replaced !
254 ! them by using the runtime variable laswflg and !
255 ! lalwflg defined in module radiation_aerosols. !
256 ! also replaced param nspc in grrad with the use of !
257 ! max_num_gridcomp in module radiation_aerosols. !
258 ! jun 2012 yu-tai hou - added sea/land madk 'slmsk' to the !
259 ! argument list of subrotine setaer call for the !
260 ! newly modified horizontal bi-linear interpolation !
261 ! in climatological aerosols schem. also moved the !
262 ! virtual temperature calculations in subroutines !
263 ! 'radiation_clouds' and 'radiation_aerosols' to !
264 ! 'grrad' to reduce repeat comps. renamed var oz as !
265 ! tracer to reflect that it carries various prog !
266 ! tracer quantities. !
267 ! - modified to add 4 compontents of sw !
268 ! surface downward fluxes to the output. (vis/nir; !
269 ! direct/diffused). re-arranged part of the fluxr !
270 ! variable fields and filled the unused slots for !
271 ! the new components. added check print of select !
272 ! data (co2 value for now). !
273 ! - changed the initialization subrution !
274 ! 'radinit' into two parts: 'radinit' is called at !
275 ! the start of model run to set up radiation related!
276 ! fixed parameters; and 'radupdate' is called in !
277 ! the time-loop to update time-varying data sets !
278 ! and module variables. !
279 ! sep 2012 h-m lin/y-t hou added option of extra top layer for !
280 ! models with low toa ceiling. the extra layer will !
281 ! help ozone absorption at higher altitude. !
282 ! nov 2012 yu-tai hou - modified control parameters through !
283 ! module 'physparam'. !
284 ! jan 2013 yu-tai hou - updated subr radupdate for including !
285 ! options of annual/monthly solar constant table. !
286 ! mar 2013 h-m lin/y-t hou corrected a bug in extra top layer !
287 ! when using ferrier microphysics. !
288 ! may 2013 s. mooorthi - removed fpkapx !
289 ! jul 2013 r. sun - added pdf cld and convective cloud water and!
290 ! cover for radiation !
291 ! aug 2013 s. moorthi - port from gfs to nems !
292 ! 13Feb2014 sarah lu - add aerodp to fluxr !
293 ! Apr 2014 Xingren Wu - add sfc SW downward fluxes nir/vis and !
294 ! sfcalb to export for A/O/I coupling !
295 ! jun 2014 y-t hou - revised code to include surface up and !
296 ! down spectral components sw fluxes as output. !
297 ! !
298 !!!!! ========================================================== !!!!!
299 !!!!! end descriptions !!!!!
300 !!!!! ========================================================== !!!!!
301 
302 
303 
304 !========================================!
305  module module_radiation_driver !
306 !........................................!
307 !
308  use physparam
309  use physcons, only : eps => con_eps, &
310  & epsm1 => con_epsm1, &
311  & fvirt => con_fvirt &
312  &, rocp => con_rocp
313  use funcphys, only : fpvs
314 
315  use module_radiation_astronomy,only: sol_init, sol_update, coszmn
316  use module_radiation_gases, only : nf_vgas, getgases, getozn, &
318  use module_radiation_aerosols,only : nf_aesw, nf_aelw, setaer, &
319  & aer_init, aer_update, &
320  & nspc1
321  use module_radiation_surface, only : nf_albd, sfc_init, setalb, &
322  & setemis
323  use module_radiation_clouds, only : nf_clds, cld_init, &
325  & diagcld1
326 
328  & profsw_type,cmpfsw_type,nbdsw
329  use module_radsw_main, only : rswinit, swrad
330 
332  & proflw_type, nbdlw
333  use module_radlw_main, only : rlwinit, lwrad
334 !
335  implicit none
336 !
337  private
338 
339 ! --- version tag and last revision date
340  character(40), parameter :: &
341  & VTAGRAD='NCEP-Radiation_driver v5.2 Jan 2013 '
342 ! & VTAGRAD='NCEP-Radiation_driver v5.1 Nov 2012 '
343 ! & VTAGRAD='NCEP-Radiation_driver v5.0 Aug 2012 '
344 
346 
348  real (kind=kind_phys) :: qmin
350  real (kind=kind_phys) :: qme5
352  real (kind=kind_phys) :: qme6
354  real (kind=kind_phys) :: epsq
355 ! parameter (QMIN=1.0e-10, QME5=1.0e-5, QME6=1.0e-6, EPSQ=1.0e-12)
356  parameter(qmin=1.0e-10, qme5=1.0e-7, qme6=1.0e-7, epsq=1.0e-12)
357 ! parameter (QMIN=1.0e-10, QME5=1.0e-20, QME6=1.0e-20, EPSQ=1.0e-12)
358 
360  real, parameter :: prsmin = 1.0e-6
361 
364  integer :: itsfc =0
365 
367  integer :: month0=0, iyear0=0, monthd=0
368 
372  logical :: loz1st =.true.
373 
376  integer, parameter :: ltp = 0 ! no extra top layer
377 ! integer, parameter :: LTP = 1 ! add an extra top layer
378 
380  logical, parameter :: lextop = (ltp > 0)
381 
382 ! --- publicly accessible module programs:
383 
384  public radinit, radupdate, grrad
385 
386 
387 ! =================
388  contains
389 ! =================
390 
402 !-----------------------------------
403  subroutine radinit( si, NLAY, me )
404 !...................................
405 
406 ! --- inputs:
407 ! & ( si, NLAY, me )
408 ! --- outputs:
409 ! ( none )
410 
411 ! ================= subprogram documentation block ================ !
412 ! !
413 ! subprogram: radinit initialization of radiation calculations !
414 ! !
415 ! usage: call radinit !
416 ! !
417 ! attributes: !
418 ! language: fortran 90 !
419 ! machine: wcoss !
420 ! !
421 ! ==================== definition of variables ==================== !
422 ! !
423 ! input parameters: !
424 ! si : model vertical sigma interface !
425 ! NLAY : number of model vertical layers !
426 ! me : print control flag !
427 ! !
428 ! outputs: (none) !
429 ! !
430 ! external module variables: (in module physparam) !
431 ! isolar : solar constant cntrol flag !
432 ! = 0: use the old fixed solar constant in "physcon" !
433 ! =10: use the new fixed solar constant in "physcon" !
434 ! = 1: use noaa ann-mean tsi tbl abs-scale with cycle apprx!
435 ! = 2: use noaa ann-mean tsi tbl tim-scale with cycle apprx!
436 ! = 3: use cmip5 ann-mean tsi tbl tim-scale with cycl apprx!
437 ! = 4: use cmip5 mon-mean tsi tbl tim-scale with cycl apprx!
438 ! iaerflg : 3-digit aerosol flag (abc for volc, lw, sw) !
439 ! a:=0 use background stratospheric aerosol !
440 ! =1 include stratospheric vocanic aeros !
441 ! b:=0 no topospheric aerosol in lw radiation !
442 ! =1 compute tropspheric aero in 1 broad band for lw !
443 ! =2 compute tropspheric aero in multi bands for lw !
444 ! c:=0 no topospheric aerosol in sw radiation !
445 ! =1 include tropspheric aerosols for sw !
446 ! ico2flg : co2 data source control flag !
447 ! =0: use prescribed global mean co2 (old oper) !
448 ! =1: use observed co2 annual mean value only !
449 ! =2: use obs co2 monthly data with 2-d variation !
450 ! ictmflg : =yyyy#, external data ic time/date control flag !
451 ! = -2: same as 0, but superimpose seasonal cycle !
452 ! from climatology data set. !
453 ! = -1: use user provided external data for the !
454 ! forecast time, no extrapolation. !
455 ! = 0: use data at initial cond time, if not !
456 ! available, use latest, no extrapolation. !
457 ! = 1: use data at the forecast time, if not !
458 ! available, use latest and extrapolation. !
459 ! =yyyy0: use yyyy data for the forecast time, !
460 ! no further data extrapolation. !
461 ! =yyyy1: use yyyy data for the fcst. if needed, do !
462 ! extrapolation to match the fcst time. !
463 ! ioznflg : ozone data source control flag !
464 ! =0: use climatological ozone profile !
465 ! =1: use interactive ozone profile !
466 ! ialbflg : albedo scheme control flag !
467 ! =0: climatology, based on surface veg types !
468 ! =1: modis retrieval based surface albedo scheme !
469 ! iemsflg : emissivity scheme cntrl flag (ab 2-digit integer) !
470 ! a:=0 set sfc air/ground t same for lw radiation !
471 ! =1 set sfc air/ground t diff for lw radiation !
472 ! b:=0 use fixed sfc emissivity=1.0 (black-body) !
473 ! =1 use varying climtology sfc emiss (veg based) !
474 ! =2 future development (not yet) !
475 ! icldflg : cloud optical property scheme control flag !
476 ! =0: use diagnostic cloud scheme !
477 ! =1: use prognostic cloud scheme (default) !
478 ! icmphys : cloud microphysics scheme control flag !
479 ! =1 zhao/carr/sundqvist microphysics scheme !
480 ! =2 brad ferrier microphysics scheme !
481 ! =3 zhao/carr/sundqvist microphysics+pdf cloud & cnvc,cnvw!
482 ! iovrsw : control flag for cloud overlap in sw radiation !
483 ! iovrlw : control flag for cloud overlap in lw radiation !
484 ! =0: random overlapping clouds !
485 ! =1: max/ran overlapping clouds !
486 ! isubcsw : sub-column cloud approx control flag in sw radiation !
487 ! isubclw : sub-column cloud approx control flag in lw radiation !
488 ! =0: with out sub-column cloud approximation !
489 ! =1: mcica sub-col approx. prescribed random seed !
490 ! =2: mcica sub-col approx. provided random seed !
491 ! lcrick : control flag for eliminating CRICK !
492 ! =t: apply layer smoothing to eliminate CRICK !
493 ! =f: do not apply layer smoothing !
494 ! lcnorm : control flag for in-cld condensate !
495 ! =t: normalize cloud condensate !
496 ! =f: not normalize cloud condensate !
497 ! lnoprec : precip effect in radiation flag (ferrier microphysics) !
498 ! =t: snow/rain has no impact on radiation !
499 ! =f: snow/rain has impact on radiation !
500 ! ivflip : vertical index direction control flag !
501 ! =0: index from toa to surface !
502 ! =1: index from surface to toa !
503 ! !
504 ! subroutines called: sol_init, aer_init, gas_init, cld_init, !
505 ! sfc_init, rlwinit, rswinit !
506 ! !
507 ! usage: call radinit !
508 ! !
509 ! =================================================================== !
510 !
511  implicit none
512 
513 ! --- inputs:
514  integer, intent(in) :: NLAY, me
515 
516  real (kind=kind_phys), intent(in) :: si(:)
517 
518 ! --- outputs: (none, to module variables)
519 
520 ! --- locals:
521 
522 !
523 !===> ... begin here
524 !
527  itsfc = iemsflg / 10 ! sfc air/ground temp control
528  loz1st = (ioznflg == 0) ! first-time clim ozone data read flag
529  month0 = 0
530  iyear0 = 0
531  monthd = 0
532 
533  if (me == 0) then
534 ! print *,' NEW RADIATION PROGRAM STRUCTURES -- SEP 01 2004'
535  print *,' NEW RADIATION PROGRAM STRUCTURES BECAME OPER. ', &
536  & ' May 01 2007'
537  print *, vtagrad !print out version tag
538  print *,' - Selected Control Flag settings: ICTMflg=',ictmflg, &
539  & ' ISOLar =',isolar, ' ICO2flg=',ico2flg,' IAERflg=',iaerflg, &
540  & ' IALBflg=',ialbflg,' IEMSflg=',iemsflg,' ICLDflg=',icldflg, &
541  & ' ICMPHYS=',icmphys,' IOZNflg=',ioznflg
542  print *,' IVFLIP=',ivflip,' IOVRSW=',iovrsw,' IOVRLW=',iovrlw, &
543  & ' ISUBCSW=',isubcsw,' ISUBCLW=',isubclw
544 ! write(0,*)' IVFLIP=',ivflip,' IOVRSW=',iovrsw,' IOVRLW=',iovrlw,&
545 ! & ' ISUBCSW=',isubcsw,' ISUBCLW=',isubclw
546  print *,' LCRICK=',lcrick,' LCNORM=',lcnorm,' LNOPREC=',lnoprec
547  print *,' LTP =',ltp,', add extra top layer =',lextop
548 
549  if ( ictmflg==0 .or. ictmflg==-2 ) then
550  print *,' Data usage is limited by initial condition!'
551  print *,' No volcanic aerosols'
552  endif
553 
554  if ( isubclw == 0 ) then
555  print *,' - ISUBCLW=',isubclw,' No McICA, use grid ', &
556  & 'averaged cloud in LW radiation'
557  elseif ( isubclw == 1 ) then
558  print *,' - ISUBCLW=',isubclw,' Use McICA with fixed ', &
559  & 'permutation seeds for LW random number generator'
560  elseif ( isubclw == 2 ) then
561  print *,' - ISUBCLW=',isubclw,' Use McICA with random ', &
562  & 'permutation seeds for LW random number generator'
563  else
564  print *,' - ERROR!!! ISUBCLW=',isubclw,' is not a ', &
565  & 'valid option '
566  stop
567  endif
568 
569  if ( isubcsw == 0 ) then
570  print *,' - ISUBCSW=',isubcsw,' No McICA, use grid ', &
571  & 'averaged cloud in SW radiation'
572  elseif ( isubcsw == 1 ) then
573  print *,' - ISUBCSW=',isubcsw,' Use McICA with fixed ', &
574  & 'permutation seeds for SW random number generator'
575  elseif ( isubcsw == 2 ) then
576  print *,' - ISUBCSW=',isubcsw,' Use McICA with random ', &
577  & 'permutation seeds for SW random number generator'
578  else
579  print *,' - ERROR!!! ISUBCSW=',isubcsw,' is not a ', &
580  & 'valid option '
581  stop
582  endif
583 
584  if ( isubcsw /= isubclw ) then
585  print *,' - *** Notice *** ISUBCSW /= ISUBCLW !!!', &
586  & isubcsw, isubclw
587  endif
588  endif
589 
605 ! Initialization
606 
607  call sol_init ( me ) ! --- ... astronomy initialization routine
608 
609  call aer_init ( nlay, me ) ! --- ... aerosols initialization routine
610 
611  call gas_init ( me ) ! --- ... co2 and other gases initialization routine
612 
613  call sfc_init ( me ) ! --- ... surface initialization routine
614 
615  call cld_init ( si, nlay, me) ! --- ... cloud initialization routine
616 
617  call rlwinit ( me ) ! --- ... lw radiation initialization routine
618 
619  call rswinit ( me ) ! --- ... sw radiation initialization routine
620 !
621  return
622 !...................................
623  end subroutine radinit
624 !-----------------------------------
626 
647 !-----------------------------------
648  subroutine radupdate( idate,jdate,deltsw,deltim,lsswr, me, &
649  & slag,sdec,cdec,solcon)
650 !...................................
651 
652 ! ================= subprogram documentation block ================ !
653 ! !
654 ! subprogram: radupdate calls many update subroutines to check and !
655 ! update radiation required but time varying data sets and module !
656 ! variables. !
657 ! !
658 ! usage: call radupdate !
659 ! !
660 ! attributes: !
661 ! language: fortran 90 !
662 ! machine: ibm sp !
663 ! !
664 ! ==================== definition of variables ==================== !
665 ! !
666 ! input parameters: !
667 ! idate(8) : ncep absolute date and time of initial condition !
668 ! (yr, mon, day, t-zone, hr, min, sec, mil-sec) !
669 ! jdate(8) : ncep absolute date and time at fcst time !
670 ! (yr, mon, day, t-zone, hr, min, sec, mil-sec) !
671 ! deltsw : sw radiation calling frequency in seconds !
672 ! deltim : model timestep in seconds !
673 ! lsswr : logical flags for sw radiation calculations !
674 ! me : print control flag !
675 ! !
676 ! outputs: !
677 ! slag : equation of time in radians !
678 ! sdec, cdec : sin and cos of the solar declination angle !
679 ! solcon : sun-earth distance adjusted solar constant (w/m2) !
680 ! !
681 ! external module variables: !
682 ! isolar : solar constant cntrl (in module physparam) !
683 ! = 0: use the old fixed solar constant in "physcon" !
684 ! =10: use the new fixed solar constant in "physcon" !
685 ! = 1: use noaa ann-mean tsi tbl abs-scale with cycle apprx!
686 ! = 2: use noaa ann-mean tsi tbl tim-scale with cycle apprx!
687 ! = 3: use cmip5 ann-mean tsi tbl tim-scale with cycl apprx!
688 ! = 4: use cmip5 mon-mean tsi tbl tim-scale with cycl apprx!
689 ! ictmflg : =yyyy#, external data ic time/date control flag !
690 ! = -2: same as 0, but superimpose seasonal cycle !
691 ! from climatology data set. !
692 ! = -1: use user provided external data for the !
693 ! forecast time, no extrapolation. !
694 ! = 0: use data at initial cond time, if not !
695 ! available, use latest, no extrapolation. !
696 ! = 1: use data at the forecast time, if not !
697 ! available, use latest and extrapolation. !
698 ! =yyyy0: use yyyy data for the forecast time, !
699 ! no further data extrapolation. !
700 ! =yyyy1: use yyyy data for the fcst. if needed, do !
701 ! extrapolation to match the fcst time. !
702 ! !
703 ! module variables: !
704 ! loz1st : first-time clim ozone data read flag !
705 ! !
706 ! subroutines called: sol_update, aer_update, gas_update !
707 ! !
708 ! =================================================================== !
709 !
710  implicit none
711 
712 ! --- inputs:
713  integer, intent(in) :: idate(:), jdate(:), me
714  logical, intent(in) :: lsswr
715 
716  real (kind=kind_phys), intent(in) :: deltsw, deltim
717 
718 ! --- outputs:
719  real (kind=kind_phys), intent(out) :: slag, sdec, cdec, solcon
720 
721 ! --- locals:
722  integer :: iyear, imon, iday, ihour
723  integer :: kyear, kmon, kday, khour
724 
725  logical :: lmon_chg ! month change flag
726  logical :: lco2_chg ! cntrl flag for updating co2 data
727  logical :: lsol_chg ! cntrl flag for updating solar constant
728 !
729 !===> ... begin here
730 !
733 ! --- ... time stamp at fcst time
734 
735  iyear = jdate(1)
736  imon = jdate(2)
737  iday = jdate(3)
738  ihour = jdate(5)
739 
740 ! --- ... set up time stamp used for green house gases (** currently co2 only)
741 
742  if ( ictmflg==0 .or. ictmflg==-2 ) then ! get external data at initial condition time
743  kyear = idate(1)
744  kmon = idate(2)
745  kday = idate(3)
746  khour = idate(5)
747  else ! get external data at fcst or specified time
748  kyear = iyear
749  kmon = imon
750  kday = iday
751  khour = ihour
752  endif ! end if_ictmflg_block
753 
754  if ( month0 /= imon ) then
755  lmon_chg = .true.
756  month0 = imon
757  else
758  lmon_chg = .false.
759  endif
760 
763  if (lsswr) then
764 
765  if ( isolar == 0 .or. isolar == 10 ) then
766  lsol_chg = .false.
767  elseif ( iyear0 /= iyear ) then
768  lsol_chg = .true.
769  else
770  lsol_chg = ( isolar==4 .and. lmon_chg )
771  endif
772  iyear0 = iyear
773 
774  call sol_update &
775 ! --- inputs:
776  & ( jdate,kyear,deltsw,deltim,lsol_chg, me, &
777 ! --- outputs:
778  & slag,sdec,cdec,solcon &
779  & )
780 
781  endif ! end_if_lsswr_block
782 
785  if ( lmon_chg ) then
786  call aer_update ( iyear, imon, me )
787  endif
788 
791  if ( monthd /= kmon ) then
792  monthd = kmon
793  lco2_chg = .true.
794  else
795  lco2_chg = .false.
796  endif
797 
798  call gas_update ( kyear,kmon,kday,khour,loz1st,lco2_chg, me )
799 
800  if ( loz1st ) loz1st = .false.
801 
803 ! call sfc_update ( iyear, imon, me )
804 
806 ! call cld_update ( iyear, imon, me )
807 !
808  return
809 !...................................
810  end subroutine radupdate
811 !-----------------------------------
813 
994 !-----------------------------------
995  subroutine grrad &
996  & ( prsi,prsl,prslk,tgrs,qgrs,tracer,vvl,slmsk, & ! --- inputs
997  & xlon,xlat,tsfc,snowd,sncovr,snoalb,zorl,hprim, &
998  & alvsf,alnsf,alvwf,alnwf,facsf,facwf,fice,tisfc, &
999  & sinlat,coslat,solhr,jdate,solcon, &
1000  & cv,cvt,cvb,fcice,frain,rrime,flgmin, &
1001  & icsdsw,icsdlw, ntcw,ncld,ntoz, ntrac,nfxr, &
1002  & dtlw,dtsw, lsswr,lslwr,lssav, uni_cld,lmfshal,lmfdeep2, &
1003  & ix, im, lm, me, lprnt, ipt, kdt, deltaq,sup,cnvw,cnvc, &
1004  & htrsw,topfsw,sfcfsw,dswcmp,uswcmp,sfalb,coszen,coszdg, & ! --- outputs:
1005  & htrlw,topflw,sfcflw,tsflw,semis,cldcov, &
1006  & fluxr & ! --- input/output:
1007  &, htrlw0,htrsw0,htrswb,htrlwb & !! --- optional outputs:
1008  & )
1010 ! ================= subprogram documentation block ================ !
1011 ! !
1012 ! this program is the driver of radiation calculation subroutines. * !
1013 ! It sets up profile variables for radiation input, including * !
1014 ! clouds, surface albedos, atmospheric aerosols, ozone, etc. * !
1015 ! * !
1016 ! usage: call grrad * !
1017 ! * !
1018 ! subprograms called: * !
1019 ! setalb, setemis, setaer, getozn, getgases, * !
1020 ! progcld1, progcld2, diagcds, * !
1021 ! swrad, lwrad, fpvs * !
1022 ! * !
1023 ! attributes: * !
1024 ! language: fortran 90 * !
1025 ! machine: ibm-sp, sgi * !
1026 ! * !
1027 ! * !
1028 ! ==================== definition of variables ==================== !
1029 ! !
1030 ! input variables: !
1031 ! prsi (IX,LM+1) : model level pressure in Pa !
1032 ! prsl (IX,LM) : model layer mean pressure Pa !
1033 ! prslk (IX,LM) : exner function = (p/p0)**rocp !
1034 ! tgrs (IX,LM) : model layer mean temperature in k !
1035 ! qgrs (IX,LM) : layer specific humidity in gm/gm !
1036 ! tracer(IX,LM,NTRAC):layer prognostic tracer amount/mixing-ratio !
1037 ! incl: oz, cwc, aeros, etc. !
1038 ! vvl (IX,LM) : layer mean vertical velocity in pa/sec !
1039 ! slmsk (IM) : sea/land mask array (sea:0,land:1,sea-ice:2) !
1040 ! xlon (IM) : grid longitude in radians, ok for both 0->2pi !
1041 ! or -pi -> +pi ranges !
1042 ! xlat (IM) : grid latitude in radians, default to pi/2 -> !
1043 ! -pi/2 range, otherwise adj in subr called !
1044 ! tsfc (IM) : surface temperature in k !
1045 ! snowd (IM) : snow depth water equivalent in mm !
1046 ! sncovr(IM) : snow cover in fraction !
1047 ! snoalb(IM) : maximum snow albedo in fraction !
1048 ! zorl (IM) : surface roughness in cm !
1049 ! hprim (IM) : topographic standard deviation in m !
1050 ! alvsf (IM) : mean vis albedo with strong cosz dependency !
1051 ! alnsf (IM) : mean nir albedo with strong cosz dependency !
1052 ! alvwf (IM) : mean vis albedo with weak cosz dependency !
1053 ! alnwf (IM) : mean nir albedo with weak cosz dependency !
1054 ! facsf (IM) : fractional coverage with strong cosz dependen !
1055 ! facwf (IM) : fractional coverage with weak cosz dependency !
1056 ! fice (IM) : ice fraction over open water grid !
1057 ! tisfc (IM) : surface temperature over ice fraction !
1058 ! sinlat(IM) : sine of the grids' corresponding latitudes !
1059 ! coslat(IM) : cosine of the grids' corresponding latitudes !
1060 ! solhr : hour time after 00z at the t-stepe !
1061 ! jdate (8) : current forecast date and time !
1062 ! (yr, mon, day, t-zone, hr, min, sec, mil-sec) !
1063 ! solcon : solar constant (sun-earth distant adjusted) !
1064 ! cv (IM) : fraction of convective cloud !
1065 ! cvt, cvb (IM) : convective cloud top/bottom pressure in pa !
1066 ! fcice : fraction of cloud ice (in ferrier scheme) !
1067 ! frain : fraction of rain water (in ferrier scheme) !
1068 ! rrime : mass ratio of total to unrimed ice ( >= 1 ) !
1069 ! flgmin : minimim large ice fraction !
1070 ! icsdsw/icsdlw : auxiliary cloud control arrays passed to main !
1071 ! (IM) radiations. if isubcsw/isubclw (input to init) !
1072 ! are set to 2, the arrays contains provided !
1073 ! random seeds for sub-column clouds generators !
1074 ! lmfshal : mass-flux shallow conv scheme flag !
1075 ! lmfdeep2 : scale-aware mass-flux deep conv scheme flag !
1076 ! ntcw : =0 no cloud condensate calculated !
1077 ! >0 array index location for cloud condensate !
1078 ! ncld : only used when ntcw .gt. 0 !
1079 ! ntoz : =0 climatological ozone profile !
1080 ! >0 interactive ozone profile !
1081 ! NTRAC : dimension veriable for array oz !
1082 ! NFXR : second dimension of input/output array fluxr !
1083 ! dtlw, dtsw : time duration for lw/sw radiation call in sec !
1084 ! lsswr, lslwr : logical flags for sw/lw radiation calls !
1085 ! lssav : logical flag for store 3-d cloud field !
1086 ! IX,IM : horizontal dimention and num of used points !
1087 ! LM : vertical layer dimension !
1088 ! me : control flag for parallel process !
1089 ! lprnt : control flag for diagnostic print out !
1090 ! ipt : index for diagnostic printout point !
1091 ! kdt : time-step number !
1092 ! deltaq : half width of uniform total water distribution !
1093 ! sup : supersaturation in pdf cloud when t is very low!
1094 ! cnvw : layer convective cloud water !
1095 ! cnvc : layer convective cloud cover !
1096 ! !
1097 ! output variables: !
1098 ! htrsw (IX,LM) : total sky sw heating rate in k/sec !
1099 ! topfsw(IM) : sw radiation fluxes at toa, components: !
1100 ! (check module_radsw_parameters for definition) !
1101 ! %upfxc - total sky upward sw flux at toa (w/m**2) !
1102 ! %dnflx - total sky downward sw flux at toa (w/m**2) !
1103 ! %upfx0 - clear sky upward sw flux at toa (w/m**2) !
1104 ! sfcfsw(IM) : sw radiation fluxes at sfc, components: !
1105 ! (check module_radsw_parameters for definition) !
1106 ! %upfxc - total sky upward sw flux at sfc (w/m**2) !
1107 ! %dnfxc - total sky downward sw flux at sfc (w/m**2) !
1108 ! %upfx0 - clear sky upward sw flux at sfc (w/m**2) !
1109 ! %dnfx0 - clear sky downward sw flux at sfc (w/m**2) !
1110 ! dswcmp(IX,4) : dn sfc sw spectral components: !
1111 ! ( :, 1) - total sky sfc downward nir direct flux !
1112 ! ( :, 2) - total sky sfc downward nir diffused flux !
1113 ! ( :, 3) - total sky sfc downward uv+vis direct flux !
1114 ! ( :, 4) - total sky sfc downward uv+vis diff flux !
1115 ! uswcmp(IX,4) : up sfc sw spectral components: !
1116 ! ( :, 1) - total sky sfc upward nir direct flux !
1117 ! ( :, 2) - total sky sfc upward nir diffused flux !
1118 ! ( :, 3) - total sky sfc upward uv+vis direct flux !
1119 ! ( :, 4) - total sky sfc upward uv+vis diff flux !
1120 ! sfalb (IM) : mean surface diffused sw albedo !
1121 ! coszen(IM) : mean cos of zenith angle over rad call period !
1122 ! coszdg(IM) : daytime mean cosz over rad call period !
1123 ! htrlw (IX,LM) : total sky lw heating rate in k/sec !
1124 ! topflw(IM) : lw radiation fluxes at top, component: !
1125 ! (check module_radlw_paramters for definition) !
1126 ! %upfxc - total sky upward lw flux at toa (w/m**2) !
1127 ! %upfx0 - clear sky upward lw flux at toa (w/m**2) !
1128 ! sfcflw(IM) : lw radiation fluxes at sfc, component: !
1129 ! (check module_radlw_paramters for definition) !
1130 ! %upfxc - total sky upward lw flux at sfc (w/m**2) !
1131 ! %upfx0 - clear sky upward lw flux at sfc (w/m**2) !
1132 ! %dnfxc - total sky downward lw flux at sfc (w/m**2) !
1133 ! %dnfx0 - clear sky downward lw flux at sfc (w/m**2) !
1134 ! semis (IM) : surface lw emissivity in fraction !
1135 ! cldcov(IX,LM) : 3-d cloud fraction !
1136 ! tsflw (IM) : surface air temp during lw calculation in k !
1137 ! !
1138 ! input and output variables: !
1139 ! fluxr (IX,NFXR) : to save time accumulated 2-d fields defined as:!
1140 ! 1 - toa total sky upwd lw radiation flux !
1141 ! 2 - toa total sky upwd sw radiation flux !
1142 ! 3 - sfc total sky upwd sw radiation flux !
1143 ! 4 - sfc total sky dnwd sw radiation flux !
1144 ! 5 - high domain cloud fraction !
1145 ! 6 - mid domain cloud fraction !
1146 ! 7 - low domain cloud fraction !
1147 ! 8 - high domain mean cloud top pressure !
1148 ! 9 - mid domain mean cloud top pressure !
1149 ! 10 - low domain mean cloud top pressure !
1150 ! 11 - high domain mean cloud base pressure !
1151 ! 12 - mid domain mean cloud base pressure !
1152 ! 13 - low domain mean cloud base pressure !
1153 ! 14 - high domain mean cloud top temperature !
1154 ! 15 - mid domain mean cloud top temperature !
1155 ! 16 - low domain mean cloud top temperature !
1156 ! 17 - total cloud fraction !
1157 ! 18 - boundary layer domain cloud fraction !
1158 ! 19 - sfc total sky dnwd lw radiation flux !
1159 ! 20 - sfc total sky upwd lw radiation flux !
1160 ! 21 - sfc total sky dnwd sw uv-b radiation flux !
1161 ! 22 - sfc clear sky dnwd sw uv-b radiation flux !
1162 ! 23 - toa incoming solar radiation flux !
1163 ! 24 - sfc vis beam dnwd sw radiation flux !
1164 ! 25 - sfc vis diff dnwd sw radiation flux !
1165 ! 26 - sfc nir beam dnwd sw radiation flux !
1166 ! 27 - sfc nir diff dnwd sw radiation flux !
1167 ! 28 - toa clear sky upwd lw radiation flux !
1168 ! 29 - toa clear sky upwd sw radiation flux !
1169 ! 30 - sfc clear sky dnwd lw radiation flux !
1170 ! 31 - sfc clear sky upwd sw radiation flux !
1171 ! 32 - sfc clear sky dnwd sw radiation flux !
1172 ! 33 - sfc clear sky upwd lw radiation flux !
1173 !optional 34 - aeros opt depth at 550nm (all components) !
1174 ! 35 - aeros opt depth at 550nm for du component !
1175 ! 36 - aeros opt depth at 550nm for bc component !
1176 ! 37 - aeros opt depth at 550nm for oc component !
1177 ! 38 - aeros opt depth at 550nm for su component !
1178 ! 39 - aeros opt depth at 550nm for ss component !
1179 ! !
1180 ! optional output variables: !
1181 ! htrswb(IX,LM,NBDSW) : spectral band total sky sw heating rate !
1182 ! htrlwb(IX,LM,NBDLW) : spectral band total sky lw heating rate !
1183 ! !
1184 ! !
1185 ! definitions of internal variable arrays: !
1186 ! !
1187 ! 1. fixed gases: (defined in 'module_radiation_gases') !
1188 ! gasvmr(:,:,1) - co2 volume mixing ratio !
1189 ! gasvmr(:,:,2) - n2o volume mixing ratio !
1190 ! gasvmr(:,:,3) - ch4 volume mixing ratio !
1191 ! gasvmr(:,:,4) - o2 volume mixing ratio !
1192 ! gasvmr(:,:,5) - co volume mixing ratio !
1193 ! gasvmr(:,:,6) - cf11 volume mixing ratio !
1194 ! gasvmr(:,:,7) - cf12 volume mixing ratio !
1195 ! gasvmr(:,:,8) - cf22 volume mixing ratio !
1196 ! gasvmr(:,:,9) - ccl4 volume mixing ratio !
1197 ! !
1198 ! 2. cloud profiles: (defined in 'module_radiation_clouds') !
1199 ! --- for prognostic cloud --- !
1200 ! clouds(:,:,1) - layer total cloud fraction !
1201 ! clouds(:,:,2) - layer cloud liq water path !
1202 ! clouds(:,:,3) - mean effective radius for liquid cloud !
1203 ! clouds(:,:,4) - layer cloud ice water path !
1204 ! clouds(:,:,5) - mean effective radius for ice cloud !
1205 ! clouds(:,:,6) - layer rain drop water path !
1206 ! clouds(:,:,7) - mean effective radius for rain drop !
1207 ! clouds(:,:,8) - layer snow flake water path !
1208 ! clouds(:,:,9) - mean effective radius for snow flake !
1209 ! --- for diagnostic cloud --- !
1210 ! clouds(:,:,1) - layer total cloud fraction !
1211 ! clouds(:,:,2) - layer cloud optical depth !
1212 ! clouds(:,:,3) - layer cloud single scattering albedo !
1213 ! clouds(:,:,4) - layer cloud asymmetry factor !
1214 ! !
1215 ! 3. surface albedo: (defined in 'module_radiation_surface') !
1216 ! sfcalb( :,1 ) - near ir direct beam albedo !
1217 ! sfcalb( :,2 ) - near ir diffused albedo !
1218 ! sfcalb( :,3 ) - uv+vis direct beam albedo !
1219 ! sfcalb( :,4 ) - uv+vis diffused albedo !
1220 ! !
1221 ! 4. sw aerosol profiles: (defined in 'module_radiation_aerosols') !
1222 ! faersw(:,:,:,1)- sw aerosols optical depth !
1223 ! faersw(:,:,:,2)- sw aerosols single scattering albedo !
1224 ! faersw(:,:,:,3)- sw aerosols asymmetry parameter !
1225 ! !
1226 ! 5. lw aerosol profiles: (defined in 'module_radiation_aerosols') !
1227 ! faerlw(:,:,:,1)- lw aerosols optical depth !
1228 ! faerlw(:,:,:,2)- lw aerosols single scattering albedo !
1229 ! faerlw(:,:,:,3)- lw aerosols asymmetry parameter !
1230 ! !
1231 ! 6. sw fluxes at toa: (defined in 'module_radsw_main') !
1232 ! (topfsw_type -- derived data type for toa rad fluxes) !
1233 ! topfsw(:)%upfxc - total sky upward flux at toa !
1234 ! topfsw(:)%dnfxc - total sky downward flux at toa !
1235 ! topfsw(:)%upfx0 - clear sky upward flux at toa !
1236 ! !
1237 ! 7. lw fluxes at toa: (defined in 'module_radlw_main') !
1238 ! (topflw_type -- derived data type for toa rad fluxes) !
1239 ! topflw(:)%upfxc - total sky upward flux at toa !
1240 ! topflw(:)%upfx0 - clear sky upward flux at toa !
1241 ! !
1242 ! 8. sw fluxes at sfc: (defined in 'module_radsw_main') !
1243 ! (sfcfsw_type -- derived data type for sfc rad fluxes) !
1244 ! sfcfsw(:)%upfxc - total sky upward flux at sfc !
1245 ! sfcfsw(:)%dnfxc - total sky downward flux at sfc !
1246 ! sfcfsw(:)%upfx0 - clear sky upward flux at sfc !
1247 ! sfcfsw(:)%dnfx0 - clear sky downward flux at sfc !
1248 ! !
1249 ! 9. lw fluxes at sfc: (defined in 'module_radlw_main') !
1250 ! (sfcflw_type -- derived data type for sfc rad fluxes) !
1251 ! sfcflw(:)%upfxc - total sky upward flux at sfc !
1252 ! sfcflw(:)%dnfxc - total sky downward flux at sfc !
1253 ! sfcflw(:)%dnfx0 - clear sky downward flux at sfc !
1254 ! !
1255 !! optional radiation outputs: !
1256 !! 10. sw flux profiles: (defined in 'module_radsw_main') !
1257 !! (profsw_type -- derived data type for rad vertical profiles) !
1258 !! fswprf(:,:)%upfxc - total sky upward flux !
1259 !! fswprf(:,:)%dnfxc - total sky downward flux !
1260 !! fswprf(:,:)%upfx0 - clear sky upward flux !
1261 !! fswprf(:,:)%dnfx0 - clear sky downward flux !
1262 !! !
1263 !! 11. lw flux profiles: (defined in 'module_radlw_main') !
1264 !! (proflw_type -- derived data type for rad vertical profiles) !
1265 !! flwprf(:,:)%upfxc - total sky upward flux !
1266 !! flwprf(:,:)%dnfxc - total sky downward flux !
1267 !! flwprf(:,:)%upfx0 - clear sky upward flux !
1268 !! flwprf(:,:)%dnfx0 - clear sky downward flux !
1269 !! !
1270 !! 12. sw sfc components: (defined in 'module_radsw_main') !
1271 !! (cmpfsw_type -- derived data type for component sfc fluxes) !
1272 !! scmpsw(:)%uvbfc - total sky downward uv-b flux at sfc !
1273 !! scmpsw(:)%uvbf0 - clear sky downward uv-b flux at sfc !
1274 !! scmpsw(:)%nirbm - total sky sfc downward nir direct flux !
1275 !! scmpsw(:)%nirdf - total sky sfc downward nir diffused flux !
1276 !! scmpsw(:)%visbm - total sky sfc downward uv+vis direct flx !
1277 !! scmpsw(:)%visdf - total sky sfc downward uv+vis diff flux !
1278 ! !
1279 ! external module variables: !
1280 ! ivflip : control flag for in/out vertical indexing !
1281 ! =0 index from toa to surface !
1282 ! =1 index from surface to toa !
1283 ! icmphys : cloud microphysics scheme control flag !
1284 ! =1 zhao/carr/sundqvist microphysics scheme !
1285 ! =2 brad ferrier microphysics scheme !
1286 ! =3 zhao/carr/sundqvist microphysics +pdf cloud !
1287 ! !
1288 ! module variables: !
1289 ! itsfc : =0 use same sfc skin-air/ground temp !
1290 ! =1 use diff sfc skin-air/ground temp (not yet) !
1291 ! !
1292 ! ====================== end of definitions ======================= !
1293 !
1294  implicit none
1295 
1296 ! --- inputs: (for rank>1 arrays, horizontal dimensioned by IX)
1297  integer, intent(in) :: IX,IM, LM, NTRAC, NFXR, me, &
1298  & ntoz, ntcw, ncld, ipt, kdt
1299  integer, intent(in) :: icsdsw(im), icsdlw(im), jdate(8)
1300 
1301  logical, intent(in) :: lsswr, lslwr, lssav, lprnt, uni_cld, &
1302  & lmfshal, lmfdeep2
1303 
1304  real (kind=kind_phys), dimension(IX,LM+1), intent(in) :: prsi
1305 
1306  real (kind=kind_phys), dimension(IX,LM), intent(in) :: prsl, &
1307  & prslk, tgrs, qgrs, vvl, fcice, frain, rrime, deltaq, cnvw, &
1308  & cnvc
1309  real (kind=kind_phys), dimension(IM), intent(in) :: flgmin
1310  real(kind=kind_phys), intent(in) :: sup
1311 
1312  real (kind=kind_phys), dimension(IM), intent(in) :: slmsk, &
1313  & xlon, xlat, tsfc, snowd, zorl, hprim, alvsf, alnsf, alvwf, &
1314  & alnwf, facsf, facwf, cv, cvt, cvb, fice, tisfc, &
1315  & sncovr, snoalb, sinlat, coslat
1316 
1317  real (kind=kind_phys), intent(in) :: solcon, dtlw, dtsw, solhr, &
1318  & tracer(IX,LM,NTRAC)
1319 
1320  real (kind=kind_phys), dimension(IX,LM),intent(inout):: cldcov
1321 
1322 ! --- outputs: (horizontal dimensioned by IX)
1323  real (kind=kind_phys), dimension(IX,LM),intent(out):: htrsw,htrlw
1324 
1325  real (kind=kind_phys), dimension(IX,4), intent(out) :: dswcmp, &
1326  & uswcmp
1327 
1328  real (kind=kind_phys), dimension(IM), intent(out):: tsflw, &
1329  & sfalb, semis, coszen, coszdg
1330 
1331  type(topfsw_type), dimension(IM), intent(out) :: topfsw
1332  type(sfcfsw_type), dimension(IM), intent(out) :: sfcfsw
1333 
1334  type(topflw_type), dimension(IM), intent(out) :: topflw
1335  type(sfcflw_type), dimension(IM), intent(out) :: sfcflw
1336 
1337 ! --- variables are for both input and output:
1338  real (kind=kind_phys), intent(inout) :: fluxr(ix,nfxr)
1339 
1340 !! --- optional outputs:
1341  real (kind=kind_phys), dimension(IX,LM,NBDSW), optional,
1342  & intent(out) :: htrswb
1343  real (kind=kind_phys), dimension(IX,LM,NBDLW), optional,
1344  & intent(out) :: htrlwb
1345  real (kind=kind_phys), dimension(ix,lm), optional, &
1346  & intent(out) :: htrlw0
1347  real (kind=kind_phys), dimension(ix,lm), optional, &
1348  & intent(out) :: htrsw0
1349 
1350 ! --- local variables: (horizontal dimensioned by IM)
1351  real (kind=kind_phys), dimension(IM,LM+1+LTP):: plvl, tlvl
1352 
1353  real (kind=kind_phys), dimension(IM,LM+LTP) :: plyr, tlyr, qlyr, &
1354  & olyr, rhly, qstl, vvel, clw, prslk1, tem2da, tem2db, tvly
1355 
1356  real (kind=kind_phys), dimension(IM) :: tsfa, cvt1, cvb1, tem1d, &
1357  & sfcemis, tsfg, tskn
1358 
1359  real (kind=kind_phys), dimension(IM,LM+LTP,NF_CLDS) :: clouds
1360  real (kind=kind_phys), dimension(IM,LM+LTP,NF_VGAS) :: gasvmr
1361  real (kind=kind_phys), dimension(IM, NF_ALBD) :: sfcalb
1362  real (kind=kind_phys), dimension(IM, NSPC1) :: aerodp
1363  real (kind=kind_phys), dimension(IM,LM+LTP,NTRAC) :: tracer1
1364 
1365  real (kind=kind_phys), dimension(IM,LM+LTP,NBDSW,NF_AESW)::faersw
1366  real (kind=kind_phys), dimension(IM,LM+LTP,NBDLW,NF_AELW)::faerlw
1367 
1368  real (kind=kind_phys), dimension(IM,LM+LTP) :: htswc
1369  real (kind=kind_phys), dimension(IM,LM+LTP) :: htlwc
1370 
1371  real (kind=kind_phys), dimension(IM,LM+LTP) :: gcice, grain, grime
1372 
1373 !! --- may be used for optional sw/lw outputs:
1374 !! take out "!!" as needed
1375  real (kind=kind_phys), dimension(IM,LM+LTP) :: htsw0
1376 !! type (profsw_type), dimension(IM,LM+1+LTP) :: fswprf
1377  type(cmpfsw_type), dimension(IM) :: scmpsw
1378  real (kind=kind_phys), dimension(IM,LM+LTP,NBDSW) :: htswb
1379 
1380  real (kind=kind_phys), dimension(IM,LM+LTP) :: htlw0
1381 !! type (proflw_type), dimension(IM,LM+1+LTP) :: flwprf
1382  real (kind=kind_phys), dimension(IM,LM+LTP,NBDLW) :: htlwb
1383 
1384  real (kind=kind_phys) :: raddt, es, qs, delt, tem0d, cldsa(im,5)
1385 
1386  integer :: i, j, k, k1, lv, icec, itop, ibtc, nday, idxday(im), &
1387  & mbota(IM,3), mtopa(IM,3), LP1, nb, LMK, LMP, kd, lla, llb, &
1388  & lya, lyb, kt, kb
1389 
1390 ! --- for debug test use
1391 ! real (kind=kind_phys) :: temlon, temlat, alon, alat
1392 ! integer :: ipt
1393 ! logical :: lprnt1
1394 
1395 !
1396 !===> ... begin here
1397 !
1398  lp1 = lm + 1 ! num of in/out levels
1399 
1400 ! --- ... set local /level/layer indexes corresponding to in/out variables
1401 
1402  lmk = lm + ltp ! num of local layers
1403  lmp = lmk + 1 ! num of local levels
1404 
1405  if ( lextop ) then
1406  if ( ivflip == 1 ) then ! vertical from sfc upward
1407  kd = 0 ! index diff between in/out and local
1408  kt = 1 ! index diff between lyr and upper bound
1409  kb = 0 ! index diff between lyr and lower bound
1410  lla = lmk ! local index at the 2nd level from top
1411  llb = lmp ! local index at toa level
1412  lya = lm ! local index for the 2nd layer from top
1413  lyb = lp1 ! local index for the top layer
1414  else ! vertical from toa downward
1415  kd = 1 ! index diff between in/out and local
1416  kt = 0 ! index diff between lyr and upper bound
1417  kb = 1 ! index diff between lyr and lower bound
1418  lla = 2 ! local index at the 2nd level from top
1419  llb = 1 ! local index at toa level
1420  lya = 2 ! local index for the 2nd layer from top
1421  lyb = 1 ! local index for the top layer
1422  endif ! end if_ivflip_block
1423  else
1424  kd = 0
1425  if ( ivflip == 1 ) then ! vertical from sfc upward
1426  kt = 1 ! index diff between lyr and upper bound
1427  kb = 0 ! index diff between lyr and lower bound
1428  else ! vertical from toa downward
1429  kt = 0 ! index diff between lyr and upper bound
1430  kb = 1 ! index diff between lyr and lower bound
1431  endif ! end if_ivflip_block
1432  endif ! end if_lextop_block
1433 
1434  raddt = min(dtsw, dtlw)
1435 
1436 ! --- ... for debug test
1437 ! alon = 120.0
1438 ! alat = 29.5
1439 ! ipt = 0
1440 ! do i = 1, IM
1441 ! temlon = xlon(i) * 57.29578
1442 ! if (temlon < 0.0) temlon = temlon + 360.0
1443 ! temlat = xlat(i) * 57.29578
1444 ! lprnt1 = abs(temlon-alon) < 1.1 .and. abs(temlat-alat) < 1.1
1445 ! if ( lprnt1 ) then
1446 ! ipt = i
1447 ! exit
1448 ! endif
1449 ! enddo
1450 
1451 ! print *,' in grrad : raddt=',raddt
1452 
1455 
1456  if ( itsfc == 0 ) then ! use same sfc skin-air/ground temp
1457  do i = 1, im
1458  tskn(i) = tsfc(i)
1459  tsfg(i) = tsfc(i)
1460  enddo
1461  else ! use diff sfc skin-air/ground temp
1462  do i = 1, im
1463 !! tskn(i) = ta (i) ! not yet
1464 !! tsfg(i) = tg (i) ! not yet
1465  tskn(i) = tsfc(i)
1466  tsfg(i) = tsfc(i)
1467  enddo
1468  endif
1469 
1471 !
1472 ! convert pressure unit from pa to mb
1473  do k = 1, lm
1474  k1 = k + kd
1475  do i = 1, im
1476 ! plvl(i,k1) = 10.0 * prsi(i,k) ! cb (kpa) to mb (hpa)
1477 ! plyr(i,k1) = 10.0 * prsl(i,k) ! cb (kpa) to mb (hpa)
1478  plvl(i,k1) = 0.01 * prsi(i,k) ! pa to mb (hpa)
1479  plyr(i,k1) = 0.01 * prsl(i,k) ! pa to mb (hpa)
1480  tlyr(i,k1) = tgrs(i,k)
1481  prslk1(i,k1) = prslk(i,k)
1482 
1484 ! es = min( prsl(i,k), 0.001 * fpvs( tgrs(i,k) ) ) ! fpvs in pa
1485  es = min( prsl(i,k), fpvs( tgrs(i,k) ) ) ! fpvs and prsl in pa
1486  qs = max( qmin, eps * es / (prsl(i,k) + epsm1*es) )
1487  rhly(i,k1) = max( 0.0, min( 1.0, max(qmin, qgrs(i,k))/qs ) )
1488  qstl(i,k1) = qs
1489  enddo
1490  enddo
1491  do j = 1, ntrac
1492  do k = 1, lm
1493  k1 = k + kd
1494  do i = 1, im
1495  tracer1(i,k1,j) = tracer(i,k,j)
1496  enddo
1497  enddo
1498  enddo
1499 
1500  do i = 1, im
1501 ! plvl(i,LP1+kd) = 10.0 * prsi(i,LP1) ! cb (kpa) to mb (hpa
1502  plvl(i,lp1+kd) = 0.01 * prsi(i,lp1) ! pa to mb (hpa)
1503  enddo
1504 
1505  if ( lextop ) then ! values for extra top layer
1506  do i = 1, im
1507  plvl(i,llb) = prsmin
1508  if ( plvl(i,lla) <= prsmin ) plvl(i,lla) = 2.0*prsmin
1509  plyr(i,lyb) = 0.5 * plvl(i,lla)
1510  tlyr(i,lyb) = tlyr(i,lya)
1511 ! prslk1(i,lyb) = (plyr(i,lyb)*0.001) ** rocp ! plyr in hPa
1512  prslk1(i,lyb) = (plyr(i,lyb)*0.00001) ** rocp ! plyr in Pa
1513 
1514  rhly(i,lyb) = rhly(i,lya)
1515  qstl(i,lyb) = qstl(i,lya)
1516  enddo
1517 
1518  do j = 1, ntrac
1519  do i = 1, im
1520 ! --- note: may need to take care the top layer amount
1521  tracer1(i,lyb,j) = tracer1(i,lya,j)
1522  enddo
1523  enddo
1524  endif
1525 
1527 
1528  if (icmphys == 2) then
1529  do k = 1, lm
1530  k1 = k + kd
1531 
1532  do i = 1, im
1533  gcice(i,k1) = fcice(i,k)
1534  grain(i,k1) = frain(i,k)
1535  grime(i,k1) = rrime(i,k)
1536  enddo
1537  enddo
1538 
1539  if ( lextop ) then
1540  do i = 1, im
1541  gcice(i,lyb) = fcice(i,lya)
1542  grain(i,lyb) = frain(i,lya)
1543  grime(i,lyb) = rrime(i,lya)
1544  enddo
1545  endif
1546  endif ! if_icmphys
1547 
1550 
1551  if (ntoz > 0) then ! interactive ozone generation
1552 
1553  do k = 1, lmk
1554  do i = 1, im
1555  olyr(i,k) = max( qmin, tracer1(i,k,ntoz) )
1556  enddo
1557  enddo
1558 
1559  else ! climatological ozone
1560 
1561 ! print *,' in grrad : calling getozn'
1562  call getozn &
1563 ! --- inputs:
1564  & ( prslk1,xlat, &
1565  & im, lmk, &
1566 ! --- outputs:
1567  & olyr &
1568  & )
1569 
1570  endif ! end_if_ntoz
1571 
1573 
1574  call coszmn &
1575 ! --- inputs:
1576  & ( xlon,sinlat,coslat,solhr, im, me, &
1577 ! --- outputs:
1578  & coszen, coszdg &
1579  & )
1580 
1583 ! - gasvmr(:,:,1) - co2 volume mixing ratio
1584 ! - gasvmr(:,:,2) - n2o volume mixing ratio
1585 ! - gasvmr(:,:,3) - ch4 volume mixing ratio
1586 ! - gasvmr(:,:,4) - o2 volume mixing ratio
1587 ! - gasvmr(:,:,5) - co volume mixing ratio
1588 ! - gasvmr(:,:,6) - cf11 volume mixing ratio
1589 ! - gasvmr(:,:,7) - cf12 volume mixing ratio
1590 ! - gasvmr(:,:,8) - cf22 volume mixing ratio
1591 ! - gasvmr(:,:,9) - ccl4 volume mixing ratio
1592 
1593 ! --- ... set up non-prognostic gas volume mixing ratioes
1594 
1595  call getgases &
1596 ! --- inputs:
1597  & ( plvl, xlon, xlat, &
1598  & im, lmk, &
1599 ! --- outputs:
1600  & gasvmr &
1601  & )
1602 
1604 
1605  do k = 2, lmk
1606  do i = 1, im
1607  tem2da(i,k) = log( plyr(i,k) )
1608  tem2db(i,k) = log( plvl(i,k) )
1609  enddo
1610  enddo
1611 
1612  if (ivflip == 0) then ! input data from toa to sfc
1613 
1614  do i = 1, im
1615  tem1d(i) = qme6
1616  tem2da(i,1) = log( plyr(i,1) )
1617  tem2db(i,1) = 1.0
1618  tsfa(i) = tlyr(i,lmk) ! sfc layer air temp
1619  tlvl(i,1) = tlyr(i,1)
1620  tlvl(i,lmp) = tskn(i)
1621  enddo
1622 
1623  do k = 1, lm
1624  k1 = k + kd
1625 
1626  do i = 1, im
1627  qlyr(i,k1) = max( tem1d(i), qgrs(i,k) )
1628  tem1d(i) = min( qme5, qlyr(i,k1) )
1629  tvly(i,k1) = tgrs(i,k) * (1.0 + fvirt*qlyr(i,k1)) ! virtual T (K)
1630  enddo
1631  enddo
1632 
1633  if ( lextop ) then
1634  do i = 1, im
1635  qlyr(i,lyb) = qlyr(i,lya)
1636  tvly(i,lyb) = tvly(i,lya)
1637  enddo
1638  endif
1639 
1640  do k = 2, lmk
1641  do i = 1, im
1642  tlvl(i,k) = tlyr(i,k) + (tlyr(i,k-1) - tlyr(i,k)) &
1643  & * (tem2db(i,k) - tem2da(i,k)) &
1644  & / (tem2da(i,k-1) - tem2da(i,k))
1645  enddo
1646  enddo
1647 
1648  else ! input data from sfc to toa
1649 
1650  do i = 1, im
1651  tem1d(i) = qme6
1652  tem2da(i,1) = log( plyr(i,1) )
1653  tem2db(i,1) = log( plvl(i,1) )
1654  tsfa(i) = tlyr(i,1) ! sfc layer air temp
1655  tlvl(i,1) = tskn(i)
1656  tlvl(i,lmp) = tlyr(i,lmk)
1657  enddo
1658 
1659  do k = lm, 1, -1
1660  do i = 1, im
1661  qlyr(i,k) = max( tem1d(i), qgrs(i,k) )
1662  tem1d(i) = min( qme5, qlyr(i,k) )
1663  tvly(i,k) = tgrs(i,k) * (1.0 + fvirt*qlyr(i,k)) ! virtual T (K)
1664  enddo
1665  enddo
1666 
1667  if ( lextop ) then
1668  do i = 1, im
1669  qlyr(i,lyb) = qlyr(i,lya)
1670  tvly(i,lyb) = tvly(i,lya)
1671  enddo
1672  endif
1673 
1674  do k = 1, lmk-1
1675  do i = 1, im
1676  tlvl(i,k+1) = tlyr(i,k) + (tlyr(i,k+1) - tlyr(i,k)) &
1677  & * (tem2db(i,k+1) - tem2da(i,k)) &
1678  & / (tem2da(i,k+1) - tem2da(i,k))
1679  enddo
1680  enddo
1681 
1682  endif ! end_if_ivflip
1683 
1685 
1686  nday = 0
1687  do i = 1, im
1688  if (coszen(i) >= 0.0001) then
1689  nday = nday + 1
1690  idxday(nday) = i
1691  endif
1692  enddo
1693 
1694 ! write(0,*)' plvl=',plvl(ipt,1:65)
1695 ! write(0,*)' plyr=',plyr(ipt,1:64)
1696 ! write(0,*)' tlyr=',tlyr(ipt,1:64)
1697 ! write(0,*)' tlvl=',tlvl(ipt,1:65)
1698 ! write(0,*)' qlyr=',qlyr(ipt,1:10)*1000
1699 
1702 
1703 !check print *,' in grrad : calling setaer '
1704 
1705  call setaer &
1706 ! --- inputs:
1707  & ( plvl,plyr,prslk1,tvly,rhly,slmsk,tracer1,xlon,xlat, &
1708  & im,lmk,lmp, lsswr,lslwr, &
1709 ! --- outputs:
1710  & faersw,faerlw,aerodp &
1711  & )
1712 
1725 
1726 ! --- ... obtain cloud information for radiation calculations
1727 
1728  if (ntcw > 0) then ! prognostic cloud scheme
1729 
1730  do k = 1, lmk
1731  do i = 1, im
1732  clw(i,k) = 0.0
1733  enddo
1734 
1735  do j = 1, ncld
1736  lv = ntcw + j - 1
1737  do i = 1, im
1738  clw(i,k) = clw(i,k) + tracer1(i,k,lv) ! cloud condensate amount
1739  enddo
1740  enddo
1741  enddo
1742 
1743  do k = 1, lmk
1744  do i = 1, im
1745  if ( clw(i,k) < epsq ) clw(i,k) = 0.0
1746  enddo
1747  enddo
1748 !
1749 ! --- add suspended convective cloud water to grid-scale cloud water
1750 ! only for cloud fraction & radiation computation
1751 ! it is to enhance cloudiness due to suspended convec cloud water
1752 ! for zhao/moorthi's (icmphys=1) &
1753 ! ferrier's (icmphys=2) microphysics schemes
1754 !
1755  if (icmphys == 1 .or. icmphys == 2) then
1756  do k = 1, lmk
1757  do i = 1, im
1758  clw(i,k) = clw(i,k) + cnvw(i,k)
1759  enddo
1760  enddo
1761  endif
1762 !
1763 
1764  if (icmphys == 1) then ! zhao/moorthi's prognostic cloud scheme
1765 
1766  call progcld1 &
1767 ! --- inputs:
1768  & ( plyr,plvl,tlyr,tvly,qlyr,qstl,rhly,clw, &
1769  & xlat,xlon,slmsk, im, lmk, lmp, &
1770  & uni_cld, lmfshal, lmfdeep2, cldcov(1:im,1:lm), &
1771 ! --- outputs:
1772  & clouds,cldsa,mtopa,mbota &
1773  & )
1774 
1775  elseif (icmphys == 2) then ! ferrier's microphysics
1776 
1777 ! print *,' in grrad : calling progcld2'
1778  call progcld2 &
1779 ! --- inputs:
1780  & ( plyr,plvl,tlyr,tvly,qlyr,qstl,rhly,clw, &
1781  & xlat,xlon,slmsk, gcice,grain,grime,flgmin, &
1782  & im, lmk, lmp, lmfshal, lmfdeep2, &
1783 ! --- outputs:
1784  & clouds,cldsa,mtopa,mbota &
1785  & )
1786 !
1787  elseif(icmphys == 3) then ! zhao/moorthi's prognostic cloud+pdfcld
1788 
1789  call progcld3 &
1790 ! --- inputs:
1791  & ( plyr,plvl,tlyr,tvly,qlyr,qstl,rhly,clw,cnvw,cnvc, &
1792  & xlat,xlon,slmsk, &
1793  & im, lmk, lmp, &
1794  & deltaq, sup,kdt,me, &
1795 ! --- outputs:
1796  & clouds,cldsa,mtopa,mbota &
1797  & )
1798 
1799  endif ! end if_icmphys
1800 
1801  else ! diagnostic cloud scheme
1802 
1803  do i = 1, im
1804 ! cvt1(i) = 10.0 * cvt(i)
1805 ! cvb1(i) = 10.0 * cvb(i)
1806  cvt1(i) = 0.01 * cvt(i)
1807  cvb1(i) = 0.01 * cvb(i)
1808 
1809  enddo
1810 
1811  do k = 1, lm
1812  k1 = k + kd
1813 
1814  do i = 1, im
1815 ! vvel(i,k1) = 10.0 * vvl(i,k)
1816  vvel(i,k1) = 0.01 * vvl(i,k)
1817  enddo
1818  enddo
1819 
1820  if ( lextop ) then
1821  do i = 1, im
1822  vvel(i,lyb) = vvel(i,lya)
1823  enddo
1824  endif
1825 
1826 ! --- compute diagnostic cloud related quantities
1827 
1828  call diagcld1 &
1829 ! --- inputs:
1830  & ( plyr,plvl,tlyr,rhly,vvel,cv,cvt1,cvb1, &
1831  & xlat,xlon,slmsk, &
1832  & im, lmk, lmp, &
1833 ! --- outputs:
1834  & clouds,cldsa,mtopa,mbota &
1835  & )
1836 
1837  endif ! end_if_ntcw
1838 
1839 ! --- ... start radiation calculations
1840 ! remember to set heating rate unit to k/sec!
1842  if (lsswr) then
1843 
1846 
1847 
1848  call setalb &
1849 ! --- inputs:
1850  & ( slmsk,snowd,sncovr,snoalb,zorl,coszen,tsfg,tsfa,hprim, &
1851  & alvsf,alnsf,alvwf,alnwf,facsf,facwf,fice,tisfc, &
1852  & im, &
1853 ! --- outputs:
1854  & sfcalb &
1855  & )
1856 
1858 
1859  do i = 1, im
1860  sfalb(i) = max(0.01, 0.5 * (sfcalb(i,2) + sfcalb(i,4)))
1861  enddo
1862 
1863  if (nday > 0) then
1864 
1867 ! print *,' in grrad : calling swrad'
1868 
1869  if ( present(htrswb) .and. present(htrsw0)) then
1870 
1871  call swrad &
1872 ! --- inputs:
1873  & ( plyr,plvl,tlyr,tlvl,qlyr,olyr,gasvmr, &
1874  & clouds,icsdsw,faersw,sfcalb, &
1875  & coszen,solcon, nday,idxday, &
1876  & im, lmk, lmp, lprnt, &
1877 ! --- outputs:
1878  & htswc,topfsw,sfcfsw &
1879 !! --- optional:
1880 !! &, HSW0=htsw0,FLXPRF=fswprf &
1881  &, hsw0=htsw0,hswb=htswb,fdncmp=scmpsw &
1882  & )
1883 
1884  do k = 1, lm
1885  k1 = k + kd
1886 
1887  do j = 1, nbdsw
1888  do i = 1, im
1889  htrswb(i,k,j) = htswb(i,k1,j)
1890  enddo
1891  enddo
1892  enddo
1893 
1894  else if ( present(htrswb) .and. .not. present(htrsw0) ) then
1895 
1896  call swrad &
1897 ! --- inputs:
1898  & ( plyr,plvl,tlyr,tlvl,qlyr,olyr,gasvmr, &
1899  & clouds,icsdsw,faersw,sfcalb, &
1900  & coszen,solcon, nday,idxday, &
1901  & im, lmk, lmp, lprnt, &
1902 ! --- outputs:
1903  & htswc,topfsw,sfcfsw &
1904 !! --- optional:
1905 !! &, hsw0=htsw0,flxprf=fswprf &
1906  &, hswb=htswb,fdncmp=scmpsw &
1907  & )
1908 
1909  do k = 1, lm
1910  k1 = k + kd
1911  do j = 1, nbdsw
1912  do i = 1, im
1913  htrswb(i,k,j) = htswb(i,k1,j)
1914  enddo
1915  enddo
1916  enddo
1917 
1918  else if ( present(htrsw0) .and. .not. present(htrswb) ) then
1919 
1920  call swrad &
1921 ! --- inputs:
1922  & ( plyr,plvl,tlyr,tlvl,qlyr,olyr,gasvmr, &
1923  & clouds,icsdsw,faersw,sfcalb, &
1924  & coszen,solcon, nday,idxday, &
1925  & im, lmk, lmp, lprnt, &
1926 ! --- outputs:
1927  & htswc,topfsw,sfcfsw &
1928 !! --- optional:
1929 !! &, hsw0=htsw0,flxprf=fswprf &
1930  &, hsw0=htsw0,fdncmp=scmpsw &
1931  & )
1932 
1933  else
1934 
1935  call swrad &
1936 ! --- inputs:
1937  & ( plyr,plvl,tlyr,tlvl,qlyr,olyr,gasvmr, &
1938  & clouds,icsdsw,faersw,sfcalb, &
1939  & coszen,solcon, nday,idxday, &
1940  & im, lmk, lmp, lprnt, &
1941 ! --- outputs:
1942  & htswc,topfsw,sfcfsw &
1943 !! --- optional:
1944 !! &, HSW0=htsw0,FLXPRF=fswprf,HSWB=htswb &
1945  &, fdncmp=scmpsw &
1946  & )
1947 
1948  endif
1949 
1950  do k = 1, lm
1951  k1 = k + kd
1952 
1953  do i = 1, im
1954  htrsw(i,k) = htswc(i,k1)
1955  enddo
1956  enddo
1957  if (present(htrsw0)) then
1958  do k = 1, lm
1959  k1 = k + kd
1960  do i = 1, im
1961  htrsw0(i,k) = htsw0(i,k1)
1962  enddo
1963  enddo
1964  endif
1965 
1966 ! --- surface down and up spectral component fluxes
1969 
1970  do i = 1, im
1971  dswcmp(i,1) = scmpsw(i)%nirbm
1972  dswcmp(i,2) = scmpsw(i)%nirdf
1973  dswcmp(i,3) = scmpsw(i)%visbm
1974  dswcmp(i,4) = scmpsw(i)%visdf
1975 
1976  uswcmp(i,1) = scmpsw(i)%nirbm * sfcalb(i,1)
1977  uswcmp(i,2) = scmpsw(i)%nirdf * sfcalb(i,2)
1978  uswcmp(i,3) = scmpsw(i)%visbm * sfcalb(i,3)
1979  uswcmp(i,4) = scmpsw(i)%visdf * sfcalb(i,4)
1980  enddo
1981 
1982  else ! if_nday_block
1983 
1984  do k = 1, lm
1985  do i = 1, im
1986  htrsw(i,k) = 0.0
1987  enddo
1988  enddo
1989 
1990  sfcfsw = sfcfsw_type( 0.0, 0.0, 0.0, 0.0 )
1991  topfsw = topfsw_type( 0.0, 0.0, 0.0 )
1992  scmpsw = cmpfsw_type( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 )
1993 
1994  do k = 1, 4
1995  do i = 1, im
1996  dswcmp(i,k) = 0.0
1997  uswcmp(i,k) = 0.0
1998  enddo
1999  enddo
2000 
2001 !! --- optional:
2002 !! fswprf= profsw_type( 0.0, 0.0, 0.0, 0.0 )
2003 
2004  if ( present(htrswb) ) then
2005  do j = 1, nbdsw
2006  do k = 1, lm
2007  do i = 1, im
2008  htrswb(i,k,j) = 0.0
2009  enddo
2010  enddo
2011  enddo
2012  endif
2013  if ( present(htrsw0) ) then
2014  do k = 1, lm
2015  do i = 1, im
2016  htrsw0(i,k) = 0.0
2017  enddo
2018  enddo
2019  endif
2020 
2021  endif ! end_if_nday
2022 
2023  endif ! end_if_lsswr
2024 
2025 ! write(0,*)' htrsw=',htrsw(ipt,1:64)*86400
2027  if (lslwr) then
2028 
2031 
2032  call setemis &
2033 ! --- inputs:
2034  & ( xlon,xlat,slmsk,snowd,sncovr,zorl,tsfg,tsfa,hprim, &
2035  & im, &
2036 ! --- outputs:
2037  & sfcemis &
2038  & )
2039 
2042 ! print *,' in grrad : calling lwrad'
2043 
2044  if ( present(htrlwb) .and. present(htrlw0) ) then
2045 
2046  call lwrad &
2047 ! --- inputs:
2048  & ( plyr,plvl,tlyr,tlvl,qlyr,olyr,gasvmr, &
2049  & clouds,icsdlw,faerlw,sfcemis,tsfg, &
2050  & im, lmk, lmp, lprnt, &
2051 ! --- outputs:
2052  & htlwc,topflw,sfcflw &
2053 !! --- optional:
2054 !! &, HLW0=htlw0,FLXPRF=flwprf &
2055  &, hlw0=htlw0 &
2056  &, hlwb=htlwb &
2057  & )
2058 
2059  do k = 1, lm
2060  k1 = k + kd
2061 
2062  do j = 1, nbdlw
2063  do i = 1, im
2064  htrlwb(i,k,j) = htlwb(i,k1,j)
2065  enddo
2066  enddo
2067  enddo
2068 
2069  else if ( present(htrlwb) .and. .not. present(htrlw0) ) then
2070 
2071  call lwrad &
2072 ! --- inputs:
2073  & ( plyr,plvl,tlyr,tlvl,qlyr,olyr,gasvmr, &
2074  & clouds,icsdlw,faerlw,sfcemis,tsfg, &
2075  & im, lmk, lmp, lprnt, &
2076 ! --- outputs:
2077  & htlwc,topflw,sfcflw &
2078 !! --- optional:
2079 !! &, hlw0=htlw0,flxprf=flwprf &
2080  &, hlwb=htlwb &
2081  & )
2082 
2083  do k = 1, lm
2084  k1 = k + kd
2085 
2086  do j = 1, nbdlw
2087  do i = 1, im
2088  htrlwb(i,k,j) = htlwb(i,k1,j)
2089  enddo
2090  enddo
2091  enddo
2092  else if ( present(htrlw0) .and. .not. present(htrlwb) ) then
2093 
2094  !print *,'call lwrad saving clear sky component'
2095  call lwrad &
2096 ! --- inputs:
2097  & ( plyr,plvl,tlyr,tlvl,qlyr,olyr,gasvmr, &
2098  & clouds,icsdlw,faerlw,sfcemis,tsfg, &
2099  & im, lmk, lmp, lprnt, &
2100 ! --- outputs:
2101  & htlwc,topflw,sfcflw &
2102 !! --- optional:
2103 !! &, hlw0=htlw0,flxprf=flwprf &
2104  &, hlw0=htlw0 &
2105  & )
2106 
2107  else
2108 
2109  call lwrad &
2110 ! --- inputs:
2111  & ( plyr,plvl,tlyr,tlvl,qlyr,olyr,gasvmr, &
2112  & clouds,icsdlw,faerlw,sfcemis,tsfg, &
2113  & im, lmk, lmp, lprnt, &
2114 ! --- outputs:
2115  & htlwc,topflw,sfcflw &
2116 !! --- optional:
2117 !! &, HLW0=htlw0,FLXPRF=flwprf,HLWB=htlwb &
2118  & )
2119 
2120  endif
2121 
2123  do i = 1, im
2124  semis(i) = sfcemis(i)
2126  tsflw(i) = tsfa(i)
2127  enddo
2128 
2129  do k = 1, lm
2130  k1 = k + kd
2131 
2132  do i = 1, im
2133  htrlw(i,k) = htlwc(i,k1)
2134  enddo
2135  enddo
2136 
2137  if (present(htrlw0)) then
2138  do k = 1, lm
2139  k1 = k + kd
2140  do i = 1, im
2141  htrlw0(i,k) = htlw0(i,k1)
2142  enddo
2143  enddo
2144  endif
2145 
2146  endif ! end_if_lslwr
2147 
2153 
2154 ! --- ... collect the fluxr data for wrtsfc
2155 
2156  if (lssav) then
2157 
2158  if ( lsswr ) then
2159  do i = 1, im
2160  fluxr(i,34) = fluxr(i,34) + dtsw*aerodp(i,1) ! total aod at 550nm
2161  fluxr(i,35) = fluxr(i,35) + dtsw*aerodp(i,2) ! DU aod at 550nm
2162  fluxr(i,36) = fluxr(i,36) + dtsw*aerodp(i,3) ! BC aod at 550nm
2163  fluxr(i,37) = fluxr(i,37) + dtsw*aerodp(i,4) ! OC aod at 550nm
2164  fluxr(i,38) = fluxr(i,38) + dtsw*aerodp(i,5) ! SU aod at 550nm
2165  fluxr(i,39) = fluxr(i,39) + dtsw*aerodp(i,6) ! SS aod at 550nm
2166  enddo
2167  endif
2168 ! --- save lw toa and sfc fluxes
2169 
2170  if (lslwr) then
2171  do i = 1, im
2172 ! --- lw total-sky fluxes
2173  fluxr(i,1 ) = fluxr(i,1 ) + dtlw * topflw(i)%upfxc ! total sky top lw up
2174  fluxr(i,19) = fluxr(i,19) + dtlw * sfcflw(i)%dnfxc ! total sky sfc lw dn
2175  fluxr(i,20) = fluxr(i,20) + dtlw * sfcflw(i)%upfxc ! total sky sfc lw up
2176 ! --- lw clear-sky fluxes
2177  fluxr(i,28) = fluxr(i,28) + dtlw * topflw(i)%upfx0 ! clear sky top lw up
2178  fluxr(i,30) = fluxr(i,30) + dtlw * sfcflw(i)%dnfx0 ! clear sky sfc lw dn
2179  fluxr(i,33) = fluxr(i,33) + dtlw * sfcflw(i)%upfx0 ! clear sky sfc lw up
2180  enddo
2181  endif
2182 
2183 ! --- save sw toa and sfc fluxes with proper diurnal sw wgt. coszen=mean cosz over daylight
2184 ! part of sw calling interval, while coszdg= mean cosz over entire interval
2185 
2186  if (lsswr) then
2187  do i = 1, im
2188  if (coszen(i) > 0.) then
2189 ! --- sw total-sky fluxes
2190 ! -------------------
2191  tem0d = dtsw * coszdg(i) / coszen(i)
2192  fluxr(i,2 ) = fluxr(i,2) + topfsw(i)%upfxc * tem0d ! total sky top sw up
2193  fluxr(i,3 ) = fluxr(i,3) + sfcfsw(i)%upfxc * tem0d ! total sky sfc sw up
2194  fluxr(i,4 ) = fluxr(i,4) + sfcfsw(i)%dnfxc * tem0d ! total sky sfc sw dn
2195 ! --- sw uv-b fluxes
2196 ! --------------
2197  fluxr(i,21) = fluxr(i,21) + scmpsw(i)%uvbfc * tem0d ! total sky uv-b sw dn
2198  fluxr(i,22) = fluxr(i,22) + scmpsw(i)%uvbf0 * tem0d ! clear sky uv-b sw dn
2199 ! --- sw toa incoming fluxes
2200 ! ----------------------
2201  fluxr(i,23) = fluxr(i,23) + topfsw(i)%dnfxc * tem0d ! top sw dn
2202 ! --- sw sfc flux components
2203 ! ----------------------
2204  fluxr(i,24) = fluxr(i,24) + scmpsw(i)%visbm * tem0d ! uv/vis beam sw dn
2205  fluxr(i,25) = fluxr(i,25) + scmpsw(i)%visdf * tem0d ! uv/vis diff sw dn
2206  fluxr(i,26) = fluxr(i,26) + scmpsw(i)%nirbm * tem0d ! nir beam sw dn
2207  fluxr(i,27) = fluxr(i,27) + scmpsw(i)%nirdf * tem0d ! nir diff sw dn
2208 ! --- sw clear-sky fluxes
2209 ! -------------------
2210  fluxr(i,29) = fluxr(i,29) + topfsw(i)%upfx0 * tem0d ! clear sky top sw up
2211  fluxr(i,31) = fluxr(i,31) + sfcfsw(i)%upfx0 * tem0d ! clear sky sfc sw up
2212  fluxr(i,32) = fluxr(i,32) + sfcfsw(i)%dnfx0 * tem0d ! clear sky sfc sw dn
2213  endif
2214  enddo
2215  endif
2216 
2217 ! --- save total and boundary layer clouds
2218 
2219  if (lsswr .or. lslwr) then
2220  do i = 1, im
2221  fluxr(i,17) = fluxr(i,17) + raddt * cldsa(i,4)
2222  fluxr(i,18) = fluxr(i,18) + raddt * cldsa(i,5)
2223  enddo
2224 
2225 ! --- save cld frac,toplyr,botlyr and top temp, note that the order
2226 ! of h,m,l cloud is reversed for the fluxr output.
2227 ! --- save interface pressure (pa) of top/bot
2228 
2229  do j = 1, 3
2230  do i = 1, im
2231  tem0d = raddt * cldsa(i,j)
2232  itop = mtopa(i,j) - kd
2233  ibtc = mbota(i,j) - kd
2234  fluxr(i, 8-j) = fluxr(i, 8-j) + tem0d
2235  fluxr(i,11-j) = fluxr(i,11-j) + tem0d * prsi(i,itop+kt)
2236  fluxr(i,14-j) = fluxr(i,14-j) + tem0d * prsi(i,ibtc+kb)
2237  fluxr(i,17-j) = fluxr(i,17-j) + tem0d * tgrs(i,itop)
2238  enddo
2239  enddo
2240  endif
2241 
2242  if (.not. uni_cld) then
2243  do k = 1, lm
2244  k1 = k + kd
2245  do i = 1, im
2246  cldcov(i,k) = clouds(i,k1,1)
2247  enddo
2248  enddo
2249  endif
2250 
2251 ! --- save optional vertically integrated aerosol optical depth at
2252 ! wavelenth of 550nm aerodp(:,1), and other optional aod for
2253 ! individual species aerodp(:,2:NSPC1)
2254 
2255 ! if ( laswflg ) then
2256 ! if ( NFXR > 33 ) then
2257 ! do i = 1, IM
2258 ! fluxr(i,34) = fluxr(i,34) + dtsw*aerodp(i,1) ! total aod at 550nm (all species)
2259 ! enddo
2260 
2261 ! if ( lspcodp ) then
2262 ! do j = 2, NSPC1
2263 ! k = 33 + j
2264 
2265 ! do i = 1, IM
2266 ! fluxr(i,k) = fluxr(i,k) + dtsw*aerodp(i,j) ! aod at 550nm for indiv species
2267 ! enddo
2268 ! enddo
2269 ! endif ! end_if_lspcodp
2270 ! else
2271 ! print *,' !Error! Need to increase array fluxr size NFXR ',&
2272 ! & ' to be able to output aerosol optical depth'
2273 ! stop
2274 ! endif ! end_if_nfxr
2275 ! endif ! end_if_laswflg
2276 
2277  endif ! end_if_lssav
2278 !
2279  return
2280 !...................................
2281  end subroutine grrad
2282 !-----------------------------------
2283 
2284 
2285 !
2287 !........................................!
2288  end module module_radiation_driver !
2289 !========================================!
integer, save iovrsw
cloud overlapping control flag for SW =0:use random cloud overlapping method =1:use maximum-rando...
Definition: physparam.f:251
subroutine, public cld_init(si, NLAY, me)
This subroutine is an initialization program for cloud-radiation calculations and sets up boundary la...
Define type construct for radiation fluxes at surface.
Definition: radlw_param.f:84
integer, save isubcsw
sub-column cloud approx flag in SW radiation =0:no McICA approximation in SW radiation =1:use McI...
Definition: physparam.f:295
real(kind=kind_phys) epsq
EPSQ=1.0e-12.
Definition: grrad.f:354
subroutine, public setemis(xlon, xlat, slmsk, snowf, sncovr, zorlf, tsknf, tairf, hprif, IMAX, sfcemis )
This subroutine computes surface emissivity for LW radiation.
derived type for special components of surface SW fluxes
Definition: radsw_param.f:110
integer, save iaerflg
aerosol effect control flag 3-digit flag 'abc': a-stratospheric volcanic aerols b-tropospheric ...
Definition: physparam.f:177
real(kind=kind_phys) qmin
lower limit of saturation vapor pressure (=1.0e-10)
Definition: grrad.f:348
subroutine, public diagcld1(plyr, plvl, tlyr, rhly, vvel, cv, cvt, cvb, xlat, xlon, slmsk, IX, NLAY, NLP1, clouds, clds, mtop, mbot )
This subroutine computes cloud fractions for radiation calculations.
logical, save lcnorm
in-cld condensate control flag
Definition: physparam.f:260
logical, save lcrick
eliminating CRICK control flag
Definition: physparam.f:258
subroutine, public gas_update(iyear, imon, iday, ihour, loz1st, ldoco2, me)
This subroutine reads in 2-d monthly co2 data set for a specified year. Data are in a 15 degree lat/l...
real(kind=kind_phys) qme5
lower limit of specific humidity (=1.0e-7)
Definition: grrad.f:350
real, parameter prsmin
lower limit of toa pressure value in mb
Definition: grrad.f:360
integer month0
new data input control variables (set/reset in subroutines radinit/radupdate):
Definition: grrad.f:367
subroutine, public progcld2(plyr, plvl, tlyr, tvly, qlyr, qstl, rhly, clw, xlat, xlon, slmsk, f_ice, f_rain, r_rime, flgmin, IX, NLAY, NLP1, lmfshal, lmfdeep2, clouds, clds, mtop, mbot )
This subroutine computes cloud related quantities using ferrier's prognostic cloud microphysics schem...
integer, save ialbflg
surface albedo scheme control flag =0:vegetation type based climatological albedo scheme =1:seaso...
Definition: physparam.f:273
logical loz1st
control flag for the first time of reading climatological ozone data (set/reset in subroutines radini...
Definition: grrad.f:372
subroutine, public sfc_init(me)
This subroutine is the initialization program for surface radiation related quantities (albedo...
integer, parameter, public nf_aelw
num of output fields for LW rad
subroutine, public swrad(plyr, plvl, tlyr, tlvl, qlyr, olyr, gasvmr, clouds, icseed, aerosols, sfcalb, cosz, solcon, NDAY, idxday, npts, nlay, nlp1, lprnt, hswc, topflx, sfcflx, HSW0, HSWB, FLXPRF, FDNCMP )
This subroutine is the main SW radiation routine.
Definition: radsw_main.f:592
subroutine, public progcld1(plyr, plvl, tlyr, tvly, qlyr, qstl, rhly, clw, xlat, xlon, slmsk, IX, NLAY, NLP1, shoc_cld, lmfshal, lmfdeep2, cldcov, clouds, clds, mtop, mbot )
This subroutine computes cloud related quantities using zhao/moorthi's prognostic cloud microphysics ...
Define type construct for optional radiation flux profiles.
Definition: radlw_param.f:97
integer, save ico2flg
co2 data source control flag =0:prescribed value(380 ppmv) =1:yearly global averaged annual mean ...
Definition: physparam.f:205
integer, save icmphys
cloud micorphysics scheme control flag =1:modified Zhao/Carr/Sundqvist scheme (Moorthi, 2001) =2:Ferrier microphysics scheme (Ferrier et al. 2002) =3:as in 1 but with pdf method defined cloud cover
Definition: physparam.f:246
integer, parameter, public nf_albd
num of sfc albedo components
integer, save icldflg
cloud optical property scheme control flag =0:use diagnostic cloud scheme for cloud cover and mean ...
Definition: physparam.f:241
derived type for SW fluxes' column profiles (at layer interfaces)
Definition: radsw_param.f:98
integer, save iemsflg
surface emissivity scheme control flag =0:black-body surface emissivity(=1.0) =1:vegetation type ...
Definition: physparam.f:278
subroutine, public gas_init(me)
This subroutine sets up ozone, co2, etc. parameters. If climatology ozone then read in monthly ozone ...
subroutine, public aer_init(NLAY, me)
The initialization program is to set up necessary parameters and working arrays.
subroutine, public setalb(slmsk, snowf, sncovr, snoalb, zorlf, coszf, tsknf, tairf, hprif, alvsf, alnsf, alvwf, alnwf, facsf, facwf, fice, tisfc, IMAX, sfcalb )
This subroutine computes four components of surface albedos (i.e., vis-nir, direct-diffused) accordin...
subroutine, public rswinit(me)
This subroutine initializes non-varying module variables, conversion factors, and look-up tables...
Definition: radsw_main.f:1375
This module is for specifying the band structures and program parameters used by the RRTMG-SW scheme...
Definition: radsw_param.f:66
subroutine, public coszmn(xlon, sinlat, coslat, solhr, IM, me, coszen, coszdg )
This subroutine computes mean cos solar zenith angle over SW calling interval.
subroutine, public getgases(plvl, xlon, xlat, IMAX, LMAX, gasdat )
This subroutine sets up global distribution of radiation absorbing gases in volume mixing ratio...
integer, parameter, public nf_aesw
num of output fields for SW rad
logical, save lnoprec
precip effect on radiation flag (Ferrier microphysics)
Definition: physparam.f:262
integer, parameter ltp
optional extra top layer on top of low ceiling models LTP=0: no extra top layer ...
Definition: grrad.f:376
subroutine, public radinit(si, NLAY, me)
This subroutine initialize a model's radiation process through calling of specific initialization sub...
Definition: grrad.f:404
subroutine, public getozn(prslk, xlat, IMAX, LM, o3mmr )
This subroutine sets up climatological ozone profile for radiation calculation. This code is original...
This module contains LW band parameters set up.
Definition: radlw_param.f:64
Define type construct for radiation fluxes at toa.
Definition: radlw_param.f:75
subroutine, public progcld3(plyr, plvl, tlyr, tvly, qlyr, qstl, rhly, clw, cnvw, cnvc, xlat, xlon, slmsk, ix, nlay, nlp1, deltaq, sup, kdt, me, clouds, clds, mtop, mbot )
This subroutine computes cloud related quantities using zhao/moorthi's prognostic cloud microphysics ...
subroutine, public lwrad(plyr, plvl, tlyr, tlvl, qlyr, olyr, gasvmr, clouds, icseed, aerosols, sfemis, sfgtmp, npts, nlay, nlp1, lprnt, hlwc, topflx, sfcflx, HLW0, HLWB, FLXPRF )
This subroutine is the main LW radiation routine.
Definition: radlw_main.f:461
integer, save ioznflg
ozone data source control flag =0:use seasonal climatology ozone data >0:use prognostic ozone sch...
Definition: physparam.f:220
subroutine, public rlwinit(me)
This subroutine performs calculations necessary for the initialization of the longwave model...
Definition: radlw_main.f:1263
integer, parameter, public nf_clds
number of fields in cloud array
subroutine, public sol_init(me)
This subroutine initializes astronomy process, and set up module constants.
integer, save ictmflg
controls external data at initial time and data usage during forecast time =-2:as in 0...
Definition: physparam.f:215
real(kind=kind_phys) qme6
lower limit of specific humidity (=1.0e-7)
Definition: grrad.f:352
integer, save isolar
solar constant scheme control flag =0:fixed value=1366.0 (old standard) =10:fixed value=1360...
Definition: physparam.f:153
integer, parameter, public nspc1
total+species
subroutine, public aer_update(iyear, imon, me)
This subroutine checks and updates time varying climatology aerosol data sets.
integer itsfc
control flag for LW surface temperature at air/ground interface (default=0, the value will be set in ...
Definition: grrad.f:364
derived type for SW fluxes at TOA
Definition: radsw_param.f:76
subroutine, public sol_update(jdate, kyear, deltsw, deltim, lsol_chg, me, slag, sdec, cdec, solcon )
This subroutine computes solar parameters at forecast time.
subroutine, public setaer(prsi, prsl, prslk, tvly, rhlay, slmsk, tracer, xlon, xlat, IMAX, NLAY, NLP1, lsswr, lslwr, aerosw, aerolw , aerodp )
This subroutine computes aerosols optical properties.
subroutine, public radupdate(idate, jdate, deltsw, deltim, lsswr, me, slag, sdec, cdec, solcon)
This subroutine checks and updates time sensitive data used by radiation computations. This subroutine needs to be placed inside the time advancement loop but outside of the horizontal grid loop. It is invoked at radiation calling frequncy but before any actual radiative transfer computations.
Definition: grrad.f:650
integer, save isubclw
sub-column cloud approx flag in LW radiation =0:no McICA approximation in LW radiation =1:use McI...
Definition: physparam.f:301
integer, parameter, public nf_vgas
number of gas species
integer, save ivflip
vertical profile indexing flag
Definition: physparam.f:289
logical, parameter lextop
control flag for extra top layer
Definition: grrad.f:380
derived type for SW fluxes at surface
Definition: radsw_param.f:86
integer, save iovrlw
cloud overlapping control flag for LW =0:use random cloud overlapping method =1:use maximum-rando...
Definition: physparam.f:256
subroutine, public grrad(prsi, prsl, prslk, tgrs, qgrs, tracer, vvl, slmsk, xlon, xlat, tsfc, snowd, sncovr, snoalb, zorl, hprim, alvsf, alnsf, alvwf, alnwf, facsf, facwf, fice, tisfc, sinlat, coslat, solhr, jdate, solcon, cv, cvt, cvb, fcice, frain, rrime, flgmin, icsdsw, icsdlw, ntcw, ncld, ntoz, NTRAC, NFXR, dtlw, dtsw, lsswr, lslwr, lssav, uni_cld, lmfshal, lmfdeep2, IX, IM, LM, me, lprnt, ipt, kdt, deltaq, sup, cnvw, cnvc, htrsw, topfsw, sfcfsw, dswcmp, uswcmp, sfalb, coszen, coszdg, htrlw, topflw, sfcflw, tsflw, semis, cldcov, fluxr , htrlw0, htrsw0, htrswb, htrlwb )
This subroutine is the driver of main radiation calculations. It sets up column profiles, such as pressure, temperature, moisture, gases, clouds, aerosols, etc., as well as surface radiative characteristics, such as surface albedo, and emissivity. The call of this subroutine is placed inside both the time advancing loop and the horizontal grid loop.
Definition: grrad.f:1009