1 MODULE module_cam_support
2 !------------------------------------------------------------------------
3 ! This module contains global scope variables and routines shared by
4 ! multiple CAM physics routines. As much as possible, the codes is copied
5 ! verbatim from the corresponding CAM modules noted below.
7 ! Author: William.Gustafson@pnl.gov, Nov 2009
8 !------------------------------------------------------------------------
9 use module_state_description, only: param_num_moist
17 integer(SHR_KIND_IN),parameter,private :: R8 = SHR_KIND_R8 ! rename for local readability only
19 ! From spmd_utils in CAM...
20 logical, parameter :: masterproc = .true.
22 ! From ppgrid in CAM...
23 integer, parameter :: pcols = 1 !Always have a chunk size of 1 in WRF
24 integer :: pver !Number of model level middles in CAM speak
25 integer :: pverp !Number of model level interfaces in CAM speak
27 ! From constituents in CAM...
28 integer, parameter :: pcnst = param_num_moist !Number of tracer constituents for CAM q array
29 !In WRF this is currently setup to only handle
30 !the moist array, and then even in a half-handed way.
31 !We allocate the max possible size, but loops need to
32 !be over a smaller number.
33 !Scalar and chem need to eventually be handled too.
34 real(kind=r8), parameter, dimension(pcnst) :: qmin = 0. !Minimun constituent concentration
38 character(len=250) :: iulog !In CAM this is a file handle. In WRF, this is a string
39 !that can be used to send messages via wrf_message, etc.
41 !From cam_pio_utils.F90
42 integer, parameter, public :: phys_decomp=100
44 ! From cam_pio_utils (used in camuwpbl_driver module)...
45 integer, parameter :: fieldname_len = 16 ! max chars for field name
47 !------------------------------------------------------------------------
49 !------------------------------------------------------------------------
51 !!$!------------------------------------------------------------------------
52 !!$CHARACTER(len=3) FUNCTION cnst_get_type_byind(ind)
53 !!$! Gets the consituent type.
55 !!$! Replaces function of same name in constituents module in CAM.
56 !!$! ~This routine is currently hard-coded for the indices. It should be
57 !!$! generalized to handle arbitrary values, especially for chemical
58 !!$! tracers and advanced microphysics with additional phases.
60 !!$! Author: William.Gustafson@pnl.gov, Nov 2009
61 !!$!------------------------------------------------------------------------
62 !!$ integer, intent(in) :: ind !global constituent index (in q array)
67 !!$ cnst_get_type_byind = "wet"
68 !!$ case (2) !cloud droplets
69 !!$ cnst_get_type_byind = "wet"
70 !!$ case (3) !cloud ice crystals
71 !!$ cnst_get_type_byind = "wet"
73 !!$ cnst_get_type_byind = "wet"
76 !!$END FUNCTION cnst_get_type_byind
79 !------------------------------------------------------------------------
80 SUBROUTINE endrun(msg)
81 ! Pass through routine to wrf_error_fatal that mimics endrun in module
84 ! Replaces endrun in abortutils module in CAM.
86 ! Author: William.Gustafson@pnl.gov, Nov 2009
87 ! Modified : Balwinder.Singh@pnl.gov - Argument made optional
88 !------------------------------------------------------------------------
91 ! Argument of the subroutine is made optional to accomodate endrun calls with no argument
92 character(len=*), intent(in), optional :: msg
95 call wrf_error_fatal(msg)
97 ! The error message is written to iulog bwfore the endrun call
98 call wrf_error_fatal(iulog)
101 END SUBROUTINE endrun
105 !------------------------------------------------------------------------
106 SUBROUTINE t_stopf(event)
107 ! Stub to accomodate stop time calls of CAM
109 ! Replaces t_stopf in perf_mod module in CAM.
111 ! Author: Balwinder.Singh@pnl.gov
112 !------------------------------------------------------------------------
113 character(len=*), intent(in) :: event
115 END SUBROUTINE t_stopf
119 !------------------------------------------------------------------------
120 SUBROUTINE t_startf(event)
121 ! Stub to accomodate start time calls of CAM
123 ! Replaces t_startf in perf_mod module in CAM.
125 ! Author: Balwinder.Singh@pnl.gov
126 !------------------------------------------------------------------------
128 character(len=*), intent(in) :: event
130 END SUBROUTINE t_startf
134 !------------------------------------------------------------------------
135 SUBROUTINE outfld( fname, field, idim, c)
136 ! Stub to accomodate outfld calls of CAM
138 ! Replaces outfld in cam_history module in CAM.
140 ! Author: Balwinder.Singh@pnl.gov
141 !------------------------------------------------------------------------
142 character(len=*), intent(in) :: fname
143 integer, intent(in) :: idim
144 integer, intent(in) :: c
145 real(r8), intent(in) :: field(idim,*)
147 END SUBROUTINE outfld
151 !------------------------------------------------------------------------
152 SUBROUTINE addfld(fname, units, numlev, avgflag, long_name, &
153 decomp_type, flag_xyfill, flag_isccplev, sampling_seq)
154 ! Stub to accomodate addfld calls of CAM
156 ! Replaces addfld in cam_history module in CAM.
158 ! Author: Balwinder.Singh@pnl.gov
159 !------------------------------------------------------------------------
160 character(len=*), intent(in) :: fname
161 character(len=*), intent(in) :: units
162 character(len=1), intent(in) :: avgflag
163 character(len=*), intent(in) :: long_name
165 integer, intent(in) :: numlev
166 integer, intent(in) :: decomp_type
168 logical, intent(in), optional :: flag_xyfill
169 logical, intent(in), optional :: flag_isccplev
170 character(len=*), intent(in), optional :: sampling_seq
172 END SUBROUTINE ADDFLD
174 END MODULE module_cam_support