FLUKA and flair on Windows 10

FLUKA and flair can be run on a recent installation of Windows 10 using the Windows Subsystem for Linux. This document describes the installation process as of October 2019.

Obtaining FLUKA and Flair

You can download FLUKA from http://www.fluka.org after registering as a user. Several packages are available; you should download a 64-bit Linux package built with a version of gfortran that is as close as possible to the one we’ll be using. We’ll use gfortran-8 so, at the time of writing, the closest match was fluka2011.2x-linux-gfor64bit-8.3-AA.tar.gz.

Flair can be downloaded from http://www.fluka.org/flair/download.html. You should download the deb packages which are suitable for installation on 64-bit Ubuntu. At the time of writing, these were flair_2.3-0_all.deb and flair-geoviewer_2.3-0_amd64.deb.

In some of the commands that follow, we assume that the three packages referred to above have been downloaded to the directory \Users\abc\Downloads. When executing the commands, you should amend the directory and file names to reflect your own downloads.

Installing Ubuntu 18.04 LTS on Windows

In the Microsoft Store, search for “Ubuntu 18.04 LTS” and install the app. Once installed, launch the app from the Windows Start Menu. After some set up time, you will be prompted to create a UNIX user account. Choose a simple (one word) username and a password. You’ll need this password when executing commands which need admin access. (These commands are prefixed with sudo.) The Ubuntu app gives you access to a largely self-contained Linux system running within Windows. It has access to your Windows files. For example, our download directory is available at /mnt/c/Users/abc/Downloads.

Installing FLUKA in the Ubuntu app

You’ll need to run these commands in the window that opens on launching the Ubuntu app. First we’ll install some necessary software, and any updates:

sudo apt update
sudo DEBIAN_FRONTEND=noninteractive apt upgrade -y
sudo DEBIAN_FRONTEND=noninteractive apt install -y gcc gfortran-8 make

We’ll add some commands to the startup script ~/.bashrc to configure our environment. (See the FLUKA README for the use of FLUPRO, FLUFOR and GFORFLU.)

cat >>~/.bashrc <<EOF
umask 022
export DISPLAY=:0
export FLUPRO=~/fluka
export FLUFOR=gfortran
export GFORFLU=gfortran-8
EOF

We source the startup script to get this configuration. Subsequent launches of the Ubuntu app will do this by default. We then make a directory to hold the FLUKA files, extract our downloaded package to it, and build the code. (Remember to modify the path to the download if necessary.)

source ~/.bashrc
mkdir $FLUPRO
cd $FLUPRO
tar xvf /mnt/c/Users/abc/Downloads/fluka2011.2x-linux-gfor64bit-8.3-AA.tar.gz
make

If this completes without errors, FLUKA is ready to use.

Installing flair in the Ubuntu app

Flair is installed from the downloaded deb packages:

sudo DEBIAN_FRONTEND=noninteractive apt install -y /mnt/c/Users/abc/Downloads/{flair_2.3-0_all.deb,flair-geoviewer_2.3-0_amd64.deb}

As a graphical application, it needs access to an X server to run. Recently configured school machines have an X server (Xming) already installed. On other machines you may need to install one. You’ll need to make sure that the X server is running before starting flair. The DISPLAY environment variable also needs to be correctly set in Ubuntu; this should be working if you followed the instructions for ~/.bashrc above. If these conditions are met, running the command flair in the Ubuntu app should start a new window with the application.

Running flair from a Windows script

For convenience, you may create a script to run flair without going via a command window. Add the following to a file called flair.vbs:

set objShell = CreateObject("Wscript.Shell")
objShell.CurrentDirectory = objShell.ExpandEnvironmentStrings("%USERPROFILE%")
objShell.Run "ubuntu1804.exe run bash -ic flair", 0, False

Clicking on this script should launch flair. (Remember that the X server must be running before starting flair.)

A note on storing files

You can choose to keep your input and output files in the Windows filesystem and operate on them via the /mnt/ path in the Ubuntu app. This may make management and backup easier. Some Linux applications have problems with files in the Windows filesystem, but FLUKA and flair seem to be unaffected.

If you need to transfer files from the Windows filesystem to Linux, always do the transfer from inside the Ubuntu app, using Linux tools like cp. See https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/