#!/usr/bin/perl -w # Script name: convert_m6_inputs.pl # Created by: Catherine Seppanen (cseppan@unc.edu) # Last modified: 4/7/2004 # # Usage: convert_m6_inputs.pl # # Description: This script converts MOBILE6 input files into the inputs used by SMOKE. # # Files in the input directory are expected to use the following naming convention: # [A-Z](5 digit FIPS code)(2 digit particle size).IN # # The script reads all files in the input directory that are named *10.IN # Each file is assumed to contain one run with multiple scenarios. # The first 12 scenarios in the file are read and are assumed to correspond to # the inputs for January through December. # # The script creates new directories in the output directory, one for each month # (January through December). Each scenario is written to the proper directory # and named using the 5 digit FIPS code from the original input file name. use strict; # check that command line arguments were given if (scalar @ARGV != 2) { die < END } # get input and output directories from command line my $inputDir = $ARGV[0]; my $outputDir = $ARGV[1]; # strip trailing slashes from directories $inputDir =~ s/\/$//; $outputDir =~ s/\/$//; # create output directory if needed if (! -e $outputDir) { mkdir ($outputDir) or die <) { chomp; # Skip blank and comment lines if (/^>/ or /^\*/ or /^\s*$/) { next; } # Check if we are in the header if ($inHeader) { if (/^RUN DATA/) { $inHeader = 0; $inRun = 1; } next; } # Check if we are in the run level commands if ($inRun) { # Skip unused commands if (/^EXPRESS HC/ or /^NO REFUELING/ or /^EXPAND/ or /^IDLE PM/ ) { next; } if (/^SCENARIO RECORD/) { $inRun = 0; $inScenario = 1; push (@{$scenCmds[$currScen]}, $_); next; } push (@runCmds, $_); } # Check if we are in a scenario if ($inScenario) { if (/^SCENARIO RECORD/) { $currScen = $currScen + 1; # Only read first 12 scenarios if ($currScen == 12) { last; } push (@{$scenCmds[$currScen]}, $_); next; } if (/^END OF RUN/) { $inScenario = 0; next; } push (@{$scenCmds[$currScen]}, $_); } } # get FIPS code from input file name $fileName =~ /^[A-Z]([0-9]{5})10\.IN$/i; my $fipsCode = '0' . $1; # write individual output files for (my $i = 0; $i < 12; $i++) { my $outputFileName = $outputDir . '/' .$monthList[$i] . '/' . $fipsCode . '.in'; open (my $outputFile, ">$outputFileName") or die <