@@ -198,6 +198,34 @@ def main(cycle_dt_beg, sim_hrs, wrf_dir, run_dir, tmp_dir, icbc_model, exp_name,
198
198
return success
199
199
sys .exit (1 )
200
200
201
+ # If the WRF namelist has a line "iofields_filename", look for the name(s) of that file(s)
202
+ # If that file(s) exists in the templates directory, then copy it/them over to the WRF run directory
203
+ is_iofields = False
204
+ with open ('namelist.input' ) as nml :
205
+ for line in nml :
206
+ if line .strip ()[0 :17 ] == 'iofields_filename' :
207
+ # If the user didn't add an ending comma, that might be a problem...
208
+ iofields_fnames = line .split ('=' )[1 ].strip ().split (',' )
209
+ is_iofields = True
210
+ break
211
+ if is_iofields :
212
+ # How many file names were listed?
213
+ n_io_files = len (iofields_fnames )
214
+ # Loop over the file(s)
215
+ for ff in range (n_io_files ):
216
+ # Strip any spaces and get rid of any quotes around the file name that are the first/last character
217
+ io_fname = iofields_fnames [ff ].strip ()[1 :- 1 ]
218
+ # If this is blank or a newline, then we're at the end of the list.
219
+ if io_fname == '' or io_fname == '\n ' :
220
+ break
221
+ io_file = tmp_dir .joinpath (io_fname )
222
+ if io_file .is_file ():
223
+ ret , output = exec_command (['cp' , io_file , '.' ], log , False , False )
224
+ else :
225
+ log .warning (f'WARNING: WRF namelist expects to find { io_fname } to control WRF variable I/O.' )
226
+ log .warning (f' That file was not found in { tmp_dir } ,' )
227
+ log .warning (' so cannot be copied to the run directory.' )
228
+
201
229
## Clean up any rsl.out, rsl.error, and wrf log files
202
230
files = glob .glob ('rsl.*' )
203
231
for file in files :
0 commit comments