Line data Source code
1 : module microp_driver
2 :
3 : !-------------------------------------------------------------------------------------------------------
4 : !
5 : ! Driver for CAM microphysics parameterizations
6 : !
7 : !-------------------------------------------------------------------------------------------------------
8 :
9 : use shr_kind_mod, only: r8 => shr_kind_r8
10 : use ppgrid, only: pver
11 : use physics_types, only: physics_state, physics_ptend, physics_tend, &
12 : physics_ptend_copy, physics_ptend_sum
13 : use physics_buffer, only: pbuf_get_index, pbuf_get_field, physics_buffer_desc
14 : use phys_control, only: phys_getopts
15 :
16 : use micro_pumas_cam, only: micro_pumas_cam_readnl, micro_pumas_cam_register, &
17 : micro_pumas_cam_implements_cnst, micro_pumas_cam_init_cnst, &
18 : micro_pumas_cam_init, micro_pumas_cam_tend
19 : use cam_logfile, only: iulog
20 : use cam_abortutils, only: endrun
21 : use perf_mod, only: t_startf, t_stopf
22 :
23 : implicit none
24 : private
25 : save
26 :
27 : public :: &
28 : microp_driver_readnl, &
29 : microp_driver_register, &
30 : microp_driver_init_cnst, &
31 : microp_driver_implements_cnst, &
32 : microp_driver_init, &
33 : microp_driver_tend
34 :
35 : character(len=16) :: microp_scheme ! Microphysics scheme
36 :
37 : !===============================================================================
38 : contains
39 : !===============================================================================
40 :
41 1536 : subroutine microp_driver_readnl(nlfile)
42 :
43 : character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input
44 :
45 : ! Read in namelist for microphysics scheme
46 : !-----------------------------------------------------------------------
47 :
48 1536 : call phys_getopts(microp_scheme_out=microp_scheme)
49 :
50 1536 : select case (microp_scheme)
51 : case ('MG')
52 1536 : call micro_pumas_cam_readnl(nlfile)
53 : case ('NONE', 'RK')
54 0 : continue
55 : case default
56 1536 : call endrun('microp_driver_readnl:: unrecognized microp_scheme, "'//trim(microp_scheme)//'"')
57 : end select
58 :
59 1536 : end subroutine microp_driver_readnl
60 :
61 1536 : subroutine microp_driver_register
62 :
63 : ! Register microphysics constituents and fields in the physics buffer.
64 : !-----------------------------------------------------------------------
65 :
66 :
67 1536 : select case (microp_scheme)
68 : case ('MG')
69 1536 : call micro_pumas_cam_register()
70 : case ('RK')
71 : ! microp_driver doesn't handle this one
72 0 : continue
73 : case default
74 1536 : call endrun('microp_driver_register:: unrecognized microp_scheme')
75 : end select
76 :
77 1536 : end subroutine microp_driver_register
78 :
79 : !===============================================================================
80 :
81 0 : function microp_driver_implements_cnst(name)
82 :
83 : ! Return true if specified constituent is implemented by the
84 : ! microphysics package
85 :
86 : character(len=*), intent(in) :: name ! constituent name
87 : logical :: microp_driver_implements_cnst ! return value
88 :
89 : ! Local workspace
90 : integer :: m
91 : !-----------------------------------------------------------------------
92 :
93 0 : microp_driver_implements_cnst = .false.
94 :
95 0 : select case (microp_scheme)
96 : case ('MG')
97 0 : microp_driver_implements_cnst = micro_pumas_cam_implements_cnst(name)
98 : case ('NONE', 'RK')
99 0 : continue
100 : case default
101 0 : call endrun('microp_driver_implements_cnst:: unrecognized microp_scheme, '//trim(microp_scheme))
102 : end select
103 :
104 0 : end function microp_driver_implements_cnst
105 :
106 : !===============================================================================
107 :
108 0 : subroutine microp_driver_init_cnst(name, latvals, lonvals, mask, q)
109 :
110 : ! Initialize the microphysics constituents, if they are
111 : ! not read from the initial file.
112 :
113 : character(len=*), intent(in) :: name ! constituent name
114 : real(r8), intent(in) :: latvals(:) ! lat in degrees (ncol)
115 : real(r8), intent(in) :: lonvals(:) ! lon in degrees (ncol)
116 : logical, intent(in) :: mask(:) ! Only initialize where .true.
117 : real(r8), intent(out) :: q(:,:) ! kg tracer/kg dry air (gcol, plev
118 : !-----------------------------------------------------------------------
119 :
120 0 : select case (microp_scheme)
121 : case ('MG')
122 0 : call micro_pumas_cam_init_cnst(name, latvals, lonvals, mask, q)
123 : case ('RK')
124 : ! microp_driver doesn't handle this one
125 0 : continue
126 : case default
127 0 : call endrun('microp_driver_init_cnst:: unrecognized microp_scheme'//trim(microp_scheme))
128 : end select
129 :
130 0 : end subroutine microp_driver_init_cnst
131 :
132 : !===============================================================================
133 :
134 1536 : subroutine microp_driver_init(pbuf2d)
135 :
136 : type(physics_buffer_desc), pointer :: pbuf2d(:,:)
137 :
138 : ! Initialize the microphysics parameterizations
139 : !-----------------------------------------------------------------------
140 :
141 1536 : select case (microp_scheme)
142 : case ('MG')
143 1536 : call micro_pumas_cam_init(pbuf2d)
144 : case ('RK')
145 : ! microp_driver doesn't handle this one
146 0 : continue
147 : case default
148 1536 : call endrun('microp_driver_init:: unrecognized microp_scheme'//trim(microp_scheme))
149 : end select
150 :
151 :
152 1536 : end subroutine microp_driver_init
153 :
154 : !===============================================================================
155 :
156 58302720 : subroutine microp_driver_tend(state, ptend, dtime, pbuf)
157 :
158 : ! Call the microphysics parameterization run methods.
159 :
160 : ! Input arguments
161 :
162 : type(physics_state), intent(in) :: state ! State variables
163 : type(physics_ptend), intent(out) :: ptend ! Package tendencies
164 : type(physics_buffer_desc), pointer :: pbuf(:)
165 :
166 : real(r8), intent(in) :: dtime ! Timestep
167 :
168 : ! Local variables
169 :
170 : integer :: lchnk
171 : integer :: ncol
172 :
173 : !======================================================================
174 :
175 241920 : lchnk = state%lchnk
176 241920 : ncol = state%ncol
177 :
178 : ! Call MG Microphysics
179 :
180 241920 : select case (microp_scheme)
181 : case ('MG')
182 241920 : call t_startf('microp_mg_tend')
183 241920 : call micro_pumas_cam_tend(state, ptend, dtime, pbuf)
184 241920 : call t_stopf('microp_mg_tend')
185 : case ('RK')
186 : ! microp_driver doesn't handle this one
187 0 : continue
188 : case default
189 241920 : call endrun('microp_driver_tend:: unrecognized microp_scheme'//trim(microp_scheme))
190 : end select
191 :
192 241920 : end subroutine microp_driver_tend
193 :
194 : end module microp_driver
|