Interoperable Physics Driver for NGGPS
gloopr.f
Go to the documentation of this file.
1 
2 
6 
14 
15  subroutine gloopr (grid_fld, g3d_fld, aoi_fld,
16  & lats_nodes_r,global_lats_r, lonsperlar, phour,
17  & deltim,xlon,xlat,coszdg,coszen,slmsk,weasd,
18  & sncovr,snoalb,zorl,tsea,hprime,sfalb,
19  & alvsf,alnsf ,alvwf ,alnwf,facsf ,facwf,cv,cvt,
20  & cvb ,swh,swhc,hlw,hlwc,sfcnsw,sfcdlw,
21  & fice ,tisfc, sfcdsw, sfcemis,
22  & tsflw,fluxr, phy_f3d,phy_f2d,
23  & slag,sdec,cdec,nblck,kdt
24 ! &, htrswb,htrlwb
25  &, mdl_parm)
26 ! & global_times_r)
27 
28 !! Code Revision:
29 !! Oct 11 2009 Sarah Lu - grid_gr is replaced by grid_fld
30 !! Oct 16 2009 Sarah Lu - grid_fld%tracers used
31 !! Dec 01 2009 Sarah Lu - update fcld (instant cloud cover) in addition
32 !! to cldcov (cumulative cloud cover)
33 !! Dec 09 2009 Sarah Lu -(1) g3d_fld added to calling argument; (2) grrad
34 !! returns instant cloud cover (cldcov_v); the accumulative
35 !! and instant cloud cover fields are updated after grrad call
36 !! Dec 11 2009 Sarah Lu - ldiag3d removed from grrad calling argument
37 !! JulAug 2009 S Moorthi - Merged with McICA version of radiation from YuTai
38 ! apr 2012 y-t hou - modified radiation calling interval
39 ! parameters fhswr/fhlwr. changed units from hour to second
40 ! (in multiple of model time step length), thus radiation can
41 ! be invoked more frequently than the minimum of 1 hr limit.
42 ! - moved radiation initialization part to
43 ! the beginning of model initialization process. in the time
44 ! loop, added a subroutine "radupdate" to updae radiation related
45 ! external data sets (such as aerosols, gases, astronomy, etc.)
46 ! moved computation of coszen to inside subrouine "grrad"
47 ! nov 2012 y-t hou - modified many physics/radiation control
48 ! parameters through module 'physparam' which contains the
49 ! use of module 'machine'.
50 !! Nov 20 2012 Jun Wang - fix the vertical index from levs to levr for gt,gr..etc
51 ! may 2013 s moorthi - removed fpkapx
52 ! oct 2013 hmh Juang - compute prsi from model top with model pressure
53 ! thickness to surface for accuracy
54 ! Mar 2014 Xingren Wu- Add visbm/visdf/nirbm/nirdf to extract for A/O/I coupling
55 ! Jul 2014 S Moorthi - merge with GFS and clean up a bit
56 ! jun 2014 y-t hou - revised to utilize surface up/down spectral component sw
57 ! fluxes for grid composite mean (combined land,ocean,ice,
58 ! snow), also estimate ocean values without ice contamination.
59 ! Aug 2015 S Moorthi - Adding sgs clouds from shoc as an option
60 !!
61 ! Mar 2016 J. Han - add ncnvcld3d for conv cloudiness enhancement
62 ! include shal_cnv, imfdeepcnv, imfshalcnv
63 ! make new logical lmfshal & lmfdeep2
64 ! Apr 2016 W.Yang - bug fix : change do k = 1, levs to be do k = 1, min(levs, levr)
65 ! (this is really not a bug - moorthhi)
66 ! Apr 14 2016 S Moorthi - changing this fix to do k=1,levr.
67 ! levr <= levs, by definition.
68 ! Also, changing numrdm dimension and threading the loop
69 ! Mar 2016 Hang Lei - use physics driver
70 ! Jun 29 2016 S Moorthi - make gr1 allocatable and extract only tracers relevant
71 ! to radiation (i.e. remove tke and number concentration)
72 !
73  use physparam
74  use physcons, fv => con_fvirt, rerth => con_rerth, rk => con_rocp
75 
76  use namelist_physics_def, only : shoc_cld, use_nuopc
78 ! use module_radiation_astronomy,only : astronomy
79  USE gfs_phy_tracer_config, only : gfs_phy_tracer
80 
81  use module_radsw_parameters, only : topfsw_type, sfcfsw_type
82  use module_radlw_parameters, only : topflw_type, sfcflw_type
83 !
84 !! --- for optional spectral band heating outputs
85  use module_radsw_parameters, only : nbdsw
86  use module_radlw_parameters, only : nbdlw
87 !
88  use resol_def, ONLY: levs, levr, latr, lonr, lotgr, &
89  & g_t, g_p, g_q, g_dp, g_ps, &
90  & ntcw, ntoz, ncld,num_p3d, &
91  & ntke, ntiw,ntlnc,ntinc, &
92  & nmtvr, ntrac, levp1, nfxr,g_dpdt,&
93  & lgocart,ntot3d,ntot2d, &
94  & npdf3d,ncnvcld3d
95  use layout1, ONLY: me, nodes, lats_node_r, &
96  & lats_node_r_max, ipt_lats_node_r
97  use gg_def, ONLY: coslat_r, sinlat_r
98  use date_def, ONLY: idate
99  use namelist_physics_def, ONLY: lsswr,iaer,lslwr,ras,shal_cnv, &
100  & lssav, flgmin, ldiag3d, &
101  & imfshalcnv, imfdeepcnv, &
102  & iovr_lw, iovr_sw, isol, iems, &
103  & ialb, fhlwr, fhswr, ico2, ngptc, &
104  & crick_proof, norad_precip,ccnorm,&
105  & ictm, isubc_sw, isubc_lw, fdaer, &
106  & sup, ndfi, fhdfi, cplflx
107  use d3d_def , ONLY: cldcov
108  use gfs_physics_gridgr_mod, ONLY: grid_var_data
109  use gfs_physics_g3d_mod, ONLY: g3d_var_data
110  use gfs_physics_aoi_var_mod, ONLY: aoi_var_data
111  use mersenne_twister, only: random_setseed, random_index, &
112  & random_stat
113 ! use cldwat2m_micro, only: ini_micro
114 ! use aer_cloud, only: aer_cloud_init
115 
118  use nuopc_physics,
126  use nuopc_physics, only: state_fields_in,
131  & model_parameters, nuopc_rad_run,
132  & nuopc_rad_update,
133  & rad_run_savein, rad_run_readin,
134  & rad_run_saveout, rad_run_readout
135 !
136  implicit none
137 !
138  real (kind=kind_phys), parameter :: QMIN =1.0e-10 &
139  &, typical_pgr = 95.0 &
140  &, cons0 = 0.0, cons2 = 2.0 &
141  &, pt00001=1.0e-5
142 ! &, pt01=0.01
143 !
144 ! --- ... inputs:
145  integer, intent(in), dimension(nodes) :: lats_nodes_r
146  integer, intent(in), dimension(latr) :: global_lats_r, lonsperlar
147 
148 !* real(kind=kind_grid) grid_gr(lonr*lats_node_r_max,lotgr)
149 
150  TYPE(grid_var_data) :: grid_fld
151  TYPE(g3d_var_data) :: g3d_fld
152  type(aoi_var_data) :: aoi_fld
153 
154  integer, intent(in) :: NBLCK
155 
156 
157  real (kind=kind_phys), dimension(LONR,LATS_NODE_R), intent(in) :: &
158  & xlon, xlat, slmsk, weasd, zorl, tsea, &
159  & alvsf, alnsf, alvwf, alnwf, facsf, facwf, &
160  & cv, cvt, cvb, FICE, tisfc, sncovr, snoalb
161 
162  real (kind=kind_phys), intent(inout) :: &
163  & hprime(NMTVR,LONR,LATS_NODE_R), phour, deltim, &
164  & phy_f3d(NGPTC,LEVS,ntot3d,NBLCK,LATS_NODE_R), &
165  & phy_f2d(lonr,lats_node_r,ntot2d)
166 !
167 
168  real (kind=kind_phys), intent(inout) :: &
169  & fluxr (NFXR,LONR,LATS_NODE_R)
170 
171  integer, intent(in) :: KDT
172 ! --- ... outputs:
173 ! real(kind=kind_evod), intent(out) :: &
174 ! & global_times_r(latr,NODES)
175 
176  real (kind=kind_phys), intent(out), dimension &
177  & (ngptc,levs,nblck,lats_node_r) :: swh, swhc, hlw, hlwc
178 
179  real (kind=kind_phys),dimension(LONR,LATS_NODE_R), intent(out) :: &
180  & coszdg, coszen, sfcnsw, sfcdlw, tsflw, &
181  & sfcdsw, SFALB, sfcemis
182 
183  real (kind=kind_phys), intent(out) :: slag, sdec, cdec
184 
185 !! --- ... optional spectral band heating rates
186 ! real (kind=kind_phys), optional, intent(out) :: &
187 ! & htrswb(NGPTC,LEVS,NBDSW,NBLCK,LATS_NODE_R), &
188 ! & htrlwb(NGPTC,LEVS,NBDLW,NBLCK,LATS_NODE_R)
189 
190 ! --- ... locals:
191  real(kind=kind_phys) :: prsl(ngptc,levs), prslk(ngptc,levs), &
192  & prsi(NGPTC,LEVP1)
193 
194 ! real (kind=kind_phys) :: si_loc(LEVR+1)
195 
196  real (kind=kind_phys) :: dswcmp(ngptc,4), uswcmp(ngptc,4), &
197  & gt(NGPTC,LEVR), gr(NGPTC,LEVR)
198 
199  real (kind=kind_phys), allocatable :: gr1(:,:,:)
200 
201  logical :: lmfshal, lmfdeep2
202 
203  real (kind=kind_phys), dimension(ngptc,levs) :: deltaq, cnvw, cnvc
204  &, f_ice, f_rain, r_rime, hlwc_v, swhc_v, cldcov_v, vvel
205 
206  real (kind=kind_phys) :: fluxr_v(ngptc,nfxr)
207  real (kind=kind_phys) :: work1, work2
208 
209  real (kind=kind_phys), dimension(ngptc) :: coszen_v, coszdg_v, &
210  & sinlat_v, coslat_v, hprime_v, flgmin_v
211 
212 ! real (kind=kind_phys), dimension(LONR,LATS_NODE_R) :: &
213 ! & sinlat_v, coslat_v
214 
215  real (kind=kind_phys) :: rinc(5), dtsw, dtlw, solcon, raddt, solhr
216  real (kind=4) :: rinc4(5)
217  integer w3kindreal,w3kindint
218 
219  real (kind=kind_phys), save :: facoz
220 
221  integer :: njeff, lon, lan, lat, iblk, lons_lat, kk
222  integer :: idat(8), jdat(8), DAYS(13), iday, imon, midmon, id
223  integer :: nlnsp(lats_node_r)
224 
225 ! --- variables of instantaneous calculated toa/sfc radiation fluxes
226 
227  type(topfsw_type), dimension(NGPTC) :: topfsw
228  type(sfcfsw_type), dimension(NGPTC) :: sfcfsw
229 
230  type(topflw_type), dimension(NGPTC) :: topflw
231  type(sfcflw_type), dimension(NGPTC) :: sfcflw
232 
233 ! --- variables used for random number generator (thread safe mode)
234  type(random_stat) :: stat
235 ! integer :: numrdm(LONR*LATR*2), ixseed(LONR,LATS_NODE_R,2)
236  integer :: numrdm(lonr*(latr+1)), ixseed(lonr,lats_node_r,2)
237  integer :: ipseed, icsdlw(ngptc), icsdsw(ngptc)
238  integer, parameter :: ipsdlim = 1.0e8 ! upper limit for random seeds
239 
240 
241 ! integer, save :: icwp, k1oz, k2oz, midm, midp, ipsd0, iaerflg
242 
243 ! --- number of days in a month
244 ! data DAYS / 31,28,31,30,31,30,31,31,30,31,30,31,30 /
245 
246 ! --- ... control parameters:
247 ! (some of the them may be moved into model namelist)
248 
249 ! --- ICTM=yyyy#, controls time sensitive external data (e.g. CO2, solcon, aerosols, etc)
250 ! integer, parameter :: ICTM = -2 ! same as ICTM=0, but add seasonal cycle
251 ! ! from climatology. no extrapolation.
252 ! integer, parameter :: ICTM = -1 ! use user provided external data set for the
253 ! ! forecast time. no extrapolation.
254 ! integer, parameter :: ICTM = 0 ! use data at initial cond time, if not
255 ! ! available, use latest, no extrapolatio n.
256 !! integer, parameter :: ICTM = 1 ! use data at the forecast time, if not
257 ! ! available, use latest and extrapolation.
258 ! integer, parameter :: ICTM =yyyy0 ! use yyyy data for the forecast time,
259 ! ! no further data extrapolation.
260 ! integer, parameter :: ICTM =yyyy1 ! use yyyy data for the fcst. if needed, do
261 ! ! extrapolation to match the fcst time.
262 
263 ! --- ISOL controls solar constant data source
264 !! integer, parameter :: ISOL = 0 ! use prescribed solar constant
265 ! integer, parameter :: ISOL = 1 ! use varying solar const with 11-yr cycle
266 
267 ! --- ICO2 controls co2 data source for radiation
268 ! integer, parameter :: ICO2 = 0 ! prescribed global mean value (old opernl)
269 !! integer, parameter :: ICO2 = 1 ! use obs co2 annual mean value only
270 ! integer, parameter :: ICO2 = 2 ! use obs co2 monthly data with 2-d variation
271 
272 ! --- IALB controls surface albedo for sw radiation
273 !! integer, parameter :: IALB = 0 ! use climatology alb, based on sfc type
274 ! integer, parameter :: IALB = 1 ! use modis derived alb (to be developed)
275 
276 ! --- IEMS controls surface emissivity and sfc air/ground temp for lw radiation
277 ! ab: 2-digit control flags. a-for sfc temperature; b-for emissivity
278 !! integer, parameter :: IEMS = 00 ! same air/ground temp; fixed emis = 1.0
279 !! integer, parameter :: IEMS = 01 ! same air/ground temp; varying veg typ based emis
280 !! integer, parameter :: IEMS = 10 ! diff air/ground temp; fixed emis = 1.0
281 !! integer, parameter :: IEMS = 11 ! diff air/ground temp; varying veg typ based emis
282 
283 ! --- IAER controls aerosols scheme selections
284 ! integer, parameter :: IAER = abc --> abc are three digits integer
285 ! numbers
286 ! to control aerosol effect
287 ! a: stratospheric-volcanic forcing; b: lw radiation; c: sw
288 ! radiation.
289 ! a=0: no stratospheric-volcanic aerosol effect; =1: include the
290 ! effect.
291 ! b=0: no lw tropospheric aerosols; =1: lw compute 1 bnd; =2: lw
292 ! compute multi bnd.
293 ! c=0: no sw tropospheric aerosols; =1: sw compute multi band.
294 
295 ! --- IOVR controls cloud overlapping method in radiation:
296 ! integer, parameter :: IOVR_SW = 0 ! sw: random overlap clouds
297 !! integer, parameter :: IOVR_SW = 1 ! sw: max-random overlap clouds
298 
299 ! integer, parameter :: IOVR_LW = 0 ! lw: random overlap clouds
300 !! integer, parameter :: IOVR_LW = 1 ! lw: max-random overlap clouds
301 
302 ! --- ISUBC controls sub-column cloud approximation in radiation:
303 !! integer, parameter :: ISUBC_SW = 0 ! sw: without sub-col clds approx
304 ! integer, parameter :: ISUBC_SW = 1 ! sw: sub-col clds with
305 ! prescribed seeds
306 ! integer, parameter :: ISUBC_SW = 2 ! sw: sub-col clds with random seeds
307 
308 !! integer, parameter :: ISUBC_LW = 0 ! lw: without sub-col clds approx
309 ! integer, parameter :: ISUBC_LW = 1 ! lw: sub-col clds with
310 ! prescribed seeds
311 ! integer, parameter :: ISUBC_LW = 2 ! lw: sub-col clds with random seeds
312 
313 ! --- iflip indicates model vertical index direction:
314 ! integer, parameter :: IFLIP = 0 ! virtical profile index from top to bottom
315 !! integer, parameter :: IFLIP = 1 ! virtical profile index from bottom to top
316 !
317 ! The following parameters are from gbphys
318 !
319 ! real (kind=kind_phys), parameter :: dxmax=-16.118095651, &
320 ! & dxmin=-9.800790154, &
321 ! & dxinv=1.0/(dxmax-dxmin)
322 
323 ! logical :: change
324 !
325 
328  type(model_parameters) :: mdl_parm
329 
332  type(state_fields_in) :: state_fldin
333  type(sfc_properties) :: sfc_prop
334  type(diagnostics) :: diags
335  type(interface_fields) :: intrfc_fld
336  type(cloud_properties) :: cld_prop
337  type(radiation_tendencies) :: rad_tend
338  type(dynamic_parameters) :: dyn_parm
339 
340  integer :: lonbnd ! upper lon dimension in lon/lan loop!!
341 ! logical :: savecon ! Run nuopc save states
342 
343 ! --- for debug test use
344  real (kind=kind_phys) :: temlon, temlat, alon, alat
345  integer :: ipt
346  logical :: lprnt, uni_cld
347 
348  integer i,j,k,n,item,dbgu,item2,ntl
349 
350 ! --- timers:
351 ! real*8 :: rtc, timer1, timer2
352 !
353 !===> *** ... begin here
354 !!
355 ! if(ncld == 2) then
356 ! call ini_micro(350.0e-6,2.0) !Anning Cheng 09/15/2015
357 ! call aer_cloud_init()
358 ! end if
359 !!
360  ntl = 0
361  do n = 2, ntrac
362  if (n /= ntke .and. n /= ntlnc .and. n /= ntinc) then
363  ntl = ntl + 1
364  endif
365  enddo
366  if (ntl > 0) allocate(gr1(ngptc,levr,ntl))
367 !
368  idat = 0
369  idat(1) = idate(4)
370  idat(2) = idate(2)
371  idat(3) = idate(3)
372  idat(5) = idate(1)
373  rinc = 0.
374 
375 ! test repro
376 ! rinc(2) = fhour
377  rinc(2) = phour
378 ! print *,' idate ',idate,' rinc ',rinc
379  call w3kind(w3kindreal,w3kindint)
380  if(w3kindreal == 4) then
381  rinc4 = rinc
382  call w3movdat(rinc4, idat, jdat)
383  else
384  call w3movdat(rinc, idat, jdat)
385  endif
386 ! print *,' jdat ',jdat
387 !
388 !===> *** ... radiation initialization
389 !
390  dtsw = fhswr ! fhswr is in sec
391  dtlw = fhlwr ! fhlwr is in sec
392  raddt = min(dtsw, dtlw)
393 !
394 ! --- set up parameters for Xu & Randell's cloudiness computation
395 
396  lmfshal = shal_cnv .and. (imfshalcnv > 0)
397  lmfdeep2 = (imfdeepcnv == 2)
398 
399 ! if ( fhour > 0.0 ) then
400  if ( phour > 0.0 ) then
401  solhr = mod(float(jdat(5)),24.0) ! hour after 00z at current fcst time
402  else
403  solhr = idate(1) ! initial time
404  endif
405 
406 ! if (me == 0) write(0,*)' in gloopr solhr=',solhr
407  call radupdate &
408 ! --- inputs:
409  & ( idat, jdat, dtsw, deltim, lsswr, me, &
410 ! --- outputs:
411  & slag, sdec, cdec, solcon &
412  & )
413 
414 ! --- ... generate 2-d random seeds array for sub-grid cloud-radiation
415 
416  if ( isubc_lw == 2 .or. isubc_sw == 2 ) then
417 ! ipseed = mod(nint(100.0*sqrt(fhour*3600)), ipsdlim) + 1 + ipsd0
418  ipseed = mod(nint(100.0*sqrt(phour*3600)), ipsdlim) + 1 + ipsd0
419 
420  call random_setseed &
421 ! --- inputs:
422  & ( ipseed, &
423 ! --- outputs:
424  & stat &
425  & )
426  call random_index &
427 ! --- inputs:
428  & ( ipsdlim, &
429 ! --- outputs:
430  & numrdm, stat &
431  & )
432 
433 !$omp parallel do private(i,j,lat,item,item2)
434  do j = 1, lats_node_r
435  lat = global_lats_r(ipt_lats_node_r-1+j)
436  item = (lat-1)*lonr
437  item2 = item + latr
438  do i = 1, lonr
439  ixseed(i,j,1) = numrdm(i+item)
440  ixseed(i,j,2) = numrdm(i+item2)
441  enddo
442  enddo
443  endif
444 !
445 !===> *** ... starting latitude loop
446 ! ----------------------
447 !
448  do lan=1,lats_node_r
449 !
450  lat = global_lats_r(ipt_lats_node_r-1+lan)
451  lons_lat = lonsperlar(lat)
452 
453 !$omp parallel do schedule(dynamic,1)
454 !$omp+private(lon,i,j,k,item,njeff,iblk,n)
455 !$omp+private(vvel,gt,gr,gr1,work1,work2,flgmin_v)
456 !$omp+private(cldcov_v,hprime_v,fluxr_v,f_ice,f_rain,r_rime)
457 !$omp+private(deltaq,cnvw,cnvc)
458 !$omp+private(coszen_v,coszdg_v,sinlat_v,coslat_v)
459 !$omp+private(prslk,prsl,prsi,topfsw,sfcfsw,topflw,sfcflw)
460 !$omp+private(icsdsw,icsdlw)
461 !$omp+private(hlwc_v,swhc_v)
462 !$omp+private(lprnt,ipt)
463 !$omp+private(dswcmp,uswcmp)
464 !$omp+private(state_fldin,diags,cld_prop,rad_tend)
465 !$omp+private(intrfc_fld, sfc_prop,dyn_parm)
466 !$omp+private(lonbnd)
467 !!$omp+private(lonbnd,savecon)
468 
469 !!$omp+private(temlon,temlat,lprnt,ipt)
470 !!$omp+private(lprnt,ipt,dbgu)
471 
472 !!!$omp+private(temlon,temlat,lprnt,ipt)
473 
474  do lon=1,lons_lat,ngptc
475 !!
476  njeff = min(ngptc,lons_lat-lon+1)
477  iblk = (lon-1)/ngptc + 1
478 !
479  lprnt = .false.
480  ipt = 1
481 !
482 ! --- ... for debug test
483 ! alon = 0.0
484 ! alat = 2.0
485 ! alon = 236.25
486 ! alat = 56.189
487 ! alon = 22.5
488 ! alat = -12.381
489 ! ipt = 0
490 ! do i = 1, njeff
491 ! item = lon + i - 1
492 ! temlon = xlon(item,lan) * 57.29578
493 ! if (temlon < 0.0) temlon = temlon + 360.0
494 ! temlat = xlat(item,lan) * 57.29578
495 ! lprnt = abs(temlon-alon) < 0.5 .and. abs(temlat-alat) < 0.5
496 ! & .and. kdt > 0
497 ! if ( lprnt ) then
498 ! ipt = i
499 ! print *,' ipt=',ipt,' lon=',lon,' lan=',lan
500 ! exit
501 ! endif
502 ! enddo
503 !
504  do k = 1, levr
505  do i = 1, njeff
506  item = lon+i-1
507  gt(i,k) = grid_fld%t(item,lan,k)
508  gr(i,k) = max(qmin,grid_fld%tracers(1)%flds(item,lan,k))
509  prsl(i,k) = grid_fld%p(item,lan,k)
510  vvel(i,k) = grid_fld%dpdt(item,lan,k)
511  enddo
512  enddo
513 
514 !
515 !hmhj prsi should be computed from model top for accuray
516  do i = 1, njeff
517  prsi(i,levs+1) = 0.0
518  enddo
519  do k = levs, 1, -1
520  do i = 1, njeff
521  item = lon+i-1
522  prsi(i,k) = prsi(i,k+1) + grid_fld%dp(item,lan,k)
523  enddo
524  enddo
525 ! write(1000+me,*)' in gloopr lan=',lan,' prsl=',prsl(njeff,:)
526 ! write(1000+me,*)' in gloopr lan=',lan,' prsi=',prsi(njeff,:)
527 !
528 ! Remaining tracers relevant for radiation
529 !
530  item = 0
531  do n = 2, ntrac
532  if (n /= ntke .and. n /= ntlnc .and. n /= ntinc) then
533  item = item + 1
534  do k = 1, levr
535  do i = 1, njeff
536  gr1(i,k,item) = max(0.0,
537  & grid_fld%tracers(n)%flds(lon+i-1,lan,k))
538  enddo
539  enddo
540  endif
541  enddo
542 
543  if(num_p3d == 4) then
544  if(kdt == 1.or.(kdt == ndfi+1.and.fhdfi == 0.)) then
545  do k = 1, levr
546  do i = 1, njeff
547  item = lon + i - 1
548  phy_f3d(i,k,1,iblk,lan) = gt(i,k)
549  phy_f3d(i,k,2,iblk,lan) = gr(i,k)
550  phy_f3d(i,k,3,iblk,lan) = gt(i,k)
551  phy_f3d(i,k,4,iblk,lan) = gr(i,k)
552  enddo
553  enddo
554  do i=1,njeff
555  item = lon + i - 1
556  phy_f2d(item,lan,1) = prsi(i,1)
557  phy_f2d(item,lan,2) = prsi(i,1)
558  enddo
559  endif
560  endif
561 !!
562 !.....
563  if (levr < levs) then
564  do i=1,njeff
565  prsi(i,levr+1) = prsi(i,levp1)
566  prsl(i,levr) = (prsi(i,levp1)+prsi(i,levr)) * 0.5
567  enddo
568  endif
569 !
570  if (ntoz <= 0 .or. iaerflg == 2) then
571  do k = 1, levs
572  do i = 1, njeff
573  prslk(i,k) = (prsl(i,k)*pt00001)**rk
574  enddo
575  enddo
576  endif
577  uni_cld = .false.
578  if (shoc_cld) then
579  do k = 1, levs
580  do i = 1, njeff
581  cldcov_v(i,k) = phy_f3d(i,k,ntot3d-2,iblk,lan)
582  enddo
583 ! write(1000+me,*)'sgs_clds=',maxval(cldcov_v(1:njeff,:)),
584 ! & ' lan=',lan
585  enddo
586  uni_cld = .true.
587  elseif (ncld == 2) then
588  do k = 1, levs
589  do i = 1, njeff
590  cldcov_v(i,k) = phy_f3d(i,k,1,iblk,lan)
591  enddo
592  enddo
593  uni_cld = .true.
594  endif
595  uni_cld = .false.
596 !
597  do i=1,njeff
598  hprime_v(i) = hprime(1,lon+i-1,lan)
599  enddo
600 !
601  do k=1,nfxr
602  do i=1,njeff
603  fluxr_v(i,k) = fluxr(k,lon+i-1,lan)
604  enddo
605  enddo
606 
607  do j = 1, njeff
608  sinlat_v(j) = sinlat_r(lat)
609  coslat_v(j) = coslat_r(lat)
610  enddo
611 
612  if (num_p3d == 3) then
613  do k = 1, levr
614  do i = 1, njeff
615  f_ice(i,k) = phy_f3d(i,k,1,iblk,lan)
616  f_rain(i,k) = phy_f3d(i,k,2,iblk,lan)
617  r_rime(i,k) = phy_f3d(i,k,3,iblk,lan)
618  enddo
619  enddo
620 
621  work1 = (log(coslat_r(lat)/(lons_lat*latr)) - dxmin) * dxinv
622  work1 = max(0.0, min(1.0,work1))
623  work2 = flgmin(1)*work1 + flgmin(2)*(1.0-work1)
624  do i=1,njeff
625  flgmin_v(i) = work2
626  enddo
627  else
628  do i=1,njeff
629  flgmin_v(i) = 0.0
630  enddo
631  endif
632 
633  if(num_p3d == 4 .and. npdf3d == 3) then
634  do k = 1, levr
635  do i = 1, njeff
636  deltaq(i,k) = phy_f3d(i,k,5,iblk,lan)
637  cnvw(i,k) = phy_f3d(i,k,6,iblk,lan)
638  cnvc(i,k) = phy_f3d(i,k,7,iblk,lan)
639  enddo
640  enddo
641  else if(npdf3d == 0 .and. ncnvcld3d == 1) then
642  kk = num_p3d + 1
643  do k = 1, levr
644  do i = 1, njeff
645  deltaq(i,k) = 0.
646  cnvw(i,k) = phy_f3d(i,k,kk,iblk,lan)
647  cnvc(i,k) = 0.
648  enddo
649  enddo
650  else
651  do k = 1, levr
652  do i = 1, njeff
653  deltaq(i,k) = 0.0
654  cnvw(i,k) = 0.0
655  cnvc(i,k) = 0.0
656  enddo
657  enddo
658  endif
659 
660 ! --- ... assign random seeds for sw and lw radiations
661 
662  if ( isubc_lw==2 .or. isubc_sw==2 ) then
663  do i = 1, njeff
664  icsdsw(i) = ixseed(lon+i-1,lan,1)
665  icsdlw(i) = ixseed(lon+i-1,lan,2)
666  enddo
667  endif
668 
669 ! *** ... calling radiation driver
670 !
680  if (use_nuopc) then
681 
682  lonbnd = lon + njeff - 1
683 
684  call dyn_parm%setrad(
685  & xlon(lon:lonbnd,lan), xlat(lon:lonbnd,lan),
686  & sinlat_v, coslat_v, solhr, ngptc, njeff, kdt,
687  & jdat, solcon, icsdsw, icsdlw, dtlw, dtsw,
688  & lsswr, lslwr, lssav, lmfshal, lmfdeep2,
689  & ipt, lprnt, deltim,
690  & slag, sdec, cdec )
691  call state_fldin%setrad(prsi, prsl, prslk,
692  & gt, gr, gr1, vvel, ntl, uni_cld)
693  call sfc_prop%setrad(
694  & slmsk(lon:lonbnd,lan), tsea(lon:lonbnd,lan),
695  & weasd(lon:lonbnd,lan), sncovr(lon:lonbnd,lan),
696  & snoalb(lon:lonbnd,lan), zorl(lon:lonbnd,lan),
697  & hprime_v,
698  & fice(lon:lonbnd,lan), tisfc(lon:lonbnd,lan),
699  & alvsf(lon:lonbnd,lan), alnsf(lon:lonbnd,lan),
700  & alvwf(lon:lonbnd,lan), alnwf(lon:lonbnd,lan),
701  & facsf(lon:lonbnd,lan), facwf(lon:lonbnd,lan)
702  & )
703 
704  call diags%setrad(nfxr, fluxr_v, topfsw, topflw,
705  & dswcmp, uswcmp )
706 
707  call cld_prop%setrad(cv(lon:lonbnd,lan), cvt(lon:lonbnd,lan)
708  &, cvb(lon:lonbnd,lan), f_ice, f_rain
709  &, r_rime, flgmin_v
710  &, cldcov_v, deltaq, sup, cnvw, cnvc )
711 !!! cv(lon:lonbnd,lan), cvt(lon:lonbnd,lan),cvb(lon:lonbnd,lan)
712  call rad_tend%setrad(
713  & swh(1:ngptc,1:levr,iblk,lan), sfalb(lon:lonbnd,lan),
714  & coszen_v, hlw(1:ngptc,1:levr,iblk,lan),
715  & tsflw(lon:lonbnd,lan), sfcemis(lon:lonbnd,lan),
716  & coszdg_v, hlwc_v, swhc_v )
717 
718  call intrfc_fld%setrad(sfcfsw, sfcflw)
719 ! & htrlw0, htrsw0, htrswb, htrlwb)
720 
721  if (me == 0 .and. kdt == 1) then
722  print *, me, ": NUOPC DBG: before nuopc_rad_run in gloopr"
723  end if
724 
725 ! PT This is much easier interface - no change needed here
726 ! if (savecon) then
727 ! call rad_run_savein(state_fldin, sfc_prop,
728 ! & diags, intrfc_fld,
729 ! & cld_prop, rad_tend, mdl_parm, dyn_parm)
730 !!! PT TEST - read previously saved inputs
731 !! call rad_run_readin(state_fldin, sfc_prop,
732 !! & diags, intrfc_fld,
733 !! & cld_prop, rad_tend, mdl_parm, dyn_parm)
734 ! end if
735 
738  call nuopc_rad_run (state_fldin, sfc_prop,
739  & diags, intrfc_fld,
740  & cld_prop, rad_tend, mdl_parm, dyn_parm)
741 
742  if (me == 0 .and. kdt == 1) then
743  print *, me, ": NUOPC DBG: after nuopc_rad_run in gloopr"
744  end if
745 
746 ! if (savecon) then
747 ! call rad_run_saveout(diags, intrfc_fld,
748 ! & cld_prop, rad_tend)
749 ! end if
750 
751  else
752 
753  call grrad
754 ! --- inputs:
755  & ( prsi,prsl,prslk,gt,gr,gr1,vvel,slmsk(lon,lan), &
756  & xlon(lon,lan),xlat(lon,lan),tsea(lon,lan), &
757  & weasd(lon,lan),sncovr(lon,lan),snoalb(lon,lan), &
758  & zorl(lon,lan),hprime_v, &
759  & alvsf(lon,lan),alnsf(lon,lan),alvwf(lon,lan), &
760  & alnwf(lon,lan),facsf(lon,lan),facwf(lon,lan), &
761  & fice(lon,lan),tisfc(lon,lan), &
762  & sinlat_v,coslat_v,solhr,jdat,solcon, &
763  & cv(lon,lan),cvt(lon,lan),cvb(lon,lan), &
764  & f_ice,f_rain,r_rime,flgmin_v, &
765  & icsdsw,icsdlw,ntcw-1,ncld,ntoz-1,ntl,nfxr, &
766 ! & icsdsw,icsdlw,NTCW-1,NCLD,NTOZ-1,NTRAC-1,NFXR, &
767 ! & dtlw,dtsw, lsswr,lslwr,lssav, &
768  & dtlw,dtsw, lsswr,lslwr,lssav,uni_cld,lmfshal,lmfdeep2, &
769  & ngptc,njeff,levr,me, lprnt, ipt, kdt, deltaq,sup,cnvw,cnvc,&
770 
771 ! --- outputs:
772  & swh(1:ngptc,1:levr,iblk,lan),topfsw,sfcfsw,dswcmp,uswcmp, &
773  & sfalb(lon,lan),coszen_v,coszdg_v, &
774  & hlw(1:ngptc,1:levr,iblk,lan),topflw,sfcflw,tsflw(lon,lan), &
775  & sfcemis(lon,lan),cldcov_v, &
776 ! --- input/output:
777  & fluxr_v, &
778 ! & fluxr_v, dbgu &
779 !! --- optional outputs:
780  & htrlw0=hlwc_v,htrsw0=swhc_v &
781 
782 !! &, HTRSWB=htrswb(1,1,1,iblk,lan), &
783 !! &, HTRLWB=htrlwb(1,1,1,iblk,lan) &
784 
785  & )
786 
787  end if ! if use_nuopc
788 
789  do j = 1, njeff
790  coszen(lon+j-1,lan) = coszen_v(j)
791  coszdg(lon+j-1,lan) = coszdg_v(j)
792  enddo
793 
794  do k=1,nfxr
795  do i=1,njeff
796  fluxr(k,lon+i-1,lan) = fluxr_v(i,k)
797  enddo
798  enddo
799 
800 ! --- ... radiation fluxes for other physics process or diagnostics
801 
802  if (lsswr) then
803  do i = 1, njeff
804  j = lon + i - 1
805  sfcdsw(j,lan) = sfcfsw(i)%dnfxc
806  sfcnsw(j,lan) = sfcfsw(i)%dnfxc - sfcfsw(i)%upfxc
807 
808 ! sfcnirbmd(j,lan)=dswcmp(i,1)
809 ! sfcnirdfd(j,lan)=dswcmp(i,2)
810 ! sfcvisbmd(j,lan)=dswcmp(i,3)
811 ! sfcvisdfd(j,lan)=dswcmp(i,4)
812 ! sfcnirbmu(j,lan)=uswcmp(i,1)
813 ! sfcnirdfu(j,lan)=uswcmp(i,2)
814 ! sfcvisbmu(j,lan)=uswcmp(i,3)
815 ! sfcvisdfu(j,lan)=uswcmp(i,4)
816  enddo
817  if (cplflx) then
818  do i = 1, njeff
819  j = lon + i - 1
820  aoi_fld%nirbmdi(j,lan) = dswcmp(i,1)
821  aoi_fld%nirdfdi(j,lan) = dswcmp(i,2)
822  aoi_fld%visbmdi(j,lan) = dswcmp(i,3)
823  aoi_fld%visdfdi(j,lan) = dswcmp(i,4)
824  aoi_fld%nirbmui(j,lan) = uswcmp(i,1)
825  aoi_fld%nirdfui(j,lan) = uswcmp(i,2)
826  aoi_fld%visbmui(j,lan) = uswcmp(i,3)
827  aoi_fld%visdfui(j,lan) = uswcmp(i,4)
828  enddo
829 
830  endif
831  endif
832  if (lslwr) then
833  do i = 1, njeff
834  j = lon + i - 1
835  sfcdlw(j,lan) = sfcflw(i)%dnfxc
836  enddo
837  do k=1,levr
838  do i=1,njeff
839  hlwc(i,k,iblk,lan) = hlwc_v(i,k)
840  enddo
841  enddo
842  endif
843  do k=1,levr
844  do i=1,njeff
845  swhc(i,k,iblk,lan) = swhc_v(i,k)
846  enddo
847  enddo
848 
849  if (levr < levs) then
850  do k=levr+1,levs
851  do i=1,njeff
852  hlw(i,k,iblk,lan) = hlw(i,levr,iblk,lan)
853  hlwc(i,k,iblk,lan) = hlwc(i,levr,iblk,lan)
854  swh(i,k,iblk,lan) = swh(i,levr,iblk,lan)
855  swhc(i,k,iblk,lan) = swhc(i,levr,iblk,lan)
856  enddo
857  enddo
858  endif
859 
860 ! if (lprnt) then
861 ! write(0,*)' hlw=',hlw(ipt,1:10,iblk,lan),' lan=',lan,' ipt=',ipt,
862 ! & ' njeff=',njeff
863 ! write(0,*)' swh=',swh(ipt,1:10,iblk,lan),' lan=',lan
864 ! endif
865 !
866 ! grrad routine computes cldcov_v (instant 3D cloud cover) -- Sarah Lu
867 ! if ldiag3d is T, update cldcov (accumulative 3D cloud cover)
868 ! if lgocart is T, update fcld (instant 3D cloud cover)
869 
870  if (lssav) then
871  if (ldiag3d) then
872  do k=1,levr
873  do i=1,njeff
874  item = lon+i-1
875  cldcov(k,item,lan) = cldcov(k,item,lan) &
876  & + cldcov_v(i,k) * raddt
877  enddo
878  enddo
879  endif
880  endif
881  if (lgocart) then
882  do k=1,levr
883  do i=1,njeff
884  g3d_fld%fcld(lon+i-1,lan,k) = cldcov_v(i,k)
885  enddo
886  enddo
887  endif
888 
889 !$$$ write(2900+lat,*) ' ilon = ',lon
890 !$$$ write(2900+lat,'("swh",T16,"hlw")')
891 !$$$ do k=1,levs
892 !$$$ write(2900+lat,
893 !$$$ . '(e10.3,T16,e10.3,T31,e10.3)')
894 !$$$ . swh(1,k,iblk,lan),hlw(1,k,iblk,lan)
895 !$$$ enddo
896 !
897  enddo ! end of lon if loop
898 !
899  enddo ! end of lan if loop
900 !
901  if (allocated(gr1)) deallocate(gr1)
902 
903  return
904  end subroutine gloopr
DDT for fields typically only used for diagnostic output.
DDT for basic inputs of radiation and physics parameters.
subroutine, public rad_run_readin(statein, sfc_prop, diags, intrfc_fld, cld_prop, rad_tend, mdl_parm, dyn_parm)
Reads inputs to nuopc_rad_run from file radrun_savein.dat.
integer, save iaerflg
aerosol effect control flag
Definition: physparam.f:148
DDT for radiation tendencies.
subroutine gloopr(grid_fld, g3d_fld, aoi_fld,
subroutine gloopr invokes the physcis driver&#39;s call to the radiation portion of the physics through t...
Definition: gloopr.f:16
DDT for surface fields.
DDT for basic outputs from radiation and physics.
subroutine, public rad_run_savein(statein, sfc_prop, diags, intrfc_fld, cld_prop, rad_tend, mdl_parm, dyn_parm)
Write inputs to nuopc_rad_run to file radrun_savein.dat.
subroutine, public rad_run_readout(diags, intrfc_fld, cld_prop, rad_tend)
Read outputs from nuopc_rad_run from radrun_saveout.dat.
DDT for data that changes frequently (e.g. inner loops)
DDT for data used for coupling (e.g. land and ocean)
subroutine, public nuopc_rad_run(statein, sfc_prop, diags, intrfc_fld, cld_prop, rad_tend, mdl_parm, dyn_parm)
Wrapper for grrad (grrad.f).
DDT for non-changing model parameters - set once in initialize.
DDT for cloud data and parameters. Used by grrad and gbphys with different intent.
integer, save ipsd0
initial permutaion seed for mcica radiation
Definition: physparam.f:228
the interface between the dynamic core and the physics packages
subroutine, public radupdate(idate, jdate, deltsw, deltim, lsswr, me, slag, sdec, cdec, solcon)
This subroutine calls many update subroutines to check and update radiation required but time varying...
Definition: grrad.f:627
subroutine, public nuopc_rad_update(mdl, dyn)
Wrapper for radupdate (grrad.f) - updates some fields between timesteps.
subroutine, public rad_run_saveout(diags, intrfc_fld, cld_prop, rad_tend)
Write outputs from nuopc_rad_run to radrun_saveout.dat.
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 radiation calculation subroutines. It sets up profile variables for ...
Definition: grrad.f:957