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