Wednesday, May 25, 2011

Use HEC-1 under Windows 7

Well, I got tired of firing up older computers to run HEC-1, and I still don't find HEC-HMS to be totally compatible with the jurisdictional methods here in Arizona. So I decided to figure out a Windows 7 HEC-1 system. While this system works fine for me, it may be less than optimal for a newcomer to HEC-1, since my system doesn't include the old DOS COED help program that puts (or used to put) the HEC-1 manual at your onscreen fingertips. On the other hand, if you put the HEC-1 reference manual on a nearby desk or screen window, you will probably have enough help to get going even if you are a HEC-1 novice.

My system is simply to put HEC-1.EXE alone somewhere permanently accessible, then call it from command batch files I keep in each project. The batch files run their corresponding project data file in HEC-1 with a double-click.

You'll need the following tools to make this HEC-1 system work:
  • The latest HEC-1 installation package from the Hydrologic Engineering Center
  • A Zip file management program (Windows File Explorer does this, calling Zip files "compressed folders")
  • A good text editor. You can probably squeak by with Windows Notepad, but I strongly recommend you download and install the Open Source Notepad++.
What you will do with those tools is create a command batch file that you can use to run HEC-1 with one double-click. These are the steps to setting it all up HEC-1:
  1. Download the HEC-1 installation package
  2. Rename the extension of the package from "exe" to "zip" (yes, it's really a zip file; renaming it works)
  3. Extract the HEC1.EXE file from the package. You don't need any of the other files in the package, but you can also extract the other files including samples if you want.
  4. Move the HEC1.EXE file to an official and permanent location (like "C:\Program Files (x86)\HEC\HEC-1")
  5. Test the HEC1.EXE file by double clicking it. You should get a prompt for input filename.
  6. Download and install Notepad++.
  7. Open Notepad++ and paste something like the following command into it: "C:\Program Files (x86)\HEC\HEC-1\HEC1.exe" testfile.dat
  8. Save the file as "testfile.bat" to any working directory such as a project directory.
  9. Save a sample HEC-1 data file as testfile.dat to the working directory.
  10. Double-click on the testfile.bat file. A window should open briefly while HEC-1 runs. When HEC-1 is finished. A few new files including TAPE## files and testfile.OUT should appear in that working directory.
  11. Use right-click to open the testfile.OUT in Notepad++
  12. Use right-click to open the testfile.dat in Notepad++
  13. Now with both the data file and the output file open in Notepad++, make a change to the data file and CTRL+S save the change. Then go back to Windows Explorer and run the data file in HEC-1 again by double clicking the batch file. When you return to Notepad++, you will be notified that the output file has changed, and you will be permitted to reload it. This is the optimized edit/run/view/debug cycle for HEC-1 in Windows 7.
  14. When you are ready to start a new project or data file, simply make a copy of the testfile.bat batch file, open it in Notepad++, and change the name of the data file testfile.dat. Then rename the batch file to keep the names synchronized. Every project will remain set up to run HEC-1 with a double-click.
  15. Advanced Tip: If you want to put HEC-1 output into a word processor with a professional look, use the following Search and Replace feature of Notepad++ to replace all 1's on new lines with Form Feed characters. In early versions of Notepad++, the procedure was as follows: Type CTRL+R to bring up the advanced Replace box. Then in the search area, type "1" and CTRL+M. CTRL+M adds a carriage return to search for. In the replace area, type ALT+NUM0, ALT+NUM1, ALT+NUM2 (ALT+012) using the number pad instead of the numbers at the top of your keyboard to create the ASCII 012 Form Feed character. Then add a carriage return using CTRL+M again. Now make sure the Wrap and Selection checkboxes in the Search box are not checked. Click Find, then Replace Rest. Now your output is ready for pasting for presentation in the appendix of your drainage report (with a small monospaced font like Courier New, Monospac, or Andale Mono, of course).
Be sure to leave me any questions about this procedure or any other ideas you have.

9 comments:

Kevin W. said...

This saved my life. Thanks Tom.swar

Anonymous said...

I wrote a simple interface for HEC-1 called HEC1vm which gives allows you to edit data files and run the anaysis . in Windows and view the HEC-1 help (it actually uses the COED HP1 file) and HEC1 user manual PDF. you can download it from our web site: http://www.mde.state.md.us/programs/Water/DamSafety/TechnicalReferences/Pages/Programs/WaterPrograms/Dam_Safety/techref/dambreakguidelines.aspx

Anonymous said...
This comment has been removed by a blog administrator.
Unknown said...

What about HEC-2?

Thomas Gail Haws said...

Have you tried using a similar process for HEC-2? How has it gone?

Anonymous said...

Are you using Windows 7 32 bit or 64 bit? A DOS emulator may be required to run under 64 bit Windows.

Thomas Gail Haws said...

I am using Windows 7 64-bit. Yes. I believe you are right. Something like DosBox does work.

Anonymous said...

This method doesn't work if there are ZW (DSS write) cards in the model. Do you have any idea how to create a shortcut which will work with that?

Thomas Gail Haws said...

Unfortunately I haven't used ZW cards, so I can't test that or help you.