Installing EPA SWMM on a Mac using WineBottler

A while ago, I posted a video tutorial on how to use WineBottler to install some engineering software on a Mac that often only works on Windows. I just realized I never posted it here, so the video is embedded below! YouTube also has a more general tutorial on WineBottler that is linked here.

We have had some success using this for HEC programs and EPA programs, but sometimes there are issues that preclude this solution working for all programs. But it is nice when it does work!

Launching Jupyter Notebook Using an Icon/Shortcut in the Current Working Directory Folder

Launching Jupyter Notebook Using an Icon/Shortcut in the Current Working Directory Folder

A petty annoyance I’ve encountered when wanting to open Jupyter Notebook (overview) is that I couldn’t find a way to instantly open it in my current Windows Explorer window. While one trick you can use to open the Command Prompt in this folder is by typing ‘cmd’ in the navigation bar above (shown below) and pressing Enter/Return, I wanted to create a shortcut or icon I could double-click in any given folder and have it open Jupyter Notebook in that same working directory. cmd.png

This method allows you to drag-and-drop the icon you create into any folder and have it launch Jupyter Notebook from the new folder. It works for Windows 7, 8, and 10. Please feel free to let me know if you encounter any errors!

A great application for this shortcut may be to include this shortcut in GitHub folders where you wish to direct someone to launch Jupyter Notebook with minimal confusion. Just direct them to double-click on the icon and away they go!

Creating Your Own Jupyter Notebook Shortcut

new_shortcut.png

To begin, we must have already installed Jupyter Notebook or Jupyter Lab. Next, navigate to the folder we want to create your shortcut. Right-click, select ‘New’, then create a shortcut. 

shortcut_34.PNG

In the Create Shortcut Windows prompt, type the location of the item you want the Shortcut Icon to direct to. In this case, we are wanting direct this shortcut to the Command Prompt and have it run the command to open Jupyter Notebook. Copy/paste or type the following into the prompt:

cmd /k “jupyter notebook”

Note that cmd will change to the location of the Command Prompt executable file (e.g. C:\Windows\System32\cmd.exe), and ‘/k’ keeps the Command Prompt window open to ensure Jypyter Notebook does not crash. You can edit the command in the quotation marks to any command you would want, but in this case ‘jupyter notebook’ launches an instance of Jupyter Notebook.

You can then save this shortcut with whatever name you wish!

At this point, double-clicking the shortcut will open Jupyter Notebook in a static default directory (e.g. ‘C:\Windows\system32’). To fix this, we need to ensure that this shortcut instead directs to the current working directory (the location of the shortcut).

Picture1321.png

Next, we need to edit the location where the Command Prompt will run in. Right-click on your newly-created icon and select ‘Properties’ at the bottom of the menu to open the window shown on the left. One thing to note is that the ‘Target’ input is where we initially put in our ‘location’ prompt from above.

At this point, change the ‘Start in:’ input (e.g. ‘C:\Windows\system32’) to the following:

%cd%

By changing this input, instead of starting the Command Prompt in a static default directory, it instead starts the command prompt  in the current working directory for the shortcut.

At this point, you’re finished! You can drag and drop this icon to any new folder and have Jupyter Notebook start in that new folder.

If you wish to download a copy of the shortcut from Dropbox. Note that for security reasons, most browsers, hosting services, and email services will rename the file from ‘jupyter_notebook_shortcut.lnk’ to ‘jupyter_notebook_shortcut.downloads’.

Many thanks to users on superuser for helping develop this solution!

Please let me know if you have any questions, comments, or additional suggestions on applications for this shortcut!

 

Using a virtual machine to run 32-bit software on a modern PC

In this post, I’ll talk about how to set up a virtual machine on a PC, in order to run outdated software that may have been optimized for a different version of Windows. For example, a collaborator of mine uses the EPA Water Treatment Plant model which only seems to work under 32-bit versions of the operating system.

Continue reading

How to set up MinGW for the first time

I was quite surprised that no one on the internet has written a simple list of what to do to get a code compiled with MinGW before.  Seems like you have to have 3 PhDs in computer science to read the directions (or maybe I’m just having a bad day).  Nonetheless, we’re here to help.

By the way, you may be asking “What is MinGW?” It is a port of the GNU compilers on Windows (the GNU compilers being the ones that are used on things like Linux and the computing clusters).  Its website is here.  “Wait a sec, why would we want to use MinGW if we already have Cygwin?  Doesn’t it do the same thing?”  Yes.  But, sometimes things won’t work on Cygwin.   Also, I think MinGW is a lot smaller and lighter weight than Cygwin so if you are limited in resources that’s another reason.

Anyway, here goes:

  1. Go to the MinGW website: http://www.mingw.org/.

  2. Click Downloads, and select ‘mingw-get-setup.exe.’

  3. This is an installer that will grab all the proper packages for you.  Make sure to keep the installation directory the same as default: ‘C:\MinGW\’.  Once you click through the set of initial prompts, you will see an install manager.  That install manager has a set of checkboxes, that ask you if you want gfortran, g++, etc.  Right click on the check boxes and select ‘Mark for Installation.’

  4. In the program, under the Installation menu, select ‘Apply Changes’

  5. Wait for everything to download and install, and follow the instructions.  After you are done, it won’t tell you anything, you should just trust that it has completed.

  6. Note that there is a utility called MINSYS that is installed with MinGW.  What that is, is kind of like ‘Cygwin Lite’.  It is a small set of linux commands and a shell, that you can use to compile programs.  We aren’t going to cover MINSYS here but, this is a set of instructions for how to use it.  But what we want to do, is compile programs in the native DOS command window of Windows.  So we need to do a few more things.

  7. Next we need to set the PATH of windows to know where MinGW is.  Why?  Well you want to open a command window in any directory in Windows, and type ‘g++’ and have the computer know what it is you’re talking about. For Windows XP – Windows 7 users, check out instructions here.  We are using Windows 8, so we can use the search functionality.  If you type ‘environment’ in the Windows search box, you’ll see a link for ‘Set System Environment Variables’. Click it.

  8. It brings you to a window that is titled ‘System Properties’.  Click the button that says ‘Environment variables…’  In that window, in the second box, you can scroll down and see a variable called Path.  It should start with ‘C:\windows\system32;C:\windows;’  Highlight Path and click Edit…

  9. At the very end of the list, type a ; (without a space) and ‘C:\MinGW\bin’  So your path should look like: ‘C:\windows\system32;C:\windows;[otherstuff];C:\MinGW\bin

  10. Click OK three times, to get out of all of the windows.

  11. This step is very important!  Restart your computer, otherwise the Path settings won’t take.

  12. Now, after you are restarted, get to the command line by typing ‘cmd’ in a search box.  A black, old-timey window will pop up.  If you type the command: ‘g++’ , it should tell you “g++: fatal error: no input files”  This means g++ is installed, and it is on the path correctly, and it (ostensibly) works.

  13. You will likely need an additional command instead of just the vanilla ‘g++’ and ‘gfortran’  If you are using a Makefile, you need an additional utility.  On Linux this is called ‘make’, but here it’s called something different: mingw32-make.  Thanks to this forum post for this (and other helpful) hint(s)!

You should be good to go.  Now, you have a minimalistic way to compile stuff that is supposed to work using GNU compilers (on Unix and the clusters) on Windows!  As usual, comments questions and concerns should be posted below.

MOEAframework on Windows

A lot of the posts on this blog cover MOEAframework used on Unix machines and high performance computing clusters.  However you can also easily use it on Windows!  Here are some steps to get started:

At java.com, you need the “Java Development Kit” in addition to the regular Java already installed on your machine.

Next, follow the instructions here: http://vietpad.sourceforge.net/javaonwindows.html to set up environment variables for your Windows machine. Make sure to add the JAVA_HOME and CLASSPATH environment variables and then add the JAVA_HOME string to the PATH as instructed.

Then, restart your computer

Open a command prompt (type cmd in the “run” window or search box on Windows 7/8).  Navigate to the directory in the command prompt that contains your MOEAframework example files.  The MOEAFramework-1.15-Executable.jar file should be in that directory along with Example1.java.  To compile Example1.java the command is:

javac -classpath MOEAFramework-1.15-Executable.jar Example1.java

Then to run it, you type:

java -classpath MOEAFramework-1.15-Executable.jar Example1

That’s it!  You should see some output in the command window that signifies that everything worked.  You can also use the MOEAframework GUI in Windows by double clicking the MOEAframework executable.

As always let us know if you have questions/comments below.