Why would you want swap usage to be higher?
Reading/writing to the swap is 1000 times slower than reading/writing to the RAM.
The system may not be hanging, it's just that it's so busy swapping stuff back and forth, it appears as though it hung.
@phihag said in the comments:
Most likely, when swap reaches 4GB this happens to be around the time
that some part of the user interface gets swapped out. For instance,
that could be the code to handle Ctrl+C, the keyboard layout handler,
the code that displays output in the terminal, some data buffer of the
terminal, some data buffer of the X server which paints pictures, etc.
. Chances are if you wait a couple of hours either your swap is filled
up or all of the data and code necessary for the Ctrl+C to be handled
at the various layers has finally resulted in killing your Fortran
process
I would suggest getting some more RAM. It will drastically speed up your compile. It's quite inexpensive nowadays, ~$60 for 16GB.