1 subroutine read_namelist(hstart, hend, delta_time, ntimes,&
2 ordered_by_date, debug_level, out_format, prefix)
4 use misc_definitions_module
8 integer , parameter :: maxim_doms = 21
9 character(len=200) :: extdataroot, file_name_namelist
10 character(len=19) :: hstart, hend
13 logical :: ordered_by_date
14 integer :: debug_level
19 ! Declare the namelist variables:
21 integer , dimension(maxim_doms) :: start_year
22 integer , dimension(maxim_doms) :: start_month
23 integer , dimension(maxim_doms) :: start_day
24 integer , dimension(maxim_doms) :: start_hour
25 integer , dimension(maxim_doms) :: start_minute
26 integer , dimension(maxim_doms) :: start_second
28 integer , dimension(maxim_doms) :: end_year
29 integer , dimension(maxim_doms) :: end_month
30 integer , dimension(maxim_doms) :: end_day
31 integer , dimension(maxim_doms) :: end_hour
32 integer , dimension(maxim_doms) :: end_minute
33 integer , dimension(maxim_doms) :: end_second
35 logical , dimension(maxim_doms) :: active_grid
36 integer , dimension(maxim_doms) :: subgrid_ratio_x
37 integer , dimension(maxim_doms) :: subgrid_ratio_y
39 character (len=128) , dimension(maxim_doms) :: start_date, end_date
40 character (len=MAX_FILENAME_LEN) :: opt_output_from_geogrid_path
41 integer :: interval_seconds = 0
42 character (len=3) :: wrf_core = 'ARW'
43 integer :: max_dom, io_form_geogrid
45 character(len=3) :: out_format
46 character(len=MAX_FILENAME_LEN) :: prefix
48 namelist /share/ wrf_core, max_dom, &
49 start_year, start_month, start_day, start_hour, &
50 start_minute, start_second, &
51 end_year, end_month, end_day, end_hour, &
52 end_minute, end_second,&
54 start_date, end_date, &
55 io_form_geogrid, opt_output_from_geogrid_path, debug_level, active_grid, &
56 subgrid_ratio_x, subgrid_ratio_y
58 namelist /ungrib/ out_format, &
59 ordered_by_date, prefix
83 ! Build the namelist file name:
86 CALL GETENV('EXT_DATAROOT',extdataroot)
88 file_name_namelist = 'namelist.wps'
90 ! Open the namelist file:
91 open(10, file=file_name_namelist, status='old', iostat=ierr)
92 call mprintf((ierr.ne.0),ERROR,"**** Error opening namelist file namelist.wps")
97 ordered_by_date = .TRUE.
98 start_date(1)(1:4) = '0000'
99 end_date(1)(1:4) = '0000'
103 if (debug_level.gt.100) then
104 call set_debug_level(DEBUG)
106 call set_debug_level(WARN)
110 ! Build the Starting date HSTART and the ending date HEND from the namelist
111 ! date/time information. start_date takes priority over the multi-variable method.
113 if ( start_date(1)(1:4) .eq. '0000' ) then
114 call build_hdate(hstart, start_year(1), start_month(1), start_day(1), start_hour(1), &
115 start_minute(1), start_second(1))
117 hstart = start_date(1)(1:19)
119 if ( end_date(1)(1:4) .eq. '0000' ) then
120 call build_hdate(hend, end_year(1), end_month(1), end_day(1), end_hour(1), &
121 end_minute(1), end_second(1))
123 hend = end_date(1)(1:19)
126 ! Compute the time difference between start date and end date:
128 call geth_idts(hend, hstart, idts)
130 ! Check that INTERVAL is greater than zero:
132 if (interval_seconds <= 0) then
133 call mprintf(.true.,STDOUT,"ERROR STOP IN READ_NAMELIST")
134 call mprintf(.true.,STDOUT,"INTERVAL must be greater than zero:")
135 call mprintf(.true.,STDOUT,"Start time: %s",s1=hstart)
136 call mprintf(.true.,STDOUT,"End time: %s",s1=hend)
137 call mprintf(.true.,STDOUT,"INTERVAL: %i",i1=interval_seconds)
138 call mprintf(.true.,LOGFILE,"ERROR STOP IN READ_NAMELIST")
139 call mprintf(.true.,LOGFILE,"INTERVAL must be greater than zero:")
140 call mprintf(.true.,LOGFILE,"Start time: %s",s1=hstart)
141 call mprintf(.true.,LOGFILE,"End time: %s",s1=hend)
142 call mprintf(.true.,LOGFILE,"INTERVAL: %i",i1=interval_seconds)
143 call mprintf(.true.,ERROR,"Change your namelist, and resubmit")
146 ! Check that the selected INTERVAL evenly fills difference between
147 ! start time and end time:
149 if ((idts/interval_seconds)*interval_seconds /= idts) then
150 call mprintf(.true.,STDOUT,"ERROR STOP IN READ_NAMELIST")
151 call mprintf(.true.,STDOUT,"INTERVAL must fit evenly between start time and end time:")
152 call mprintf(.true.,STDOUT,"Start time: %s",s1=hstart)
153 call mprintf(.true.,STDOUT,"End time: %s",s1=hend)
154 call mprintf(.true.,STDOUT,"INTERVAL : %i seconds, %f hours",&
155 i1=interval_seconds,f1=float(interval_seconds)/3600.)
156 call mprintf(.true.,LOGFILE,"ERROR STOP IN READ_NAMELIST")
157 call mprintf(.true.,LOGFILE,"INTERVAL must fit evenly between start time and end time:")
158 call mprintf(.true.,LOGFILE,"Start time: %s",s1=hstart)
159 call mprintf(.true.,LOGFILE,"End time: %s",s1=hend)
160 call mprintf(.true.,LOGFILE,"INTERVAL : %i seconds, %f hours",&
161 i1=interval_seconds,f1=float(interval_seconds)/3600.)
162 call mprintf(.true.,ERROR,"Change your namelist, and resubmit")
165 ! Check that start time is not later than end time:
167 if (hstart > hend) then
168 call mprintf(.true.,STDOUT,"ERROR STOP IN READ_NAMELIST")
169 call mprintf(.true.,STDOUT,"Start time must not be later than end time:")
170 call mprintf(.true.,STDOUT,"Start time: %s",s1=hstart)
171 call mprintf(.true.,STDOUT,"End time: %s",s1=hend)
172 call mprintf(.true.,STDOUT,"INTERVAL: %i",i1=interval_seconds)
173 call mprintf(.true.,LOGFILE,"ERROR STOP IN READ_NAMELIST")
174 call mprintf(.true.,LOGFILE,"Start time must not be later than end time:")
175 call mprintf(.true.,LOGFILE,"Start time: %s",s1=hstart)
176 call mprintf(.true.,LOGFILE,"End time: %s",s1=hend)
177 call mprintf(.true.,LOGFILE,"INTERVAL: %i",i1=interval_seconds)
178 call mprintf(.true.,ERROR,"Change your namelist, and resubmit")
181 ! Compute the number of time periods to process:
183 ntimes = idts/interval_seconds + 1
185 call mprintf(.true.,STDOUT, &
186 "Start_date = %s , End_date = %s ",s1=hstart,s2=hend)
187 call mprintf(.true.,LOGFILE, &
188 "Start_date = %s , End_date = %s ",s1=hstart,s2=hend)
190 if (debug_level.gt.0) then
191 call mprintf(.true.,LOGFILE,"Namelist information (coarse domain): ")
192 call mprintf(.true.,LOGFILE,' START_YEAR = %i',i1=start_year(1))
193 call mprintf(.true.,LOGFILE,' START_MONTH = %i',i1=start_month(1))
194 call mprintf(.true.,LOGFILE,' START_DAY = %i',i1=start_day(1))
195 call mprintf(.true.,LOGFILE,' START_HOUR = %i',i1=start_hour(1))
196 ! call mprintf(.true.,LOGFILE,"start_minute = %i",i1=start_minute(1))
197 ! call mprintf(.true.,LOGFILE,"start_second = %i",i1=start_second(1))
198 call mprintf(.true.,LOGFILE,' END_YEAR = %i',i1=end_year(1))
199 call mprintf(.true.,LOGFILE,' END_MONTH = %i',i1=end_month(1))
200 call mprintf(.true.,LOGFILE,' END_DAY = %i',i1=end_day(1))
201 call mprintf(.true.,LOGFILE,' END_HOUR = %i',i1=end_hour(1))
202 ! call mprintf(.true.,LOGFILE,"end_minute = %i",i1=end_minute(1))
203 ! call mprintf(.true.,LOGFILE,"end_second = %i",i1=end_second(1))
204 call mprintf(.true.,LOGFILE,' START_DATE = %s',s1=start_date(1))
205 call mprintf(.true.,LOGFILE,' END_DATE = %s',s1=end_date(1))
206 call mprintf(.true.,LOGFILE,' INTERVAL_SECONDS = %i',i1=interval_seconds)
207 call mprintf(.true.,LOGFILE,' DEBUG_LEVEL = %i',i1=debug_level)
208 call mprintf(.true.,LOGFILE,'/')
213 delta_time = interval_seconds
218 read(10,NML=ungrib,END=100)
220 call mprintf(.true.,LOGFILE,'&UNGRIB')
221 call mprintf(.true.,LOGFILE,"out_format = %s",s1=out_format)
222 if (ordered_by_date) then
223 call mprintf(.true.,LOGFILE,"ordered_by_date = %s",s1='TRUE')
225 call mprintf(.true.,LOGFILE,"ordered_by_date = %s",s1='FALSE')
227 call mprintf(.true.,LOGFILE,"prefix = %s",s1=trim(prefix))
228 call mprintf(.true.,LOGFILE,'/')
231 if (out_format(1:2) .eq. 'WP' .or. out_format(1:2) .eq. 'wp') then
233 call mprintf(.true.,STDOUT,'output format is WPS')
234 call mprintf(.true.,LOGFILE,'output format is WPS')
235 else if (out_format(1:2) .eq. 'SI' .or. out_format(1:2) .eq. 'si') then
237 call mprintf(.true.,STDOUT,'output format is SI')
238 call mprintf(.true.,LOGFILE,'output format is SI')
239 else if (out_format(1:2) .eq. 'MM' .or. out_format(1:2) .eq. 'mm') then
241 call mprintf(.true.,STDOUT,'output format is MM5 pregrid')
242 call mprintf(.true.,LOGFILE,'output format is MM5 pregrid')
244 call mprintf(.true.,ERROR, &
245 'read_namelist: I do not recognize the output format, %s , stopping.',s1=out_format)
248 ! Close the namelist file:
252 end subroutine read_namelist