Interoperable Physics Driver for NGGPS
nuopc_physics.F90
Go to the documentation of this file.
1 
4 
9 !$$$ Module Documentation Block
10 !
11 ! Module: nuopc_physics
12 ! Initial Author: Patrick Tripp - NOAA/NCEP/EMC
13 ! Current code developer: Hang Lei
14 ! Email: Hang.Lei@noaa.gov
15 ! Abstract: Wrapper for GFS physics
16 ! History Log:
17 ! Tripp - 5/2015 - Initial release
18 ! Tripp - 8/2015 - Added nems_slg_shoc updates
19 ! Hang - 1/2016 - change the newsas and sashal into integer variables
20 ! Hang - 2/2016 - Adjust the radiation calculation based on levr
21 ! Hang - 3/2016 - Fix the WAM driving data flow
22 ! Hang - 4/2016 - Adjust to fit new features in clouds, convections, and sst
23 !
24 ! NEW model parameters: cscnv, nctp, ntke, do_shoc, shocaftcnv, ntot3d, ntot2d, shoc_cld
25 ! NEW nuopc_phys_init arguments
26 ! NEW grrad arguments shoc_cld
27 ! NEW gbphys arguments cscnv, nctp, ntke, do_shoc, shocaftcnv, ntot3d, ntot2d
28 ! NEW phy_fctd array for CS convection in gbphys
29 ! Tripp - 9/2015 - Added more output on read and save, some code cleanup
30 ! Hang Lei - 3/2016 : Change the data types of newsas and sashal
31 ! into logical variables. Add new physics variables into the physics driver.
32 ! Hang Lei - 4/2016 : Reorganize the functions for DDTs defined in
33 ! this drver. Adopt levr in radation calculations and levs in surface
34 ! process calculations.
35 !
36 ! Public Variables:
37 !
38 ! Derived Data Types (DDTs)
39 ! state_fields_in ! basic inputs of radiation and physics parameters
40 ! state_fields_out ! basic outputs from radiation and physics
41 ! sfc_properties ! surface fields
42 ! diagnostics ! fields typically only used for diagnostic output
43 ! cloud_properties ! cloud data and parameters
44 ! radiation_tendencies ! radiation data
45 ! model_parameters ! non-changing model parameters - set once in nuopc_phys_init
46 ! interface_fields ! data used for coupling (e.g. land and ocean)
47 ! dynamic_parameters ! data that changes frequently (e.g. inner loops)
48 ! tbd_ddt ! to be determined data that has not been pigeonholed
49 !
50 ! use_nuopc ! flag to use this driver
51 !
52 ! Public Subroutines:
53 ! nuopc_phys_init ! initialize routine, run once at beginning to set model options, etc.
54 ! nuopc_phys_run ! wrapper for gbphys - the core physics component
55 ! nuopc_rad_run ! wrapper for grrad - the main radiation driver
56 ! nuopc_rad_update ! wrapper for radupdate - update values between timesteps, solar, etc.
57 !
58 ! DDT type bound procedures
59 ! [DDT]%set ! define scalar values and assign pointers to array data
60 ! [DDT]%setrad ! set the items required by radiation
61 ! [DDT]%setphys ! set the items required by physics
62 ! [DDT]%print ! for printing debug output - only partially implemented
63 !
64 ! ! Subroutines for standalone test driver
65 ! phys_init_savein ! write/read inputs to nuopc_phys_init
66 ! phys_init_readin
67 !
68 ! phys_run_savein ! write/read inputs to nuopc_phys_run
69 ! phys_run_readin
70 ! phys_run_saveout ! write/read outputs from nuopc_phys_run
71 ! phys_run_readout
72 !
73 ! rad_run_savein ! write/read inputs to nuopc_rad_run
74 ! rad_run_readin
75 ! rad_run_saveout ! write/read outputs from nuopc_rad_ru
76 ! rad_run_readout
77 !
78 ! Private
79 ! dbgprint ! Simple debug print subroutine
80 
81 !! Type example complex derived data type
82 !!\n type model_data_in
83 !!\n private
84 !!\n real :: vara
85 !!\n real :: varb
86 !!\n end type
87 !!\n
88 !!\n type model_data
89 !!\n private
90 !!\n
91 !!\n type (model_data_in) :: data_in
92 !!\n type (model_data_out) :: data_out
93 !!\n type (model_data_inout) :: data_inout
94 !!\n
95 !!\n contains
96 !!\n procedure :: setin => set_model_in
97 !!\n procedure :: setout => set_model_out
98 !!\n procedure :: setinout => set_model_inout
99 !!\n
100 !!\n end type
101 
102 ! Type phys_restart
103 ! type phys_restart
104 ! private
105 !
106 ! integer :: dim1, dim2
107 ! real (kind=kind_phys), public, pointer :: restart_data (:,:) ! Contains what exactly?
108 ! ! Data needed between timesteps to physics
109 ! end type
110 
113 
114  use machine, only: kind_phys
115  use physcons, only: dxmax, dxmin, dxinv ! lon lat dependant variables set in initialize
116 
117 
119  use module_radsw_parameters, only : topfsw_type, sfcfsw_type
120  use module_radlw_parameters, only : topflw_type, sfcflw_type
121  use funcphys, only : gfuncphys
122 
123  implicit none
124  private
125 
126  ! Derived Data Types
127 
128  public :: state_fields_in
129  public :: state_fields_out
130  public :: sfc_properties
131  public :: diagnostics
132  public :: cloud_properties
133  public :: radiation_tendencies
134  public :: model_parameters
135  public :: interface_fields
136  public :: dynamic_parameters
137  public :: tbd_ddt
138 
139  public :: use_nuopc ! flag to use this driver
140 
141  ! Main Subroutines
142  public :: nuopc_phys_init
143  public :: nuopc_phys_run
144  public :: nuopc_rad_run
145  public :: nuopc_rad_update
146  public :: nuopc_sppt_phys ! stochastic physics
147  public :: ozoneini
148  public :: h2oini
149 
150 ! public :: dyn_param_setphys
151 ! public :: state_fld_setphys_in
152 ! public :: state_fld_setphys_out
153 ! public :: diagnostics_setphys
154 ! public :: interface_fld_setphys
155 ! public :: rad_tend_set
156 ! public :: sfc_prop_setphys
157 ! public :: cld_prop_setphys
158 ! public :: tbd_set
159 
160  ! Subroutines for standalone test driver
161  public :: phys_init_savein ! write/read inputs to nuopc_phys_init
162  public :: phys_init_readin
163 
164  public :: phys_run_savein ! write/read inputs to nuopc_phys_run
165  public :: phys_run_readin
166  public :: phys_run_saveout ! write/read outputs from nuopc_phys_run
167  public :: phys_run_readout
168 
169  public :: rad_run_savein ! write/read inputs to nuopc_rad_run
170  public :: rad_run_readin
171  public :: rad_run_saveout ! write/read outputs from nuopc_rad_ru
172  public :: rad_run_readout
173 
174 
175  integer :: myme ! My mpi mpe - set in initialize
176  logical, parameter :: debug = .false. ! Flag toggle for debug print output
177  !logical, parameter :: debug = .true.
178  logical, parameter :: use_nuopc = .false.
179  ! logical, parameter :: use_nuopc = .true. !< Flag to use this wrapper
180 
181 
182 !******************************************
183 ! Type tbd_ddt
184 !******************************************
185 
186  type tbd_ddt
187 
188  private
189 
190 ! In
191  real (kind=kind_phys), pointer :: dpshc (:) => null()
192  real (kind=kind_phys), pointer :: o3out(:,:,:) => null() ! ozplout ozone output data
193  integer, pointer :: lan
194  real (kind=kind_phys), pointer :: prdout(:,:,:) => null()
195  real (kind=kind_phys), pointer :: h2oplout(:,:,:) => null()
196  real (kind=kind_phys), pointer :: h2oplout_v(:,:,:) => null()
197  real (kind=kind_phys), pointer :: poz(:) => null()
198  real (kind=kind_phys), pointer :: rann(:,:) => null()
199  real (kind=kind_phys) :: xkzm_m
200  real (kind=kind_phys) :: xkzm_h
201  real (kind=kind_phys) :: xkzm_s
202  real (kind=kind_phys) :: psautco(2)
203  real (kind=kind_phys) :: prautco(2)
204  real (kind=kind_phys) :: evpco
205  real (kind=kind_phys) :: wminco(2)
206 
207 ! Moved to dyn_param
208 ! ! These might be able to be computed elsewhere
209 ! real (kind=kind_phys) :: slag ! equation of time ( radian )
210 ! real (kind=kind_phys) :: sdec ! sin of the solar declination angle
211 ! real (kind=kind_phys) :: cdec ! cos of the solar declination angle
212 
213 ! In/Out
214  real (kind=kind_phys), pointer :: acv (:) => null()
215  real (kind=kind_phys), pointer :: acvb(:) => null()
216  real (kind=kind_phys), pointer :: acvt(:) => null()
217  real (kind=kind_phys), pointer :: slc(:,:) => null()
218  real (kind=kind_phys), pointer :: smc(:,:) => null()
219  real (kind=kind_phys), pointer :: stc(:,:) => null()
220  real (kind=kind_phys), pointer :: upd_mf(:,:) => null()
221  real (kind=kind_phys), pointer :: dwn_mf(:,:) => null()
222  real (kind=kind_phys), pointer :: det_mf(:,:) => null()
223  real (kind=kind_phys), pointer :: phy_f3d(:,:,:) => null()
224  real (kind=kind_phys), pointer :: phy_f2d(:,:) => null()
225  real (kind=kind_phys), pointer :: tprcp (:) => null()
226  real (kind=kind_phys), pointer :: srflag(:) => null()
227 
228 ! NEW
229  real (kind=kind_phys), pointer :: phy_fctd(:,:) => null()
230 
231 ! Out
232  real (kind=kind_phys), pointer :: tref(:) => null()
233  real (kind=kind_phys), pointer :: z_c(:) => null()
234  real (kind=kind_phys), pointer :: c_0(:) => null()
235  real (kind=kind_phys), pointer :: c_d(:) => null()
236  real (kind=kind_phys), pointer :: w_0(:) => null()
237  real (kind=kind_phys), pointer :: w_d(:) => null()
238 
239 ! Unknown (InOut??)
240  real (kind=kind_phys), pointer :: fscav(:) => null()
241  real (kind=kind_phys), pointer :: fswtr(:) => null()
242 
243  contains
244  procedure :: set => tbd_set
245 
246  end type
247 !******************************************
248 !
249 ! Type example complex derived data type
250 ! type model_data_in
251 ! private
252 ! real :: vara
253 ! real :: varb
254 ! end type
255 !
256 ! type model_data
257 ! private
258 !
259 ! type (model_data_in) :: data_in
260 ! type (model_data_out) :: data_out
261 ! type (model_data_inout) :: data_inout
262 !
263 ! contains
264 ! procedure :: setin => set_model_in
265 ! procedure :: setout => set_model_out
266 ! procedure :: setinout => set_model_inout
267 !
268 ! end type
269 
270 !! Type phys_restart
271 ! type phys_restart
272 ! private
273 !
274 ! integer :: dim1, dim2
275 ! real (kind=kind_phys), public, pointer :: restart_data (:,:) ! Contains what exactly?
276 ! ! Data needed between timesteps to physics
277 ! end type
278 
279 
280 
281 
282 !******************************************
283 ! Type state_fields in and out
284 !******************************************
286 
287  private
288 
289  !! Inputs (also in rad)
290  real (kind=kind_phys), pointer :: prsi (:,:) => null()
291  real (kind=kind_phys), pointer :: prsl (:,:) => null()
292  real (kind=kind_phys), pointer :: prslk (:,:) => null()
293  real (kind=kind_phys), pointer :: tgrs (:,:) => null()
294 
295  ! Only in grrad
296  real (kind=kind_phys), pointer :: qgrs_rad(:,:) => null()
297  real (kind=kind_phys), pointer :: tracer(:,:,:) => null()
298  ! incl: oz, cwc, aeros, etc. [dim(ix,lm,ntrac): created in grrad.f]
299  real (kind=kind_phys), pointer :: vvl(:,:) => null()
300  integer :: ntl
301  logical :: uni_cld
302 
303  !! Inputs only in phys
304  real (kind=kind_phys), pointer :: pgr (:) => null()
305  real (kind=kind_phys), pointer :: ugrs (:,:) => null()
306  real (kind=kind_phys), pointer :: vgrs (:,:) => null()
307  real (kind=kind_phys), pointer :: qgrs (:,:,:) => null()
308  ! Note in grrad.f only declared as 2D array with dim(ix,levs).
309  real (kind=kind_phys), pointer :: prsik (:,:) => null()
310  real (kind=kind_phys), pointer :: phii (:,:) => null()
311  real (kind=kind_phys), pointer :: phil (:,:) => null()
312  real (kind=kind_phys), pointer :: adjtrc(:) => null()
313 
314  contains
315  procedure :: setrad => state_fld_setrad_in
316  procedure :: setphys => state_fld_setphys_in
317  procedure :: print => state_fld_in_print
318  end type
319 !******************************************
320 
321 
322 
323 
324 
325 !******************************************
326 ! Type state_fields out
327 !******************************************
329 
330  private
331 
332  !! Outputs (only in physics)
333  real (kind=kind_phys), pointer :: gt0 (:,:) => null()
334  real (kind=kind_phys), pointer :: gq0 (:,:,:) => null()
335  real (kind=kind_phys), pointer :: gu0 (:,:) => null()
336  real (kind=kind_phys), pointer :: gv0 (:,:) => null()
337 
338  contains
339  procedure :: setphys => state_fld_setphys_out
340  procedure :: print => state_fld_out_print
341  end type
342 !******************************************
343 
344 
345 
346 
347 
348 !******************************************
349 ! Type sfc_properties
350 !******************************************
352 
353  private
354 
355  ! Inputs
356  real (kind=kind_phys), pointer :: slmsk (:) => null()
357  real (kind=kind_phys), pointer :: tsfc (:) => null()
358  real (kind=kind_phys), pointer :: snowd (:) => null()
359  real (kind=kind_phys), pointer :: sncovr(:) => null()
360  real (kind=kind_phys), pointer :: snoalb(:) => null()
361  real (kind=kind_phys), pointer :: zorl (:) => null()
362  real (kind=kind_phys), pointer :: hprim (:) => null()
363  real (kind=kind_phys), pointer :: fice (:) => null()
364  real (kind=kind_phys), pointer :: tisfc (:) => null()
365  real (kind=kind_phys), pointer :: alvsf (:) => null()
366  real (kind=kind_phys), pointer :: alnsf (:) => null()
367  real (kind=kind_phys), pointer :: alvwf (:) => null()
368  real (kind=kind_phys), pointer :: alnwf (:) => null()
369  real (kind=kind_phys), pointer :: facsf (:) => null()
370  real (kind=kind_phys), pointer :: facwf (:) => null()
371 
372 
373  ! gbphys only
374  ! hprim is in rad but only 1D
375  ! in gloopb is 2D hprime_v(ngptc,nmtvr) - Can FIX later
376  real (kind=kind_phys), pointer :: hprime2(:,:) => null()
377  real (kind=kind_phys), pointer :: slope (:) => null()
378  real (kind=kind_phys), pointer :: shdmin (:) => null()
379  real (kind=kind_phys), pointer :: shdmax (:) => null()
380  real (kind=kind_phys), pointer :: tg3 (:) => null()
381  real (kind=kind_phys), pointer :: vfrac (:) => null()
382  real (kind=kind_phys), pointer :: vtype (:) => null()
383  real (kind=kind_phys), pointer :: stype (:) => null()
384  real (kind=kind_phys), pointer :: uustar (:) => null()
385  real (kind=kind_phys), pointer :: oro (:) => null()
386  real (kind=kind_phys), pointer :: oro_uf (:) => null()
387 
388  ! In/Out
389  real (kind=kind_phys), pointer :: hice (:) => null()
390  real (kind=kind_phys), pointer :: weasd (:) => null()
391  real (kind=kind_phys), pointer :: canopy(:) => null()
392  real (kind=kind_phys), pointer :: ffmm (:) => null()
393  real (kind=kind_phys), pointer :: ffhh (:) => null()
394  real (kind=kind_phys), pointer :: f10m (:) => null()
395 
396  ! Outputs
397  real (kind=kind_phys), pointer :: t2m(:) => null()
398  real (kind=kind_phys), pointer :: q2m(:) => null()
399 
400  contains
401  procedure :: setrad => sfc_prop_setrad
402  procedure :: setphys => sfc_prop_setphys
403  !procedure :: print => sfc_prop_print
404  end type
405 !******************************************
406 
407 
408 
409 
410 
411 !******************************************
412 ! Type diagnostics
413 !******************************************
415 
416  private
417 
418  integer :: nfxr
419 
420  !! Input/Output only in radiation
421  real (kind=kind_phys), pointer :: fluxr (:,:) => null()
422  ! hardcoded field indices, opt. includes aerosols
423 
424  real (kind=kind_phys), pointer :: dswcmp(:,:) => null()
425  real (kind=kind_phys), pointer :: uswcmp(:,:) => null()
426 
427  type(topfsw_type), pointer :: topfsw(:) => null()
431 
432  type(topflw_type), pointer :: topflw(:) => null()
435 
436  ! Input/output - used by physics
437  real (kind=kind_phys), pointer :: srunoff(:) => null()
438  real (kind=kind_phys), pointer :: evbsa (:) => null()
439  real (kind=kind_phys), pointer :: evcwa (:) => null()
440  real (kind=kind_phys), pointer :: snohfa (:) => null()
441  real (kind=kind_phys), pointer :: transa (:) => null()
442  real (kind=kind_phys), pointer :: sbsnoa (:) => null()
443  real (kind=kind_phys), pointer :: snowca (:) => null()
444  real (kind=kind_phys), pointer :: soilm (:) => null()
445  real (kind=kind_phys), pointer :: tmpmin (:) => null()
446  real (kind=kind_phys), pointer :: tmpmax (:) => null()
447  real (kind=kind_phys), pointer :: dusfc (:) => null()
448  real (kind=kind_phys), pointer :: dvsfc (:) => null()
449  real (kind=kind_phys), pointer :: dtsfc (:) => null()
450  real (kind=kind_phys), pointer :: dqsfc (:) => null()
451  real (kind=kind_phys), pointer :: totprcp(:) => null()
452  real (kind=kind_phys), pointer :: gflux (:) => null()
453  real (kind=kind_phys), pointer :: dlwsfc (:) => null()
454  real (kind=kind_phys), pointer :: ulwsfc (:) => null()
455  real (kind=kind_phys), pointer :: suntim (:) => null()
456  real (kind=kind_phys), pointer :: runoff (:) => null()
457  real (kind=kind_phys), pointer :: ep (:) => null()
458  real (kind=kind_phys), pointer :: cldwrk (:) => null()
459  real (kind=kind_phys), pointer :: dugwd (:) => null()
460  real (kind=kind_phys), pointer :: dvgwd (:) => null()
461  real (kind=kind_phys), pointer :: psmean (:) => null()
462  real (kind=kind_phys), pointer :: cnvprcp(:) => null()
463  real (kind=kind_phys), pointer :: spfhmin(:) => null()
464  real (kind=kind_phys), pointer :: spfhmax(:) => null()
465  real (kind=kind_phys), pointer :: rain (:) => null()
466  real (kind=kind_phys), pointer :: rainc (:) => null()
467 ! real (kind=kind_phys), pointer :: snow (:) => null() !< [in,out] for phys:flx_fld%rainc convective rain at this time step [dim(im): created in gbphys.f]
468  real (kind=kind_phys), pointer :: dt3dt (:,:,:) => null()
469  real (kind=kind_phys), pointer :: dq3dt (:,:,:) => null()
470  real (kind=kind_phys), pointer :: du3dt (:,:,:) => null()
471  real (kind=kind_phys), pointer :: dv3dt (:,:,:) => null()
472  real (kind=kind_phys), pointer :: dqdt_v(:,:) => null()
473 
474  ! Output - only in physics
475  real (kind=kind_phys), pointer :: u10m (:) => null()
476  real (kind=kind_phys), pointer :: v10m (:) => null()
477  real (kind=kind_phys), pointer :: zlvl (:) => null()
478  real (kind=kind_phys), pointer :: psurf (:) => null()
479  real (kind=kind_phys), pointer :: hpbl (:) => null()
480  real (kind=kind_phys), pointer :: pwat (:) => null()
481  real (kind=kind_phys), pointer :: t1 (:) => null()
482  real (kind=kind_phys), pointer :: q1 (:) => null()
483  real (kind=kind_phys), pointer :: u1 (:) => null()
484  real (kind=kind_phys), pointer :: v1 (:) => null()
485  real (kind=kind_phys), pointer :: chh (:) => null()
486  real (kind=kind_phys), pointer :: cmm (:) => null()
487  real (kind=kind_phys), pointer :: dlwsfci(:) => null()
488  real (kind=kind_phys), pointer :: ulwsfci(:) => null()
489  real (kind=kind_phys), pointer :: dswsfci(:) => null()
490  real (kind=kind_phys), pointer :: uswsfci(:) => null()
491  real (kind=kind_phys), pointer :: dusfci (:) => null()
492  real (kind=kind_phys), pointer :: dvsfci (:) => null()
493  real (kind=kind_phys), pointer :: dtsfci (:) => null()
494  real (kind=kind_phys), pointer :: dqsfci (:) => null()
495  real (kind=kind_phys), pointer :: gfluxi (:) => null()
496  real (kind=kind_phys), pointer :: epi (:) => null()
497  real (kind=kind_phys), pointer :: smcwlt2(:) => null()
498  real (kind=kind_phys), pointer :: smcref2(:) => null()
499  real (kind=kind_phys), pointer :: wet1 (:) => null()
500  real (kind=kind_phys), pointer :: sr (:) => null()
501 
502  contains
503  procedure :: setrad => diagnostics_setrad
504  procedure :: setphys => diagnostics_setphys
505  !procedure :: print => diagnostics_print
506  end type
507 
508 
509 
510 
511 
512 !******************************************
513 ! Type interface_fields
514 !******************************************
516 
517  private
518 
519  ! Radiation output only
520  type(sfcfsw_type), pointer :: sfcfsw(:) => null()
526 
527  type(sfcflw_type), pointer :: sfcflw(:) => null()
533 
534  !! Optional radiation output variables: - Used by WAM
535  real (kind=kind_phys), pointer :: htrswb(:,:,:) => null()
536  real (kind=kind_phys), pointer :: htrlwb(:,:,:) => null()
537 
538  !! Optional radiation output variables:
539  real (kind=kind_phys), pointer :: htrlw0(:,:) => null()
540  real (kind=kind_phys), pointer :: htrsw0(:,:) => null()
541 
542  ! Inputs - physics only
543  real (kind=kind_phys), pointer :: sfcdsw(:) => null()
544  real (kind=kind_phys), pointer :: sfcnsw(:) => null()
545  real (kind=kind_phys), pointer :: sfcdlw(:) => null()
546 
547  ! Inputs moved from - TBD physics only
548  real (kind=kind_phys), pointer :: sfcnirbmu(:) => null()
549  real (kind=kind_phys), pointer :: sfcnirdfu(:) => null()
550  real (kind=kind_phys), pointer :: sfcvisbmu(:) => null()
551  real (kind=kind_phys), pointer :: sfcvisdfu(:) => null()
552 
553  ! Inputs moved from diagnostics - physics only
554  real (kind=kind_phys), pointer :: sfcnirbmd(:) => null()
555  real (kind=kind_phys), pointer :: sfcnirdfd(:) => null()
556  real (kind=kind_phys), pointer :: sfcvisbmd(:) => null()
557  real (kind=kind_phys), pointer :: sfcvisdfd(:) => null()
558 
559  ! Input/Output - physics only
560  real (kind=kind_phys), pointer :: dusfc_cpl (:) => null()
561  real (kind=kind_phys), pointer :: dvsfc_cpl (:) => null()
562  real (kind=kind_phys), pointer :: dtsfc_cpl (:) => null()
563  real (kind=kind_phys), pointer :: dqsfc_cpl (:) => null()
564  real (kind=kind_phys), pointer :: dlwsfc_cpl(:) => null()
565  real (kind=kind_phys), pointer :: dswsfc_cpl(:) => null()
566  real (kind=kind_phys), pointer :: dnirbm_cpl(:) => null()
567  real (kind=kind_phys), pointer :: dnirdf_cpl(:) => null()
568  real (kind=kind_phys), pointer :: dvisbm_cpl(:) => null()
569  real (kind=kind_phys), pointer :: dvisdf_cpl(:) => null()
570  real (kind=kind_phys), pointer :: rain_cpl (:) => null()
571  real (kind=kind_phys), pointer :: snow_cpl (:) => null()
572  real (kind=kind_phys), pointer :: nlwsfc_cpl(:) => null()
573  real (kind=kind_phys), pointer :: nswsfc_cpl(:) => null()
574  real (kind=kind_phys), pointer :: nnirbm_cpl(:) => null()
575  real (kind=kind_phys), pointer :: nnirdf_cpl(:) => null()
576  real (kind=kind_phys), pointer :: nvisbm_cpl(:) => null()
577  real (kind=kind_phys), pointer :: nvisdf_cpl(:) => null()
578  real (kind=kind_phys), pointer :: slimskin_cpl(:) => null()
579  real (kind=kind_phys), pointer :: dusfcin_cpl(:) => null()
580  real (kind=kind_phys), pointer :: dvsfcin_cpl(:) => null()
581  real (kind=kind_phys), pointer :: dtsfcin_cpl(:) => null()
582  real (kind=kind_phys), pointer :: dqsfcin_cpl(:) => null()
583  real (kind=kind_phys), pointer :: ulwsfcin_cpl(:) => null()
584 
585 
586  real (kind=kind_phys), pointer :: xt (:) => null()
587  real (kind=kind_phys), pointer :: xs (:) => null()
588  real (kind=kind_phys), pointer :: xu (:) => null()
589  real (kind=kind_phys), pointer :: xv (:) => null()
590  real (kind=kind_phys), pointer :: xz (:) => null()
591  real (kind=kind_phys), pointer :: zm (:) => null()
592  real (kind=kind_phys), pointer :: xtts (:) => null()
593  real (kind=kind_phys), pointer :: xzts (:) => null()
594  real (kind=kind_phys), pointer :: d_conv (:) => null()
595  real (kind=kind_phys), pointer :: ifd (:) => null()
596  real (kind=kind_phys), pointer :: dt_cool(:) => null()
597  real (kind=kind_phys), pointer :: qrain (:) => null()
598 
599  ! Outputs - physics only
600  real (kind=kind_phys), pointer :: dusfci_cpl (:) => null()
601  real (kind=kind_phys), pointer :: dvsfci_cpl (:) => null()
602  real (kind=kind_phys), pointer :: dtsfci_cpl (:) => null()
603  real (kind=kind_phys), pointer :: dqsfci_cpl (:) => null()
604  real (kind=kind_phys), pointer :: dlwsfci_cpl(:) => null()
605  real (kind=kind_phys), pointer :: dswsfci_cpl(:) => null()
606  real (kind=kind_phys), pointer :: dnirbmi_cpl(:) => null()
607  real (kind=kind_phys), pointer :: dnirdfi_cpl(:) => null()
608  real (kind=kind_phys), pointer :: dvisbmi_cpl(:) => null()
609  real (kind=kind_phys), pointer :: dvisdfi_cpl(:) => null()
610  real (kind=kind_phys), pointer :: nlwsfci_cpl(:) => null()
611  real (kind=kind_phys), pointer :: nswsfci_cpl(:) => null()
612  real (kind=kind_phys), pointer :: nnirbmi_cpl(:) => null()
613  real (kind=kind_phys), pointer :: nnirdfi_cpl(:) => null()
614  real (kind=kind_phys), pointer :: nvisbmi_cpl(:) => null()
615  real (kind=kind_phys), pointer :: nvisdfi_cpl(:) => null()
616  real (kind=kind_phys), pointer :: t2mi_cpl (:) => null()
617  real (kind=kind_phys), pointer :: q2mi_cpl (:) => null()
618  real (kind=kind_phys), pointer :: u10mi_cpl (:) => null()
619  real (kind=kind_phys), pointer :: v10mi_cpl (:) => null()
620  real (kind=kind_phys), pointer :: tseai_cpl (:) => null()
621  real (kind=kind_phys), pointer :: psurfi_cpl (:) => null()
622  real (kind=kind_phys), pointer :: oro_cpl (:) => null()
623  real (kind=kind_phys), pointer :: slmsk_cpl (:) => null()
624  ! Input/Output - stochastic physics only
625  real (kind=kind_phys), pointer :: s_shum_wts(:,:) => null() !
626  real (kind=kind_phys), pointer :: s_sppt_wts(:,:) => null() !
627 ! real (kind=kind_phys), pointer :: s_sppt_wts
628  real (kind=kind_phys), pointer :: s_skebu_wts(:,:) => null() !
629  real (kind=kind_phys), pointer :: s_skebv_wts(:,:) => null() !
630  real (kind=kind_phys), pointer :: s_vcu_wts(:,:) => null() !
631  real (kind=kind_phys), pointer :: s_vcv_wts(:,:) => null() !
632  real (kind=kind_phys), pointer :: s_uphys(:,:) => null() !
633  real (kind=kind_phys), pointer :: s_vphys(:,:) => null() !
634  real (kind=kind_phys), pointer :: s_tphys(:,:) => null() !
635 ! real (kind=kind_phys), pointer :: s_qphys(:,:) => null() !
636  real (kind=kind_phys), pointer :: s_qphys(:,:) => null() !
637  real (kind=kind_phys), pointer :: s_tpphys(:) => null() !
638  real (kind=kind_phys), pointer :: s_cpphys(:) => null() !
639  real (kind=kind_phys), pointer :: s_cplrain0(:) => null() !
640  real (kind=kind_phys), pointer :: s_cplsnow0(:) => null() !
641  real (kind=kind_phys), pointer :: s_raincpl(:) => null() !
642  real (kind=kind_phys), pointer :: s_snowcpl(:) => null() !
643  real (kind=kind_phys), pointer :: s_totprcp0(:) => null() !
644  real (kind=kind_phys), pointer :: s_cnvprcp0(:) => null() !
645  real (kind=kind_phys), pointer :: s_gu0(:,:) => null() !
646  real (kind=kind_phys), pointer :: s_gv0(:,:) => null() !
647  real (kind=kind_phys), pointer :: s_gt0(:,:) => null() !
648  real (kind=kind_phys), pointer :: s_gr0(:,:,:) => null() !
649  logical :: s_do_sppt
650  logical :: s_do_shum
651  logical :: s_do_skeb
652  logical :: s_do_vc
653 
654  contains
655  procedure :: setrad => interface_fld_setrad
656  procedure :: setphys => interface_fld_setphys
657 
658  end type
659 
660 
661 
662 
663 
664 !******************************************
665 ! Type cloud_properties
666 ! ******************************************
668 
669  private
670 
671  ! grrad in
672  ! gbphys inout
673  real (kind=kind_phys), pointer :: cv (:) => null()
674  real (kind=kind_phys), pointer :: cvt (:) => null()
675  real (kind=kind_phys), pointer :: cvb (:) => null()
676 
677  ! grrad in
678  real (kind=kind_phys), pointer :: fcice(:,:) => null()
679  real (kind=kind_phys), pointer :: frain(:,:) => null()
680  real (kind=kind_phys), pointer :: rrime(:,:) => null()
681 
682  ! grrad, gbphys in
683  real (kind=kind_phys), pointer :: flgmin(:) => null()
684 
685  ! grrad in
686  real (kind=kind_phys), pointer :: deltaq(:,:) => null()
687  real (kind=kind_phys), pointer :: cnvw (:,:) => null()
688  real (kind=kind_phys), pointer :: cnvc (:,:) => null()
689 
690  ! grrad in
691  ! gbphys inout
692  real (kind=kind_phys), pointer :: sup => null()
693 
694  ! gbphys inout
695  real (kind=kind_phys), pointer :: cnvqc_v(:,:) => null()
696 
697  !! grrad out
698  real (kind=kind_phys), pointer :: cldcov(:,:) => null()
699 
700 
701 
702  contains
703  procedure :: setrad => cld_prop_setrad
704  procedure :: setphys => cld_prop_setphys
705  !procedure :: print => cld_prop_print
706  end type
707 
708 !******************************************
709 
710 
711 
712 
713 
714 
715 
716 !******************************************
717 ! Type radiation_tendencies
718 !******************************************
720 
721  private
722 
723  !! Outputs from grrad
724  real (kind=kind_phys), pointer :: htrsw (:,:) => null()
725  real (kind=kind_phys), pointer :: htrlw (:,:) => null()
726  real (kind=kind_phys), pointer :: sfalb (:) => null()
727 
728  real (kind=kind_phys), pointer :: coszen(:) => null()
729  real (kind=kind_phys), pointer :: tsflw (:) => null()
730  real (kind=kind_phys), pointer :: semis (:) => null()
731 
732  ! Used only by grrad
733  real (kind=kind_phys), pointer :: coszdg(:) => null()
734 
735  ! Used only by gbphys
736  real (kind=kind_phys), pointer :: rqtk (:) => null()
737  real (kind=kind_phys), pointer :: hlwd (:,:,:) => null()
738  real (kind=kind_phys), pointer :: dtdtr(:,:) => null()
739 
740  real (kind=kind_phys), pointer :: swhc (:,:) => null()
741  real (kind=kind_phys), pointer :: hlwc (:,:) => null()
742 
743  real (kind=kind_phys), pointer :: hlwc_v(:,:) => null()
744  real (kind=kind_phys), pointer :: swhc_v(:,:) => null()
745 
746  contains
747  procedure :: setrad => rad_tend_set
748  procedure :: setphys => rad_phys_set
749  !procedure :: print => rad_tend_print
750  end type
751 
752 
753 
754 
755 
756 
757 !******************************************
758 ! Type dynamic parameters
759 !******************************************
761 
762  private
763 
764  real (kind=kind_phys), pointer :: xlon (:) => null()
766  real (kind=kind_phys), pointer :: xlat (:) => null()
768  real (kind=kind_phys), pointer :: sinlat(:) => null()
769  real (kind=kind_phys), pointer :: coslat(:) => null()
770  real (kind=kind_phys) :: solhr !! hour time after 00z at the t-step
771 
772  integer :: ix
773  integer :: im
774  integer :: kdt
775  logical :: lssav
776  logical :: lmfshal
777  logical :: lmfdeep2
778 
779  ! Radiation only
780  integer, pointer :: icsdsw(:) => null()
781  integer, pointer :: icsdlw(:) => null()
784 
785  integer :: jdate(8)
787  real (kind=kind_phys) :: solcon
788 
789  real (kind=kind_phys) :: dtlw
790  real (kind=kind_phys) :: dtsw
791  logical :: lsswr
792  logical :: lslwr
793  integer :: ipt
794  logical :: lprnt
795  real (kind=kind_phys) :: deltim
796  ! End Radiation only
797 
798  ! These might be able to be computed elsewhere
799  real (kind=kind_phys) :: slag
800  real (kind=kind_phys) :: sdec
801  real (kind=kind_phys) :: cdec
802 
803 
804  ! Physics only
805  integer :: lat
806  real (kind=kind_phys) :: dtp
807  real (kind=kind_phys) :: dtf
808  real (kind=kind_phys) :: clstp
809  integer :: nnp
810  integer, pointer :: nlons(:)
811  real (kind=kind_phys) :: fhour
812  ! End Physics only
813 
814  contains
815  procedure :: setrad => dyn_param_setrad
816  procedure :: setphys => dyn_param_setphys
817 
818  end type
819 
820 
821 
822 
823 
824 !******************************************
825 ! Type model parameters
826 !******************************************
827 
829 
830  private
831 
832  integer :: ntcw
834  integer :: ncld
835  integer :: ntoz
837  integer :: ntrac
838  integer :: levs
839  integer :: me
840  integer :: lsoil
841  integer :: ntiw
842  integer :: ntlnc
843  integer :: ntinc
844  integer :: lsm
845  integer :: nmtvr
846  integer :: nrcm
847  integer :: levozp
848  integer :: levh2o
849  integer :: lonr
850  integer :: latr
851  integer :: jcap
852  integer :: num_p3d
853  integer :: num_p2d
854  integer :: npdf3d
855  integer :: ncnvcld3d
856  integer :: pl_coeff
857  integer :: ncw(2)
858  integer :: idate(4)
859  integer :: idat(8)
861  integer :: h2o_coeff ! number coefficients in h2o stratosphere
862  integer :: lats_node_r
863  integer, pointer :: jindx1(:) => null() !
864  integer, pointer :: jindx2(:) => null() !
865  integer, pointer :: jindx1_h(:) => null() !
866  integer, pointer :: jindx2_h(:) => null() !
867 
868 
869  ! NEW in nems_slg_shoc branch
870  integer :: nctp
871  integer :: ntke
872  integer :: ntot3d
873  integer :: ntot2d
874  integer :: imfshalcnv
875  integer :: imfdeepcnv
876  integer :: isot
877  integer :: ivegsrc
878 
879  real (kind=kind_phys) :: crtrh(3)
880  real (kind=kind_phys) :: cdmbgwd(2)
881  real (kind=kind_phys) :: ccwf(2)
882  real (kind=kind_phys) :: dlqf(2)
883  real (kind=kind_phys) :: ctei_rm(2)
884  real (kind=kind_phys) :: cgwf(2)
885  real (kind=kind_phys) :: prslrd0
886  real (kind=kind_phys) :: ral_ts
887  real (kind=kind_phys), pointer :: ozplin(:,:,:,:) => null() !ozplin ozone input data
888  real (kind=kind_phys), pointer :: ddy(:) => null() !
889  real (kind=kind_phys), pointer :: h2oplin(:,:,:,:) => null() !h2oplin h2o stratosphere input data
890  real (kind=kind_phys), pointer :: ddy_h(:) => null()
891  real (kind=kind_phys), pointer :: h2o_lat(:) => null()
892  real (kind=kind_phys), pointer :: h2o_pres(:) => null()
893 
894  logical :: ras
895  logical :: pre_rad
896  logical :: ldiag3d
897  logical :: lgocart
898  logical :: lssav_cpl
899  logical :: flipv
900  logical :: old_monin
901  logical :: cnvgwd
902 
903  logical :: shal_cnv
904 ! logical :: imfshalcnv ! flag for new shallow conv scheme
905 
906 ! logical :: imfdeepcnv ! flag for new sas conv scheme
907  logical :: cal_pre
908  logical :: mom4ice
909  logical :: mstrat
910  logical :: trans_trac
911  integer :: nstf_name(5)
912  logical :: moist_adj
913  integer :: thermodyn_id
914  integer :: sfcpress_id
915  logical :: gen_coord_hybrid
916  integer :: levr
917  logical :: lsidea
918  logical :: pdfcld
919  logical :: shcnvcw
920  logical :: redrag
921  logical :: hybedmf
922  logical :: dspheat
923  logical :: h2o_phys ! flag for stratosphere h2o
924 
925  ! NEW
926  logical :: shoc_cld
927  logical :: cscnv
928  logical :: do_shoc
929  logical :: shocaftcnv
930 
931  contains
932 
933  procedure :: print => mdl_param_print
934 
935  end type
936 !******************************************
937 
938 
939 
940 
941 ! Module Subroutines and Type bound procedures
942 !******************************************
943  contains ! module
944 !******************************************
945 
946 
947 
948 
949 !******************************************
950 ! tbd_ddt methods
951 !******************************************
953 
954  subroutine tbd_set ( this, dpshc, o3out, lan, prdout, h2oplout, h2oplout_v, &
955  poz, rann, &
956  xkzm_m, xkzm_h, xkzm_s, psautco, prautco, evpco, wminco, &
957  acv, acvb, acvt, slc, smc, stc, &
958  upd_mf, dwn_mf, det_mf, phy_f3d, phy_f2d, tprcp, &
959  srflag, tref, z_c, c_0, c_d, w_0, w_d, fscav, fswtr, phy_fctd)
960 
961  class(tbd_ddt) :: this
962 
963 ! In
964  real (kind=kind_phys), target :: dpshc (:) ! maximum pressure depth for shallow convection
965  real (kind=kind_phys), target :: o3out(:,:,:)
966  integer, target :: lan
967  real (kind=kind_phys), target :: prdout(:,:,:) ! ozplout_v ozone forcing data
968  real (kind=kind_phys), target :: h2oplout(:,:,:)
969  real (kind=kind_phys), target :: h2oplout_v(:,:,:)
970  real (kind=kind_phys), target :: poz(:) ! pl_pres ozone forcing data level pressure (ln(Pa))
971  real (kind=kind_phys), target :: rann(:,:) ! random number array (0-1)
972 
973  real (kind=kind_phys) :: xkzm_m ! bkgd_vdif_m background vertical diffusion for momentum
974  real (kind=kind_phys) :: xkzm_h ! bkgd_vdif_h background vertical diffusion for heat q
975  real (kind=kind_phys) :: xkzm_s ! bkgd_vdif_s sigma threshold for background mom. diffusn
976  real (kind=kind_phys) :: psautco(2) ! auto conversion coeff from ice to snow
977  real (kind=kind_phys) :: prautco(2) ! auto conversion coeff from cloud to rain
978  real (kind=kind_phys) :: evpco ! coeff for evaporation of largescale rain
979  real (kind=kind_phys) :: wminco(2) ! water and ice minimum threshold for Zhao
980 
981 ! Moved to interface fields
982 ! real (kind=kind_phys), target :: sfcnirbmu(:) ! aoi_fld%nirbmui sfc nir beam sw upward flux (w/m2)
983 ! real (kind=kind_phys), target :: sfcnirdfu(:) ! aoi_fld%nirdfui sfc nir diff sw upward flux (w/m2)
984 ! real (kind=kind_phys), target :: sfcvisbmu(:) ! aoi_fld%visbmui sfc uv+vis beam sw upward flux (w/m2)
985 ! real (kind=kind_phys), target :: sfcvisdfu(:) ! aoi_fld%visdfui sfc uv+vis diff sw upward flux (w/m2)
986 
987 ! Moved to dyn_parm
988 ! real (kind=kind_phys) :: slag ! equation of time ( radian )
989 ! real (kind=kind_phys) :: sdec ! sin of the solar declination angle
990 ! real (kind=kind_phys) :: cdec ! cos of the solar declination angle
991 
992 ! In/Out
993  real (kind=kind_phys), target :: acv (:) ! array containing accumulated convective clouds
994  real (kind=kind_phys), target :: acvb(:) ! arrays used by cnvc90 bottom
995  real (kind=kind_phys), target :: acvt(:) ! arrays used by cnvc9 top
996  real (kind=kind_phys), target :: slc(:,:) ! liquid soil moisture
997  real (kind=kind_phys), target :: smc(:,:) ! total soil moisture
998  real (kind=kind_phys), target :: stc(:,:) ! soil temperature
999  real (kind=kind_phys), target :: upd_mf(:,:) ! convective updraft mass flux
1000  real (kind=kind_phys), target :: dwn_mf(:,:) ! convective downdraft mass flux
1001  real (kind=kind_phys), target :: det_mf(:,:) ! convective detrainment mass flux
1002  real (kind=kind_phys), target :: phy_f3d(:,:,:) ! 3d arrays saved for restart
1003  real (kind=kind_phys), target :: phy_f2d(:,:) ! phy_f2dv 2d arrays save for restart
1004  real (kind=kind_phys), target :: tprcp (:) ! sfc_fld%tprcp total precipitation
1005  real (kind=kind_phys), target :: srflag(:) ! sfc_fld%srflag snow/rain flag for precipitation
1006 
1007 ! NEW
1008  real (kind=kind_phys), target :: phy_fctd(:,:) ! For CS convection
1009 
1010 ! Out
1011  real (kind=kind_phys), target :: tref(:) ! nst_fld%Tref Reference Temperature
1012  real (kind=kind_phys), target :: z_c(:) ! nst_fld%z_c Sub layer cooling thickness
1013  real (kind=kind_phys), target :: c_0(:) ! nst_fld%c_0 coefficient1 to calculate d(Tz)/d(Ts)
1014  real (kind=kind_phys), target :: c_d(:) ! nst_fld%c_d coefficient2 to calculate d(Tz)/d(Ts)
1015  real (kind=kind_phys), target :: w_0(:) ! nst_fld%w_0 coefficient3 to calculate d(Tz)/d(Ts)
1016  real (kind=kind_phys), target :: w_d(:) ! nst_fld%w_d coefficient4 to calculate d(Tz)/d(Ts)
1017 
1018 ! Unknown
1019  real (kind=kind_phys), target :: fscav(:) ! tracer scavenging
1020  real (kind=kind_phys), target :: fswtr(:)
1021 
1022 
1023  this%dpshc => dpshc
1024  this%o3out => o3out
1025  this%lan => lan
1026  this%prdout => prdout
1027  this%h2oplout => h2oplout
1028  this%h2oplout_v => h2oplout_v
1029  this%poz => poz
1030  this%rann => rann
1031 
1032  this%xkzm_m = xkzm_m
1033  this%xkzm_h = xkzm_h
1034  this%xkzm_s = xkzm_s
1035  this%psautco = psautco
1036  this%prautco = prautco
1037  this%evpco = evpco
1038  this%wminco = wminco
1039 
1040  this%acv => acv
1041  this%acvb => acvb
1042  this%acvt => acvt
1043  this%slc => slc
1044  this%smc => smc
1045  this%stc => stc
1046  this%upd_mf => upd_mf
1047  this%dwn_mf => dwn_mf
1048  this%det_mf => det_mf
1049  this%phy_f3d => phy_f3d
1050  this%phy_f2d => phy_f2d
1051  this%tprcp => tprcp
1052  this%srflag => srflag
1053 
1054  this%tref => tref
1055  this%z_c => z_c
1056  this%c_0 => c_0
1057  this%c_d => c_d
1058  this%w_0 => w_0
1059  this%w_d => w_d
1060 
1061  this%fscav => fscav
1062  this%fswtr => fswtr
1063 
1064  this%phy_fctd => phy_fctd
1065  end subroutine
1067 
1068 
1069 
1070 
1072 !******************************************
1073 ! State field methods
1074 !******************************************
1075 
1076  subroutine state_fld_setrad_in (this, prsi, prsl, prslk, tgrs, qgrs_rad, tracer, vvl, ntl, uni_cld)
1077 
1078  implicit none
1079 
1080  class(state_fields_in) :: this
1081 
1082  real (kind=kind_phys), intent(in), target :: prsi (:,:)
1083  real (kind=kind_phys), target :: prsl (:,:)
1084  real (kind=kind_phys), target :: prslk (:,:)
1085  real (kind=kind_phys), target :: tgrs (:,:)
1086  real (kind=kind_phys), target :: qgrs_rad (:,:)
1087  real (kind=kind_phys), target :: tracer(:,:,:)
1088  real (kind=kind_phys), target :: vvl (:,:)
1089  integer :: ntl
1090  logical :: uni_cld
1091  call dbgprint("state_fld_setradin")
1092 
1093  select type (this)
1094  class is (state_fields_in)
1095  this%prsi => prsi
1096  this%prsl => prsl
1097  this%prslk => prslk
1098  this%tgrs => tgrs
1099  this%qgrs_rad => qgrs_rad
1100  this%tracer => tracer
1101  this%vvl => vvl
1102  this%ntl = ntl
1103  this%uni_cld = uni_cld
1104  end select
1105 
1106  end subroutine
1108 
1109 
1111  subroutine state_fld_setphys_in (this, prsi, prsl, prslk, tgrs, qgrs, vvl, &
1112  pgr, ugrs, vgrs, prsik, phii, phil, adjtrc)
1113 
1114  implicit none
1115 
1116  class(state_fields_in) :: this
1117 
1118  real (kind=kind_phys), target :: prsi (:,:)
1119  real (kind=kind_phys), target :: prsl (:,:)
1120  real (kind=kind_phys), target :: prslk (:,:)
1121  real (kind=kind_phys), target :: tgrs (:,:)
1122  real (kind=kind_phys), target :: qgrs (:,:,:)
1123  real (kind=kind_phys), target :: vvl (:,:)
1124 
1125  !! The following not in radiation
1126  real (kind=kind_phys), target :: pgr (:)
1127  real (kind=kind_phys), target :: ugrs (:,:)
1128  real (kind=kind_phys), target :: vgrs (:,:)
1129  real (kind=kind_phys), target :: prsik (:,:)
1130  real (kind=kind_phys), target :: phii (:,:)
1131  real (kind=kind_phys), target :: phil (:,:)
1132 
1133  real (kind=kind_phys), target :: adjtrc (:)
1134 
1135  call dbgprint("state_fld_setphys_in")
1136 
1137  select type (this)
1138  class is (state_fields_in)
1139 
1140  this%prsi => prsi
1141  this%prsl => prsl
1142  this%prslk => prslk
1143  this%tgrs => tgrs
1144  this%qgrs => qgrs
1145  this%vvl => vvl
1146 
1147  this%pgr => pgr
1148  this%ugrs => ugrs
1149  this%vgrs => vgrs
1150  this%prsik => prsik
1151  this%phii => phii
1152  this%phil => phil
1153 
1154  this%adjtrc => adjtrc
1155 
1156  ! class default
1157  ! print *, "class default"
1158  end select
1159 
1160  end subroutine
1162 
1163 
1165  subroutine state_fld_setphys_out (this, gt0, gq0, gu0, gv0)
1166 
1167  implicit none
1168 
1169  class(state_fields_out) :: this
1170 
1171  !! Outputs (only in physics)
1172  real (kind=kind_phys), target :: gt0 (:,:)
1173  real (kind=kind_phys), target :: gq0 (:,:,:)
1174  real (kind=kind_phys), target :: gu0 (:,:)
1175  real (kind=kind_phys), target :: gv0 (:,:)
1176 
1177  call dbgprint("state_fld_setphys_out")
1178 
1179  select type (this)
1180  class is (state_fields_out)
1181  this%gt0 => gt0
1182  this%gq0 => gq0
1183  this%gu0 => gu0
1184  this%gv0 => gv0
1185  end select
1186 
1187  end subroutine
1189 
1190 
1192  subroutine state_fld_out_print (this)
1193 
1194  implicit none
1195 
1196  class(state_fields_out) :: this
1197 
1198 
1199  print *, "STATE FIELDS OUT"
1200  print *, "----- ------ ---"
1201  print *, this%gt0
1202  print *, this%gq0
1203  print *, this%gu0
1204  print *, this%gv0
1205 
1206  end subroutine
1208 
1210  subroutine state_fld_in_print (this)
1211 
1212  implicit none
1213 
1214  class(state_fields_in) :: this
1215 
1216  print *, "stub : state_fields_in print"
1217 
1218  end subroutine
1220 
1222 
1223 !******************************************
1224 ! Surface properties methods
1225 !******************************************
1226  subroutine sfc_prop_setrad (this, slmsk, tsfc, snowd, sncovr, snoalb, &
1227  zorl, hprim, fice, tisfc, &
1228  alvsf, alnsf, alvwf, alnwf, facsf, facwf )
1229 
1230 
1231  implicit none
1232 
1233  class(sfc_properties) :: this
1234 
1235  real (kind=kind_phys), target :: slmsk (:)
1236  real (kind=kind_phys), target :: tsfc (:)
1237  real (kind=kind_phys), target :: snowd (:)
1238  real (kind=kind_phys), target :: sncovr(:)
1239  real (kind=kind_phys), target :: snoalb(:)
1240  real (kind=kind_phys), target :: zorl (:)
1241  real (kind=kind_phys), target :: hprim (:)
1242  real (kind=kind_phys), target :: fice (:)
1243  real (kind=kind_phys), target :: tisfc (:)
1244 
1245  !!! GSM grrad.f ONLY
1246  real (kind=kind_phys), optional, target :: alvsf (:)
1247  real (kind=kind_phys), optional, target :: alnsf (:)
1248  real (kind=kind_phys), optional, target :: alvwf (:)
1249  real (kind=kind_phys), optional, target :: alnwf (:)
1250  real (kind=kind_phys), optional, target :: facsf (:)
1251  real (kind=kind_phys), optional, target :: facwf (:)
1252  !!! END
1253 
1254  call dbgprint("sfc_prop_set")
1255 
1256  select type (this)
1257  class is (sfc_properties)
1258  this%slmsk => slmsk
1259  this%tsfc => tsfc
1260  this%snowd => snowd
1261  this%sncovr => sncovr
1262  this%snoalb => snoalb
1263  this%zorl => zorl
1264  this%hprim => hprim
1265  this%fice => fice
1266  this%tisfc => tisfc
1267 
1268  !!! GSM
1269  if (present(alvsf)) this%alvsf => alvsf
1270  if (present(alnsf)) this%alnsf => alnsf
1271  if (present(alvwf)) this%alvwf => alvwf
1272  if (present(alnwf)) this%alnwf => alnwf
1273  if (present(facsf)) this%facsf => facsf
1274  if (present(facwf)) this%facwf => facwf
1275 
1276  end select
1277 
1278  end subroutine
1280 
1282 
1283  subroutine sfc_prop_setphys ( this, &
1284  hprime2, slope, shdmin, shdmax, snoalb, tg3, slmsk, vfrac, &
1285  vtype, stype, uustar, oro, oro_uf, hice, fice, tisfc, &
1286  tsea, snwdph, weasd, sncovr, zorl, canopy, ffmm, ffhh, &
1287  f10m, t2m, q2m &
1288  )
1289  implicit none
1290 
1291  class(sfc_properties) :: this
1292 
1293  ! In
1294  real (kind=kind_phys), target :: hprime2(:,:)
1295  real (kind=kind_phys), target :: slope(:)
1296  real (kind=kind_phys), target :: shdmin(:)
1297  real (kind=kind_phys), target :: shdmax(:)
1298  real (kind=kind_phys), target :: snoalb(:)
1299  real (kind=kind_phys), target :: tg3(:)
1300  real (kind=kind_phys), target :: slmsk(:)
1301  real (kind=kind_phys), target :: vfrac(:)
1302  real (kind=kind_phys), target :: vtype(:)
1303  real (kind=kind_phys), target :: stype(:)
1304  real (kind=kind_phys), target :: uustar(:)
1305  real (kind=kind_phys), target :: oro(:)
1306  real (kind=kind_phys), target :: oro_uf(:)
1307 
1308  ! In/Out
1309  real (kind=kind_phys), target :: hice(:)
1310  real (kind=kind_phys), target :: fice(:)
1311  real (kind=kind_phys), target :: tisfc(:)
1312  real (kind=kind_phys), target :: tsea(:)
1313  real (kind=kind_phys), target :: snwdph(:)
1314  real (kind=kind_phys), target :: weasd(:)
1315  real (kind=kind_phys), target :: sncovr(:)
1316  real (kind=kind_phys), target :: zorl(:)
1317  real (kind=kind_phys), target :: canopy(:)
1318  real (kind=kind_phys), target :: ffmm(:)
1319  real (kind=kind_phys), target :: ffhh(:)
1320  real (kind=kind_phys), target :: f10m(:)
1321 
1322  ! Outputs
1323  real (kind=kind_phys), target :: t2m(:)
1324  real (kind=kind_phys), target :: q2m(:)
1325 
1326  this%hprime2 => hprime2
1327  this%slope => slope
1328  this%shdmin => shdmin
1329  this%shdmax => shdmax
1330  this%snoalb => snoalb
1331  this%tg3 => tg3
1332  this%slmsk => slmsk
1333  this%vfrac => vfrac
1334  this%vtype => vtype
1335  this%stype => stype
1336  this%uustar => uustar
1337  this%oro => oro
1338  this%oro_uf => oro_uf
1339  this%hice => hice
1340  this%fice => fice
1341  this%tisfc => tisfc
1342  this%tsfc => tsea
1343  this%snowd => snwdph ! snowd
1344  this%weasd => weasd
1345  this%sncovr => sncovr
1346  this%zorl => zorl
1347  this%canopy => canopy
1348  this%ffmm => ffmm
1349  this%ffhh => ffhh
1350  this%f10m => f10m
1351  this%t2m => t2m
1352  this%q2m => q2m
1353 
1354 
1355  end subroutine
1358 !******************************************
1359 ! Diagnostics methods
1360 !******************************************
1361  subroutine diagnostics_setrad (this, NFXR, fluxr, topfsw, topflw, dswcmp, uswcmp)
1362 
1363  implicit none
1364 
1365  class(diagnostics) :: this
1366 
1367  integer :: NFXR
1368 
1369  real (kind=kind_phys), target :: fluxr (:,:)
1370  type(topfsw_type), target :: topfsw(:)
1371  type(topflw_type), target :: topflw(:)
1372 
1373  real (kind=kind_phys), target :: dswcmp(:,:)
1374  real (kind=kind_phys), target :: uswcmp(:,:)
1375 
1376  call dbgprint("diagnostics_setrad")
1377 
1378  select type (this)
1379  class is (diagnostics)
1380 
1381  this%NFXR = nfxr
1382  this%fluxr => fluxr
1383  this%topfsw => topfsw
1384  this%topflw => topflw
1385  this%dswcmp => dswcmp
1386  this%uswcmp => uswcmp
1387 
1388  end select
1389 
1390  end subroutine
1393  subroutine diagnostics_setphys ( this, srunoff, evbsa, evcwa, &
1394  snohfa, transa, sbsnoa, snowca, soilm, &
1395  tmpmin, tmpmax, dusfc, dvsfc, dtsfc, dqsfc, totprcp, gflux, &
1396  dlwsfc, ulwsfc, suntim, runoff, ep, cldwrk, dugwd, dvgwd, &
1397  psmean, cnvprcp, spfhmin, spfhmax, rain, rainc, &
1398  dt3dt, dq3dt, du3dt, dv3dt, dqdt_v, &
1399  u10m, v10m, zlvl, psurf, hpbl, pwat, t1, q1, &
1400  u1, v1, chh, cmm, dlwsfci, ulwsfci, dswsfci, uswsfci, &
1401  dusfci, dvsfci, dtsfci, dqsfci, gfluxi, epi, smcwlt2, smcref2, &
1402  wet1, sr )
1403 
1404  implicit none
1405 
1406  class(diagnostics) :: this
1407 
1408 
1409  ! Inputs
1410 
1411  ! Moved to interface fields ddt
1412  ! real (kind=kind_phys), target :: sfcnirbmd(:)
1413  ! real (kind=kind_phys), target :: sfcnirdfd(:)
1414  ! real (kind=kind_phys), target :: sfcvisbmd(:)
1415  ! real (kind=kind_phys), target :: sfcvisdfd(:)
1416 
1417  ! In/Out
1418  real (kind=kind_phys), target :: srunoff (:)
1419  real (kind=kind_phys), target :: evbsa (:)
1420  real (kind=kind_phys), target :: evcwa (:)
1421  real (kind=kind_phys), target :: snohfa (:)
1422  real (kind=kind_phys), target :: transa (:)
1423  real (kind=kind_phys), target :: sbsnoa (:)
1424  real (kind=kind_phys), target :: snowca (:)
1425  real (kind=kind_phys), target :: soilm (:)
1426  real (kind=kind_phys), target :: tmpmin (:)
1427  real (kind=kind_phys), target :: tmpmax (:)
1428  real (kind=kind_phys), target :: dusfc (:)
1429  real (kind=kind_phys), target :: dvsfc (:)
1430  real (kind=kind_phys), target :: dtsfc (:)
1431  real (kind=kind_phys), target :: dqsfc (:)
1432  real (kind=kind_phys), target :: totprcp (:)
1433  real (kind=kind_phys), target :: gflux (:)
1434  real (kind=kind_phys), target :: dlwsfc (:)
1435  real (kind=kind_phys), target :: ulwsfc (:)
1436  real (kind=kind_phys), target :: suntim (:)
1437  real (kind=kind_phys), target :: runoff (:)
1438  real (kind=kind_phys), target :: ep (:)
1439  real (kind=kind_phys), target :: cldwrk (:)
1440  real (kind=kind_phys), target :: dugwd (:)
1441  real (kind=kind_phys), target :: dvgwd (:)
1442  real (kind=kind_phys), target :: psmean (:)
1443  real (kind=kind_phys), target :: cnvprcp (:)
1444  real (kind=kind_phys), target :: spfhmin (:)
1445  real (kind=kind_phys), target :: spfhmax (:)
1446  real (kind=kind_phys), target :: rain (:)
1447  real (kind=kind_phys), target :: rainc (:)
1448 ! real (kind=kind_phys), target :: snow (:)
1449  real (kind=kind_phys), target :: dt3dt (:,:,:)
1450  real (kind=kind_phys), target :: dq3dt (:,:,:)
1451  real (kind=kind_phys), target :: du3dt (:,:,:)
1452  real (kind=kind_phys), target :: dv3dt (:,:,:)
1453  real (kind=kind_phys), target :: dqdt_v(:,:)
1454 
1455  ! Outputs
1456  real (kind=kind_phys), target :: u10m(:)
1457  real (kind=kind_phys), target :: v10m(:)
1458  real (kind=kind_phys), target :: zlvl(:)
1459  real (kind=kind_phys), target :: psurf(:)
1460  real (kind=kind_phys), target :: hpbl(:)
1461  real (kind=kind_phys), target :: pwat(:)
1462  real (kind=kind_phys), target :: t1(:)
1463  real (kind=kind_phys), target :: q1(:)
1464  real (kind=kind_phys), target :: u1(:)
1465  real (kind=kind_phys), target :: v1(:)
1466  real (kind=kind_phys), target :: chh(:)
1467  real (kind=kind_phys), target :: cmm(:)
1468  real (kind=kind_phys), target :: dlwsfci(:)
1469  real (kind=kind_phys), target :: ulwsfci(:)
1470  real (kind=kind_phys), target :: dswsfci(:)
1471  real (kind=kind_phys), target :: uswsfci(:)
1472  real (kind=kind_phys), target :: dusfci(:)
1473  real (kind=kind_phys), target :: dvsfci(:)
1474  real (kind=kind_phys), target :: dtsfci(:)
1475  real (kind=kind_phys), target :: dqsfci(:)
1476  real (kind=kind_phys), target :: gfluxi(:)
1477  real (kind=kind_phys), target :: epi(:)
1478  real (kind=kind_phys), target :: smcwlt2(:)
1479  real (kind=kind_phys), target :: smcref2(:)
1480  real (kind=kind_phys), target :: wet1(:)
1481  real (kind=kind_phys), target :: sr(:)
1482 
1483 
1484  call dbgprint("diagnostics_setphys")
1485 
1486  ! In/Out
1487  this%srunoff => srunoff
1488  this%evbsa => evbsa
1489  this%evcwa => evcwa
1490  this%snohfa => snohfa
1491  this%transa => transa
1492  this%sbsnoa => sbsnoa
1493  this%snowca => snowca
1494  this%soilm => soilm
1495  this%tmpmin => tmpmin
1496  this%tmpmax => tmpmax
1497  this%dusfc => dusfc
1498  this%dvsfc => dvsfc
1499  this%dtsfc => dtsfc
1500  this%dqsfc => dqsfc
1501  this%totprcp => totprcp
1502  this%gflux => gflux
1503  this%dlwsfc => dlwsfc
1504  this%ulwsfc => ulwsfc
1505  this%suntim => suntim
1506  this%runoff => runoff
1507  this%ep => ep
1508  this%cldwrk => cldwrk
1509  this%dugwd => dugwd
1510  this%dvgwd => dvgwd
1511  this%psmean => psmean
1512  this%cnvprcp => cnvprcp
1513  this%spfhmin => spfhmin
1514  this%spfhmax => spfhmax
1515  this%rain => rain
1516  this%rainc => rainc
1517 ! this%snow => snow
1518  this%dt3dt => dt3dt
1519  this%dq3dt => dq3dt
1520  this%du3dt => du3dt
1521  this%dv3dt => dv3dt
1522  this%dqdt_v => dqdt_v
1523 
1524  ! Output
1525  this%u10m => u10m
1526  this%v10m => v10m
1527  this%zlvl => zlvl
1528  this%psurf => psurf
1529  this%hpbl => hpbl
1530  this%pwat => pwat
1531  this%t1 => t1
1532  this%q1 => q1
1533  this%u1 => u1
1534  this%v1 => v1
1535  this%chh => chh
1536  this%cmm => cmm
1537  this%dlwsfci => dlwsfci
1538  this%ulwsfci => ulwsfci
1539  this%dswsfci => dswsfci
1540  this%uswsfci => uswsfci
1541  this%dusfci => dusfci
1542  this%dvsfci => dvsfci
1543  this%dtsfci => dtsfci
1544  this%dqsfci => dqsfci
1545  this%gfluxi => gfluxi
1546  this%epi => epi
1547  this%smcwlt2 => smcwlt2
1548  this%smcref2 => smcref2
1549  this%wet1 => wet1
1550  this%sr => sr
1551 
1552  end subroutine
1554 
1556 !******************************************
1557 ! Interface Fields methods
1558 !******************************************
1559  subroutine interface_fld_setrad (this, sfcfsw, sfcflw, htrlw0, htrsw0, htrswb, htrlwb)
1560 
1561  implicit none
1562 
1563  class(interface_fields) :: this
1564 
1565  type(sfcfsw_type), target :: sfcfsw(:)
1566  type(sfcflw_type), target :: sfcflw(:)
1567 
1568  !! Optional output variables:
1569  real (kind=kind_phys), target, optional :: htrlw0(:,:)
1570  real (kind=kind_phys), target, optional :: htrsw0(:,:)
1571 
1572  real (kind=kind_phys), target, optional :: htrswb(:,:,:)
1573  real (kind=kind_phys), target, optional :: htrlwb(:,:,:)
1574 
1575  call dbgprint("interface_fld_setrad")
1576 
1577  select type (this)
1578  class is (interface_fields)
1579 
1580  this%sfcfsw => sfcfsw
1581  this%sfcflw => sfcflw
1582 
1583  if (present(htrswb)) this%htrswb => htrswb
1584  if (present(htrlwb)) this%htrlwb => htrlwb
1585 
1586  if (present(htrlw0)) this%htrlw0 => htrlw0
1587  if (present(htrsw0)) this%htrsw0 => htrsw0
1588 
1589  end select
1590 
1591  end subroutine
1593 
1594 
1595 
1597  subroutine interface_fld_setphys(this, sfcdsw, sfcnsw, sfcdlw, sfcnirbmu, sfcnirdfu, sfcvisbmu, &
1598  sfcvisdfu, sfcnirbmd, sfcnirdfd, sfcvisbmd, sfcvisdfd, &
1599  dusfc_cpl, dvsfc_cpl, dtsfc_cpl, dqsfc_cpl, dlwsfc_cpl, dswsfc_cpl, dnirbm_cpl, &
1600  dnirdf_cpl, dvisbm_cpl, dvisdf_cpl, rain_cpl, nlwsfc_cpl, nswsfc_cpl, nnirbm_cpl, nnirdf_cpl, &
1601  nvisbm_cpl, nvisdf_cpl, &
1602  slimskin_cpl, ulwsfcin_cpl, dusfcin_cpl, dvsfcin_cpl, dtsfcin_cpl, dqsfcin_cpl, &
1603  snow_cpl, xt, xs, xu, xv, xz, zm, xtts, xzts, d_conv, ifd, dt_cool, qrain, &
1604  dusfci_cpl, dvsfci_cpl, dtsfci_cpl, dqsfci_cpl, &
1605  dlwsfci_cpl, dswsfci_cpl, dnirbmi_cpl, dnirdfi_cpl, &
1606  dvisbmi_cpl, dvisdfi_cpl, nlwsfci_cpl, nswsfci_cpl, &
1607  nnirbmi_cpl, nnirdfi_cpl, nvisbmi_cpl, nvisdfi_cpl, &
1608  t2mi_cpl, q2mi_cpl, u10mi_cpl, v10mi_cpl, tseai_cpl, psurfi_cpl, & !oro_cpl, slmsk_cpl, &
1609 ! s_shum_wts, &
1610  s_sppt_wts, &
1611 ! s_skebu_wts,s_skebv_wts,s_vcu_wts,s_vcv_wts,s_uphys,s_vphys,s_tphys, &
1612  s_qphys, &
1613 ! s_tpphys,s_cpphys, &
1614  s_cplrain0,s_cplsnow0, &
1615 ! s_raincpl,s_snowcpl, &
1616  s_totprcp0,s_cnvprcp0, &
1617  s_gu0,s_gv0,s_gt0,s_gr0,s_do_sppt,s_do_shum,s_do_skeb,s_do_vc)
1618 
1619  implicit none
1620 
1621  class(interface_fields) :: this
1622 
1623  ! Inputs
1624  real (kind=kind_phys), target :: sfcdsw(:)
1625  real (kind=kind_phys), target :: sfcnsw(:)
1626  real (kind=kind_phys), target :: sfcdlw(:)
1627 
1628  ! Inputs moved from TBD physics only
1629  real (kind=kind_phys), target :: sfcnirbmu(:) ! aoi_fld%nirbmui sfc nir beam sw upward flux (w/m2)
1630  real (kind=kind_phys), target :: sfcnirdfu(:) ! aoi_fld%nirdfui sfc nir diff sw upward flux (w/m2)
1631  real (kind=kind_phys), target :: sfcvisbmu(:) ! aoi_fld%visbmui sfc uv+vis beam sw upward flux (w/m2)
1632  real (kind=kind_phys), target :: sfcvisdfu(:) ! aoi_fld%visdfui sfc uv+vis diff sw upward flux (w/m2)
1633 
1634  ! Inputs moved from diagnostics - physics only
1635  real (kind=kind_phys), target :: sfcnirbmd(:) ! aoi_fld%nirbmdi sfc nir beam sw downward flux (w/m2)
1636  real (kind=kind_phys), target :: sfcnirdfd(:) ! aoi_fld%nirdfdi sfc nir diff sw downward flux (w/m2)
1637  real (kind=kind_phys), target :: sfcvisbmd(:) ! aoi_fld%visbmdi sfc uv+vis beam sw downward flux (w/m2)
1638  real (kind=kind_phys), target :: sfcvisdfd(:) ! aoi_fld%visdfdi sfc uv+vis diff sw downward flux (w/m2)
1639 
1640  ! In/out
1641  real (kind=kind_phys), target :: dusfc_cpl(:)
1642  real (kind=kind_phys), target :: dvsfc_cpl(:)
1643  real (kind=kind_phys), target :: dtsfc_cpl(:)
1644  real (kind=kind_phys), target :: dqsfc_cpl(:)
1645  real (kind=kind_phys), target :: dlwsfc_cpl(:)
1646  real (kind=kind_phys), target :: dswsfc_cpl(:)
1647  real (kind=kind_phys), target :: dnirbm_cpl(:)
1648  real (kind=kind_phys), target :: dnirdf_cpl(:)
1649  real (kind=kind_phys), target :: dvisbm_cpl(:)
1650  real (kind=kind_phys), target :: dvisdf_cpl(:)
1651  real (kind=kind_phys), target :: rain_cpl(:)
1652  real (kind=kind_phys), target :: snow_cpl(:)
1653  real (kind=kind_phys), target :: nlwsfc_cpl(:)
1654  real (kind=kind_phys), target :: nswsfc_cpl(:)
1655  real (kind=kind_phys), target :: nnirbm_cpl(:)
1656  real (kind=kind_phys), target :: nnirdf_cpl(:)
1657  real (kind=kind_phys), target :: nvisbm_cpl(:)
1658  real (kind=kind_phys), target :: nvisdf_cpl(:)
1659  real (kind=kind_phys), target :: slimskin_cpl(:)
1660  real (kind=kind_phys), target :: dusfcin_cpl(:)
1661  real (kind=kind_phys), target :: dvsfcin_cpl(:)
1662  real (kind=kind_phys), target :: dtsfcin_cpl(:)
1663  real (kind=kind_phys), target :: dqsfcin_cpl(:)
1664  real (kind=kind_phys), target :: ulwsfcin_cpl(:)
1665  real (kind=kind_phys), target :: xt(:)
1666  real (kind=kind_phys), target :: xs(:)
1667  real (kind=kind_phys), target :: xu(:)
1668  real (kind=kind_phys), target :: xv(:)
1669  real (kind=kind_phys), target :: xz(:)
1670  real (kind=kind_phys), target :: zm(:)
1671  real (kind=kind_phys), target :: xtts(:)
1672  real (kind=kind_phys), target :: xzts(:)
1673  real (kind=kind_phys), target :: d_conv(:)
1674  real (kind=kind_phys), target :: ifd(:)
1675  real (kind=kind_phys), target :: dt_cool(:)
1676  real (kind=kind_phys), target :: Qrain(:)
1677 
1678  ! Outputs
1679  real (kind=kind_phys), optional, target :: dusfci_cpl(:)
1680  real (kind=kind_phys), optional, target :: dvsfci_cpl(:)
1681  real (kind=kind_phys), optional, target :: dtsfci_cpl(:)
1682  real (kind=kind_phys), optional, target :: dqsfci_cpl(:)
1683  real (kind=kind_phys), optional, target :: dlwsfci_cpl(:)
1684  real (kind=kind_phys), optional, target :: dswsfci_cpl(:)
1685  real (kind=kind_phys), optional, target :: dnirbmi_cpl(:)
1686  real (kind=kind_phys), optional, target :: dnirdfi_cpl(:)
1687  real (kind=kind_phys), optional, target :: dvisbmi_cpl(:)
1688  real (kind=kind_phys), optional, target :: dvisdfi_cpl(:)
1689  real (kind=kind_phys), optional, target :: nlwsfci_cpl(:)
1690  real (kind=kind_phys), optional, target :: nswsfci_cpl(:)
1691  real (kind=kind_phys), optional, target :: nnirbmi_cpl(:)
1692  real (kind=kind_phys), optional, target :: nnirdfi_cpl(:)
1693  real (kind=kind_phys), optional, target :: nvisbmi_cpl(:)
1694  real (kind=kind_phys), optional, target :: nvisdfi_cpl(:)
1695  real (kind=kind_phys), optional, target :: t2mi_cpl(:)
1696  real (kind=kind_phys), optional, target :: q2mi_cpl(:)
1697  real (kind=kind_phys), optional, target :: u10mi_cpl(:)
1698  real (kind=kind_phys), optional, target :: v10mi_cpl(:)
1699  real (kind=kind_phys), optional, target :: tseai_cpl(:)
1700  real (kind=kind_phys), optional, target :: psurfi_cpl(:)
1701 ! real (kind=kind_phys), optional, target :: oro_cpl(:)
1702 ! real (kind=kind_phys), optional, target :: slmsk_cpl(:)
1703 
1704  !for stochastic physics
1705 ! real (kind=kind_phys), target :: s_shum_wts(:,:)
1706  real (kind=kind_phys), target :: s_sppt_wts(:,:)
1707 ! real (kind=kind_phys), target :: s_skebu_wts(:,:)
1708 ! real (kind=kind_phys), target :: s_skebv_wts(:,:)
1709 ! real (kind=kind_phys), target :: s_vcu_wts(:,:)
1710 ! real (kind=kind_phys), target :: s_vcv_wts(:,:)
1711 ! real (kind=kind_phys), target :: s_uphys(:,:)
1712 ! real (kind=kind_phys), target :: s_vphys(:,:)
1713 ! real (kind=kind_phys), target :: s_tphys(:,:)
1714  real (kind=kind_phys), target :: s_qphys(:,:)
1715 ! real (kind=kind_phys), target :: s_tpphys(:)
1716 ! real (kind=kind_phys), target :: s_cpphys(:)
1717  real (kind=kind_phys), target :: s_cplrain0(:)
1718  real (kind=kind_phys), target :: s_cplsnow0(:)
1719 ! real (kind=kind_phys), target :: s_raincpl(:)
1720 ! real (kind=kind_phys), target :: s_snowcpl(:)
1721  real (kind=kind_phys), target :: s_totprcp0(:)
1722  real (kind=kind_phys), target :: s_cnvprcp0(:)
1723  real (kind=kind_phys), target :: s_gu0(:,:)
1724  real (kind=kind_phys), target :: s_gv0(:,:)
1725  real (kind=kind_phys), target :: s_gt0(:,:)
1726  real (kind=kind_phys), target :: s_gr0(:,:,:)
1727  logical :: s_do_sppt
1728  logical :: s_do_shum
1729  logical :: s_do_skeb
1730  logical :: s_do_vc
1731 
1732  call dbgprint("interface_fld_setphys")
1733 
1734  ! Input
1735  this%sfcdsw => sfcdsw
1736  this%sfcnsw => sfcnsw
1737  this%sfcdlw => sfcdlw
1738 
1739  this%sfcnirbmu => sfcnirbmu
1740  this%sfcnirdfu => sfcnirdfu
1741  this%sfcvisbmu => sfcvisbmu
1742  this%sfcvisdfu => sfcvisdfu
1743 
1744  this%sfcnirbmd => sfcnirbmd
1745  this%sfcnirdfd => sfcnirdfd
1746  this%sfcvisbmd => sfcvisbmd
1747  this%sfcvisdfd => sfcvisdfd
1748 
1749  ! In/Out
1750  this%dusfc_cpl => dusfc_cpl
1751  this%dvsfc_cpl => dvsfc_cpl
1752  this%dtsfc_cpl => dtsfc_cpl
1753  this%dqsfc_cpl => dqsfc_cpl
1754  this%dlwsfc_cpl => dlwsfc_cpl
1755  this%dswsfc_cpl => dswsfc_cpl
1756  this%dnirbm_cpl => dnirbm_cpl
1757  this%dnirdf_cpl => dnirdf_cpl
1758  this%dvisbm_cpl => dvisbm_cpl
1759  this%dvisdf_cpl => dvisdf_cpl
1760  this%rain_cpl => rain_cpl
1761  this%nlwsfc_cpl => nlwsfc_cpl
1762  this%nswsfc_cpl => nswsfc_cpl
1763  this%nnirbm_cpl => nnirbm_cpl
1764  this%nnirdf_cpl => nnirdf_cpl
1765  this%nvisbm_cpl => nvisbm_cpl
1766  this%nvisdf_cpl => nvisdf_cpl
1767  this%slimskin_cpl => slimskin_cpl
1768  this%dusfcin_cpl => dusfcin_cpl
1769  this%dvsfcin_cpl => dvsfcin_cpl
1770  this%dtsfcin_cpl => dtsfcin_cpl
1771  this%dqsfcin_cpl => dqsfcin_cpl
1772  this%ulwsfcin_cpl => ulwsfcin_cpl
1773  this%snow_cpl => snow_cpl
1774 
1775  this%xt => xt
1776  this%xs => xs
1777  this%xu => xu
1778  this%xv => xv
1779  this%xz => xz
1780  this%zm => zm
1781  this%xtts => xtts
1782  this%xzts => xzts
1783  this%d_conv => d_conv
1784  this%ifd => ifd
1785  this%dt_cool => dt_cool
1786  this%Qrain => qrain
1787 
1788  ! Output
1789  if (present(dusfci_cpl)) this%dusfci_cpl => dusfci_cpl
1790  if (present(dvsfci_cpl)) this%dvsfci_cpl => dvsfci_cpl
1791  if (present(dtsfci_cpl)) this%dtsfci_cpl => dtsfci_cpl
1792  if (present(dqsfci_cpl)) this%dqsfci_cpl => dqsfci_cpl
1793  if (present(dlwsfci_cpl)) this%dlwsfci_cpl => dlwsfci_cpl
1794  if (present(dswsfci_cpl)) this%dswsfci_cpl => dswsfci_cpl
1795  if (present(dnirbmi_cpl)) this%dnirbmi_cpl => dnirbmi_cpl
1796  if (present(dnirdfi_cpl)) this%dnirdfi_cpl => dnirdfi_cpl
1797  if (present(dvisbmi_cpl)) this%dvisbmi_cpl => dvisbmi_cpl
1798  if (present(dvisdfi_cpl)) this%dvisdfi_cpl => dvisdfi_cpl
1799  if (present(nlwsfci_cpl)) this%nlwsfci_cpl => nlwsfci_cpl
1800  if (present(nswsfci_cpl)) this%nswsfci_cpl => nswsfci_cpl
1801  if (present(nnirbmi_cpl)) this%nnirbmi_cpl => nnirbmi_cpl
1802  if (present(nnirdfi_cpl)) this%nnirdfi_cpl => nnirdfi_cpl
1803  if (present(nvisbmi_cpl)) this%nvisbmi_cpl => nvisbmi_cpl
1804  if (present(nvisdfi_cpl)) this%nvisdfi_cpl => nvisdfi_cpl
1805  if (present(t2mi_cpl)) this%t2mi_cpl => t2mi_cpl
1806  if (present(q2mi_cpl)) this%q2mi_cpl => q2mi_cpl
1807  if (present(u10mi_cpl)) this%u10mi_cpl => u10mi_cpl
1808  if (present(v10mi_cpl)) this%v10mi_cpl => v10mi_cpl
1809  if (present(tseai_cpl)) this%tseai_cpl => tseai_cpl
1810  if (present(psurfi_cpl)) this%psurfi_cpl => psurfi_cpl
1811  ! call dbgprint('setting oro_cpl')
1812 ! if (present(oro_cpl)) this%oro_cpl => oro_cpl
1813  ! call dbgprint('setting slmsk_cpl')
1814 ! if (present(slmsk_cpl)) this%slmsk_cpl => slmsk_cpl
1815 
1816  !for stochastic physics
1817 ! this%s_shum_wts => s_shum_wts
1818  this%s_sppt_wts => s_sppt_wts
1819 ! this%s_skebu_wts => s_skebu_wts
1820 ! this%s_skebv_wts => s_skebv_wts
1821 ! this%s_vcu_wts => s_vcu_wts
1822 ! this%s_vcv_wts => s_vcv_wts
1823 ! this%s_uphys => s_uphys
1824 ! this%s_vphys => s_vphys
1825 ! this%s_tphys => s_tphys
1826  this%s_qphys => s_qphys
1827 ! this%s_tpphys => s_tpphys
1828 ! this%s_cpphys => s_cpphys
1829  this%s_cplrain0 => s_cplrain0
1830  this%s_cplsnow0 =>s_cplsnow0
1831 ! this%s_raincpl => s_raincpl
1832 ! this%s_snowcpl => s_snowcpl
1833  this%s_totprcp0 => s_totprcp0
1834  this%s_cnvprcp0 => s_cnvprcp0
1835  this%s_gu0 => s_gu0
1836  this%s_gv0 => s_gv0
1837  this%s_gt0 => s_gt0
1838  this%s_gr0 => s_gr0
1839  this%s_do_sppt = s_do_sppt
1840  this%s_do_shum = s_do_shum
1841  this%s_do_skeb = s_do_skeb
1842  this%s_do_vc = s_do_vc
1843 
1844 
1845  end subroutine
1847 
1848 
1850 !******************************************
1851 ! Cloud properties methods
1852 !******************************************
1853  subroutine cld_prop_setrad (this, cv, cvt, cvb, fcice, frain, rrime, flgmin, &
1854  cldcov, deltaq, sup, cnvw, cnvc)
1855 
1856  implicit none
1857 
1858  class(cloud_properties) :: this
1859 
1860  ! PT intent ?
1861  real (kind=kind_phys), target :: cv (:)
1862  real (kind=kind_phys), target :: cvt (:)
1863  real (kind=kind_phys), target :: cvb (:)
1864  real (kind=kind_phys), target :: fcice (:,:)
1865  real (kind=kind_phys), target :: frain (:,:)
1866  real (kind=kind_phys), target :: rrime (:,:)
1867  real (kind=kind_phys), target :: flgmin (:)
1868 
1869  real (kind=kind_phys), target :: deltaq(:,:)
1870  real (kind=kind_phys), target :: sup
1871  real (kind=kind_phys), target :: cnvw(:,:)
1872  real (kind=kind_phys), target :: cnvc(:,:)
1873 
1874  !! Outputs from radiation
1875  real (kind=kind_phys), target :: cldcov(:,:)
1876 
1877  call dbgprint("cld_prop_setrad")
1878 
1879  select type (this)
1880  class is (cloud_properties)
1881  this%cv => cv
1882  this%cvt => cvt
1883  this%cvb => cvb
1884  this%fcice => fcice
1885  this%frain => frain
1886  this%rrime => rrime
1887  this%flgmin => flgmin
1888  this%cldcov => cldcov
1889  this%deltaq => deltaq
1890  this%sup => sup
1891  this%cnvw => cnvw
1892  this%cnvc => cnvc
1893  end select
1894 
1895  end subroutine
1897 
1898 
1900  subroutine cld_prop_setphys (this, flgmin, cv, cvt, cvb, cnvqc_v, sup )
1901 
1902  implicit none
1903 
1904  class(cloud_properties) :: this
1905 
1906  ! Input
1907  real (kind=kind_phys), target :: flgmin (:)
1908 
1909  ! Input/output
1910  real (kind=kind_phys), target :: cv (:)
1911  real (kind=kind_phys), target :: cvt (:)
1912  real (kind=kind_phys), target :: cvb (:)
1913  real (kind=kind_phys), target :: cnvqc_v(:,:)
1914  real (kind=kind_phys), target :: sup
1915 
1916  call dbgprint("cld_prop_setphys")
1917 
1918  this%cv => cv
1919  this%cvt => cvt
1920  this%cvb => cvb
1921  this%flgmin => flgmin
1922  this%cnvqc_v => cnvqc_v
1923  this%sup => sup
1924 
1925  end subroutine
1927 
1928 
1930 !******************************************
1931 ! Radiation tendencies methods
1932 !******************************************
1933  subroutine rad_phys_set (this, htrsw, sfalb, coszen, htrlw, &
1934  tsflw, semis, rqtk, hlwd, dtdtr, swhc, hlwc)
1935  implicit none
1936  class(radiation_tendencies) :: this
1937  real (kind=kind_phys), target :: htrsw (:,:)
1938  real (kind=kind_phys), target :: sfalb (:)
1939 
1940  real (kind=kind_phys), target :: coszen(:)
1941  real (kind=kind_phys), target :: htrlw (:,:)
1942  real (kind=kind_phys), target :: tsflw (:)
1943  real (kind=kind_phys), target :: semis (:)
1944 
1945  ! Optional, used only by gbphys
1946  real (kind=kind_phys), target :: rqtk (:)
1947  real (kind=kind_phys), target :: hlwd (:,:,:)
1948  real (kind=kind_phys), target :: dtdtr(:,:)
1949 
1950  real (kind=kind_phys), target :: swhc(:,:)
1951  real (kind=kind_phys), target :: hlwc(:,:)
1952 
1953  select type (this)
1954  class is (radiation_tendencies)
1955  this%htrsw => htrsw
1956  this%sfalb => sfalb
1957  this%coszen => coszen
1958  this%htrlw => htrlw
1959  this%tsflw => tsflw
1960  this%semis => semis
1961 
1962  this%rqtk => rqtk
1963  this%hlwd => hlwd
1964  this%dtdtr => dtdtr
1965 
1966  this%swhc => swhc
1967  this%hlwc => hlwc
1968  end select
1969 
1970 ! where(this%dtdtr(:,:) >= 10.0 .or. this%dtdtr(:,:) .lt. 0.)
1971 ! print*,'rad%dtdtr', rad%dtdtr
1972 ! this%dtdtr=0.0444
1973 ! end where
1974 ! print*,'this%dtdtr', this%dtdtr
1975  end subroutine rad_phys_set
1976 
1977  ! swh ! hlw
1978  subroutine rad_tend_set (this, htrsw, sfalb, coszen, htrlw, tsflw, semis, coszdg,hlwc_v, swhc_v)
1979 
1980  implicit none
1981 
1982  class(radiation_tendencies) :: this
1983 
1984  !! Outputs from grrad
1985  real (kind=kind_phys), target :: htrsw (:,:)
1986  real (kind=kind_phys), target :: sfalb (:)
1987 
1988  real (kind=kind_phys), target :: coszen(:)
1989  real (kind=kind_phys), target :: htrlw (:,:)
1990  real (kind=kind_phys), target :: tsflw (:)
1991  real (kind=kind_phys), target :: semis (:)
1992  real (kind=kind_phys), target :: coszdg(:)
1993  real (kind=kind_phys), target :: hlwc_v(:,:)
1994  real (kind=kind_phys), target :: swhc_v(:,:)
1995 
1996  ! Optional, used only by grrad
1997 ! real (kind=kind_phys), optional, target :: coszdg(:)
1998 
1999  call dbgprint("rad_tend_set")
2000 
2001  select type (this)
2002  class is (radiation_tendencies)
2003  this%htrsw => htrsw
2004  this%sfalb => sfalb
2005  this%coszen => coszen
2006  this%htrlw => htrlw
2007  this%tsflw => tsflw
2008  this%semis => semis
2009  this%hlwc_v => hlwc_v
2010  this%swhc_v => swhc_v
2011  this%coszdg => coszdg
2012 ! if (present(coszdg)) this%coszdg => coszdg
2013  end select
2014 
2015  end subroutine rad_tend_set
2017 
2018 
2019 
2021 !******************************************
2022 ! Model parameters methods
2023 !******************************************
2024 
2025  subroutine mdl_param_print (this, msg)
2026 
2027  class(model_parameters) :: this
2028  character*(*) msg !declares a dummy argument
2029 
2030  if (this%me .eq. 0) then
2031  print *, msg
2032  print *, "MODEL PARAMETERS"
2033  print *, "----- ----------"
2034  print *,"ntcw : ", this%ntcw
2035  print *,"ncld : ", this%ncld
2036  print *,"ntoz : ", this%ntoz
2037  print *,"NTRAC : ", this%NTRAC
2038  print *,"levs : ", this%levs
2039  print *,"me : ", this%me
2040  print *,"lsoil : ", this%lsoil
2041  print *,"lsm : ", this%lsm
2042  print *,"nmtvr : ", this%nmtvr
2043  print *,"nrcm : ", this%nrcm
2044  print *,"levozp : ", this%levozp
2045  print *,"lonr : ", this%lonr
2046  print *,"latr : ", this%latr
2047  print *,"jcap : ", this%jcap
2048  print *,"num_p3d : ", this%num_p3d
2049  print *,"num_p2d : ", this%num_p2d
2050  print *,"npdf3d : ", this%npdf3d
2051  print *,"ncnvcld3d : ", this%ncnvcld3d
2052  print *,"pl_coeff : ", this%pl_coeff
2053  print *,"ncw : ", this%ncw
2054  print *,"idate : ", this%idate
2055  print *,"idat : ", this%idat
2056  print *,"crtrh : ", this%crtrh
2057  print *,"cdmbgwd : ", this%cdmbgwd
2058  print *,"ccwf : ", this%ccwf
2059  print *,"dlqf : ", this%dlqf
2060  print *,"ctei_rm : ", this%ctei_rm
2061  print *,"cgwf : ", this%cgwf
2062  print *,"prslrd0 : ", this%prslrd0
2063  print *,"ral_ts : ", this%ral_ts
2064  print *,"ras : ", this%ras
2065  print *,"pre_rad : ", this%pre_rad
2066  print *,"ldiag3d : ", this%ldiag3d
2067  print *,"lgocart : ", this%lgocart
2068  print *,"lssav_cpl : ", this%lssav_cpl
2069  print *,"flipv : ", this%flipv
2070  print *,"old_monin : ", this%old_monin
2071  print *,"cnvgwd : ", this%cnvgwd
2072  print *,"shal_cnv : ", this%shal_cnv
2073  print *,"imfshalcnv : ", this%imfshalcnv
2074  print *,"imfdeepcnv : ", this%imfdeepcnv
2075  print *,"cal_pre : ", this%cal_pre
2076  print *,"mom4ice : ", this%mom4ice
2077  print *,"mstrat : ", this%mstrat
2078  print *,"trans_trac : ", this%trans_trac
2079  print *,"nstf_name : ", this%nstf_name
2080  print *,"moist_adj : ", this%moist_adj
2081  print *,"thermodyn_id : ", this%thermodyn_id
2082  print *,"sfcpress_id : ", this%sfcpress_id
2083  print *,"gen_coord_hybrid : ", this%gen_coord_hybrid
2084  print *,"levr : ", this%levr
2085  print *,"lsidea : ", this%lsidea
2086  print *,"pdfcld : ", this%pdfcld
2087  print *,"shcnvcw : ", this%shcnvcw
2088  print *,"redrag : ", this%redrag
2089  print *,"hybedmf : ", this%hybedmf
2090  print *,"dspheat : ", this%dspheat
2091 ! print *,"LATS_NODE_R :", this%lats_node_r
2092 ! print *,"JINDX1 :", this%jindx1
2093 ! print *,"JINDX2 :", this%jindx2
2094 ! print *,"ddy :", this%ddy
2095 
2096  endif
2097 
2098  end subroutine
2099 
2101 
2102 
2104 !******************************************
2105 ! Dynamic_parameter methods
2106 !******************************************
2107 
2108  subroutine dyn_param_setrad (this, xlon, xlat, sinlat, coslat, solhr, &
2109  ix, im, kdt, jdate, solcon, icsdsw, icsdlw, &
2110  dtlw, dtsw, lsswr, lslwr, lssav, lmfshal, lmfdeep2, &
2111  ipt, lprnt, deltim, &
2112  slag, sdec, cdec)
2113 
2114  implicit none
2115 
2116  class(dynamic_parameters) :: this
2117 
2118  real (kind=kind_phys), target :: xlon(:)
2119  real (kind=kind_phys), target :: xlat(:)
2120  real (kind=kind_phys), target :: sinlat(:)
2121  real (kind=kind_phys), target :: coslat(:)
2122  real (kind=kind_phys) :: solhr
2123  integer :: IX
2124  integer :: IM
2125  integer :: kdt
2126  logical :: lssav
2127  logical :: lmfshal
2128  logical :: lmfdeep2
2129 
2130  ! Radiation only
2131  integer :: jdate (8)
2132  real (kind=kind_phys) :: solcon
2133 
2134  integer, target :: icsdsw(:)
2135  integer, target :: icsdlw(:)
2136  real (kind=kind_phys) :: dtlw
2137  real (kind=kind_phys) :: dtsw
2138  logical :: lsswr
2139  logical :: lslwr
2140  integer :: ipt
2141  logical :: lprnt
2142  real (kind=kind_phys) :: deltim
2143 
2144  ! These might be able to be computed elsewhere
2145  real (kind=kind_phys) :: slag ! equation of time ( radian )
2146  real (kind=kind_phys) :: sdec ! sin of the solar declination angle
2147  real (kind=kind_phys) :: cdec ! cos of the solar declination angle
2148  ! End Radiation only
2149 
2150  call dbgprint("dyn_param_setrad")
2151 
2152  select type (this)
2153  class is (dynamic_parameters)
2154  this%xlon => xlon
2155  this%xlat => xlat
2156  this%sinlat => sinlat
2157  this%coslat => coslat
2158  this%solhr = solhr
2159  this%IX = ix
2160  this%IM = im
2161  this%kdt = kdt
2162  this%jdate = jdate
2163  this%solcon = solcon
2164  this%icsdsw => icsdsw
2165  this%icsdlw => icsdlw
2166  this%dtlw = dtlw
2167  this%dtsw = dtsw
2168  this%lsswr = lsswr
2169  this%lslwr = lslwr
2170  this%lssav = lssav
2171  this%lmfshal = lmfshal
2172  this%lmfdeep2 = lmfdeep2
2173  this%ipt = ipt
2174  this%lprnt = lprnt
2175  this%deltim = deltim
2176 
2177  this%slag = slag
2178  this%sdec = sdec
2179  this%cdec = cdec
2180 
2181  class default
2182  print *, "class default"
2183  end select
2184 
2185  end subroutine
2187 
2188 
2190  subroutine dyn_param_setphys (this, xlon, xlat, sinlat, coslat, solhr, &
2191  ix, im, kdt, lssav, lat, dtp, dtf, clstp, &
2192  nnp, nlons, fhour, slag, sdec, cdec )
2193  implicit none
2194 
2195  class(dynamic_parameters) :: this
2196 
2197  real (kind=kind_phys), target :: xlon(:)
2198  real (kind=kind_phys), target :: xlat(:)
2199  real (kind=kind_phys), target :: sinlat(:)
2200  real (kind=kind_phys), target :: coslat(:)
2201  real (kind=kind_phys) :: solhr
2202  integer :: IX
2203  integer :: IM
2204  integer :: kdt
2205  logical :: lssav
2206 
2207 
2208  ! Physics only
2209  integer :: lat
2210  real (kind=kind_phys) :: dtp
2211  real (kind=kind_phys) :: dtf
2212  real (kind=kind_phys) :: clstp
2213  integer :: nnp
2214  integer, target :: nlons(:)
2215  real (kind=kind_phys) :: fhour
2216 
2217 
2218  ! These might be able to be computed elsewhere
2219  real (kind=kind_phys) :: slag ! equation of time ( radian )
2220  real (kind=kind_phys) :: sdec ! sin of the solar declination angle
2221  real (kind=kind_phys) :: cdec ! cos of the solar declination angle
2222 
2223  call dbgprint("dyn_param_setphys")
2224 
2225  select type (this)
2226  class is (dynamic_parameters)
2227  this%xlon => xlon
2228  this%xlat => xlat
2229  this%sinlat => sinlat
2230  this%coslat => coslat
2231  this%solhr = solhr
2232  this%IX = ix
2233  this%IM = im
2234  this%kdt = kdt
2235  this%lssav = lssav
2236  this%lat = lat
2237  this%dtp = dtp
2238  this%dtf = dtf
2239  this%clstp = clstp
2240  this%nnp = nnp
2241  this%nlons => nlons
2242  this%fhour = fhour
2243 
2244  this%slag = slag
2245  this%sdec = sdec
2246  this%cdec = cdec
2247 
2248  class default
2249  print *, "class default"
2250  end select
2251 
2252  end subroutine
2254 
2255 
2256 
2257 
2258 !******************************************
2259 ! Non type-bound procedures methods
2260 !******************************************
2261 
2262 
2264 
2265  subroutine nuopc_phys_init (mdl, ntcw, ncld, ntoz, NTRAC, levs, me, lsoil, &
2266  ntiw, ntlnc, ntinc, lsm, nmtvr, nrcm, levozp, levh2o, &
2267  lonr, latr, jcap, num_p3d, num_p2d, npdf3d, ncnvcld3d, pl_coeff, ncw, crtrh, cdmbgwd, &
2268  ccwf, dlqf, ctei_rm, cgwf, prslrd0, ral_ts, ras, pre_rad, ldiag3d, lgocart, &
2269  lssav_cpl, flipv, old_monin, cnvgwd, shal_cnv, imfshalcnv, imfdeepcnv, cal_pre, mom4ice, &
2270  mstrat, trans_trac, nstf_name, moist_adj, thermodyn_id, sfcpress_id, &
2271  gen_coord_hybrid, levr, lsidea, pdfcld, shcnvcw, redrag, hybedmf, dspheat, &
2272  dxmaxin, dxminin, dxinvin, h2o_phys, h2o_coeff,&
2273  ! NEW from nems_slg_shoc
2274  cscnv, nctp, ntke, do_shoc, shocaftcnv, ntot3d, ntot2d, &
2275  ! For radiation
2276  si, ictm, isol, ico2, iaer, ialb, iems, isot, ivegsrc, &
2277  iovr_sw,iovr_lw,isubc_sw,isubc_lw, shoc_cld, &
2278  crick_proof,ccnorm,norad_precip,idate,iflip, nlunit,lats_node_r)
2279 
2280 
2281  ! use physcons, only: dxmin, dxmax, dxinv
2282 
2283  implicit none
2284 
2285  ! Add intent ?
2286  type(model_parameters) :: mdl
2287 
2288  integer :: ntcw
2289  integer :: ncld
2290  integer :: ntoz
2291  integer :: NTRAC
2292  integer :: levs
2293  integer :: me
2294  integer :: lsoil
2295  integer :: ntiw
2296  integer :: ntlnc
2297  integer :: ntinc
2298  integer :: lsm
2299  integer :: nmtvr
2300  integer :: nrcm
2301  integer :: levozp
2302  integer :: levh2o
2303  integer :: lonr
2304  integer :: latr
2305  integer :: jcap
2306  integer :: num_p3d
2307  integer :: num_p2d
2308  integer :: npdf3d
2309  integer :: ncnvcld3d
2310  integer :: pl_coeff
2311  integer :: h2o_coeff
2312  integer :: ncw(2)
2313  integer :: lats_node_r
2314  integer :: isot
2315  integer :: ivegsrc
2316 
2317  ! NEW 9/2015
2318  integer :: nctp
2319  integer :: ntke
2320  integer :: ntot3d
2321  integer :: ntot2d
2322  integer :: imfshalcnv, imfdeepcnv
2323 
2324  real (kind=kind_phys) :: crtrh(3)
2325  real (kind=kind_phys) :: cdmbgwd(2)
2326  real (kind=kind_phys) :: ccwf(2)
2327  real (kind=kind_phys) :: dlqf(2)
2328  real (kind=kind_phys) :: ctei_rm(2)
2329  real (kind=kind_phys) :: cgwf(2)
2330  real (kind=kind_phys) :: prslrd0
2331  real (kind=kind_phys) :: ral_ts
2332 
2333  logical :: ras
2334  logical :: pre_rad
2335  logical :: ldiag3d
2336  logical :: lgocart
2337  logical :: lssav_cpl
2338  logical :: flipv
2339  logical :: old_monin
2340  logical :: cnvgwd
2341  logical :: shal_cnv
2342 ! logical :: imfshalcnv
2343 ! logical :: imfdeepcnv
2344  logical :: cal_pre
2345  logical :: mom4ice
2346  logical :: mstrat
2347  logical :: trans_trac
2348  integer :: nstf_name(5)
2349  logical :: moist_adj
2350  integer :: thermodyn_id
2351  integer :: sfcpress_id
2352  logical :: gen_coord_hybrid
2353  integer :: levr
2354  logical :: lsidea
2355  logical :: pdfcld
2356  logical :: shcnvcw
2357  logical :: redrag
2358  logical :: hybedmf
2359  logical :: dspheat
2360  logical :: h2o_phys
2361 
2362  ! NEW 9/2015
2363  logical :: shoc_cld
2364  logical :: cscnv
2365  logical :: do_shoc
2366  logical :: shocaftcnv
2367 
2368  real(kind=kind_phys) :: dxmaxin, dxminin, dxinvin
2369  ! For rad_initialize
2370  real (kind=kind_phys), intent(in) :: si(levr+1)
2371 
2372  integer, intent(in) :: ictm, isol, ico2, iaer, ialb, iems
2373  integer, intent(in) :: iovr_sw, iovr_lw, isubc_sw, isubc_lw
2374 
2375 
2376 ! idate - in date_def in gfs_physics_initialize - set way up in the esmf gc
2377 ! iflip - is not the same as flipv iflip is integer, flipv is logical
2378  integer, intent(in) :: idate(4), iflip
2379  integer :: idat(8) ! Different scheme for idate
2380 
2381 ! sas_shal is NOT the same as imfshalcnv : sas_shal = imfshalcnv .and. (.not. ras)
2382  logical, intent(in) :: crick_proof, ccnorm, norad_precip
2383 
2384  integer, intent(in) :: nlunit ! local namelist unit for set_soilveg, legacy, unused
2385 
2388  idat = 0
2389  idat(1) = idate(4)
2390  idat(2) = idate(2)
2391  idat(3) = idate(3)
2392  idat(5) = idate(1)
2393 
2394  myme = me
2395  call dbgprint("entering nuopc_phys_init")
2396 ! if (.not.associated(mdl%jindx1)) allocate(mdl%jindx1(lats_node_r))
2397 ! if (.not.associated(mdl%jindx2)) allocate(mdl%jindx2(lats_node_r))
2398 ! if (.not.associated(mdl%ddy)) allocate(mdl%ddy(lats_node_r))
2399 
2400  mdl%idate = idate
2401  mdl%idat = idat
2402  mdl%ntcw = ntcw
2403  mdl%ncld = ncld
2404  mdl%ntoz = ntoz
2405  mdl%NTRAC = ntrac
2406  mdl%levs = levs
2407  mdl%me = me
2408  mdl%lsoil = lsoil
2409  mdl%ntiw = ntiw
2410  mdl%ntlnc = ntlnc
2411  mdl%ntinc = ntinc
2412  mdl%lsm = lsm
2413  mdl%nmtvr = nmtvr
2414  mdl%nrcm = nrcm
2415  mdl%levozp = levozp
2416  mdl%levh2o = levh2o
2417  mdl%lonr = lonr
2418  mdl%latr = latr
2419  mdl%jcap = jcap
2420  mdl%num_p3d = num_p3d
2421  mdl%num_p2d = num_p2d
2422  mdl%npdf3d = npdf3d
2423  mdl%ncnvcld3d = ncnvcld3d
2424  mdl%pl_coeff = pl_coeff
2425  mdl%h2o_coeff = h2o_coeff
2426  mdl%ncw = ncw
2427  mdl%lats_node_r = lats_node_r
2428  mdl%crtrh = crtrh
2429  mdl%cdmbgwd = cdmbgwd
2430  mdl%ccwf = ccwf
2431  mdl%dlqf = dlqf
2432  mdl%ctei_rm = ctei_rm
2433  mdl%cgwf = cgwf
2434  mdl%prslrd0 = prslrd0
2435  mdl%ral_ts = ral_ts
2436  mdl%ras = ras
2437  mdl%pre_rad = pre_rad
2438  mdl%ldiag3d = ldiag3d
2439  mdl%lgocart = lgocart
2440  mdl%lssav_cpl = lssav_cpl
2441  mdl%flipv = flipv
2442  mdl%old_monin = old_monin
2443  mdl%cnvgwd = cnvgwd
2444  mdl%shal_cnv = shal_cnv
2445  mdl%imfshalcnv = imfshalcnv
2446  mdl%imfdeepcnv = imfdeepcnv
2447  mdl%cal_pre = cal_pre
2448  mdl%mom4ice = mom4ice
2449  mdl%mstrat = mstrat
2450  mdl%trans_trac = trans_trac
2451  mdl%nstf_name = nstf_name
2452  mdl%moist_adj = moist_adj
2453  mdl%thermodyn_id = thermodyn_id
2454  mdl%sfcpress_id = sfcpress_id
2455  mdl%gen_coord_hybrid = gen_coord_hybrid
2456  mdl%levr = levr
2457  mdl%lsidea = lsidea
2458  mdl%pdfcld = pdfcld
2459  mdl%shcnvcw = shcnvcw
2460  mdl%redrag = redrag
2461  mdl%hybedmf = hybedmf
2462  mdl%dspheat = dspheat
2463  mdl%isot = isot
2464  mdl%ivegsrc = ivegsrc
2465  mdl%h2o_phys = h2o_phys
2466  ! NEW CS Scheme
2467  mdl%cscnv = cscnv
2468  mdl%nctp = nctp
2469  mdl%ntke = ntke
2470  mdl%do_shoc = do_shoc
2471  mdl%shocaftcnv = shocaftcnv
2472  mdl%ntot3d = ntot3d
2473  mdl%ntot2d = ntot2d
2474  mdl%shoc_cld = shoc_cld
2475 
2476  ! physcons module variables
2477  dxmax = dxmaxin
2478  dxmin = dxminin
2479  dxinv = dxinvin
2480 
2482  call gfuncphys
2483 
2485  call rad_initialize &
2486 ! --- inputs:
2487  & ( si,levr,ictm,isol,ico2,iaer,ialb,iems,ntcw, &
2488  & num_p3d,npdf3d, ntoz,iovr_sw,iovr_lw,isubc_sw,isubc_lw, &
2489  & crick_proof,ccnorm,norad_precip,idate,iflip,me )
2490 ! --- outputs: ( none )
2491 
2493  call set_soilveg(me,isot, ivegsrc,nlunit)
2494 
2495  end subroutine
2496 
2497  subroutine ozoneini(this,jindx1,jindx2,ozplin,ddy)
2498  implicit none
2499  class(model_parameters) :: this
2500 
2502  integer, target :: jindx1 (:)
2503  integer, target :: jindx2 (:)
2504  real (kind=kind_phys), target :: ozplin(:,:,:,:)
2505  real (kind=kind_phys), target :: ddy (:)
2506 
2507  select type (this)
2508  class is (model_parameters)
2509  this%jindx1 => jindx1
2510  this%jindx2 => jindx2
2511  this%ozplin => ozplin
2512  this%ddy => ddy
2513  class default
2514  end select
2515 
2516  end subroutine
2517 
2518  subroutine h2oini(this,jindx1_h,jindx2_h,h2oplin,ddy_h, h2o_pres)
2519  implicit none
2520  class(model_parameters) :: this
2521 
2522  integer, target :: jindx1_h (:)
2523  integer, target :: jindx2_h (:)
2524  real (kind=kind_phys), target :: h2oplin(:,:,:,:)
2525  real (kind=kind_phys), target :: ddy_h (:)
2526 ! real (kind=kind_phys), target :: h2o_lat(:)
2527  real (kind=kind_phys), target :: h2o_pres(:)
2528 
2529  select type (this)
2530  class is (model_parameters)
2531  this%jindx1_h => jindx1_h
2532  this%jindx2_h => jindx2_h
2533  this%h2oplin => h2oplin
2534  this%ddy_h => ddy_h
2535 ! this%h2o_lat => h2o_lat
2536  this%h2o_pres => h2o_pres
2537  class default
2538  end select
2539 
2540  end subroutine
2541 
2542  subroutine phys_init_savein ( levr, ntcw, ncld, ntoz, NTRAC, levs, me, lsoil, lsm, nmtvr, nrcm, levozp, &
2543  lonr, latr, jcap, num_p3d, num_p2d, npdf3d, ncnvcld3d, pl_coeff, ncw, nstf_name, &
2544  thermodyn_id, sfcpress_id, crtrh, cdmbgwd, &
2545  ccwf, dlqf, ctei_rm, cgwf, prslrd0, ral_ts, ras, pre_rad, ldiag3d, lgocart, &
2546  lssav_cpl, flipv, old_monin, cnvgwd, shal_cnv, imfshalcnv, imfdeepcnv, cal_pre, mom4ice, &
2547  mstrat, trans_trac, moist_adj, &
2548  gen_coord_hybrid, lsidea, pdfcld, shcnvcw, redrag, hybedmf, dspheat, &
2549  dxmax, dxmin, dxinv, &
2550  ! NEW from nems_slg_shoc
2551  cscnv, nctp, ntke, do_shoc, shocaftcnv, ntot3d, ntot2d, &
2552  ! For radiation
2553  si, ictm, isol, ico2, iaer, ialb, iems, &
2554  iovr_sw,iovr_lw,isubc_sw,isubc_lw, shoc_cld, &
2555  sas_shal,crick_proof,ccnorm,norad_precip,idate,iflip, nlunit)
2556 
2557  implicit none
2558 
2559  ! need a file unit and filename to write to
2560  integer, parameter :: funit = 99
2561  integer :: ios
2562 
2563  integer, intent(in) :: levr ! This must be provided by caller - used as dimension for si
2564  integer :: ntcw
2565  integer :: ncld
2566  integer :: ntoz
2567  integer :: NTRAC
2568  integer :: levs
2569  integer :: me
2570  integer :: lsoil
2571  integer :: lsm
2572  integer :: nmtvr
2573  integer :: nrcm
2574  integer :: levozp
2575  integer :: lonr
2576  integer :: latr
2577  integer :: jcap
2578  integer :: num_p3d
2579  integer :: num_p2d
2580  integer :: npdf3d
2581  integer :: ncnvcld3d
2582  integer :: pl_coeff
2583  integer :: ncw(2)
2584 
2585  integer :: nstf_name(5)
2586  integer :: thermodyn_id
2587  integer :: sfcpress_id
2588  integer :: imfshalcnv, imfdeepcnv
2589 
2590  real (kind=kind_phys) :: crtrh(3)
2591  real (kind=kind_phys) :: cdmbgwd(2)
2592  real (kind=kind_phys) :: ccwf(2)
2593  real (kind=kind_phys) :: dlqf(2)
2594  real (kind=kind_phys) :: ctei_rm(2)
2595  real (kind=kind_phys) :: cgwf(2)
2596  real (kind=kind_phys) :: prslrd0
2597  real (kind=kind_phys) :: ral_ts
2598 
2599  logical :: ras
2600  logical :: pre_rad
2601  logical :: ldiag3d
2602  logical :: lgocart
2603  logical :: lssav_cpl
2604  logical :: flipv
2605  logical :: old_monin
2606  logical :: cnvgwd
2607  logical :: shal_cnv
2608 ! logical :: imfshalcnv
2609 ! logical :: imfdeepcnv
2610  logical :: cal_pre
2611  logical :: mom4ice
2612  logical :: mstrat
2613  logical :: trans_trac
2614  logical :: moist_adj
2615  logical :: gen_coord_hybrid
2616  logical :: lsidea
2617  logical :: pdfcld
2618  logical :: shcnvcw
2619  logical :: redrag
2620  logical :: hybedmf
2621  logical :: dspheat
2622 
2623  ! NEW 9/2015
2624  integer :: nctp
2625  integer :: ntke
2626  integer :: ntot3d
2627  integer :: ntot2d
2628 
2629  logical :: shoc_cld
2630  logical :: cscnv
2631  logical :: do_shoc
2632  logical :: shocaftcnv
2633 
2634 
2635  real(kind=kind_phys) :: dxmax, dxmin, dxinv ! based on max lon/lat
2636 
2637  ! Radiation option control parameters
2638  real (kind=kind_phys), intent(in) :: si(levr+1)
2639  integer, intent(in) :: ictm, isol, ico2, iaer, ialb, iems
2640  integer, intent(in) :: iovr_sw, iovr_lw, isubc_sw, isubc_lw
2641  integer, intent(in) :: idate(4), iflip
2642  logical, intent(in) :: sas_shal, crick_proof, ccnorm, norad_precip
2643 
2644  ! For set_vegtype - not needed
2645  integer, intent(in) :: nlunit
2646 
2647  call dbgprint("phys_init_savein")
2648 
2649  ! print *, "NUOPC DBG before write"
2650 
2651  ! open file
2652  open (funit, file='init_savein.dat', status='new', form='unformatted', iostat=ios)
2653 
2654  ! write each record
2655  write (funit, iostat=ios, err=900) levr
2656 
2657  write (funit, iostat=ios, err=900) ntcw, ncld, ntoz, ntrac, levs, me, lsoil, lsm, nmtvr, nrcm, levozp, &
2658  lonr, latr, jcap, num_p3d, num_p2d, npdf3d, ncnvcld3d, pl_coeff, ncw, nstf_name, &
2659  thermodyn_id, sfcpress_id, crtrh, cdmbgwd, &
2660  ccwf, dlqf, ctei_rm, cgwf, prslrd0, ral_ts, ras, pre_rad, ldiag3d, lgocart, &
2661  lssav_cpl, flipv, old_monin, cnvgwd, shal_cnv, imfshalcnv, imfdeepcnv, cal_pre, mom4ice, &
2662  mstrat, trans_trac, moist_adj, &
2663  gen_coord_hybrid, lsidea, pdfcld, shcnvcw, redrag, hybedmf, dspheat, &
2664  dxmax, dxmin, dxinv, &
2665  cscnv, nctp, ntke, do_shoc, shocaftcnv, ntot3d, ntot2d
2666 
2667 
2668  ! For radiation
2669  write (funit, iostat=ios, err=900) si
2670  write (funit, iostat=ios, err=900) ictm
2671  write (funit, iostat=ios, err=900) isol
2672  write (funit, iostat=ios, err=900) ico2
2673  write (funit, iostat=ios, err=900) iaer
2674  write (funit, iostat=ios, err=900) ialb
2675  write (funit, iostat=ios, err=900) iems
2676  write (funit, iostat=ios, err=900) iovr_sw
2677  write (funit, iostat=ios, err=900) iovr_lw
2678  write (funit, iostat=ios, err=900) isubc_sw
2679  write (funit, iostat=ios, err=900) isubc_lw
2680  write (funit, iostat=ios, err=900) shoc_cld
2681  write (funit, iostat=ios, err=900) sas_shal
2682  write (funit, iostat=ios, err=900) crick_proof
2683  write (funit, iostat=ios, err=900) ccnorm
2684  write (funit, iostat=ios, err=900) norad_precip
2685  write (funit, iostat=ios, err=900) idate
2686  write (funit, iostat=ios, err=900) iflip
2687  write (funit, iostat=ios, err=900) nlunit
2688 
2689  flush (funit, iostat=ios, err=900)
2690 
2691  ! close file
2692  close (funit, iostat=ios)
2693 
2694  ! report any errors
2695 900 if (ios .ne. 0 ) print *, "DBG NUOPC IOERR : ", ios
2696 
2697  if (debug) then
2698 
2699  print *, "BEFORE INIT SAVE"
2700  print *, "---------------------------"
2701 
2702  print *, "ntcw : ", ntcw
2703  print *, "ncld : ", ncld
2704  print *, "ntoz : ", ntoz
2705  print *, "NTRAC : ", ntrac
2706  print *, "levs : ", levs
2707  print *, "me : ", me
2708  print *, "lsoil : ", lsoil
2709  print *, "lsm : ", lsm
2710  print *, "nmtvr : ", nmtvr
2711  print *, "nrcm : ", nrcm
2712  print *, "levozp : ", levozp
2713  print *, "lonr : ", lonr
2714  print *, "latr : ", latr
2715  print *, "jcap : ", jcap
2716  print *, "num_p3d : ", num_p3d
2717  print *, "num_p2d : ", num_p2d
2718  print *, "npdf3d : ", npdf3d
2719  print *, "ncnvcld3d : ", ncnvcld3d
2720  print *, "pl_coeff : ", pl_coeff
2721  print *, "ncw : ", ncw
2722  print *, "crtrh : ", crtrh
2723  print *, "cdmbgwd : ", cdmbgwd
2724  print *, "ccwf : ", ccwf
2725  print *, "dlqf : ", dlqf
2726  print *, "ctei_rm : ", ctei_rm
2727  print *, "cgwf : ", cgwf
2728  print *, "prslrd0 : ", prslrd0
2729  print *, "ral_ts : ", ral_ts
2730  print *, "ras : ", ras
2731  print *, "pre_rad : ", pre_rad
2732  print *, "ldiag3d : ", ldiag3d
2733  print *, "lgocart : ", lgocart
2734  print *, "lssav_cpl : ", lssav_cpl
2735  print *, "flipv : ", flipv
2736  print *, "old_monin : ", old_monin
2737  print *, "cnvgwd : ", cnvgwd
2738  print *, "shal_cnv : ", shal_cnv
2739  print *, "imfshalcnv : ", imfshalcnv
2740  print *, "imfdeepcnv : ", imfdeepcnv
2741  print *, "cal_pre : ", cal_pre
2742  print *, "mom4ice : ", mom4ice
2743  print *, "mstrat : ", mstrat
2744  print *, "trans_trac : ", trans_trac
2745  print *, "nstf_name : ", nstf_name
2746  print *, "moist_adj : ", moist_adj
2747  print *, "thermodyn_id : ", thermodyn_id
2748  print *, "sfcpress_id : ", sfcpress_id
2749  print *, "gen_coord_hybrid : ", gen_coord_hybrid
2750  print *, "levr : ", levr
2751  print *, "lsidea : ", lsidea
2752  print *, "pdfcld : ", pdfcld
2753  print *, "shcnvcw : ", shcnvcw
2754  print *, "redrag : ", redrag
2755  print *, "hybedmf : ", hybedmf
2756  print *, "dspheat : ", dspheat
2757  print *, "dxmax : ", dxmax
2758  print *, "dxmin : ", dxmin
2759  print *, "dxinv : ", dxinv
2760  print *, "si : ", si
2761  print *, "ictm : ", ictm
2762  print *, "isol : ", isol
2763  print *, "ico2 : ", ico2
2764  print *, "iaer : ", iaer
2765  print *, "ialb : ", ialb
2766  print *, "iems : ", iems
2767  print *, "iovr_sw : ", iovr_sw
2768  print *, "iovr_lw : ", iovr_lw
2769  print *, "isubc_sw : ", isubc_sw
2770  print *, "isubc_lw : ", isubc_lw
2771  print *, "sas_shal : ", sas_shal
2772  print *, "crick_proof : ", crick_proof
2773  print *, "ccnorm : ", ccnorm
2774  print *, "norad_precip : ", norad_precip
2775  print *, "idate : ", idate
2776  print *, "iflip : ", iflip
2777 
2778  print *, "cscnv : ", cscnv
2779  print *, "nctp : ", nctp
2780  print *, "ntke : ", ntke
2781  print *, "do_shoc : ", do_shoc
2782  print *, "shocaftcnv : ", shocaftcnv
2783  print *, "ntot3d : ", ntot3d
2784  print *, "ntot2d : ", ntot2d
2785  print *, "shoc_cld : ", shoc_cld
2786 
2787  end if
2788 
2789  end subroutine
2790 
2791 
2794  subroutine phys_init_readin ( levr, ntcw, ncld, ntoz, NTRAC, levs, me, lsoil, lsm, nmtvr, nrcm, levozp, &
2795  lonr, latr, jcap, num_p3d, num_p2d, npdf3d, ncnvcld3d, pl_coeff, ncw, nstf_name, &
2796  thermodyn_id, sfcpress_id, crtrh, cdmbgwd, &
2797  ccwf, dlqf, ctei_rm, cgwf, prslrd0, ral_ts, ras, pre_rad, ldiag3d, lgocart, &
2798  lssav_cpl, flipv, old_monin, cnvgwd, shal_cnv, imfshalcnv, imfdeepcnv, cal_pre, mom4ice, &
2799  mstrat, trans_trac, moist_adj, &
2800  gen_coord_hybrid, lsidea, pdfcld, shcnvcw, redrag, hybedmf, dspheat, &
2801  dxmaxin, dxminin, dxinvin, &
2802  ! NEW from nems_slg_shoc
2803  cscnv, nctp, ntke, do_shoc, shocaftcnv, ntot3d, ntot2d, &
2804  ! For radiation
2805  si, ictm, isol, ico2, iaer, ialb, iems, &
2806  iovr_sw,iovr_lw,isubc_sw,isubc_lw,shoc_cld, &
2807  sas_shal,crick_proof,ccnorm,norad_precip,idate,iflip,nlunit)
2808 
2809  ! use physcons, only: dxmax, dxmin, dxinv
2810 
2811  implicit none
2812 
2813  ! file unit and filename to write to
2814  integer, parameter :: funit = 98
2815  integer :: ios
2816 
2817  integer :: levr_loc ! local instance of levr for read
2818  integer, intent(in) :: levr ! This must be provided by caller - used as dimension
2819  integer :: ntcw
2820  integer :: ncld
2821  integer :: ntoz
2822  integer :: NTRAC
2823  integer :: levs
2824  integer :: me
2825  integer :: lsoil
2826  integer :: lsm
2827  integer :: nmtvr
2828  integer :: nrcm
2829  integer :: levozp
2830  integer :: lonr
2831  integer :: latr
2832  integer :: jcap
2833  integer :: num_p3d
2834  integer :: num_p2d
2835  integer :: npdf3d
2836  integer :: ncnvcld3d
2837  integer :: pl_coeff
2838  integer :: ncw(2)
2839 
2840  integer :: nstf_name(5)
2841  integer :: thermodyn_id
2842  integer :: sfcpress_id
2843  integer :: imfshalcnv, imfdeepcnv
2844 
2845  real (kind=kind_phys) :: crtrh(3)
2846  real (kind=kind_phys) :: cdmbgwd(2)
2847  real (kind=kind_phys) :: ccwf(2)
2848  real (kind=kind_phys) :: dlqf(2)
2849  real (kind=kind_phys) :: ctei_rm(2)
2850  real (kind=kind_phys) :: cgwf(2)
2851  real (kind=kind_phys) :: prslrd0
2852  real (kind=kind_phys) :: ral_ts
2853 
2854  logical :: ras
2855  logical :: pre_rad
2856  logical :: ldiag3d
2857  logical :: lgocart
2858  logical :: lssav_cpl
2859  logical :: flipv
2860  logical :: old_monin
2861  logical :: cnvgwd
2862  logical :: shal_cnv
2863 ! logical :: imfshalcnv
2864 ! logical :: imfdeepcnv
2865  logical :: cal_pre
2866  logical :: mom4ice
2867  logical :: mstrat
2868  logical :: trans_trac
2869  logical :: moist_adj
2870  logical :: gen_coord_hybrid
2871  logical :: lsidea
2872  logical :: pdfcld
2873  logical :: shcnvcw
2874  logical :: redrag
2875  logical :: hybedmf
2876  logical :: dspheat
2877 
2878  real(kind=kind_phys) :: dxmaxin, dxminin, dxinvin ! based on max lon/lat
2879 
2880  integer :: nctp
2881  integer :: ntke
2882  integer :: ntot3d
2883  integer :: ntot2d
2884 
2885  logical :: shoc_cld
2886  logical :: cscnv
2887  logical :: do_shoc
2888  logical :: shocaftcnv
2889 
2890 
2891  ! Radiation option control parameters
2892  real (kind=kind_phys) :: si(levr+1)
2893  integer :: ictm, isol, ico2, iaer, ialb, iems
2894  integer :: iovr_sw, iovr_lw, isubc_sw, isubc_lw
2895  integer :: idate(4), iflip
2896  logical :: sas_shal, crick_proof, ccnorm, norad_precip
2897 
2898  ! for set_vegtype
2899  integer :: nlunit
2900 
2901  integer :: kindphys
2902 
2903  real (kind=kind_phys) :: si_loc(levr+1)
2904 
2905  call dbgprint("phys_init_readin")
2906 
2907  if (debug) then
2908  print *, "BEFORE INIT READ"
2909  print *, "---------------------------"
2910 
2911  print *, "ntcw : ", ntcw
2912  print *, "ncld : ", ncld
2913  print *, "ntoz : ", ntoz
2914  print *, "NTRAC : ", ntrac
2915  print *, "levs : ", levs
2916  print *, "me : ", me
2917  print *, "lsoil : ", lsoil
2918  print *, "lsm : ", lsm
2919  print *, "nmtvr : ", nmtvr
2920  print *, "nrcm : ", nrcm
2921  print *, "levozp : ", levozp
2922  print *, "lonr : ", lonr
2923  print *, "latr : ", latr
2924  print *, "jcap : ", jcap
2925  print *, "num_p3d : ", num_p3d
2926  print *, "num_p2d : ", num_p2d
2927  print *, "npdf3d : ", npdf3d
2928  print *, "ncnvcld3d : ", ncnvcld3d
2929  print *, "pl_coeff : ", pl_coeff
2930  print *, "ncw : ", ncw
2931  print *, "crtrh : ", crtrh
2932  print *, "cdmbgwd : ", cdmbgwd
2933  print *, "ccwf : ", ccwf
2934  print *, "dlqf : ", dlqf
2935  print *, "ctei_rm : ", ctei_rm
2936  print *, "cgwf : ", cgwf
2937  print *, "prslrd0 : ", prslrd0
2938  print *, "ral_ts : ", ral_ts
2939  print *, "ras : ", ras
2940  print *, "pre_rad : ", pre_rad
2941  print *, "ldiag3d : ", ldiag3d
2942  print *, "lgocart : ", lgocart
2943  print *, "lssav_cpl : ", lssav_cpl
2944  print *, "flipv : ", flipv
2945  print *, "old_monin : ", old_monin
2946  print *, "cnvgwd : ", cnvgwd
2947  print *, "shal_cnv : ", shal_cnv
2948  print *, "imfshalcnv : ", imfshalcnv
2949  print *, "imfdeepcnv : ", imfdeepcnv
2950  print *, "cal_pre : ", cal_pre
2951  print *, "mom4ice : ", mom4ice
2952  print *, "mstrat : ", mstrat
2953  print *, "trans_trac : ", trans_trac
2954  print *, "nstf_name : ", nstf_name
2955  print *, "moist_adj : ", moist_adj
2956  print *, "thermodyn_id : ", thermodyn_id
2957  print *, "sfcpress_id : ", sfcpress_id
2958  print *, "gen_coord_hybrid : ", gen_coord_hybrid
2959  print *, "levr : ", levr
2960  print *, "lsidea : ", lsidea
2961  print *, "pdfcld : ", pdfcld
2962  print *, "shcnvcw : ", shcnvcw
2963  print *, "redrag : ", redrag
2964  print *, "hybedmf : ", hybedmf
2965  print *, "dspheat : ", dspheat
2966  print *, "dxmaxin : ", dxmaxin
2967  print *, "dxminin : ", dxminin
2968  print *, "dxinvin : ", dxinvin
2969  print *, "si : ", si
2970  print *, "ictm : ", ictm
2971  print *, "isol : ", isol
2972  print *, "ico2 : ", ico2
2973  print *, "iaer : ", iaer
2974  print *, "ialb : ", ialb
2975  print *, "iems : ", iems
2976  print *, "iovr_sw : ", iovr_sw
2977  print *, "iovr_lw : ", iovr_lw
2978  print *, "isubc_sw : ", isubc_sw
2979  print *, "isubc_lw : ", isubc_lw
2980  print *, "sas_shal : ", sas_shal
2981  print *, "crick_proof : ", crick_proof
2982  print *, "ccnorm : ", ccnorm
2983  print *, "norad_precip : ", norad_precip
2984  print *, "idate : ", idate
2985  print *, "iflip : ", iflip
2986  print *, "cscnv : ", cscnv
2987  print *, "nctp : ", nctp
2988  print *, "ntke : ", ntke
2989  print *, "do_shoc : ", do_shoc
2990  print *, "shocaftcnv : ", shocaftcnv
2991  print *, "ntot3d : ", ntot3d
2992  print *, "ntot2d : ", ntot2d
2993  print *, "shoc_cld : ", shoc_cld
2994  end if
2995 
2996 
2997  ! open file
2998  open (funit, file='init_savein.dat', status='old', form='unformatted', iostat=ios)
2999 
3000  ! read each record
3001  read (funit, iostat=ios, err=900) levr_loc
3002 
3003  read (funit, iostat=ios, err=900) ntcw, ncld, ntoz, ntrac, levs, me, lsoil, lsm, nmtvr, nrcm, levozp, &
3004  lonr, latr, jcap, num_p3d, num_p2d, npdf3d, ncnvcld3d, pl_coeff, ncw, nstf_name, &
3005  thermodyn_id, sfcpress_id, crtrh, cdmbgwd, &
3006  ccwf, dlqf, ctei_rm, cgwf, prslrd0, ral_ts, ras, pre_rad, ldiag3d, lgocart, &
3007  lssav_cpl, flipv, old_monin, cnvgwd, shal_cnv, imfshalcnv, imfdeepcnv, cal_pre, mom4ice, &
3008  mstrat, trans_trac, moist_adj, &
3009  gen_coord_hybrid, lsidea, pdfcld, shcnvcw, redrag, hybedmf, dspheat, &
3010  dxmaxin, dxminin, dxinvin, &
3011  cscnv, nctp, ntke, do_shoc, shocaftcnv, ntot3d, ntot2d
3012 
3013  read (funit, iostat=ios, err=900) si
3014  read (funit, iostat=ios, err=900) ictm
3015  read (funit, iostat=ios, err=900) isol
3016  read (funit, iostat=ios, err=900) ico2
3017  read (funit, iostat=ios, err=900) iaer
3018  read (funit, iostat=ios, err=900) ialb
3019  read (funit, iostat=ios, err=900) iems
3020  read (funit, iostat=ios, err=900) iovr_sw
3021  read (funit, iostat=ios, err=900) iovr_lw
3022  read (funit, iostat=ios, err=900) isubc_sw
3023  read (funit, iostat=ios, err=900) isubc_lw
3024  read (funit, iostat=ios, err=900) shoc_cld
3025  read (funit, iostat=ios, err=900) sas_shal
3026  read (funit, iostat=ios, err=900) crick_proof
3027  read (funit, iostat=ios, err=900) ccnorm
3028  read (funit, iostat=ios, err=900) norad_precip
3029  read (funit, iostat=ios, err=900) idate
3030  read (funit, iostat=ios, err=900) iflip
3031  read (funit, iostat=ios, err=900) nlunit
3032 
3033  ! close file
3034  close (funit, iostat=ios)
3035 
3036  ! Set physcons module variables
3037  dxmax = dxmaxin
3038  dxmin = dxminin
3039  dxinv = dxinvin
3040 
3041  if (debug) then
3042  print *, "AFTER INIT READ"
3043  print *, "---------------------------"
3044  print *, "ntcw : ", ntcw
3045  print *, "ncld : ", ncld
3046  print *, "ntoz : ", ntoz
3047  print *, "NTRAC : ", ntrac
3048  print *, "levs : ", levs
3049  print *, "me : ", me
3050  print *, "lsoil : ", lsoil
3051  print *, "lsm : ", lsm
3052  print *, "nmtvr : ", nmtvr
3053  print *, "nrcm : ", nrcm
3054  print *, "levozp : ", levozp
3055  print *, "lonr : ", lonr
3056  print *, "latr : ", latr
3057  print *, "jcap : ", jcap
3058  print *, "num_p3d : ", num_p3d
3059  print *, "num_p2d : ", num_p2d
3060  print *, "npdf3d : ", npdf3d
3061  print *, "ncnvcld3d : ", ncnvcld3d
3062  print *, "pl_coeff : ", pl_coeff
3063  print *, "ncw : ", ncw
3064  print *, "crtrh : ", crtrh
3065  print *, "cdmbgwd : ", cdmbgwd
3066  print *, "ccwf : ", ccwf
3067  print *, "dlqf : ", dlqf
3068  print *, "ctei_rm : ", ctei_rm
3069  print *, "cgwf : ", cgwf
3070  print *, "prslrd0 : ", prslrd0
3071  print *, "ral_ts : ", ral_ts
3072  print *, "ras : ", ras
3073  print *, "pre_rad : ", pre_rad
3074  print *, "ldiag3d : ", ldiag3d
3075  print *, "lgocart : ", lgocart
3076  print *, "lssav_cpl : ", lssav_cpl
3077  print *, "flipv : ", flipv
3078  print *, "old_monin : ", old_monin
3079  print *, "cnvgwd : ", cnvgwd
3080  print *, "shal_cnv : ", shal_cnv
3081  print *, "imfshalcnv : ", imfshalcnv
3082  print *, "imfdeepcnv : ", imfdeepcnv
3083  print *, "cal_pre : ", cal_pre
3084  print *, "mom4ice : ", mom4ice
3085  print *, "mstrat : ", mstrat
3086  print *, "trans_trac : ", trans_trac
3087  print *, "nstf_name : ", nstf_name
3088  print *, "moist_adj : ", moist_adj
3089  print *, "thermodyn_id : ", thermodyn_id
3090  print *, "sfcpress_id : ", sfcpress_id
3091  print *, "gen_coord_hybrid : ", gen_coord_hybrid
3092  print *, "levr : ", levr
3093  print *, "levr_loc : ", levr_loc
3094  print *, "lsidea : ", lsidea
3095  print *, "pdfcld : ", pdfcld
3096  print *, "shcnvcw : ", shcnvcw
3097  print *, "redrag : ", redrag
3098  print *, "hybedmf : ", hybedmf
3099  print *, "dspheat : ", dspheat
3100  print *, "dxmaxin : ", dxmaxin
3101  print *, "dxminin : ", dxminin
3102  print *, "dxinvin : ", dxinvin
3103  print *, "si : ", si
3104  print *, "ictm : ", ictm
3105  print *, "isol : ", isol
3106  print *, "ico2 : ", ico2
3107  print *, "iaer : ", iaer
3108  print *, "ialb : ", ialb
3109  print *, "iems : ", iems
3110  print *, "iovr_sw : ", iovr_sw
3111  print *, "iovr_lw : ", iovr_lw
3112  print *, "isubc_sw : ", isubc_sw
3113  print *, "isubc_lw : ", isubc_lw
3114  print *, "sas_shal : ", sas_shal
3115  print *, "crick_proof : ", crick_proof
3116  print *, "ccnorm : ", ccnorm
3117  print *, "norad_precip : ", norad_precip
3118  print *, "idate : ", idate
3119  print *, "iflip : ", iflip
3120  print *, "cscnv : ", cscnv
3121  print *, "nctp : ", nctp
3122  print *, "ntke : ", ntke
3123  print *, "do_shoc : ", do_shoc
3124  print *, "shocaftcnv : ", shocaftcnv
3125  print *, "ntot3d : ", ntot3d
3126  print *, "ntot2d : ", ntot2d
3127  print *, "shoc_cld : ", shoc_cld
3128  end if ! debug
3129 
3130  ! report any errors
3131 900 if (ios .ne. 0 ) print *, "DBG NUOPC IOERR : ", ios
3132 
3133  end subroutine
3134 
3135 
3136 
3138  subroutine nuopc_rad_update(mdl, dyn)
3140  implicit none
3141 
3142  type(model_parameters) :: mdl
3143  type(dynamic_parameters) :: dyn
3144 
3145  call radupdate ( mdl%idat, dyn%jdate, dyn%dtsw, dyn%deltim, dyn%lsswr, &
3146  mdl%me, dyn%slag, dyn%sdec, dyn%cdec, dyn%solcon )
3147 
3148  end subroutine
3149 
3150 
3152  subroutine nuopc_rad_run (statein, sfc_prop, diags, intrfc_fld, cld_prop, rad_tend, mdl_parm, dyn_parm)
3154  implicit none
3155 
3156  type(state_fields_in) :: statein
3157  type(sfc_properties) :: sfc_prop
3158  type(diagnostics) :: diags
3159  type(interface_fields) :: intrfc_fld
3160  type(cloud_properties) :: cld_prop
3161  type(radiation_tendencies) :: rad_tend
3162  type(model_parameters) :: mdl_parm
3163  type(dynamic_parameters) :: dyn_parm
3164 
3165  ! class(model_parameters) :: mdl_parm ! (Polymorphic type)
3166 
3167  ! call to grrad, using all of the nuopc field variables
3168 
3169  call dbgprint("entering nuopc_rad_run")
3170 
3171  call grrad(statein%prsi, statein%prsl, statein%prslk, &
3172  statein%tgrs, statein%qgrs_rad, &
3173  statein%tracer, statein%vvl, sfc_prop%slmsk, &
3174  dyn_parm%xlon, dyn_parm%xlat, &
3175  sfc_prop%tsfc, sfc_prop%snowd, sfc_prop%sncovr, &
3176  sfc_prop%snoalb, sfc_prop%zorl, &
3177  sfc_prop%hprim, sfc_prop%alvsf, sfc_prop%alnsf, &
3178  sfc_prop%alvwf, sfc_prop%alnwf, &
3179  sfc_prop%facsf, sfc_prop%facwf, sfc_prop%fice, &
3180  sfc_prop%tisfc, dyn_parm%sinlat, &
3181  dyn_parm%coslat, dyn_parm%solhr, dyn_parm%jdate, &
3182  dyn_parm%solcon, cld_prop%cv, &
3183  cld_prop%cvt, cld_prop%cvb, cld_prop%fcice, &
3184  cld_prop%frain, cld_prop%rrime, &
3185  cld_prop%flgmin, dyn_parm%icsdsw, dyn_parm%icsdlw, &
3186  mdl_parm%ntcw-1, mdl_parm%ncld, mdl_parm%ntoz-1, &
3187  statein%ntl, diags%NFXR, dyn_parm%dtlw, dyn_parm%dtsw, &
3188  dyn_parm%lsswr, dyn_parm%lslwr, dyn_parm%lssav, statein%uni_cld, & !mdl_parm%shoc_cld,
3189  dyn_parm%lmfshal, dyn_parm%lmfdeep2, dyn_parm%IX, dyn_parm%IM, &
3190  mdl_parm%levr, mdl_parm%me, dyn_parm%lprnt, &
3191  dyn_parm%ipt, dyn_parm%kdt, &
3192  cld_prop%deltaq, cld_prop%sup, cld_prop%cnvw, cld_prop%cnvc, &
3193 ! Outputs
3194  rad_tend%htrsw, diags%topfsw, intrfc_fld%sfcfsw, &
3195  diags%dswcmp, diags%uswcmp, rad_tend%sfalb, &
3196  rad_tend%coszen, rad_tend%coszdg, rad_tend%htrlw, &
3197  diags%topflw, intrfc_fld%sfcflw,&
3198  rad_tend%tsflw, rad_tend%semis, cld_prop%cldcov, &
3199 ! In/Out
3200  diags%fluxr, htrlw0=rad_tend%hlwc_v,htrsw0=rad_tend%swhc_v)
3201 
3202 ! intrfc_fld%sfcnsw(:) = intrfc_fld%sfcfsw(:)%dnfxc - intrfc_fld%sfcfsw(:)%upfxc
3203 ! intrfc_fld%sfcdsw(:) = intrfc_fld%sfcfsw(:)%dnfxc
3204 ! intrfc_fld%sfcdlw(:) = intrfc_fld%sfcflw(:)%dnfxc
3205 
3206  call dbgprint("leaving nuopc_rad_run")
3207 
3208  end subroutine
3209 
3210 
3211  subroutine nuopc_sppt_phys ( stateout, diag, intr, rad, mdl, tbd, dyn)
3213  implicit none
3214 
3215 ! type(state_fields_in) :: statein
3216  type(state_fields_out) :: stateout
3217 ! type(sfc_properties) :: sfc
3218  type(diagnostics) :: diag
3219  type(interface_fields) :: intr
3220 ! type(cloud_properties) :: cld
3221  type(radiation_tendencies) :: rad
3222  type(model_parameters) :: mdl
3223  type(tbd_ddt) :: tbd
3224  type(dynamic_parameters) :: dyn
3225 
3226  if (intr%s_do_sppt) then
3227 !============original code==================================
3228 ! do j=1,dyn%im
3229 ! do k=1,mdl%levs
3230 ! sppt_wts(j,k) = grid_fld%sppt_wts(lon+j-1,lan,k)
3231 ! enddo
3232 ! enddo !stateout%gt0, stateout%gq0, stateout%gu0,
3233 ! stateout%gv0
3234 ! where(rad%dtdtr(:,:) >= 10.0 .or. rad%dtdtr(:,:) .lt. 0.)
3235 ! print*,'rad%dtdtr', rad%dtdtr
3236 ! rad%dtdtr=0.0333
3237 ! end where
3238 ! print*,'rad%dtdtr', rad%dtdtr
3239 !!= intr%s_tphys = stateout%gt0 - intr%s_gt0 - rad%dtdtr ! remove radiation contribution
3240 ! intr%s_uphys = stateout%gu0 - intr%s_gu0
3241 ! intr%s_vphys = stateout%gv0 - intr%s_gv0
3242 ! intr%s_qphys = stateout%gq0(:,:,1) - intr%s_gr0(:,:,1)
3243 !! perturb increments (adding radiation contribution back in)
3244 ! intr%s_tphys(:,:) = intr%s_tphys(:,:)*intr%s_sppt_wts(:,:) + intr%s_gt0 + rad%dtdtr
3245 ! intr%s_uphys(:,:) = intr%s_uphys(:,:)*intr%s_sppt_wts(:,:) + intr%s_gu0
3246 ! intr%s_vphys(:,:) = intr%s_vphys(:,:)*intr%s_sppt_wts(:,:) + intr%s_gv0
3247 ! intr%s_qphys(:,:) = intr%s_qphys(:,:)*intr%s_sppt_wts(:,:) + intr%s_gr0(:,:,1)
3248 !! precip perturbations
3249 ! intr%s_tpphys(:)= diag%totprcp(:)- intr%s_totprcp0(:)
3250 ! intr%s_cpphys(:)= diag%cnvprcp(:)- intr%s_cnvprcp0(:)
3251 ! intr%s_raincpl(:)= intr%rain_cpl(:)-intr%s_cplrain0(:)
3252 ! intr%s_snowcpl(:)= intr%snow_cpl(:)-intr%s_cplsnow0(:)
3253 ! diag%totprcp(:) = intr%s_tpphys(:)*intr%s_sppt_wts(:,3)+intr%s_totprcp0(:)
3254 ! diag%cnvprcp(:) = intr%s_cpphys(:)*intr%s_sppt_wts(:,3)+intr%s_cnvprcp0(:)
3255 ! tbd%tprcp(:)=tbd%tprcp(:)*intr%s_sppt_wts(:,3)
3256 ! intr%rain_cpl(:)=intr%s_raincpl(:)*intr%s_sppt_wts(:,3)+intr%s_cplrain0(:)
3257 ! intr%snow_cpl(:)=intr%s_snowcpl(:)*intr%s_sppt_wts(:,3)+intr%s_cplsnow0(:)
3258 ! intr%Qrain(:)=intr%Qrain(:)*intr%s_sppt_wts(:,3)
3259 !
3260 !! check for negative humidities
3261 ! where(intr%s_qphys(:,:) <= 0)
3262 ! intr%s_tphys(:,:) = stateout%gt0(:,:)
3263 ! intr%s_qphys(:,:) = stateout%gq0(:,:,1)
3264 !! elsewhere
3265 !! stateout%gt0(:,:) = intr%s_tphys(:,:)
3266 !! stateout%gq0(:,:,1) = intr%s_qphys(:,:)
3267 ! end where
3268 !! put new grid back into adjusted variables
3269 ! stateout%gu0 = intr%s_uphys
3270 ! stateout%gv0 = intr%s_vphys
3271 ! stateout%gt0 = intr%s_tphys
3272 !!!= stateout%gq0(:,:,1) = intr%s_qphys(:,:)
3273 !==========new simplified====================
3274  stateout%gu0 = intr%s_gu0+ &
3275  (stateout%gu0-intr%s_gu0)*intr%s_sppt_wts
3276  stateout%gv0 = intr%s_gv0 + &
3277  (stateout%gv0 - intr%s_gv0)*intr%s_sppt_wts
3278 
3280  where(intr%s_qphys(:,:) .gt. 0.0)
3281  stateout%gt0(:,:) = intr%s_gt0 +rad%dtdtr + &
3282  (stateout%gt0(:,:)-intr%s_gt0-rad%dtdtr)*intr%s_sppt_wts
3283  stateout%gq0(:,:,1) = intr%s_gr0(:,:,1) + &
3284  (stateout%gq0(:,:,1)-intr%s_gr0(:,:,1))*intr%s_sppt_wts
3285  end where
3286  diag%totprcp(:)=(diag%totprcp(:)-intr%s_totprcp0(:))* &
3287  intr%s_sppt_wts(:,3)+intr%s_totprcp0(:)
3288  diag%cnvprcp(:) = (diag%cnvprcp(:)- intr%s_cnvprcp0(:))* &
3289  intr%s_sppt_wts(:,3)+intr%s_cnvprcp0(:)
3290  tbd%tprcp(:)=tbd%tprcp(:)*intr%s_sppt_wts(:,3)
3291  intr%rain_cpl(:)=(intr%rain_cpl(:)-intr%s_cplrain0(:))* &
3292  intr%s_sppt_wts(:,3)+intr%s_cplrain0(:)
3293  intr%snow_cpl(:)=(intr%snow_cpl(:)-intr%s_cplsnow0(:))* &
3294  intr%s_sppt_wts(:,3)+intr%s_cplsnow0(:)
3295  intr%Qrain(:)=intr%Qrain(:)*intr%s_sppt_wts(:,3)
3296  endif
3297 ! do_sppt
3298 ! code section for SHUM stocastic perturbations
3299  if (intr%s_do_shum) then
3300 ! do j=1,dyn%im
3301 ! do k=1,mdl%levs
3302 ! shum_wts(j,k) = grid_fld%shum_wts(lon+j-1,lan,k)
3303 ! enddo
3304 ! enddo
3305  stateout%gq0(:,:,1) = stateout%gq0(:,:,1)*(1. + intr%s_shum_wts)
3306  endif
3307 ! do_shum
3308 !!! code section for additive noise (SKEB) perturbation
3309  if (intr%s_do_skeb) then
3310 ! do j=1,dyn%im
3311 ! do k=1,mdl%levs
3312 ! skebu_wts(j,k) = grid_fld%skebu_wts(lon+j-1,lan,k)
3313 ! skebv_wts(j,k) = grid_fld%skebv_wts(lon+j-1,lan,k)
3314 ! enddo
3315 ! enddo
3316  stateout%gu0 = stateout%gu0 + intr%s_skebu_wts
3317  stateout%gv0 = stateout%gv0 + intr%s_skebv_wts
3318  endif ! do_skeb
3319 !!! code section for vorticity confinement perturbation.
3320  if (intr%s_do_vc) then
3321 ! do j=1,dyn%im
3322 ! do k=1,mdl%levs
3323 ! vcu_wts(j,k) = grid_fld%vcu_wts(lon+j-1,lan,k)
3324 ! vcv_wts(j,k) = grid_fld%vcv_wts(lon+j-1,lan,k)
3325 ! enddo
3326 ! enddo
3327  stateout%gu0 = stateout%gu0 + intr%s_vcu_wts
3328  stateout%gv0 = stateout%gv0 + intr%s_vcv_wts
3329  endif ! do_vc
3330 
3331 !! end of stochastic physics code
3332 
3333  end subroutine
3334 
3335  subroutine nuopc_phys_run (statein, stateout, sfc, diag, intr, cld, rad, mdl, tbd, dyn)
3337  implicit none
3338 
3339  type(state_fields_in) :: statein
3340  type(state_fields_out) :: stateout
3341  type(sfc_properties) :: sfc
3342  type(diagnostics) :: diag
3343  type(interface_fields) :: intr
3344  type(cloud_properties) :: cld
3345  type(radiation_tendencies) :: rad
3346  type(model_parameters) :: mdl
3347  type(tbd_ddt) :: tbd
3348  type(dynamic_parameters) :: dyn
3349  integer :: i,j,k,l
3350 !-----initialize for stochastic physics---
3351  intr%s_gt0=statein%tgrs
3352  intr%s_gr0=statein%qgrs
3353  intr%s_gu0=statein%ugrs
3354  intr%s_gv0=statein%vgrs
3355  intr%s_cplrain0(:)=intr%rain_cpl(:)
3356  intr%s_cplsnow0(:)=intr%snow_cpl(:)
3357  intr%s_totprcp0(:)=diag%totprcp(:)
3358  intr%s_cnvprcp0(:)=diag%cnvprcp(:)
3359 !----------------------------------------
3360 
3361 
3362  if (mdl%me .eq. 1) call dbgprint("entering nuopc_phys_run")
3363  if (mdl%ntoz > 0) then
3364  call ozinterpol( mdl%me,mdl%lats_node_r,mdl%lats_node_r,mdl%idate,dyn%fhour, &
3365  mdl%jindx1,mdl%jindx2,mdl%ozplin,tbd%o3out,mdl%ddy)
3366 ! print*,'lats_node_r', tbd%lats_node_r
3367  do j=1,mdl%pl_coeff
3368  do k=1,mdl%levozp
3369  do i=1,dyn%im
3370  tbd%prdout(i,k,j) = tbd%o3out(k,tbd%lan,j)
3371  enddo
3372  enddo
3373  enddo
3374  endif
3375 
3376  if (mdl%h2o_phys) then
3377  call h2ointerpol(mdl%me,mdl%lats_node_r,mdl%lats_node_r,mdl%idate,dyn%fhour, &
3378  mdl%jindx1_h,mdl%jindx2_h,mdl%h2oplin,tbd%h2oplout,mdl%ddy_h)
3379  do j=1,mdl%h2o_coeff
3380  do k=1,mdl%levh2o
3381  do i=1,dyn%ix
3382  tbd%h2oplout_v(i,k,j) = tbd%h2oplout(k,tbd%lan,j)
3383  enddo
3384  enddo
3385  enddo
3386  endif
3387 
3388  call gbphys ( dyn%im, dyn%ix, mdl%levs, &
3389  mdl%lsoil, mdl%lsm, mdl%ntrac, &
3390  mdl%ncld, mdl%ntoz, mdl%ntcw, &
3391  mdl%ntke, mdl%ntiw, mdl%ntlnc, &
3392  mdl%ntinc, mdl%nmtvr, mdl%nrcm, &
3393  mdl%levozp, mdl%lonr, mdl%latr, &
3394  mdl%jcap, mdl%num_p3d, mdl%num_p2d, &
3395  mdl%npdf3d, mdl%ncnvcld3d, dyn%kdt, &
3396  dyn%lat, mdl%me, mdl%pl_coeff, &
3397  dyn%nlons, mdl%ncw, cld%flgmin, &
3398  mdl%crtrh, mdl%cdmbgwd, mdl%ccwf, &
3399  mdl%dlqf, mdl%ctei_rm, dyn%clstp, &
3400  mdl%cgwf, mdl%prslrd0, mdl%ral_ts, &
3401  dyn%dtp, dyn%dtf, dyn%fhour, &
3402  dyn%solhr, dyn%slag, dyn%sdec, &
3403  dyn%cdec, dyn%sinlat, dyn%coslat, &
3404  statein%pgr, statein%ugrs, statein%vgrs, &
3405  statein%tgrs, statein%qgrs, statein%vvl, &
3406  statein%prsi, statein%prsl, statein%prslk, &
3407  statein%prsik, statein%phii, statein%phil, &
3408  tbd%rann, tbd%prdout, tbd%poz, &
3409  tbd%dpshc, tbd%fscav, tbd%fswtr, &
3410  sfc%hprime2, dyn%xlon, dyn%xlat, &
3411  mdl%h2o_phys, mdl%levh2o, tbd%h2oplout_v, &
3412  mdl%h2o_pres, mdl%h2o_coeff, mdl%isot, &
3413  mdl%ivegsrc, sfc%slope, sfc%shdmin, &
3414  sfc%shdmax, sfc%snoalb, sfc%tg3, &
3415  sfc%slmsk, sfc%vfrac, sfc%vtype, &
3416  sfc%stype, sfc%uustar, sfc%oro, &
3417  sfc%oro_uf, rad%coszen, intr%sfcdsw, &
3418  intr%sfcnsw, intr%sfcnirbmd, intr%sfcnirdfd, &
3419  intr%sfcvisbmd, intr%sfcvisdfd, intr%sfcnirbmu, &
3420  intr%sfcnirdfu, intr%sfcvisbmu, intr%sfcvisdfu, &
3421  intr%slimskin_cpl,intr%ulwsfcin_cpl, intr%dusfcin_cpl,&
3422  intr%dvsfcin_cpl, intr%dtsfcin_cpl, intr%dqsfcin_cpl, &
3423  intr%sfcdlw, rad%tsflw, rad%semis, &
3424  rad%sfalb, rad%htrsw, rad%swhc, &
3425  rad%htrlw, rad%hlwc, rad%hlwd, &
3426  mdl%lsidea, mdl%ras, mdl%pre_rad, & !mdl%lsidea
3427  mdl%ldiag3d, mdl%lgocart, dyn%lssav, &
3428  mdl%lssav_cpl, tbd%xkzm_m, tbd%xkzm_h, &
3429  tbd%xkzm_s, tbd%psautco, tbd%prautco, &
3430  tbd%evpco, tbd%wminco, mdl%pdfcld, &
3431  mdl%shcnvcw, cld%sup, mdl%redrag, &
3432  mdl%hybedmf, mdl%dspheat, mdl%flipv, &
3433  mdl%old_monin, mdl%cnvgwd, mdl%shal_cnv, &
3434  mdl%imfshalcnv, mdl%imfdeepcnv, mdl%cal_pre, .false., &
3435  mdl%mom4ice, mdl%mstrat, mdl%trans_trac, &
3436  mdl%nstf_name, mdl%moist_adj, mdl%thermodyn_id, &
3437  mdl%sfcpress_id, mdl%gen_coord_hybrid, mdl%levr, &
3438  statein%adjtrc, dyn%nnp, &
3439 ! Add new nems_slg_shoc arguments
3440  mdl%cscnv, mdl%nctp, mdl%do_shoc, &
3441  mdl%shocaftcnv, mdl%ntot3d, mdl%ntot2d, &
3442 ! In/Out
3443  sfc%hice, sfc%fice, sfc%tisfc, &
3444  sfc%tsfc, tbd%tprcp, cld%cv, &
3445  cld%cvb, cld%cvt, tbd%srflag, &
3446  sfc%snowd, sfc%weasd, sfc%sncovr, &
3447  sfc%zorl, sfc%canopy, sfc%ffmm, &
3448  sfc%ffhh, sfc%f10m, diag%srunoff, &
3449  diag%evbsa, diag%evcwa, diag%snohfa, &
3450  diag%transa, diag%sbsnoa, diag%snowca, &
3451  diag%soilm, diag%tmpmin, diag%tmpmax, &
3452  diag%dusfc, diag%dvsfc, diag%dtsfc, &
3453  diag%dqsfc, diag%totprcp, diag%gflux, &
3454  diag%dlwsfc, diag%ulwsfc, diag%suntim, &
3455  diag%runoff, diag%ep, diag%cldwrk, &
3456  diag%dugwd, diag%dvgwd, diag%psmean, &
3457  diag%cnvprcp, diag%spfhmin, diag%spfhmax, &
3458  diag%rain, diag%rainc, diag%dt3dt, &
3459  diag%dq3dt, diag%du3dt, diag%dv3dt, &
3460  diag%dqdt_v, cld%cnvqc_v, tbd%acv, &
3461  tbd%acvb, tbd%acvt, tbd%slc, &
3462  tbd%smc, tbd%stc, tbd%upd_mf, &
3463  tbd%dwn_mf, tbd%det_mf, tbd%phy_f3d, &
3464  tbd%phy_f2d, intr%dusfc_cpl, intr%dvsfc_cpl, &
3465  intr%dtsfc_cpl, intr%dqsfc_cpl, intr%dlwsfc_cpl, &
3466  intr%dswsfc_cpl, intr%dnirbm_cpl, intr%dnirdf_cpl, &
3467  intr%dvisbm_cpl, intr%dvisdf_cpl, intr%rain_cpl, &
3468  intr%nlwsfc_cpl, intr%nswsfc_cpl, intr%nnirbm_cpl, &
3469  intr%nnirdf_cpl, intr%nvisbm_cpl, intr%nvisdf_cpl, &
3470  intr%snow_cpl, intr%xt, intr%xs, &
3471  intr%xu, intr%xv, intr%xz, &
3472  intr%zm, intr%xtts, intr%xzts, &
3473  intr%d_conv, intr%ifd, intr%dt_cool, &
3474  intr%Qrain, tbd%tref, tbd%z_c, &
3475  tbd%c_0, tbd%c_d, tbd%w_0, &
3476  tbd%w_d, &
3477 ! NEW
3478  tbd%phy_fctd, &
3479 ! Out
3480  stateout%gt0, stateout%gq0, stateout%gu0, &
3481  stateout%gv0, sfc%t2m, sfc%q2m, &
3482  diag%u10m, diag%v10m, diag%zlvl, &
3483  diag%psurf, diag%hpbl, diag%pwat, &
3484  diag%t1, diag%q1, diag%u1, &
3485  diag%v1, diag%chh, diag%cmm, &
3486  diag%dlwsfci, diag%ulwsfci, diag%dswsfci, &
3487  diag%uswsfci, diag%dusfci, diag%dvsfci, &
3488  diag%dtsfci, diag%dqsfci, diag%gfluxi, &
3489  diag%epi, diag%smcwlt2, diag%smcref2, &
3490  diag%wet1, diag%sr, rad%rqtk, &
3491  rad%dtdtr, intr%dusfci_cpl, intr%dvsfci_cpl, &
3492  intr%dtsfci_cpl, intr%dqsfci_cpl, intr%dlwsfci_cpl, &
3493  intr%dswsfci_cpl, intr%dnirbmi_cpl, intr%dnirdfi_cpl, &
3494  intr%dvisbmi_cpl, intr%dvisdfi_cpl, intr%nlwsfci_cpl, &
3495  intr%nswsfci_cpl, intr%nnirbmi_cpl, intr%nnirdfi_cpl, &
3496  intr%nvisbmi_cpl, intr%nvisdfi_cpl, intr%t2mi_cpl, &
3497  intr%q2mi_cpl, intr%u10mi_cpl, intr%v10mi_cpl, &
3498  intr%tseai_cpl, intr%psurfi_cpl &
3499  )
3500  end subroutine
3501 
3502 
3503 
3504 
3506  subroutine rad_run_savein (statein, sfc_prop, diags, intrfc_fld, cld_prop, rad_tend, mdl_parm, dyn_parm)
3508  implicit none
3509 
3510  type(state_fields_in) :: statein
3511  type(sfc_properties) :: sfc_prop
3512  type(diagnostics) :: diags
3513  type(interface_fields) :: intrfc_fld
3514  type(cloud_properties) :: cld_prop
3515  type(radiation_tendencies) :: rad_tend
3516  type(model_parameters) :: mdl_parm
3517  type(dynamic_parameters) :: dyn_parm
3518 
3519  ! need a file unit and filename to write to
3520  integer, parameter :: funit = 99
3521  integer :: ios
3522 
3523  call dbgprint("rad_run_savein")
3524 
3525  ! open file
3526  open (funit, file='radrun_savein.dat', status='new', form='unformatted', iostat=ios)
3527 
3528  ! write each record
3529  write (funit, iostat=ios, err=900) &
3530  statein%prsi, statein%prsl, statein%prslk, &
3531  statein%tgrs, statein%qgrs_rad, &
3532  statein%tracer, statein%vvl, sfc_prop%slmsk, &
3533  dyn_parm%xlon, dyn_parm%xlat, &
3534  sfc_prop%tsfc, sfc_prop%snowd, sfc_prop%sncovr, &
3535  sfc_prop%snoalb, sfc_prop%zorl, &
3536  sfc_prop%hprim, sfc_prop%alvsf, sfc_prop%alnsf, &
3537  sfc_prop%alvwf, sfc_prop%alnwf, &
3538  sfc_prop%facsf, sfc_prop%facwf, sfc_prop%fice, &
3539  sfc_prop%tisfc, dyn_parm%sinlat, &
3540  dyn_parm%coslat, dyn_parm%solhr, dyn_parm%jdate, &
3541  dyn_parm%solcon, cld_prop%cv, &
3542  cld_prop%cvt, cld_prop%cvb, cld_prop%fcice, &
3543  cld_prop%frain, cld_prop%rrime, &
3544  cld_prop%flgmin, dyn_parm%icsdsw, dyn_parm%icsdlw, &
3545  mdl_parm%ntcw-1, mdl_parm%ncld, mdl_parm%ntoz-1, &
3546  mdl_parm%NTRAC-1, diags%NFXR, dyn_parm%dtlw, &
3547  dyn_parm%dtsw, dyn_parm%lsswr, dyn_parm%lslwr, &
3548  dyn_parm%lssav, mdl_parm%shoc_cld, dyn_parm%lmfshal, &
3549  dyn_parm%lmfdeep2, dyn_parm%IX, dyn_parm%IM, &
3550  mdl_parm%levr, mdl_parm%me, dyn_parm%lprnt, &
3551  dyn_parm%ipt, dyn_parm%kdt, cld_prop%deltaq, &
3552  cld_prop%sup, cld_prop%cnvw, cld_prop%cnvc, &
3553 ! In/Out
3554  diags%fluxr
3555 
3556  flush (funit, iostat=ios, err=900)
3557 
3558  ! close file
3559  close (funit, iostat=ios)
3560 
3561  ! report any errors
3562 900 if (ios .ne. 0 ) print *, "DBG NUOPC IOERR : ", ios
3563 
3564  if (debug) then
3565  print *, "AFTER RAD RUN SAVEIN"
3566  print *, "---------------------------"
3567  print *, 'statein%prsi : ',statein%prsi
3568  print *, 'statein%prsl : ',statein%prsl
3569  print *, 'statein%prslk : ',statein%prslk
3570  print *, 'statein%tgrs : ',statein%tgrs
3571  print *, 'statein%qgrs_rad : ',statein%qgrs_rad
3572  print *, 'statein%tracer : ',statein%tracer
3573  print *, 'statein%vvl : ',statein%vvl
3574  print *, 'sfc_prop%slmsk : ',sfc_prop%slmsk
3575  print *, 'dyn_parm%xlon : ',dyn_parm%xlon
3576  print *, 'dyn_parm%xlat : ',dyn_parm%xlat
3577  print *, 'sfc_prop%tsfc : ',sfc_prop%tsfc
3578  print *, 'sfc_prop%snowd : ',sfc_prop%snowd
3579  print *, 'sfc_prop%sncovr : ',sfc_prop%sncovr
3580  print *, 'sfc_prop%snoalb : ',sfc_prop%snoalb
3581  print *, 'sfc_prop%zorl : ',sfc_prop%zorl
3582  print *, 'sfc_prop%hprim : ',sfc_prop%hprim
3583  print *, 'sfc_prop%alvsf : ',sfc_prop%alvsf
3584  print *, 'sfc_prop%alnsf : ',sfc_prop%alnsf
3585  print *, 'sfc_prop%alvwf : ',sfc_prop%alvwf
3586  print *, 'sfc_prop%alnwf : ',sfc_prop%alnwf
3587  print *, 'sfc_prop%facsf : ',sfc_prop%facsf
3588  print *, 'sfc_prop%facwf : ',sfc_prop%facwf
3589  print *, 'sfc_prop%fice : ',sfc_prop%fice
3590  print *, 'sfc_prop%tisfc : ',sfc_prop%tisfc
3591  print *, 'dyn_parm%sinlat : ',dyn_parm%sinlat
3592  print *, 'dyn_parm%coslat : ',dyn_parm%coslat
3593  print *, 'dyn_parm%solhr : ',dyn_parm%solhr
3594  print *, 'dyn_parm%jdate : ',dyn_parm%jdate
3595  print *, 'dyn_parm%solcon : ',dyn_parm%solcon
3596  print *, 'cld_prop%cv : ',cld_prop%cv
3597  print *, 'cld_prop%cvt : ',cld_prop%cvt
3598  print *, 'cld_prop%cvb : ',cld_prop%cvb
3599  print *, 'cld_prop%fcice : ',cld_prop%fcice
3600  print *, 'cld_prop%frain : ',cld_prop%frain
3601  print *, 'cld_prop%rrime : ',cld_prop%rrime
3602  print *, 'cld_prop%flgmin : ',cld_prop%flgmin
3603  print *, 'dyn_parm%icsdsw : ',dyn_parm%icsdsw
3604  print *, 'dyn_parm%icsdlw : ',dyn_parm%icsdlw
3605  print *, 'mdl_parm%ntcw : ',mdl_parm%ntcw
3606  print *, 'mdl_parm%ncld : ',mdl_parm%ncld
3607  print *, 'mdl_parm%ntoz : ',mdl_parm%ntoz
3608  print *, 'mdl_parm%NTRAC : ',mdl_parm%NTRAC
3609  print *, 'diags%NFXR : ',diags%NFXR
3610  print *, 'dyn_parm%dtlw : ',dyn_parm%dtlw
3611  print *, 'dyn_parm%dtsw : ',dyn_parm%dtsw
3612  print *, 'dyn_parm%lsswr : ',dyn_parm%lsswr
3613  print *, 'dyn_parm%lslwr : ',dyn_parm%lslwr
3614  print *, 'dyn_parm%lssav : ',dyn_parm%lssav
3615  print *, 'dyn_parm%lmfshal : ',dyn_parm%lmfshal
3616  print *, 'dyn_parm%lmfdeep2 : ',dyn_parm%lmfdeep2
3617  print *, 'dyn_parm%IX : ',dyn_parm%IX
3618  print *, 'dyn_parm%IM : ',dyn_parm%IM
3619  print *, 'mdl_parm%levs : ',mdl_parm%levs
3620  print *, 'mdl_parm%me : ',mdl_parm%me
3621  print *, 'dyn_parm%lprnt : ',dyn_parm%lprnt
3622  print *, 'dyn_parm%ipt : ',dyn_parm%ipt
3623  print *, 'dyn_parm%kdt : ',dyn_parm%kdt
3624  print *, 'cld_prop%deltaq : ',cld_prop%deltaq
3625  print *, 'cld_prop%sup : ',cld_prop%sup
3626  print *, 'cld_prop%cnvw : ',cld_prop%cnvw
3627  print *, 'cld_prop%cnvc : ',cld_prop%cnvc
3628  print *, 'dyn_parm%deltim : ',dyn_parm%deltim
3629  print *, 'mdl_parm%shoc_cld : ',mdl_parm%shoc_cld
3630 
3631  end if
3632 
3633  end subroutine
3634 
3635 
3637  subroutine rad_run_readin (statein, sfc_prop, diags, intrfc_fld, cld_prop, rad_tend, mdl_parm, dyn_parm)
3639  implicit none
3640 
3641  type(state_fields_in) :: statein
3642  type(sfc_properties) :: sfc_prop
3643  type(diagnostics) :: diags
3644  type(interface_fields) :: intrfc_fld
3645  type(cloud_properties) :: cld_prop
3646  type(radiation_tendencies) :: rad_tend
3647  type(model_parameters) :: mdl_parm
3648  type(dynamic_parameters) :: dyn_parm
3649 
3650  integer, parameter :: funit = 98
3651  integer :: ios
3652 
3653  call dbgprint("rad_run_readin")
3654 
3655  ! open file
3656  open (funit, file='radrun_savein.dat', status='old', form='unformatted', iostat=ios)
3657 
3658  ! read each record
3659  read (funit, iostat=ios, err=900) &
3660  statein%prsi, statein%prsl, statein%prslk, &
3661  statein%tgrs, statein%qgrs_rad, &
3662  statein%tracer, statein%vvl, sfc_prop%slmsk, &
3663  dyn_parm%xlon, dyn_parm%xlat, &
3664  sfc_prop%tsfc, sfc_prop%snowd, sfc_prop%sncovr, &
3665  sfc_prop%snoalb, sfc_prop%zorl, &
3666  sfc_prop%hprim, sfc_prop%alvsf, sfc_prop%alnsf, &
3667  sfc_prop%alvwf, sfc_prop%alnwf, &
3668  sfc_prop%facsf, sfc_prop%facwf, sfc_prop%fice, &
3669  sfc_prop%tisfc, dyn_parm%sinlat, &
3670  dyn_parm%coslat, dyn_parm%solhr, dyn_parm%jdate, &
3671  dyn_parm%solcon, cld_prop%cv, &
3672  cld_prop%cvt, cld_prop%cvb, cld_prop%fcice, &
3673  cld_prop%frain, cld_prop%rrime, &
3674  cld_prop%flgmin, dyn_parm%icsdsw, dyn_parm%icsdlw, &
3675  mdl_parm%ntcw, mdl_parm%ncld, mdl_parm%ntoz, &
3676  mdl_parm%NTRAC, diags%NFXR, dyn_parm%dtlw, &
3677  dyn_parm%dtsw, dyn_parm%lsswr, dyn_parm%lslwr, &
3678  dyn_parm%lssav, mdl_parm%shoc_cld, dyn_parm%lmfshal, &
3679  dyn_parm%lmfdeep2, dyn_parm%IX, dyn_parm%IM, &
3680  mdl_parm%levr, mdl_parm%me, dyn_parm%lprnt, &
3681  dyn_parm%ipt, dyn_parm%kdt, cld_prop%deltaq, &
3682  cld_prop%sup, cld_prop%cnvw, cld_prop%cnvc, &
3683 ! In/Out
3684  diags%fluxr
3685 
3686 
3687  ! close file
3688  close (funit, iostat=ios)
3689 
3690  ! report any errors
3691 900 if (ios .ne. 0 ) print *, "DBG NUOPC IOERR : ", ios
3692 
3693  if (debug) then
3694  print *, "AFTER RAD RUN READIN"
3695  print *, "---------------------------"
3696  print *, 'statein%prsi : ',statein%prsi
3697  print *, 'statein%prsl : ',statein%prsl
3698  print *, 'statein%prslk : ',statein%prslk
3699  print *, 'statein%tgrs : ',statein%tgrs
3700  print *, 'statein%qgrs_rad : ',statein%qgrs_rad
3701  print *, 'statein%tracer : ',statein%tracer
3702  print *, 'statein%vvl : ',statein%vvl
3703  print *, 'sfc_prop%slmsk : ',sfc_prop%slmsk
3704  print *, 'dyn_parm%xlon : ',dyn_parm%xlon
3705  print *, 'dyn_parm%xlat : ',dyn_parm%xlat
3706  print *, 'sfc_prop%tsfc : ',sfc_prop%tsfc
3707  print *, 'sfc_prop%snowd : ',sfc_prop%snowd
3708  print *, 'sfc_prop%sncovr : ',sfc_prop%sncovr
3709  print *, 'sfc_prop%snoalb : ',sfc_prop%snoalb
3710  print *, 'sfc_prop%zorl : ',sfc_prop%zorl
3711  print *, 'sfc_prop%hprim : ',sfc_prop%hprim
3712  print *, 'sfc_prop%alvsf : ',sfc_prop%alvsf
3713  print *, 'sfc_prop%alnsf : ',sfc_prop%alnsf
3714  print *, 'sfc_prop%alvwf : ',sfc_prop%alvwf
3715  print *, 'sfc_prop%alnwf : ',sfc_prop%alnwf
3716  print *, 'sfc_prop%facsf : ',sfc_prop%facsf
3717  print *, 'sfc_prop%facwf : ',sfc_prop%facwf
3718  print *, 'sfc_prop%fice : ',sfc_prop%fice
3719  print *, 'sfc_prop%tisfc : ',sfc_prop%tisfc
3720  print *, 'dyn_parm%sinlat : ',dyn_parm%sinlat
3721  print *, 'dyn_parm%coslat : ',dyn_parm%coslat
3722  print *, 'dyn_parm%solhr : ',dyn_parm%solhr
3723  print *, 'dyn_parm%jdate : ',dyn_parm%jdate
3724  print *, 'dyn_parm%solcon : ',dyn_parm%solcon
3725  print *, 'cld_prop%cv : ',cld_prop%cv
3726  print *, 'cld_prop%cvt : ',cld_prop%cvt
3727  print *, 'cld_prop%cvb : ',cld_prop%cvb
3728  print *, 'cld_prop%fcice : ',cld_prop%fcice
3729  print *, 'cld_prop%frain : ',cld_prop%frain
3730  print *, 'cld_prop%rrime : ',cld_prop%rrime
3731  print *, 'cld_prop%flgmin : ',cld_prop%flgmin
3732  print *, 'dyn_parm%icsdsw : ',dyn_parm%icsdsw
3733  print *, 'dyn_parm%icsdlw : ',dyn_parm%icsdlw
3734  print *, 'mdl_parm%ntcw : ',mdl_parm%ntcw
3735  print *, 'mdl_parm%ncld : ',mdl_parm%ncld
3736  print *, 'mdl_parm%ntoz : ',mdl_parm%ntoz
3737  print *, 'mdl_parm%NTRAC : ',mdl_parm%NTRAC
3738  print *, 'diags%NFXR : ',diags%NFXR
3739  print *, 'dyn_parm%dtlw : ',dyn_parm%dtlw
3740  print *, 'dyn_parm%dtsw : ',dyn_parm%dtsw
3741  print *, 'dyn_parm%lsswr : ',dyn_parm%lsswr
3742  print *, 'dyn_parm%lslwr : ',dyn_parm%lslwr
3743  print *, 'dyn_parm%lssav : ',dyn_parm%lssav
3744  print *, 'dyn_parm%lmfshal : ',dyn_parm%lmfshal
3745  print *, 'dyn_parm%lmfdeep2 : ',dyn_parm%lmfdeep2
3746  print *, 'dyn_parm%IX : ',dyn_parm%IX
3747  print *, 'dyn_parm%IM : ',dyn_parm%IM
3748  print *, 'mdl_parm%levs : ',mdl_parm%levs
3749  print *, 'mdl_parm%me : ',mdl_parm%me
3750  print *, 'dyn_parm%lprnt : ',dyn_parm%lprnt
3751  print *, 'dyn_parm%ipt : ',dyn_parm%ipt
3752  print *, 'dyn_parm%kdt : ',dyn_parm%kdt
3753  print *, 'cld_prop%deltaq : ',cld_prop%deltaq
3754  print *, 'cld_prop%sup : ',cld_prop%sup
3755  print *, 'cld_prop%cnvw : ',cld_prop%cnvw
3756  print *, 'cld_prop%cnvc : ',cld_prop%cnvc
3757  print *, 'dyn_parm%deltim : ',dyn_parm%deltim
3758  print *, 'mdl_parm%shoc_cld : ',mdl_parm%shoc_cld
3759 
3760  end if
3761 
3762  end subroutine
3763 
3764 
3766  subroutine rad_run_saveout (diags, intrfc_fld, cld_prop, rad_tend)
3768  implicit none
3769 
3770  type(diagnostics) :: diags
3771  type(interface_fields) :: intrfc_fld
3772  type(cloud_properties) :: cld_prop
3773  type(radiation_tendencies) :: rad_tend
3774 
3775  ! need a file unit and filename to write to
3776  integer, parameter :: funit = 99
3777  integer :: ios
3778 
3779  call dbgprint("rad_run_saveout")
3780 
3781  ! open file
3782  open (funit, file='radrun_saveout.dat', status='new', form='unformatted', iostat=ios)
3783 
3784  ! write each record
3785  write (funit, iostat=ios, err=900) &
3786 ! Outputs
3787  rad_tend%htrsw, diags%topfsw, intrfc_fld%sfcfsw, &
3788  diags%dswcmp, diags%uswcmp, rad_tend%sfalb, &
3789  rad_tend%coszen, rad_tend%coszdg, rad_tend%htrlw, &
3790  diags%topflw, intrfc_fld%sfcflw,&
3791  rad_tend%tsflw, rad_tend%semis, cld_prop%cldcov, &
3792 ! In/Out
3793  diags%fluxr
3794 
3795  flush (funit, iostat=ios, err=900)
3796 
3797  ! close file
3798  close (funit, iostat=ios)
3799 
3800  ! report any errors
3801 900 if (ios .ne. 0 ) print *, "DBG NUOPC IOERR : ", ios
3802 
3803  if (debug) then
3804  print *, "AFTER RAD RUN SAVEOUT"
3805  print *, "---------------------------"
3806  print *, "rad_tend%htrsw : ", rad_tend%htrsw
3807  print *, "diags%topfsw : ", diags%topfsw
3808  print *, "intrfc_fld%sfcfsw : ", intrfc_fld%sfcfsw
3809  print *, "diags%dswcmp : ", diags%dswcmp
3810  print *, "diags%uswcmp : ", diags%uswcmp
3811  print *, "rad_tend%sfalb : ", rad_tend%sfalb
3812  print *, "rad_tend%coszen : ", rad_tend%coszen
3813  print *, "rad_tend%coszdg : ", rad_tend%coszdg
3814  print *, "rad_tend%htrlw : ", rad_tend%htrlw
3815  print *, "diags%topflw : ", diags%topflw
3816  print *, "intrfc_fld%sfcflw : ", intrfc_fld%sfcflw
3817  print *, "rad_tend%tsflw : ", rad_tend%tsflw
3818  print *, "rad_tend%semis : ", rad_tend%semis
3819  print *, "cld_prop%cldcov : ", cld_prop%cldcov
3820  print *, "diags%fluxr : ", diags%fluxr
3821  end if
3822 
3823  end subroutine
3824 
3825 
3826 
3827 
3829  subroutine rad_run_readout (diags, intrfc_fld, cld_prop, rad_tend)
3831  implicit none
3832 
3833  type(diagnostics) :: diags
3834  type(interface_fields) :: intrfc_fld
3835  type(cloud_properties) :: cld_prop
3836  type(radiation_tendencies) :: rad_tend
3837 
3838  integer, parameter :: funit = 98
3839  integer :: ios
3840 
3841  call dbgprint("rad_run_readout")
3842 
3843  ! open file
3844  open (funit, file='radrun_saveout.dat', status='old', form='unformatted', iostat=ios)
3845 
3846  ! read each record
3847  read (funit, iostat=ios, err=900) &
3848 ! Outputs
3849  rad_tend%htrsw, diags%topfsw, intrfc_fld%sfcfsw, &
3850  diags%dswcmp, diags%uswcmp, rad_tend%sfalb, &
3851  rad_tend%coszen, rad_tend%coszdg, rad_tend%htrlw, &
3852  diags%topflw, intrfc_fld%sfcflw,&
3853  rad_tend%tsflw, rad_tend%semis, cld_prop%cldcov, &
3854 ! In/Out
3855  diags%fluxr
3856 
3857  ! close file
3858  close (funit, iostat=ios)
3859 
3860  ! report any errors
3861 900 if (ios .ne. 0 ) print *, "DBG NUOPC IOERR : ", ios
3862 
3863  if (debug) then
3864  print *, "AFTER RAD RUN READOUT"
3865  print *, "---------------------------"
3866  print *, "rad_tend%htrsw : ", rad_tend%htrsw
3867  print *, "diags%topfsw : ", diags%topfsw
3868  print *, "intrfc_fld%sfcfsw : ", intrfc_fld%sfcfsw
3869  print *, "diags%dswcmp : ", diags%dswcmp
3870  print *, "diags%uswcmp : ", diags%uswcmp
3871  print *, "rad_tend%sfalb : ", rad_tend%sfalb
3872  print *, "rad_tend%coszen : ", rad_tend%coszen
3873  print *, "rad_tend%coszdg : ", rad_tend%coszdg
3874  print *, "rad_tend%htrlw : ", rad_tend%htrlw
3875  print *, "diags%topflw : ", diags%topflw
3876  print *, "intrfc_fld%sfcflw : ", intrfc_fld%sfcflw
3877  print *, "rad_tend%tsflw : ", rad_tend%tsflw
3878  print *, "rad_tend%semis : ", rad_tend%semis
3879  print *, "cld_prop%cldcov : ", cld_prop%cldcov
3880  print *, "diags%fluxr : ", diags%fluxr
3881  end if
3882  end subroutine
3883 
3884 
3886  subroutine phys_run_savein (statein, sfc, diag, intr, cld, rad, mdl, tbd, dyn)
3888  implicit none
3889 
3890  type(state_fields_in) :: statein
3891  type(sfc_properties) :: sfc
3892  type(diagnostics) :: diag
3893  type(interface_fields) :: intr
3894  type(cloud_properties) :: cld
3895  type(radiation_tendencies) :: rad
3896  type(model_parameters) :: mdl
3897  type(tbd_ddt) :: tbd
3898  type(dynamic_parameters) :: dyn
3899 
3900 
3901  ! need a file unit and filename to write to
3902  integer, parameter :: funit = 99
3903  integer :: ios
3904 
3905  call dbgprint("phys_run_savein")
3906 
3907  ! open file
3908  open (funit, file='physrun_savein.dat', status='new', form='unformatted', iostat=ios)
3909 
3910  ! write each record
3911  write (funit, iostat=ios, err=900) &
3912  dyn%im, dyn%ix, mdl%levs, &
3913  mdl%lsoil, mdl%lsm, mdl%ntrac, &
3914  mdl%ncld, mdl%ntoz, mdl%ntcw, mdl%ntke, &
3915  mdl%nmtvr, mdl%nrcm, mdl%levozp, &
3916  mdl%lonr, mdl%latr, mdl%jcap, mdl%num_p3d,&
3917  mdl%num_p2d, mdl%npdf3d, mdl%ncnvcld3d, dyn%kdt, &
3918  dyn%lat, mdl%me, mdl%pl_coeff, &
3919  dyn%nlons, mdl%ncw, cld%flgmin, &
3920  mdl%crtrh, mdl%cdmbgwd, mdl%ccwf, &
3921  mdl%dlqf, mdl%ctei_rm, dyn%clstp, &
3922  mdl%cgwf, mdl%prslrd0, mdl%ral_ts, dyn%dtp, &
3923  dyn%dtf, dyn%fhour, dyn%solhr, &
3924  dyn%slag, dyn%sdec, dyn%cdec, &
3925  dyn%sinlat, dyn%coslat, statein%pgr, &
3926  statein%ugrs, statein%vgrs, statein%tgrs, &
3927  statein%qgrs, statein%vvl, statein%prsi, &
3928  statein%prsl, statein%prslk, statein%prsik, &
3929  statein%phii, statein%phil, tbd%rann, &
3930  tbd%prdout, tbd%poz, tbd%dpshc, &
3931  tbd%fscav, tbd%fswtr,sfc%hprime2, &
3932  dyn%xlon, dyn%xlat, sfc%slope, sfc%shdmin, &
3933  sfc%shdmax, sfc%snoalb, sfc%tg3, sfc%slmsk, &
3934  sfc%vfrac, sfc%vtype, sfc%stype, &
3935  sfc%uustar, sfc%oro,sfc%oro_uf, &
3936  rad%coszen, intr%sfcdsw, intr%sfcnsw, intr%sfcnirbmd, &
3937  intr%sfcnirdfd, intr%sfcvisbmd, &
3938  intr%sfcvisdfd, intr%sfcnirbmu, intr%sfcnirdfu, &
3939  intr%sfcvisbmu, intr%sfcvisdfu, intr%slimskin_cpl, &
3940  intr%ulwsfcin_cpl, intr%dusfcin_cpl, intr%dvsfcin_cpl, &
3941  intr%dtsfcin_cpl, intr%dqsfcin_cpl, intr%sfcdlw, &
3942  rad%tsflw, rad%semis, rad%sfalb, rad%htrsw, &
3943  rad%swhc, rad%htrlw, rad%hlwc, &
3944  rad%hlwd, mdl%lsidea, mdl%ras, & !mdl%lsidea
3945  mdl%pre_rad, mdl%ldiag3d, mdl%lgocart, dyn%lssav, &
3946  mdl%lssav_cpl, tbd%xkzm_m, tbd%xkzm_h, &
3947  tbd%xkzm_s, tbd%psautco, tbd%prautco, &
3948  tbd%evpco, tbd%wminco, mdl%pdfcld, mdl%shcnvcw, &
3949  cld%sup, mdl%redrag, mdl%hybedmf, mdl%dspheat, &
3950  mdl%flipv, mdl%old_monin, mdl%cnvgwd, mdl%shal_cnv, &
3951  mdl%imfshalcnv, mdl%imfdeepcnv, mdl%cal_pre, &
3952  mdl%mom4ice, mdl%mstrat, mdl%trans_trac, &
3953  mdl%nstf_name, mdl%moist_adj, mdl%thermodyn_id, &
3954  mdl%sfcpress_id, mdl%gen_coord_hybrid, &
3955  mdl%levr, statein%adjtrc, dyn%nnp, &
3956 ! Add new nems_slg_shoc arguments
3957  mdl%cscnv, mdl%nctp, mdl%do_shoc, &
3958  mdl%shocaftcnv, mdl%ntot3d, mdl%ntot2d, &
3959 ! In/Out
3960  sfc%hice, sfc%fice, sfc%tisfc,&
3961  sfc%tsfc, tbd%tprcp, cld%cv, &
3962  cld%cvb, cld%cvt, tbd%srflag, &
3963  sfc%snowd, sfc%weasd,sfc%sncovr, &
3964  sfc%zorl, sfc%canopy, sfc%ffmm, &
3965  sfc%ffhh, sfc%f10m, diag%srunoff, &
3966  diag%evbsa, diag%evcwa, diag%snohfa, &
3967  diag%transa, diag%sbsnoa, diag%snowca, &
3968  diag%soilm, diag%tmpmin, diag%tmpmax, &
3969  diag%dusfc, diag%dvsfc, diag%dtsfc, &
3970  diag%dqsfc, diag%totprcp, diag%gflux, &
3971  diag%dlwsfc, diag%ulwsfc, diag%suntim, &
3972  diag%runoff, diag%ep, diag%cldwrk, &
3973  diag%dugwd, diag%dvgwd, diag%psmean, &
3974  diag%cnvprcp, diag%spfhmin, diag%spfhmax, &
3975  diag%rain, diag%rainc, diag%dt3dt, &
3976  diag%dq3dt, diag%du3dt, diag%dv3dt, diag%dqdt_v, &
3977  cld%cnvqc_v, tbd%acv, tbd%acvb, tbd%acvt, tbd%slc, &
3978  tbd%smc, tbd%stc, tbd%upd_mf, tbd%dwn_mf, &
3979  tbd%det_mf, tbd%phy_f3d, tbd%phy_f2d, &
3980  intr%dusfc_cpl, intr%dvsfc_cpl, intr%dtsfc_cpl, &
3981  intr%dqsfc_cpl, intr%dlwsfc_cpl, &
3982  intr%dswsfc_cpl, intr%dnirbm_cpl, intr%dnirdf_cpl, &
3983  intr%dvisbm_cpl, intr%dvisdf_cpl, intr%rain_cpl, &
3984  intr%nlwsfc_cpl, intr%nswsfc_cpl, intr%nnirbm_cpl, &
3985  intr%nnirdf_cpl, intr%nvisbm_cpl, intr%nvisdf_cpl, &
3986  intr%snow_cpl, intr%xt, intr%xs, intr%xu, intr%xv, &
3987  intr%xz, intr%zm, intr%xtts, intr%xzts, intr%d_conv, &
3988  intr%ifd, intr%dt_cool, intr%Qrain, &
3989  tbd%tref, tbd%z_c, tbd%c_0, tbd%c_d, tbd%w_0, tbd%w_d, &
3990 ! NEW
3991  tbd%phy_fctd
3992 
3993  flush (funit, iostat=ios, err=900)
3994 
3995  ! close file
3996  close (funit, iostat=ios)
3997 
3998  ! report any errors
3999 900 if (ios .ne. 0 ) print *, "DBG NUOPC IOERR : ", ios
4000 
4001 
4002  end subroutine
4003 
4004 
4005 
4006 
4008  subroutine phys_run_readin (statein, sfc, diag, intr, cld, rad, mdl, tbd, dyn)
4010  implicit none
4011 
4012  type(state_fields_in) :: statein
4013  type(sfc_properties) :: sfc
4014  type(diagnostics) :: diag
4015  type(interface_fields) :: intr
4016  type(cloud_properties) :: cld
4017  type(radiation_tendencies) :: rad
4018  type(model_parameters) :: mdl
4019  type(tbd_ddt) :: tbd
4020  type(dynamic_parameters) :: dyn
4021 
4022 
4023  integer, parameter :: funit = 98
4024 
4025  integer :: ios
4026  ! character, dimension(1024) :: iomsg
4027  character*256 :: msg
4028  msg=''
4029 
4030  call dbgprint("phys_run_readin")
4031 
4032  ! open file
4033  open (funit, file='physrun_savein.dat', status='old', form='unformatted', &
4034  iostat=ios)
4035 
4036  ! read each record
4037  read (funit, iostat=ios, err=900, iomsg=msg ) &
4038  dyn%im, dyn%ix, mdl%levs, &
4039  mdl%lsoil, mdl%lsm, mdl%ntrac, &
4040  mdl%ncld, mdl%ntoz, mdl%ntcw, mdl%ntke, &
4041  mdl%nmtvr, mdl%nrcm, mdl%levozp, &
4042  mdl%lonr, mdl%latr, mdl%jcap, mdl%num_p3d,&
4043  mdl%num_p2d, mdl%npdf3d, mdl%ncnvcld3d, dyn%kdt, &
4044  dyn%lat, mdl%me, mdl%pl_coeff, &
4045  dyn%nlons, mdl%ncw, cld%flgmin, &
4046  mdl%crtrh, mdl%cdmbgwd, mdl%ccwf, &
4047  mdl%dlqf, mdl%ctei_rm, dyn%clstp, &
4048  mdl%cgwf, mdl%prslrd0, mdl%ral_ts, dyn%dtp, &
4049  dyn%dtf, dyn%fhour, dyn%solhr, &
4050  dyn%slag, dyn%sdec, dyn%cdec, &
4051  dyn%sinlat, dyn%coslat, statein%pgr, &
4052  statein%ugrs, statein%vgrs, statein%tgrs, &
4053  statein%qgrs, statein%vvl, statein%prsi, &
4054  statein%prsl, statein%prslk, statein%prsik, &
4055  statein%phii, statein%phil, tbd%rann, &
4056  tbd%prdout, tbd%poz, tbd%dpshc, &
4057  tbd%fscav, tbd%fswtr,sfc%hprime2, &
4058  dyn%xlon, dyn%xlat, sfc%slope, sfc%shdmin, &
4059  sfc%shdmax, sfc%snoalb, sfc%tg3, sfc%slmsk, &
4060  sfc%vfrac, sfc%vtype, sfc%stype, &
4061  sfc%uustar, sfc%oro,sfc%oro_uf, &
4062  rad%coszen, intr%sfcdsw, intr%sfcnsw, intr%sfcnirbmd, &
4063  intr%sfcnirdfd, intr%sfcvisbmd, &
4064  intr%sfcvisdfd, intr%sfcnirbmu, intr%sfcnirdfu, &
4065  intr%sfcvisbmu, intr%sfcvisdfu, intr%slimskin_cpl, &
4066  intr%ulwsfcin_cpl, intr%dusfcin_cpl, intr%dvsfcin_cpl, &
4067  intr%dtsfcin_cpl, intr%dqsfcin_cpl, intr%sfcdlw, &
4068  rad%tsflw, rad%semis, rad%sfalb, rad%htrsw, &
4069  rad%swhc, rad%htrlw, rad%hlwc, &
4070  rad%hlwd, mdl%lsidea, mdl%ras, & !mdl%lsidea
4071  mdl%pre_rad, mdl%ldiag3d, mdl%lgocart, dyn%lssav, &
4072  mdl%lssav_cpl, tbd%xkzm_m, tbd%xkzm_h, &
4073  tbd%xkzm_s, tbd%psautco, tbd%prautco, &
4074  tbd%evpco, tbd%wminco, mdl%pdfcld, mdl%shcnvcw, &
4075  cld%sup, mdl%redrag, mdl%hybedmf, mdl%dspheat, &
4076  mdl%flipv, mdl%old_monin, mdl%cnvgwd, mdl%shal_cnv, &
4077  mdl%imfshalcnv, mdl%imfdeepcnv, mdl%cal_pre, &
4078  mdl%mom4ice, mdl%mstrat, mdl%trans_trac, &
4079  mdl%nstf_name, mdl%moist_adj, mdl%thermodyn_id, &
4080  mdl%sfcpress_id, mdl%gen_coord_hybrid, &
4081  mdl%levr, statein%adjtrc, dyn%nnp, &
4082 ! Add new nems_slg_shoc arguments
4083  mdl%cscnv, mdl%nctp, mdl%do_shoc, &
4084  mdl%shocaftcnv, mdl%ntot3d, mdl%ntot2d, &
4085 ! In/Out
4086  sfc%hice, sfc%fice, sfc%tisfc,&
4087  sfc%tsfc, tbd%tprcp, cld%cv, &
4088  cld%cvb, cld%cvt, tbd%srflag, &
4089  sfc%snowd, sfc%weasd,sfc%sncovr, &
4090  sfc%zorl, sfc%canopy, sfc%ffmm, &
4091  sfc%ffhh, sfc%f10m, diag%srunoff, &
4092  diag%evbsa, diag%evcwa, diag%snohfa, &
4093  diag%transa, diag%sbsnoa, diag%snowca, &
4094  diag%soilm, diag%tmpmin, diag%tmpmax, &
4095  diag%dusfc, diag%dvsfc, diag%dtsfc, &
4096  diag%dqsfc, diag%totprcp, diag%gflux, &
4097  diag%dlwsfc, diag%ulwsfc, diag%suntim, &
4098  diag%runoff, diag%ep, diag%cldwrk, &
4099  diag%dugwd, diag%dvgwd, diag%psmean, &
4100  diag%cnvprcp, diag%spfhmin, diag%spfhmax, &
4101  diag%rain, diag%rainc, diag%dt3dt, &
4102  diag%dq3dt, diag%du3dt, diag%dv3dt, diag%dqdt_v, &
4103  cld%cnvqc_v, tbd%acv, tbd%acvb, tbd%acvt, tbd%slc, &
4104  tbd%smc, tbd%stc, tbd%upd_mf, tbd%dwn_mf, &
4105  tbd%det_mf, tbd%phy_f3d, tbd%phy_f2d, &
4106  intr%dusfc_cpl, intr%dvsfc_cpl, intr%dtsfc_cpl, &
4107  intr%dqsfc_cpl, intr%dlwsfc_cpl, &
4108  intr%dswsfc_cpl, intr%dnirbm_cpl, intr%dnirdf_cpl, &
4109  intr%dvisbm_cpl, intr%dvisdf_cpl, intr%rain_cpl, &
4110  intr%nlwsfc_cpl, intr%nswsfc_cpl, intr%nnirbm_cpl, &
4111  intr%nnirdf_cpl, intr%nvisbm_cpl, intr%nvisdf_cpl, &
4112  intr%snow_cpl, intr%xt, intr%xs, intr%xu, intr%xv, &
4113  intr%xz, intr%zm, intr%xtts, intr%xzts, intr%d_conv, &
4114  intr%ifd, intr%dt_cool, intr%Qrain, &
4115  tbd%tref, tbd%z_c, tbd%c_0, tbd%c_d, tbd%w_0, tbd%w_d, &
4116 ! NEW
4117  tbd%phy_fctd
4118 
4119  ! close file
4120  close (funit, iostat=ios)
4121 
4122  ! report any errors
4123 900 if (ios .ne. 0 ) print *, "DBG NUOPC IOERR : ", ios, trim(msg)
4124 
4125  if (debug) then
4126  print *, "AFTER PHYS RUN READIN"
4127  print *, "---------------------------"
4128  print *, "dyn%im : ", dyn%im
4129  print *, "dyn%ix : ", dyn%ix
4130  print *, "mdl%levs : ", mdl%levs
4131  print *, "mdl%lsoil : ", mdl%lsoil
4132  print *, "mdl%lsm : ", mdl%lsm
4133  print *, "mdl%ntrac : ", mdl%ntrac
4134  print *, "mdl%ncld : ", mdl%ncld
4135  print *, "mdl%ntoz : ", mdl%ntoz
4136  print *, "mdl%ntcw : ", mdl%ntcw
4137  print *, "mdl%nmtvr : ", mdl%nmtvr
4138  print *, "mdl%nrcm : ", mdl%nrcm
4139  print *, "mdl%levozp : ", mdl%levozp
4140  print *, "mdl%lonr : ", mdl%lonr
4141  print *, "mdl%latr : ", mdl%latr
4142  print *, "mdl%jcap : ", mdl%jcap
4143  print *, "mdl%num_p3d : ", mdl%num_p3d
4144  print *, "mdl%num_p2d : ", mdl%num_p2d
4145  print *, "mdl%npdf3d : ", mdl%npdf3d
4146  print *, "mdl%ncnvcld3d : ", mdl%ncnvcld3d
4147  print *, "dyn%kdt : ", dyn%kdt
4148  print *, "dyn%lat : ", dyn%lat
4149  print *, "mdl%me : ", mdl%me
4150  print *, "mdl%pl_coeff : ", mdl%pl_coeff
4151  print *, "dyn%nlons : ", dyn%nlons
4152  print *, "mdl%ncw : ", mdl%ncw
4153  print *, "cld%flgmin : ", cld%flgmin
4154  print *, "mdl%crtrh : ", mdl%crtrh
4155  print *, "mdl%cdmbgwd : ", mdl%cdmbgwd
4156  print *, "mdl%ccwf : ", mdl%ccwf
4157  print *, "mdl%dlqf : ", mdl%dlqf
4158  print *, "mdl%ctei_rm : ", mdl%ctei_rm
4159  print *, "dyn%clstp : ", dyn%clstp
4160  print *, "mdl%cgwf : ", mdl%cgwf
4161  print *, "mdl%prslrd0 : ", mdl%prslrd0
4162  print *, "mdl%ral_ts : ", mdl%ral_ts
4163  print *, "dyn%dtp : ", dyn%dtp
4164  print *, "dyn%dtf : ", dyn%dtf
4165  print *, "dyn%fhour : ", dyn%fhour
4166  print *, "dyn%solhr : ", dyn%solhr
4167  print *, "dyn%slag : ", dyn%slag
4168  print *, "dyn%sdec : ", dyn%sdec
4169  print *, "dyn%cdec : ", dyn%cdec
4170  print *, "dyn%sinlat : ", dyn%sinlat
4171  print *, "dyn%coslat : ", dyn%coslat
4172  print *, "statein%pgr : ", statein%pgr
4173  print *, "statein%ugrs : ", statein%ugrs
4174  print *, "statein%vgrs : ", statein%vgrs
4175  print *, "statein%tgrs : ", statein%tgrs
4176  print *, "statein%qgrs : ", statein%qgrs
4177  print *, "statein%vvl : ", statein%vvl
4178  print *, "statein%prsi : ", statein%prsi
4179  print *, "statein%prsl : ", statein%prsl
4180  print *, "statein%prslk : ", statein%prslk
4181  print *, "statein%prsik : ", statein%prsik
4182  print *, "statein%phii : ", statein%phii
4183  print *, "statein%phil : ", statein%phil
4184  print *, "tbd%rann : ", tbd%rann
4185  print *, "tbd%prdout : ", tbd%prdout
4186  print *, "tbd%poz : ", tbd%poz
4187  print *, "tbd%dpshc : ", tbd%dpshc
4188  print *, "sfc%hprime2 : ", sfc%hprime2
4189  print *, "dyn%xlon : ", dyn%xlon
4190  print *, "dyn%xlat : ", dyn%xlat
4191  print *, "sfc%slope : ", sfc%slope
4192  print *, "sfc%shdmin : ", sfc%shdmin
4193  print *, "sfc%shdmax : ", sfc%shdmax
4194  print *, "sfc%snoalb : ", sfc%snoalb
4195  print *, "sfc%tg3 : ", sfc%tg3
4196  print *, "sfc%slmsk : ", sfc%slmsk
4197  print *, "sfc%vfrac : ", sfc%vfrac
4198  print *, "sfc%vtype : ", sfc%vtype
4199  print *, "sfc%stype : ", sfc%stype
4200  print *, "sfc%uustar : ", sfc%uustar
4201  print *, "sfc%oro : ", sfc%oro
4202  print *, "sfc%oro_uf : ", sfc%oro_uf
4203  print *, "rad%coszen : ", rad%coszen
4204  print *, "intr%sfcdsw : ", intr%sfcdsw
4205  print *, "intr%sfcnsw : ", intr%sfcnsw
4206  print *, "intr%sfcnirbmd : ", intr%sfcnirbmd
4207  print *, "intr%sfcnirdfd : ", intr%sfcnirdfd
4208  print *, "intr%sfcvisbmd : ", intr%sfcvisbmd
4209  print *, "intr%sfcvisdfd : ", intr%sfcvisdfd
4210  print *, "intr%sfcnirbmu : ", intr%sfcnirbmu
4211  print *, "intr%sfcnirdfu : ", intr%sfcnirdfu
4212  print *, "intr%sfcvisbmu : ", intr%sfcvisbmu
4213  print *, "intr%sfcvisdfu : ", intr%sfcvisdfu
4214  print *, "intr%sfcdlw : ", intr%sfcdlw
4215  print *, "rad%tsflw : ", rad%tsflw
4216  print *, "rad%semis : ", rad%semis
4217  print *, "rad%sfalb : ", rad%sfalb
4218  print *, "rad%htrsw : ", rad%htrsw
4219  print *, "rad%swhc : ", rad%swhc
4220  print *, "rad%htrlw : ", rad%htrlw
4221  print *, "rad%hlwc : ", rad%hlwc
4222  print *, "rad%hlwd : ", rad%hlwd
4223  print *, "mdl%lsidea : ", mdl%lsidea
4224  print *, "mdl%ras : ", mdl%ras
4225  print *, "mdl%pre_rad : ", mdl%pre_rad
4226  print *, "mdl%ldiag3d : ", mdl%ldiag3d
4227  print *, "mdl%lgocart : ", mdl%lgocart
4228  print *, "dyn%lssav : ", dyn%lssav
4229  print *, "mdl%lssav_cpl : ", mdl%lssav_cpl
4230  print *, "tbd%xkzm_m : ", tbd%xkzm_m
4231  print *, "tbd%xkzm_h : ", tbd%xkzm_h
4232  print *, "tbd%xkzm_s : ", tbd%xkzm_s
4233  print *, "tbd%psautco : ", tbd%psautco
4234  print *, "tbd%prautco : ", tbd%prautco
4235  print *, "tbd%evpco : ", tbd%evpco
4236  print *, "tbd%wminco : ", tbd%wminco
4237  print *, "mdl%pdfcld : ", mdl%pdfcld
4238  print *, "mdl%shcnvcw : ", mdl%shcnvcw
4239  print *, "cld%sup : ", cld%sup
4240  print *, "mdl%redrag : ", mdl%redrag
4241  print *, "mdl%hybedmf : ", mdl%hybedmf
4242  print *, "mdl%dspheat : ", mdl%dspheat
4243  print *, "mdl%flipv : ", mdl%flipv
4244  print *, "mdl%old_monin : ", mdl%old_monin
4245  print *, "mdl%cnvgwd : ", mdl%cnvgwd
4246  print *, "mdl%shal_cnv : ", mdl%shal_cnv
4247  print *, "mdl%imfshalcnv : ", mdl%imfshalcnv
4248  print *, "mdl%imfdeepcnv : ", mdl%imfdeepcnv
4249  print *, "mdl%cal_pre : ", mdl%cal_pre
4250  print *, "mdl%mom4ice : ", mdl%mom4ice
4251  print *, "mdl%mstrat : ", mdl%mstrat
4252  print *, "mdl%trans_trac : ", mdl%trans_trac
4253  print *, "mdl%nstf_name : ", mdl%nstf_name
4254  print *, "mdl%moist_adj : ", mdl%moist_adj
4255  print *, "mdl%thermodyn_id : ", mdl%thermodyn_id
4256  print *, "mdl%sfcpress_id : ", mdl%sfcpress_id
4257  print *, "mdl%gen_coord_hybrid : ", mdl%gen_coord_hybrid
4258  print *, "mdl%levr : ", mdl%levr
4259  print *, "statein%adjtrc : ", statein%adjtrc
4260  print *, "dyn%nnp : ", dyn%nnp
4261  print *, "mdl%cscnv : ", mdl%cscnv
4262  print *, "mdl%nctp : ", mdl%nctp
4263  print *, "mdl%do_shoc : ", mdl%do_shoc
4264  print *, "mdl%shocaftcnv : ", mdl%shocaftcnv
4265  print *, "mdl%ntot3d : ", mdl%ntot3d
4266  print *, "mdl%ntot2d : ", mdl%ntot2d
4267  print *, "sfc%hice : ", sfc%hice
4268  print *, "sfc%fice : ", sfc%fice
4269  print *, "sfc%tisfc : ", sfc%tisfc
4270  print *, "sfc%tsfc : ", sfc%tsfc
4271  print *, "tbd%tprcp : ", tbd%tprcp
4272  print *, "cld%cv : ", cld%cv
4273  print *, "cld%cvb : ", cld%cvb
4274  print *, "cld%cvt : ", cld%cvt
4275  print *, "tbd%srflag : ", tbd%srflag
4276  print *, "sfc%snowd : ", sfc%snowd
4277  print *, "sfc%weasd : ", sfc%weasd
4278  print *, "sfc%sncovr : ", sfc%sncovr
4279  print *, "sfc%zorl : ", sfc%zorl
4280  print *, "sfc%canopy : ", sfc%canopy
4281  print *, "sfc%ffmm : ", sfc%ffmm
4282  print *, "sfc%ffhh : ", sfc%ffhh
4283  print *, "sfc%f10m : ", sfc%f10m
4284  print *, "diag%srunoff : ", diag%srunoff
4285  print *, "diag%evbsa : ", diag%evbsa
4286  print *, "diag%evcwa : ", diag%evcwa
4287  print *, "diag%snohfa : ", diag%snohfa
4288  print *, "diag%transa : ", diag%transa
4289  print *, "diag%sbsnoa : ", diag%sbsnoa
4290  print *, "diag%snowca : ", diag%snowca
4291  print *, "diag%soilm : ", diag%soilm
4292  print *, "diag%tmpmin : ", diag%tmpmin
4293  print *, "diag%tmpmax : ", diag%tmpmax
4294  print *, "diag%dusfc : ", diag%dusfc
4295  print *, "diag%dvsfc : ", diag%dvsfc
4296  print *, "diag%dtsfc : ", diag%dtsfc
4297  print *, "diag%dqsfc : ", diag%dqsfc
4298  print *, "diag%totprcp : ", diag%totprcp
4299  print *, "diag%gflux : ", diag%gflux
4300  print *, "diag%dlwsfc : ", diag%dlwsfc
4301  print *, "diag%ulwsfc : ", diag%ulwsfc
4302  print *, "diag%suntim : ", diag%suntim
4303  print *, "diag%runoff : ", diag%runoff
4304  print *, "diag%ep : ", diag%ep
4305  print *, "diag%cldwrk : ", diag%cldwrk
4306  print *, "diag%dugwd : ", diag%dugwd
4307  print *, "diag%dvgwd : ", diag%dvgwd
4308  print *, "diag%psmean : ", diag%psmean
4309  print *, "diag%cnvprcp : ", diag%cnvprcp
4310  print *, "diag%spfhmin : ", diag%spfhmin
4311  print *, "diag%spfhmax : ", diag%spfhmax
4312  print *, "diag%rain : ", diag%rain
4313  print *, "diag%rainc : ", diag%rainc
4314  print *, "diag%dt3dt : ", diag%dt3dt
4315  print *, "diag%dq3dt : ", diag%dq3dt
4316  print *, "diag%du3dt : ", diag%du3dt
4317  print *, "diag%dv3dt : ", diag%dv3dt
4318  print *, "diag%dqdt_v : ", diag%dqdt_v
4319  print *, "cld%cnvqc_v : ", cld%cnvqc_v
4320  print *, "tbd%acv : ", tbd%acv
4321  print *, "tbd%acvb : ", tbd%acvb
4322  print *, "tbd%acvt : ", tbd%acvt
4323  print *, "tbd%slc : ", tbd%slc
4324  print *, "tbd%smc : ", tbd%smc
4325  print *, "tbd%stc : ", tbd%stc
4326  print *, "tbd%upd_mf : ", tbd%upd_mf
4327  print *, "tbd%dwn_mf : ", tbd%dwn_mf
4328  print *, "tbd%det_mf : ", tbd%det_mf
4329  print *, "tbd%phy_f3d : ", tbd%phy_f3d
4330  print *, "tbd%phy_f2d : ", tbd%phy_f2d
4331  print *, "intr%dusfc_cpl : ", intr%dusfc_cpl
4332  print *, "intr%dvsfc_cpl : ", intr%dvsfc_cpl
4333  print *, "intr%dtsfc_cpl : ", intr%dtsfc_cpl
4334  print *, "intr%dqsfc_cpl : ", intr%dqsfc_cpl
4335  print *, "intr%dlwsfc_cpl : ", intr%dlwsfc_cpl
4336  print *, "intr%dswsfc_cpl : ", intr%dswsfc_cpl
4337  print *, "intr%dnirbm_cpl : ", intr%dnirbm_cpl
4338  print *, "intr%dnirdf_cpl : ", intr%dnirdf_cpl
4339  print *, "intr%dvisbm_cpl : ", intr%dvisbm_cpl
4340  print *, "intr%dvisdf_cpl : ", intr%dvisdf_cpl
4341  print *, "intr%rain_cpl : ", intr%rain_cpl
4342  print *, "intr%nlwsfc_cpl : ", intr%nlwsfc_cpl
4343  print *, "intr%nswsfc_cpl : ", intr%nswsfc_cpl
4344  print *, "intr%nnirbm_cpl : ", intr%nnirbm_cpl
4345  print *, "intr%nnirdf_cpl : ", intr%nnirdf_cpl
4346  print *, "intr%nvisbm_cpl : ", intr%nvisbm_cpl
4347  print *, "intr%nvisdf_cpl : ", intr%nvisdf_cpl
4348  print *, "intr%slimskin_cpl : ", intr%slimskin_cpl
4349  print *, "intr%snow_cpl : ", intr%snow_cpl
4350  print *, "intr%xt : ", intr%xt
4351  print *, "intr%xs : ", intr%xs
4352  print *, "intr%xu : ", intr%xu
4353  print *, "intr%xv : ", intr%xv
4354  print *, "intr%xz : ", intr%xz
4355  print *, "intr%zm : ", intr%zm
4356  print *, "intr%xtts : ", intr%xtts
4357  print *, "intr%xzts : ", intr%xzts
4358  print *, "intr%d_conv : ", intr%d_conv
4359  print *, "intr%ifd : ", intr%ifd
4360  print *, "intr%dt_cool : ", intr%dt_cool
4361  print *, "intr%Qrain : ", intr%Qrain
4362  print *, "tbd%phy_fctd : ", tbd%phy_fctd
4363  end if
4364 
4365  end subroutine
4366 
4367 
4368 
4369 
4371  subroutine phys_run_saveout (stateout, sfc, diag, intr, cld, rad, tbd)
4373  implicit none
4374 
4375  type(state_fields_out) :: stateout
4376  type(sfc_properties) :: sfc
4377  type(diagnostics) :: diag
4378  type(interface_fields) :: intr
4379  type(cloud_properties) :: cld
4380  type(radiation_tendencies) :: rad
4381  type(tbd_ddt) :: tbd
4382 
4383 
4384  ! need a file unit and filename to write to
4385  integer, parameter :: funit = 99
4386  integer :: ios
4387 
4388  call dbgprint("phys_run_saveout")
4389 
4390  ! open file
4391  open (funit, file='physrun_saveout.dat', status='new', form='unformatted', iostat=ios)
4392 
4393  write (funit, iostat=ios, err=900) &
4394 ! In/Out
4395  sfc%hice, sfc%fice, sfc%tisfc,&
4396  sfc%tsfc, tbd%tprcp, cld%cv, &
4397  cld%cvb, cld%cvt, tbd%srflag, &
4398  sfc%snowd, sfc%weasd,sfc%sncovr, &
4399  sfc%zorl, sfc%canopy, sfc%ffmm, &
4400  sfc%ffhh, sfc%f10m, diag%srunoff, &
4401  diag%evbsa, diag%evcwa, diag%snohfa, &
4402  diag%transa, diag%sbsnoa, diag%snowca, &
4403  diag%soilm, diag%tmpmin, diag%tmpmax, &
4404  diag%dusfc, diag%dvsfc, diag%dtsfc, &
4405  diag%dqsfc, diag%totprcp, diag%gflux, &
4406  diag%dlwsfc, diag%ulwsfc, diag%suntim, &
4407  diag%runoff, diag%ep, diag%cldwrk, &
4408  diag%dugwd, diag%dvgwd, diag%psmean, &
4409  diag%cnvprcp, diag%spfhmin, diag%spfhmax, &
4410  diag%rain, diag%rainc, diag%dt3dt, &
4411  diag%dq3dt, diag%du3dt, diag%dv3dt, diag%dqdt_v, &
4412  cld%cnvqc_v, tbd%acv, tbd%acvb, tbd%acvt, tbd%slc, &
4413  tbd%smc, tbd%stc, tbd%upd_mf, tbd%dwn_mf, &
4414  tbd%det_mf, tbd%phy_f3d, tbd%phy_f2d, &
4415  intr%dusfc_cpl, intr%dvsfc_cpl, intr%dtsfc_cpl, &
4416  intr%dqsfc_cpl, intr%dlwsfc_cpl, &
4417  intr%dswsfc_cpl, intr%dnirbm_cpl, intr%dnirdf_cpl, &
4418  intr%dvisbm_cpl, intr%dvisdf_cpl, intr%rain_cpl, &
4419  intr%nlwsfc_cpl, intr%nswsfc_cpl, intr%nnirbm_cpl, &
4420  intr%nnirdf_cpl, intr%nvisbm_cpl, intr%nvisdf_cpl, &
4421  intr%snow_cpl, intr%xt, intr%xs, intr%xu, intr%xv, &
4422  intr%xz, intr%zm, intr%xtts, intr%xzts, intr%d_conv, &
4423  intr%ifd, intr%dt_cool, intr%Qrain, &
4424  tbd%tref, tbd%z_c, tbd%c_0, tbd%c_d, tbd%w_0, tbd%w_d, &
4425 ! NEW
4426  tbd%phy_fctd, &
4427 ! Out
4428  stateout%gt0, stateout%gq0, stateout%gu0, stateout%gv0, &
4429  sfc%t2m, sfc%q2m, diag%u10m, diag%v10m, diag%zlvl, &
4430  diag%psurf, diag%hpbl, diag%pwat, &
4431  diag%t1, diag%q1, diag%u1, diag%v1, diag%chh, diag%cmm, &
4432  diag%dlwsfci, diag%ulwsfci, diag%dswsfci, &
4433  diag%uswsfci, diag%dusfci, diag%dvsfci, &
4434  diag%dtsfci, diag%dqsfci, diag%gfluxi, &
4435  diag%epi, diag%smcwlt2, diag%smcref2, &
4436  diag%wet1, diag%sr, rad%rqtk, rad%dtdtr, &
4437  intr%dusfci_cpl, intr%dvsfci_cpl, intr%dtsfci_cpl, &
4438  intr%dqsfci_cpl, intr%dlwsfci_cpl, intr%dswsfci_cpl, &
4439  intr%dnirbmi_cpl, intr%dnirdfi_cpl, intr%dvisbmi_cpl, &
4440  intr%dvisdfi_cpl, intr%nlwsfci_cpl, intr%nswsfci_cpl, &
4441  intr%nnirbmi_cpl, intr%nnirdfi_cpl, intr%nvisbmi_cpl, &
4442  intr%nvisdfi_cpl, intr%t2mi_cpl, intr%q2mi_cpl, &
4443  intr%u10mi_cpl, intr%v10mi_cpl, intr%tseai_cpl, &
4444  intr%psurfi_cpl
4445 
4446  flush (funit, iostat=ios, err=900)
4447 
4448  ! close file
4449  close (funit, iostat=ios)
4450 
4451  ! report any errors
4452 900 if (ios .ne. 0 ) print *, "DBG NUOPC IOERR : ", ios
4453 
4454 
4455  if (debug) then
4456  print *, "AFTER PHYS RUN SAVEOUT"
4457  print *, "---------------------------"
4458  print *, "stateout%gt0 : ", stateout%gt0
4459  print *, "stateout%gq0 : ", stateout%gq0
4460  print *, "stateout%gu0 : ", stateout%gu0
4461  print *, "stateout%gv0 : ", stateout%gv0
4462  print *, "sfc%t2m : ", sfc%t2m
4463  print *, "sfc%q2m : ", sfc%q2m
4464  print *, "diag%u10m : ", diag%u10m
4465  print *, "diag%v10m : ", diag%v10m
4466  print *, "diag%zlvl : ", diag%zlvl
4467  print *, "diag%psurf : ", diag%psurf
4468  print *, "diag%hpbl : ", diag%hpbl
4469  print *, "diag%pwat : ", diag%pwat
4470  print *, "diag%t1 : ", diag%t1
4471  print *, "diag%q1 : ", diag%q1
4472  print *, "diag%u1 : ", diag%u1
4473  print *, "diag%v1 : ", diag%v1
4474  print *, "diag%chh : ", diag%chh
4475  print *, "diag%cmm : ", diag%cmm
4476  print *, "diag%dlwsfci : ", diag%dlwsfci
4477  print *, "diag%ulwsfci : ", diag%ulwsfci
4478  print *, "diag%dswsfci : ", diag%dswsfci
4479  print *, "diag%uswsfci : ", diag%uswsfci
4480  print *, "diag%dusfci : ", diag%dusfci
4481  print *, "diag%dvsfci : ", diag%dvsfci
4482  print *, "diag%dtsfci : ", diag%dtsfci
4483  print *, "diag%dqsfci : ", diag%dqsfci
4484  print *, "diag%gfluxi : ", diag%gfluxi
4485  print *, "diag%epi : ", diag%epi
4486  print *, "diag%smcwlt2 : ", diag%smcwlt2
4487  print *, "diag%smcref2 : ", diag%smcref2
4488  print *, "diag%wet1 : ", diag%wet1
4489  print *, "diag%sr : ", diag%sr
4490  print *, "rad%rqtk : ", rad%rqtk
4491  print *, "rad%dtdtr : ", rad%dtdtr
4492  print *, "intr%dusfci_cpl : ", intr%dusfci_cpl
4493  print *, "intr%dvsfci_cpl : ", intr%dvsfci_cpl
4494  print *, "intr%dtsfci_cpl : ", intr%dtsfci_cpl
4495  print *, "intr%dqsfci_cpl : ", intr%dqsfci_cpl
4496  print *, "intr%dlwsfci_cpl : ", intr%dlwsfci_cpl
4497  print *, "intr%dswsfci_cpl : ", intr%dswsfci_cpl
4498  print *, "intr%dnirbmi_cpl : ", intr%dnirbmi_cpl
4499  print *, "intr%dnirdfi_cpl : ", intr%dnirdfi_cpl
4500  print *, "intr%dvisbmi_cpl : ", intr%dvisbmi_cpl
4501  print *, "intr%dvisdfi_cpl : ", intr%dvisdfi_cpl
4502  print *, "intr%nlwsfci_cpl : ", intr%nlwsfci_cpl
4503  print *, "intr%nswsfci_cpl : ", intr%nswsfci_cpl
4504  print *, "intr%nnirbmi_cpl : ", intr%nnirbmi_cpl
4505  print *, "intr%nnirdfi_cpl : ", intr%nnirdfi_cpl
4506  print *, "intr%nvisbmi_cpl : ", intr%nvisbmi_cpl
4507  print *, "intr%nvisdfi_cpl : ", intr%nvisdfi_cpl
4508  print *, "intr%t2mi_cpl : ", intr%t2mi_cpl
4509  print *, "intr%q2mi_cpl : ", intr%q2mi_cpl
4510  print *, "intr%u10mi_cpl : ", intr%u10mi_cpl
4511  print *, "intr%v10mi_cpl : ", intr%v10mi_cpl
4512  print *, "intr%tseai_cpl : ", intr%tseai_cpl
4513  print *, "intr%psurfi_cpl : ", intr%psurfi_cpl
4514  print *, "tbd%tref : ", tbd%tref
4515  print *, "tbd%z_c : ", tbd%z_c
4516  print *, "tbd%c_0 : ", tbd%c_0
4517  print *, "tbd%c_d : ", tbd%c_d
4518  print *, "tbd%w_0 : ", tbd%w_0
4519  print *, "tbd%w_d : ", tbd%w_d
4520  end if ! debug
4521 
4522  end subroutine
4523 
4524 
4525 
4526 
4528  subroutine phys_run_readout (stateout, sfc, diag, intr, cld, rad, tbd)
4530  implicit none
4531 
4532  type(state_fields_out) :: stateout
4533  type(sfc_properties) :: sfc
4534  type(diagnostics) :: diag
4535  type(interface_fields) :: intr
4536  type(cloud_properties) :: cld
4537  type(radiation_tendencies) :: rad
4538  type(tbd_ddt) :: tbd
4539 
4540 
4541  integer, parameter :: funit = 98
4542  integer :: ios
4543 
4544  call dbgprint("phys_run_readout")
4545 
4546  ! open file
4547  open (funit, file='physrun_saveout.dat', status='old', form='unformatted', iostat=ios)
4548 
4549  read (funit, iostat=ios, err=900) &
4550 ! In/Out
4551  sfc%hice, sfc%fice, sfc%tisfc,&
4552  sfc%tsfc, tbd%tprcp, cld%cv, &
4553  cld%cvb, cld%cvt, tbd%srflag, &
4554  sfc%snowd, sfc%weasd,sfc%sncovr, &
4555  sfc%zorl, sfc%canopy, sfc%ffmm, &
4556  sfc%ffhh, sfc%f10m, diag%srunoff, &
4557  diag%evbsa, diag%evcwa, diag%snohfa, &
4558  diag%transa, diag%sbsnoa, diag%snowca, &
4559  diag%soilm, diag%tmpmin, diag%tmpmax, &
4560  diag%dusfc, diag%dvsfc, diag%dtsfc, &
4561  diag%dqsfc, diag%totprcp, diag%gflux, &
4562  diag%dlwsfc, diag%ulwsfc, diag%suntim, &
4563  diag%runoff, diag%ep, diag%cldwrk, &
4564  diag%dugwd, diag%dvgwd, diag%psmean, &
4565  diag%cnvprcp, diag%spfhmin, diag%spfhmax, &
4566  diag%rain, diag%rainc, diag%dt3dt, &
4567  diag%dq3dt, diag%du3dt, diag%dv3dt, diag%dqdt_v, &
4568  cld%cnvqc_v, tbd%acv, tbd%acvb, tbd%acvt, tbd%slc, &
4569  tbd%smc, tbd%stc, tbd%upd_mf, tbd%dwn_mf, &
4570  tbd%det_mf, tbd%phy_f3d, tbd%phy_f2d, &
4571  intr%dusfc_cpl, intr%dvsfc_cpl, intr%dtsfc_cpl, &
4572  intr%dqsfc_cpl, intr%dlwsfc_cpl, &
4573  intr%dswsfc_cpl, intr%dnirbm_cpl, intr%dnirdf_cpl, &
4574  intr%dvisbm_cpl, intr%dvisdf_cpl, intr%rain_cpl, &
4575  intr%nlwsfc_cpl, intr%nswsfc_cpl, intr%nnirbm_cpl, &
4576  intr%nnirdf_cpl, intr%nvisbm_cpl, intr%nvisdf_cpl, &
4577  intr%snow_cpl, intr%xt, intr%xs, intr%xu, intr%xv, &
4578  intr%xz, intr%zm, intr%xtts, intr%xzts, intr%d_conv, &
4579  intr%ifd, intr%dt_cool, intr%Qrain, &
4580  tbd%tref, tbd%z_c, tbd%c_0, tbd%c_d, tbd%w_0, tbd%w_d, &
4581 ! NEW
4582  tbd%phy_fctd, &
4583 ! Out
4584  stateout%gt0, stateout%gq0, stateout%gu0, stateout%gv0, &
4585  sfc%t2m, sfc%q2m, diag%u10m, diag%v10m, diag%zlvl, &
4586  diag%psurf, diag%hpbl, diag%pwat, &
4587  diag%t1, diag%q1, diag%u1, diag%v1, diag%chh, diag%cmm, &
4588  diag%dlwsfci, diag%ulwsfci, diag%dswsfci, &
4589  diag%uswsfci, diag%dusfci, diag%dvsfci, &
4590  diag%dtsfci, diag%dqsfci, diag%gfluxi, &
4591  diag%epi, diag%smcwlt2, diag%smcref2, &
4592  diag%wet1, diag%sr, rad%rqtk, rad%dtdtr, &
4593  intr%dusfci_cpl, intr%dvsfci_cpl, intr%dtsfci_cpl, &
4594  intr%dqsfci_cpl, intr%dlwsfci_cpl, intr%dswsfci_cpl, &
4595  intr%dnirbmi_cpl, intr%dnirdfi_cpl, intr%dvisbmi_cpl, &
4596  intr%dvisdfi_cpl, intr%nlwsfci_cpl, intr%nswsfci_cpl, &
4597  intr%nnirbmi_cpl, intr%nnirdfi_cpl, intr%nvisbmi_cpl, &
4598  intr%nvisdfi_cpl, intr%t2mi_cpl, intr%q2mi_cpl, &
4599  intr%u10mi_cpl, intr%v10mi_cpl, intr%tseai_cpl, &
4600  intr%psurfi_cpl
4601 
4602  ! close file
4603  close (funit, iostat=ios)
4604 
4605  if (debug) then
4606  print *, "AFTER PHYS RUN READOUT"
4607  print *, "---------------------------"
4608  print *, "stateout%gt0 : ", stateout%gt0
4609  print *, "stateout%gq0 : ", stateout%gq0
4610  print *, "stateout%gu0 : ", stateout%gu0
4611  print *, "stateout%gv0 : ", stateout%gv0
4612  print *, "sfc%t2m : ", sfc%t2m
4613  print *, "sfc%q2m : ", sfc%q2m
4614  print *, "diag%u10m : ", diag%u10m
4615  print *, "diag%v10m : ", diag%v10m
4616  print *, "diag%zlvl : ", diag%zlvl
4617  print *, "diag%psurf : ", diag%psurf
4618  print *, "diag%hpbl : ", diag%hpbl
4619  print *, "diag%pwat : ", diag%pwat
4620  print *, "diag%t1 : ", diag%t1
4621  print *, "diag%q1 : ", diag%q1
4622  print *, "diag%u1 : ", diag%u1
4623  print *, "diag%v1 : ", diag%v1
4624  print *, "diag%chh : ", diag%chh
4625  print *, "diag%cmm : ", diag%cmm
4626  print *, "diag%dlwsfci : ", diag%dlwsfci
4627  print *, "diag%ulwsfci : ", diag%ulwsfci
4628  print *, "diag%dswsfci : ", diag%dswsfci
4629  print *, "diag%uswsfci : ", diag%uswsfci
4630  print *, "diag%dusfci : ", diag%dusfci
4631  print *, "diag%dvsfci : ", diag%dvsfci
4632  print *, "diag%dtsfci : ", diag%dtsfci
4633  print *, "diag%dqsfci : ", diag%dqsfci
4634  print *, "diag%gfluxi : ", diag%gfluxi
4635  print *, "diag%epi : ", diag%epi
4636  print *, "diag%smcwlt2 : ", diag%smcwlt2
4637  print *, "diag%smcref2 : ", diag%smcref2
4638  print *, "diag%wet1 : ", diag%wet1
4639  print *, "diag%sr : ", diag%sr
4640  print *, "rad%rqtk : ", rad%rqtk
4641  print *, "rad%dtdtr : ", rad%dtdtr
4642  print *, "intr%dusfci_cpl : ", intr%dusfci_cpl
4643  print *, "intr%dvsfci_cpl : ", intr%dvsfci_cpl
4644  print *, "intr%dtsfci_cpl : ", intr%dtsfci_cpl
4645  print *, "intr%dqsfci_cpl : ", intr%dqsfci_cpl
4646  print *, "intr%dlwsfci_cpl : ", intr%dlwsfci_cpl
4647  print *, "intr%dswsfci_cpl : ", intr%dswsfci_cpl
4648  print *, "intr%dnirbmi_cpl : ", intr%dnirbmi_cpl
4649  print *, "intr%dnirdfi_cpl : ", intr%dnirdfi_cpl
4650  print *, "intr%dvisbmi_cpl : ", intr%dvisbmi_cpl
4651  print *, "intr%dvisdfi_cpl : ", intr%dvisdfi_cpl
4652  print *, "intr%nlwsfci_cpl : ", intr%nlwsfci_cpl
4653  print *, "intr%nswsfci_cpl : ", intr%nswsfci_cpl
4654  print *, "intr%nnirbmi_cpl : ", intr%nnirbmi_cpl
4655  print *, "intr%nnirdfi_cpl : ", intr%nnirdfi_cpl
4656  print *, "intr%nvisbmi_cpl : ", intr%nvisbmi_cpl
4657  print *, "intr%nvisdfi_cpl : ", intr%nvisdfi_cpl
4658  print *, "intr%t2mi_cpl : ", intr%t2mi_cpl
4659  print *, "intr%q2mi_cpl : ", intr%q2mi_cpl
4660  print *, "intr%u10mi_cpl : ", intr%u10mi_cpl
4661  print *, "intr%v10mi_cpl : ", intr%v10mi_cpl
4662  print *, "intr%tseai_cpl : ", intr%tseai_cpl
4663  print *, "intr%psurfi_cpl : ", intr%psurfi_cpl
4664  print *, "tbd%tref : ", tbd%tref
4665  print *, "tbd%z_c : ", tbd%z_c
4666  print *, "tbd%c_0 : ", tbd%c_0
4667  print *, "tbd%c_d : ", tbd%c_d
4668  print *, "tbd%w_0 : ", tbd%w_0
4669  print *, "tbd%w_d : ", tbd%w_d
4670  end if ! debug
4671 
4672 
4673  ! report any errors
4674 900 if (ios .ne. 0 ) print *, "DBG NUOPC IOERR : ", ios
4675 
4676  end subroutine
4677 
4678 
4680 
4681  subroutine dbgprint(msg)
4682 
4683  implicit none
4684 
4685  integer :: me
4686  character*(*) msg
4687 
4688  me = myme
4689 
4690  if (debug .and. (me .eq. 0)) then
4691  print *, me, ":DBG NUOPC: ", msg
4692  end if
4693 
4694  end subroutine
4696  end module
DDT for fields typically only used for diagnostic output.
DDT for basic inputs of radiation and physics parameters.
subroutine, public phys_run_readout(stateout, sfc, diag, intr, cld, rad, tbd)
Read outputs from nuopc_phys_run from physrun_saveout.dat.
subroutine, public nuopc_phys_init(mdl, ntcw, ncld, ntoz, NTRAC, levs, me, lsoil, ntiw, ntlnc, ntinc, lsm, nmtvr, nrcm, levozp, levh2o, lonr, latr, jcap, num_p3d, num_p2d, npdf3d, ncnvcld3d, pl_coeff, ncw, crtrh, cdmbgwd, ccwf, dlqf, ctei_rm, cgwf, prslrd0, ral_ts, ras, pre_rad, ldiag3d, lgocart, lssav_cpl, flipv, old_monin, cnvgwd, shal_cnv, imfshalcnv, imfdeepcnv, cal_pre, mom4ice, mstrat, trans_trac, nstf_name, moist_adj, thermodyn_id, sfcpress_id, gen_coord_hybrid, levr, lsidea, pdfcld, shcnvcw, redrag, hybedmf, dspheat, dxmaxin, dxminin, dxinvin, h2o_phys, h2o_coeff,
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.
DDT for radiation tendencies.
DDT for surface fields.
DDT for basic outputs from radiation and physics.
subroutine rad_initialize
Definition: rad_initialize.f:4
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
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 gfuncphys
Definition: funcphys.f:2851
subroutine, public phys_init_savein(levr, ntcw, ncld, ntoz, NTRAC, levs, me, lsoil, lsm, nmtvr, nrcm, levozp, lonr, latr, jcap, num_p3d, num_p2d, npdf3d, ncnvcld3d, pl_coeff, ncw, nstf_name, thermodyn_id, sfcpress_id, crtrh, cdmbgwd, ccwf, dlqf, ctei_rm, cgwf, prslrd0, ral_ts, ras, pre_rad, ldiag3d, lgocart, lssav_cpl, flipv, old_monin, cnvgwd, shal_cnv, imfshalcnv, imfdeepcnv, cal_pre, mom4ice, mstrat, trans_trac, moist_adj, gen_coord_hybrid, lsidea, pdfcld, shcnvcw, redrag, hybedmf, dspheat, dxmax, dxmin, dxinv,
subroutine, public rad_run_readout(diags, intrfc_fld, cld_prop, rad_tend)
Read outputs from nuopc_rad_run from radrun_saveout.dat.
subroutine, public phys_run_readin(statein, sfc, diag, intr, cld, rad, mdl, tbd, dyn)
@ brief Read inputs to nuopc_phys_run from physrun_savein.dat.
subroutine, public nuopc_sppt_phys(stateout, diag, intr, rad, mdl, tbd, dyn)
subroutine, public phys_init_readin(levr, ntcw, ncld, ntoz, NTRAC, levs, me, lsoil, lsm, nmtvr, nrcm, levozp, lonr, latr, jcap, num_p3d, num_p2d, npdf3d, ncnvcld3d, pl_coeff, ncw, nstf_name, thermodyn_id, sfcpress_id, crtrh, cdmbgwd, ccwf, dlqf, ctei_rm, cgwf, prslrd0, ral_ts, ras, pre_rad, ldiag3d, lgocart, lssav_cpl, flipv, old_monin, cnvgwd, shal_cnv, imfshalcnv, imfdeepcnv, cal_pre, mom4ice, mstrat, trans_trac, moist_adj, gen_coord_hybrid, lsidea, pdfcld, shcnvcw, redrag, hybedmf, dspheat, dxmaxin, dxminin, dxinvin,
Reads inputs that are used for nuopc_phys_init from init_savein.dat.
subroutine, public phys_run_savein(statein, sfc, diag, intr, cld, rad, mdl, tbd, dyn)
@ brief Write inputs to nuopc_phys_run to physrun_savein.dat.
subroutine, public h2oini(this, jindx1_h, jindx2_h, h2oplin, ddy_h, h2o_pres)
subroutine gbphys
Definition: gbphys.f:739
logical, parameter, public use_nuopc
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).
subroutine, public ozoneini(this, jindx1, jindx2, ozplin, ddy)
Writes inputs that are used for nuopc_phys_init to init_savein.dat.
DDT for data that has not been pigeonholed and is left to be determined.
DDT for non-changing model parameters - set once in initialize.
subroutine, public phys_run_saveout(stateout, sfc, diag, intr, cld, rad, tbd)
Write outputs from nuopc_phys_run to physrun_saveout.dat.
DDT for cloud data and parameters. Used by grrad and gbphys with different intent.
logical, parameter debug
the interface between the dynamic core and the physics packages
subroutine set_soilveg(me, isot, ivet, nlunit)
Definition: set_soilveg.f:2
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 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
subroutine, public nuopc_phys_run(statein, stateout, sfc, diag, intr, cld, rad, mdl, tbd, dyn)