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
49 namelist /share/ wrf_core, max_dom, &
50 start_year, start_month, start_day, start_hour, &
51 start_minute, start_second, &
52 end_year, end_month, end_day, end_hour, &
53 end_minute, end_second,&
55 start_date, end_date, &
56 io_form_geogrid, opt_output_from_geogrid_path, &
57 debug_level, active_grid, &
58 subgrid_ratio_x, subgrid_ratio_y, &
61 namelist /ungrib/ out_format, &
62 ordered_by_date, prefix
87 ! Build the namelist file name:
90 CALL GETENV('EXT_DATAROOT',extdataroot)
92 file_name_namelist = 'namelist.wps'
94 ! Open the namelist file:
95 open(10, file=file_name_namelist, status='old', iostat=ierr)
96 call mprintf((ierr.ne.0),ERROR,"**** Error opening namelist file namelist.wps")
101 ordered_by_date = .TRUE.
102 start_date(1)(1:4) = '0000'
103 end_date(1)(1:4) = '0000'
107 if (debug_level.gt.100) then
108 call set_debug_level(DEBUG)
110 call set_debug_level(WARN)
114 ! Build the Starting date HSTART and the ending date HEND from the namelist
115 ! date/time information. start_date takes priority over the multi-variable method.
117 if ( start_date(1)(1:4) .eq. '0000' ) then
118 call build_hdate(hstart, start_year(1), start_month(1), start_day(1), start_hour(1), &
119 start_minute(1), start_second(1))
121 hstart = start_date(1)(1:19)
123 if ( end_date(1)(1:4) .eq. '0000' ) then
124 call build_hdate(hend, end_year(1), end_month(1), end_day(1), end_hour(1), &
125 end_minute(1), end_second(1))
127 hend = end_date(1)(1:19)
130 ! Compute the time difference between start date and end date:
132 call geth_idts(hend, hstart, idts)
134 ! Check that INTERVAL is greater than zero:
136 if (interval_seconds <= 0) then
137 call mprintf(.true.,STDOUT,"ERROR STOP IN READ_NAMELIST")
138 call mprintf(.true.,STDOUT,"INTERVAL must be greater than zero:")
139 call mprintf(.true.,STDOUT,"Start time: %s",s1=hstart)
140 call mprintf(.true.,STDOUT,"End time: %s",s1=hend)
141 call mprintf(.true.,STDOUT,"INTERVAL: %i",i1=interval_seconds)
142 call mprintf(.true.,LOGFILE,"ERROR STOP IN READ_NAMELIST")
143 call mprintf(.true.,LOGFILE,"INTERVAL must be greater than zero:")
144 call mprintf(.true.,LOGFILE,"Start time: %s",s1=hstart)
145 call mprintf(.true.,LOGFILE,"End time: %s",s1=hend)
146 call mprintf(.true.,LOGFILE,"INTERVAL: %i",i1=interval_seconds)
147 call mprintf(.true.,ERROR,"Change your namelist, and resubmit")
150 ! Check that the selected INTERVAL evenly fills difference between
151 ! start time and end time:
153 if ((idts/interval_seconds)*interval_seconds /= idts) then
154 call mprintf(.true.,STDOUT,"ERROR STOP IN READ_NAMELIST")
155 call mprintf(.true.,STDOUT,"INTERVAL must fit evenly between start time and end time:")
156 call mprintf(.true.,STDOUT,"Start time: %s",s1=hstart)
157 call mprintf(.true.,STDOUT,"End time: %s",s1=hend)
158 call mprintf(.true.,STDOUT,"INTERVAL : %i seconds, %f hours",&
159 i1=interval_seconds,f1=float(interval_seconds)/3600.)
160 call mprintf(.true.,LOGFILE,"ERROR STOP IN READ_NAMELIST")
161 call mprintf(.true.,LOGFILE,"INTERVAL must fit evenly between start time and end time:")
162 call mprintf(.true.,LOGFILE,"Start time: %s",s1=hstart)
163 call mprintf(.true.,LOGFILE,"End time: %s",s1=hend)
164 call mprintf(.true.,LOGFILE,"INTERVAL : %i seconds, %f hours",&
165 i1=interval_seconds,f1=float(interval_seconds)/3600.)
166 call mprintf(.true.,ERROR,"Change your namelist, and resubmit")
169 ! Check that start time is not later than end time:
171 if (hstart > hend) then
172 call mprintf(.true.,STDOUT,"ERROR STOP IN READ_NAMELIST")
173 call mprintf(.true.,STDOUT,"Start time must not be later than end time:")
174 call mprintf(.true.,STDOUT,"Start time: %s",s1=hstart)
175 call mprintf(.true.,STDOUT,"End time: %s",s1=hend)
176 call mprintf(.true.,STDOUT,"INTERVAL: %i",i1=interval_seconds)
177 call mprintf(.true.,LOGFILE,"ERROR STOP IN READ_NAMELIST")
178 call mprintf(.true.,LOGFILE,"Start time must not be later than end time:")
179 call mprintf(.true.,LOGFILE,"Start time: %s",s1=hstart)
180 call mprintf(.true.,LOGFILE,"End time: %s",s1=hend)
181 call mprintf(.true.,LOGFILE,"INTERVAL: %i",i1=interval_seconds)
182 call mprintf(.true.,ERROR,"Change your namelist, and resubmit")
185 ! Compute the number of time periods to process:
187 ntimes = idts/interval_seconds + 1
189 call mprintf(.true.,STDOUT, &
190 "Start_date = %s , End_date = %s ",s1=hstart,s2=hend)
191 call mprintf(.true.,LOGFILE, &
192 "Start_date = %s , End_date = %s ",s1=hstart,s2=hend)
194 if (debug_level.gt.0) then
195 call mprintf(.true.,LOGFILE,"Namelist information (coarse domain): ")
196 call mprintf(.true.,LOGFILE,' START_YEAR = %i',i1=start_year(1))
197 call mprintf(.true.,LOGFILE,' START_MONTH = %i',i1=start_month(1))
198 call mprintf(.true.,LOGFILE,' START_DAY = %i',i1=start_day(1))
199 call mprintf(.true.,LOGFILE,' START_HOUR = %i',i1=start_hour(1))
200 ! call mprintf(.true.,LOGFILE,"start_minute = %i",i1=start_minute(1))
201 ! call mprintf(.true.,LOGFILE,"start_second = %i",i1=start_second(1))
202 call mprintf(.true.,LOGFILE,' END_YEAR = %i',i1=end_year(1))
203 call mprintf(.true.,LOGFILE,' END_MONTH = %i',i1=end_month(1))
204 call mprintf(.true.,LOGFILE,' END_DAY = %i',i1=end_day(1))
205 call mprintf(.true.,LOGFILE,' END_HOUR = %i',i1=end_hour(1))
206 ! call mprintf(.true.,LOGFILE,"end_minute = %i",i1=end_minute(1))
207 ! call mprintf(.true.,LOGFILE,"end_second = %i",i1=end_second(1))
208 call mprintf(.true.,LOGFILE,' START_DATE = %s',s1=start_date(1))
209 call mprintf(.true.,LOGFILE,' END_DATE = %s',s1=end_date(1))
210 call mprintf(.true.,LOGFILE,' INTERVAL_SECONDS = %i',i1=interval_seconds)
211 call mprintf(.true.,LOGFILE,' DEBUG_LEVEL = %i',i1=debug_level)
212 call mprintf(.true.,LOGFILE,'/')
217 delta_time = interval_seconds
222 read(10,NML=ungrib,END=100)
224 call mprintf(.true.,LOGFILE,'&UNGRIB')
225 call mprintf(.true.,LOGFILE,"out_format = %s",s1=out_format)
226 if (ordered_by_date) then
227 call mprintf(.true.,LOGFILE,"ordered_by_date = %s",s1='TRUE')
229 call mprintf(.true.,LOGFILE,"ordered_by_date = %s",s1='FALSE')
231 call mprintf(.true.,LOGFILE,"prefix = %s",s1=trim(prefix))
232 call mprintf(.true.,LOGFILE,'/')
235 if (out_format(1:2) .eq. 'WP' .or. out_format(1:2) .eq. 'wp') then
237 call mprintf(.true.,STDOUT,'output format is WPS')
238 call mprintf(.true.,LOGFILE,'output format is WPS')
239 else if (out_format(1:2) .eq. 'SI' .or. out_format(1:2) .eq. 'si') then
241 call mprintf(.true.,STDOUT,'output format is SI')
242 call mprintf(.true.,LOGFILE,'output format is SI')
243 else if (out_format(1:2) .eq. 'MM' .or. out_format(1:2) .eq. 'mm') then
245 call mprintf(.true.,STDOUT,'output format is MM5 pregrid')
246 call mprintf(.true.,LOGFILE,'output format is MM5 pregrid')
248 call mprintf(.true.,ERROR, &
249 'read_namelist: I do not recognize the output format, %s , stopping.',s1=out_format)
252 ! Close the namelist file:
256 end subroutine read_namelist