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 integer , dimension(maxim_doms) :: sr_x
36 integer , dimension(maxim_doms) :: sr_y
38 character (len=128) , dimension(maxim_doms) :: start_date, end_date
39 character (len=MAX_FILENAME_LEN) :: opt_output_from_geogrid_path
40 integer :: interval_seconds = 0
41 character (len=3) :: wrf_core = 'ARW'
42 integer :: max_dom, io_form_geogrid
44 character(len=3) :: out_format
45 character(len=MAX_FILENAME_LEN) :: prefix
47 namelist /share/ wrf_core, max_dom, &
48 start_year, start_month, start_day, start_hour, &
49 start_minute, start_second, &
50 end_year, end_month, end_day, end_hour, &
51 end_minute, end_second,&
53 start_date, end_date, &
54 io_form_geogrid, opt_output_from_geogrid_path, debug_level, &
57 namelist /ungrib/ out_format, &
58 ordered_by_date, prefix
82 ! Build the namelist file name:
85 CALL GETENV('EXT_DATAROOT',extdataroot)
87 file_name_namelist = 'namelist.wps'
89 ! Open the namelist file:
90 open(10, file=file_name_namelist, status='old', iostat=ierr)
91 call mprintf((ierr.ne.0),ERROR,"**** Error opening namelist file namelist.wps")
96 ordered_by_date = .TRUE.
97 start_date(1)(1:4) = '0000'
98 end_date(1)(1:4) = '0000'
102 if (debug_level.gt.100) then
103 call set_debug_level(DEBUG)
105 call set_debug_level(WARN)
109 ! Build the Starting date HSTART and the ending date HEND from the namelist
110 ! date/time information. start_date takes priority over the multi-variable method.
112 if ( start_date(1)(1:4) .eq. '0000' ) then
113 call build_hdate(hstart, start_year(1), start_month(1), start_day(1), start_hour(1), &
114 start_minute(1), start_second(1))
116 hstart = start_date(1)(1:19)
118 if ( end_date(1)(1:4) .eq. '0000' ) then
119 call build_hdate(hend, end_year(1), end_month(1), end_day(1), end_hour(1), &
120 end_minute(1), end_second(1))
122 hend = end_date(1)(1:19)
125 ! Compute the time difference between start date and end date:
127 call geth_idts(hend, hstart, idts)
129 ! Check that INTERVAL is greater than zero:
131 if (interval_seconds <= 0) then
132 call mprintf(.true.,STDOUT,"ERROR STOP IN READ_NAMELIST")
133 call mprintf(.true.,STDOUT,"INTERVAL must be greater than zero:")
134 call mprintf(.true.,STDOUT,"Start time: %s",s1=hstart)
135 call mprintf(.true.,STDOUT,"End time: %s",s1=hend)
136 call mprintf(.true.,STDOUT,"INTERVAL: %i",i1=interval_seconds)
137 call mprintf(.true.,LOGFILE,"ERROR STOP IN READ_NAMELIST")
138 call mprintf(.true.,LOGFILE,"INTERVAL must be greater than zero:")
139 call mprintf(.true.,LOGFILE,"Start time: %s",s1=hstart)
140 call mprintf(.true.,LOGFILE,"End time: %s",s1=hend)
141 call mprintf(.true.,LOGFILE,"INTERVAL: %i",i1=interval_seconds)
142 call mprintf(.true.,ERROR,"Change your namelist, and resubmit")
145 ! Check that the selected INTERVAL evenly fills difference between
146 ! start time and end time:
148 if ((idts/interval_seconds)*interval_seconds /= idts) then
149 call mprintf(.true.,STDOUT,"ERROR STOP IN READ_NAMELIST")
150 call mprintf(.true.,STDOUT,"INTERVAL must fit evenly between start time and end time:")
151 call mprintf(.true.,STDOUT,"Start time: %s",s1=hstart)
152 call mprintf(.true.,STDOUT,"End time: %s",s1=hend)
153 call mprintf(.true.,STDOUT,"INTERVAL : %i seconds, %f hours",&
154 i1=interval_seconds,f1=float(interval_seconds)/3600.)
155 call mprintf(.true.,LOGFILE,"ERROR STOP IN READ_NAMELIST")
156 call mprintf(.true.,LOGFILE,"INTERVAL must fit evenly between start time and end time:")
157 call mprintf(.true.,LOGFILE,"Start time: %s",s1=hstart)
158 call mprintf(.true.,LOGFILE,"End time: %s",s1=hend)
159 call mprintf(.true.,LOGFILE,"INTERVAL : %i seconds, %f hours",&
160 i1=interval_seconds,f1=float(interval_seconds)/3600.)
161 call mprintf(.true.,ERROR,"Change your namelist, and resubmit")
164 ! Check that start time is not later than end time:
166 if (hstart > hend) then
167 call mprintf(.true.,STDOUT,"ERROR STOP IN READ_NAMELIST")
168 call mprintf(.true.,STDOUT,"Start time must not be later than end time:")
169 call mprintf(.true.,STDOUT,"Start time: %s",s1=hstart)
170 call mprintf(.true.,STDOUT,"End time: %s",s1=hend)
171 call mprintf(.true.,STDOUT,"INTERVAL: %i",i1=interval_seconds)
172 call mprintf(.true.,LOGFILE,"ERROR STOP IN READ_NAMELIST")
173 call mprintf(.true.,LOGFILE,"Start time must not be later than end time:")
174 call mprintf(.true.,LOGFILE,"Start time: %s",s1=hstart)
175 call mprintf(.true.,LOGFILE,"End time: %s",s1=hend)
176 call mprintf(.true.,LOGFILE,"INTERVAL: %i",i1=interval_seconds)
177 call mprintf(.true.,ERROR,"Change your namelist, and resubmit")
180 ! Compute the number of time periods to process:
182 ntimes = idts/interval_seconds + 1
184 call mprintf(.true.,STDOUT, &
185 "Start_date = %s , End_date = %s ",s1=hstart,s2=hend)
186 call mprintf(.true.,LOGFILE, &
187 "Start_date = %s , End_date = %s ",s1=hstart,s2=hend)
189 if (debug_level.gt.0) then
190 call mprintf(.true.,LOGFILE,"Namelist information (coarse domain): ")
191 call mprintf(.true.,LOGFILE,' START_YEAR = %i',i1=start_year(1))
192 call mprintf(.true.,LOGFILE,' START_MONTH = %i',i1=start_month(1))
193 call mprintf(.true.,LOGFILE,' START_DAY = %i',i1=start_day(1))
194 call mprintf(.true.,LOGFILE,' START_HOUR = %i',i1=start_hour(1))
195 ! call mprintf(.true.,LOGFILE,"start_minute = %i",i1=start_minute(1))
196 ! call mprintf(.true.,LOGFILE,"start_second = %i",i1=start_second(1))
197 call mprintf(.true.,LOGFILE,' END_YEAR = %i',i1=end_year(1))
198 call mprintf(.true.,LOGFILE,' END_MONTH = %i',i1=end_month(1))
199 call mprintf(.true.,LOGFILE,' END_DAY = %i',i1=end_day(1))
200 call mprintf(.true.,LOGFILE,' END_HOUR = %i',i1=end_hour(1))
201 ! call mprintf(.true.,LOGFILE,"end_minute = %i",i1=end_minute(1))
202 ! call mprintf(.true.,LOGFILE,"end_second = %i",i1=end_second(1))
203 call mprintf(.true.,LOGFILE,' START_DATE = %s',s1=start_date(1))
204 call mprintf(.true.,LOGFILE,' END_DATE = %s',s1=end_date(1))
205 call mprintf(.true.,LOGFILE,' INTERVAL_SECONDS = %i',i1=interval_seconds)
206 call mprintf(.true.,LOGFILE,' DEBUG_LEVEL = %i',i1=debug_level)
207 call mprintf(.true.,LOGFILE,'/')
212 delta_time = interval_seconds
217 read(10,NML=ungrib,END=100)
219 call mprintf(.true.,LOGFILE,'&UNGRIB')
220 call mprintf(.true.,LOGFILE,"out_format = %s",s1=out_format)
221 if (ordered_by_date) then
222 call mprintf(.true.,LOGFILE,"ordered_by_date = %s",s1='TRUE')
224 call mprintf(.true.,LOGFILE,"ordered_by_date = %s",s1='FALSE')
226 call mprintf(.true.,LOGFILE,"prefix = %s",s1=trim(prefix))
227 call mprintf(.true.,LOGFILE,'/')
230 if (out_format(1:2) .eq. 'WP' .or. out_format(1:2) .eq. 'wp') then
232 call mprintf(.true.,STDOUT,'output format is WPS')
233 call mprintf(.true.,LOGFILE,'output format is WPS')
234 else if (out_format(1:2) .eq. 'SI' .or. out_format(1:2) .eq. 'si') then
236 call mprintf(.true.,STDOUT,'output format is SI')
237 call mprintf(.true.,LOGFILE,'output format is SI')
238 else if (out_format(1:2) .eq. 'MM' .or. out_format(1:2) .eq. 'mm') then
240 call mprintf(.true.,STDOUT,'output format is MM5 pregrid')
241 call mprintf(.true.,LOGFILE,'output format is MM5 pregrid')
243 call mprintf(.true.,ERROR, &
244 'read_namelist: I do not recognize the output format, %s , stopping.',s1=out_format)
247 ! Close the namelist file:
251 end subroutine read_namelist