Compilation of PHITS using the free Intel Fortran compiler(OneAPI toolkits)Contents
1. Windows ……………………………………………………2
2. Linux……………………………………………………23

3. macOS ……………………………………………………2811. Windows
Phase I: Install Visual Studio IDE (integrated development environment)
I-1
Search “visual studio” or go to https://visualstudio.microsoft.com/

I-2
Download “Visual Studio Community 2019”
Note : In April 2022, OneAPI and Visual Studio Community/professional/enterprise 2022
are incompatible. Please don’t select 2022 unless the latest OneAPI solves this compatibilityproblem.
I-3
Install “Visual Studio Community 2019” using the downloaded installer.
In the window below, please tick “Desktop development with C++”. It says C++ while PHITS
is Fortran, but this is OK.
Then click the right bottom button to start installation.

2

I-4
After installation, by launching the installer again, one can see if Visual Studio has been reallyinstalled. You will see “Visual Studio Community 2019” installed.

3

Phase II: Install OneAPI (Fortran compiler and its associated libraries)
II-1
Search “OneAPI BaseToolKit download” or go tohttps://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkitdownload.html

II-2
Select your OS, Online & Offline, and Online(If you fail the installation owing to network access instability, please consider choosingOffline )4

If a pop-up message says “Get Your Download. Sign in to your My Intel account using yourexisting credentials.”, click “Continue as a Guest (download starts immediately)” to proceed.
II-3
Launch the downloaded installer. Following popup window will show up.

5

II-4
Tick “I accept the terms of the license agreements” and click “continue” of “Recommended
Installation” on the right.

II-5
If you see a warning message below, something is wrong with Visual Studio installation. Pleasego back to Phase I.

6

II-6
Tick Microsoft Visual Studio* 2019 and click right arrow button on the bottom.

II-7
Tick whichever you prefer and click “Install” button.

7

II-8
Wait until the progress bars reach the right edges.

II-9
When installation ends, click “Finish” of the popup window.

8

9

II-10
Search “OneAPI HPCToolKit download” or go tohttps://www.intel.com/content/www/us/en/developer/tools/oneapi/hpc-toolkitdownload.html
II-11
Do the same as BaseToolkit explained above. Below are screenshots during HPCToolKitinstallation.

10

11

12

Phase III: Compile PHITS
III-0
Launch Visual Studio

III-1
From “Open a project or solution”, open /phits/bin/phits-intel.vfproj
If you cannot select it, please make sure that Intel oneAPI appears in Menu
Bar>Tool>Options. If not, oneAPI installation was not successful or you installed Visual
Studio 2022.

13

III-2
Select “Release” mode and “x64”. This configuration is the most memory/CPU effective.

14

III-3Create an executable file byBuild > Build Solution
In Windows, please see “Execute via Command Prompt” in the manual on how to launch theexecutable file.

15

III-3’To use OpenMP, activate “Qopenmp” option from
Menu bar > Project > Properties > Fortran > Language > Process OpenMP directives >Generate Parallel code16

III-3’’
III-3’’-1
To use MPI, you need to•

Install MS-MPI (not explained in this manual. Please search “MS-MPI install”)•Configure the Build of Visual Studio

To configure the Build of Visual Studio, close Visual Studio and open phits\bin\phitsintel.vfproj with a text editor (e.g. notepad++). Then replace a line
<File RelativePath="..\src\mpi-non.f"/>
with<File RelativePath="..\src\mpi-win.f"/>and save, open phits\bin\phits-intel.vfproj with Visual Studio again.

Updated project includes mpi-win.f in the solution explorer sub-window.

17

III-3’’-2
Add library files “msmpi.lib”, “msmpifec.lib”, and header files “mpif.h”,“mpifptr.h” to the solution explorer.

The directory of the files are as follows by default.

18

C:\Program Files (x86)\Microsoft SDKs\MPI\Include\mpif.h
C:\Program Files (x86)\Microsoft SDKs\MPI\Include\x64\mpifptr.h
C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64\msmpi.lib
C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64\msmpifec.lib

III-3’’-3Configure the Intel Fortran compiler in Visual studio.
Menu bar -> Tools -> Options -> IFORT Intel Fortran Classic -> Compilers -> x64 (tab) > “…” of Includes
Add following 2 folders"C:\Program Files (x86)\Microsoft SDKs\MPI\Include""C:\Program Files (x86)\Microsoft SDKs\MPI\Include\x64"

19III-3’’-4Consecutively
In the same tab x64, add a following folder to “…” of Libraries"C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64"
Then «Build» to create binary executable.

III-3’’-520

Modify phits/bin/phits.bat to use the MPI version of PHITS exe file. If the built executable
is at
C:/Users/ogawa/Documents/trans/PHITStest/compile/x64/Release/phits-intel.exe
Change the 4th line ofphits/bin/phits.bat
to be
set PHITS_MPI_EXE = C:
/Users/ogawa/Documents/trans/PHITStest/compile/x64/Release/phits-intel.exe

III-3’’-6Modify another line which specifies MPI_EXE in phits/bin/phits.bat to point the mpi
executable (not PHITS executable)
set MPI_EXE=”C:/Program Files/Microsoft MPI/Bin/mpiexec.exe”

21III-3’’-7
Insert a line
$OMP=**
at the top of PHITS input file where ** is the number of cores you would like to use. Thenlaunch PHITS (e.g. Run shortcut command) with this input file.

22III-3’’-8
In the terminal, batch report ends with “pe = ” if MPI works.

23

2. Linux
Phase I: Install OneAPI (Fortran compiler and its associated libraries)
I-1
Access to Intel official web site and download toolkits (the Base Kit and the HPC kit are
required for the Fortran compiler).
https://www.intel.com/content/www/us/en/developer/articles/news/free-intel-softwaredeveloper-tools.html

By clicking either of the above link, it will navigate to the following download page. Then you
need to download the “Intel oneAPI Base Toolkit” and “Intel oneAPI HPC Toolkit”. The link24

will navigate to the page to choose “Operating System” and “Distribution”. Please choose“Linux” for the “Operating System” and select the distribution choice which is suitable foryour distribution. If you are not sure for the choice of “Distribution”, you can choose “Online& Offline”.

I-2
Install the toolkits (the Base Kit and the HPC kit). Please install those toolkits following tothe instruction given in the download page. Normally you need to open a terminal and execute25

a shell script at the location of the download directory. The super user authorization may berequired. Then follow the instruction to continue the installation. The OpenMP and MPI
libraries are also included in those toolkits so that parallel computation of PHITS with
OpenMP and MPI can be easily performed.
I-3
Environmental setup is required to use the installed oneAPI libraries. The setup shell script
isprepared

in/opt/intel/oneapi/setvars.sh(forsystemwideinstallation)or~/intel/oneapi/setvars.sh (for private installation). The execution of the setup shell script isrequired at each time when you open a new terminal window command such as. /opt/intel/oneapi/setvar.sh (for system wide installation)or. ~/intel/oneapi/setvar.sh (for private installation).
If you think it is tedious to do at each opening of new terminal windows, you can add theabove command in your setup shell such as ~/.bashrc, ~/.bashrc_profile, or ~/.profile
according to your environment. Then the oneAPI setup shell script will be automatically
executed when you open a new terminal window.

Phase II: Compile PHITS
II-0
GNU make is required to compile PHITS. So please install GNU make package according toyour environment.
II-1
Open a terminal window and change directory to the source code directory of PHITS(phits/src).
II-2
Check (or modify) the makefile located in the source directory. The environmental flag
“ENVFLAGS” needs to be changed according to your compilation environment. To use theIntel Fortran compiler for Linux, please set “ENVFLAGS=LinIfort”, which should be default
option.
If you want to compile PHITS with activating MPI parallelization, please erase “#” before“USEMPI = true”. If you want to compile PHITS with activating OpenMP parallelization,please erase “#” before “USEOMP = true”.
26

II-3
Type “make” and return to compile PHITS in the terminal window. You can also parallelize
the compilation by typing “make -j **”, where ** is the number of computation cores you want
to use for this compilation.
You may see some warning messages but you can ignore those unless you see error messages
and the compilation stops. For the parallel compilation, there are cases you see errors by
unsolved dependence of the source codes. Please “make” again several times, which may solve
the dependence and successfully compile PHITS.
Successful compilation of PHITS will produce the PHITS executable in the parent directoryof the source code directory:
phits_LinIfort (without parallelization)phits_LinIfort_OMP (with OpenMP parallelization)phits_LinIfort_MPI (with MPI parallelization).
II-4
A setup to use the PHITS shell script as “phits.sh ***.inp” to execute PHITS by overwriting
the existing PHITS executables.
Please copy those files into the PHITS binary executable directory (phits/bin) by renaming
the file tophits_LinIfort => phits***_lin.exe
phits_LinIfort_OMP => phits***_lin_openmp.exe
phits_LinIfort_MPI => phits***_lin_mpi.exe
where *** is the PHITS version number.
Using the PHITS shell script, the parallelization can be controlled by the specification in the
1st line of the PHITS input file; “$OMP=**” and “$MPI=**”.
II-4’
A setup to use the PHITS shell script as “phits.sh ***.inp” to execute PHITS with keeping theold PHITS executables.
Please copy the compiled executable files into the PHITS binary executable directory(phits/bin). You can change the file name if you want. Then please modify the PHITS shell
script “phits.sh” in the directory according to match the names. The names of executables are
specified in “phits.sh” by
PHITS_SINGLE_EXE=phits***_lin.exe (without parallelization)
PHITS_OMP_EXE=phits***_lin_openmp.exe (with OpenMP parallelization)
27

PHITS_MPI_EXE=phits***_lin_mpi.exe (with MPI parallelization).
So please change the names of executables after “=” to be consistent.
Using the PHITS shell script, the parallelization can be controlled by the specification in the
1st line of the PHITS input file; “$OMP=**” and “$MPI=**”.
II-4’’
Directly use the executables to perform PHITS execution.
The created PHITS executables can be also used alone such as
phits_LinIfort < ***.inpphits_LinIfort_OMP < ***.inp
mpiexec -n 8 phits_LinIfort_MPI
where ***.inp is the PHITS input file. In this MPI execution, the file phits.in with“file=***.inp” at the 1st line is required in the execution directory. The MPI executioncommand and options may differ by your environment. Here “-n 8” means the 8 MPI processparallelization (7 calculation processes + 1 master process in PHITS).

28

3. macOS
Free use of Intel Fortran (Intel oneAPI Base Toolkit + HPC Toolkit)
Fortran Software:Intel® oneAPI Base Toolkit (version 2022.2, or later)Intel® oneAPI HPC Toolkit (version 2022.2, or later)
Please note that the oneAPI for macOS does not include MPI.
Phase I: Download and installation
1. Download
1.1 Go to the following and click the download button for Base Toolkit and HPC Toolkit.
https://www.intel.com/content/www/us/en/developer/tools/oneapi/toolkits.html#base-kit

291.2 Download Base Toolkit.

30

1.3 Download HPC Toolkit.

2. Installation of Base Kit
2.1. Expand the dmg file. You will get bootstrapper.app.

2.2. Double-click bootstrapper.app.
After a few minutes of waiting and a security warningmenu will appear, and "Continue" will take you to the installation screen. (At this point, there
are three oneAPI icons lined up in the Dock.)31

32

3. Installation of HPC Kit
3.1. Expand the dmg file. You will get bootstrapper.app.

3.2. Double-click bootstrapper.app.
After a few minutes of waiting and a security warningmenu will appear, and "Continue" will take you to the installation screen.

33

34

4. Environment setup
Environment setup is required to use the installed oneAPI libraries. The setup shell script isprepared in /opt/intel/oneapi/setvars.sh (for system wide installation). The execution of thesetup shell script is required at each time when you open a new terminal window commandsuch assource /opt/intel/oneapi/setvars.sh
If you think it is tedious to do at each opening of new terminal windows, you can add theabove command in your setup shell such as ~/.zshrc, ~/.bashrc, ~/.bashrc_profile, or~/.profile according to your environment. Then the oneAPI setup shell script will be
automatically executed when you open a new terminal window.

Phase II: Compile PHITS
0
The “make” package is required to compile PHITS. So please install the “make” package withHomebrew or MacPorts.
Homebrew: https://brew.sh/
MacPorts: https://www.macports.org/
1
Open a terminal window and change directory to the source code directory of PHITS(phits/src).
2
Check (or modify) the makefile located in the source directory. The environmental flag
“ENVFLAGS” needs to be changed according to your compilation environment. To use theIntel Fortran compiler for Linux, please set “ENVFLAGS=MacIfort”, which should be defaultoption.
If you want to compile PHITS with activating OpenMP parallelization, please erase “#” before“USEOMP = true”.

35

3
Type “make” and return to compile PHITS in the terminal window. You may see somewarning messages but you can ignore those unless you see error messages and the compilation
stops. Successful compilation of PHITS will produce the PHITS executable in the parent
directory of the source code directory:
phits_MacIfort (without parallelization)phits_MacIfort_OMP (with OpenMP parallelization)
4
A setup to use the PHITS shell script as “phits.sh ***.inp” to execute PHITS by overwriting
the existing PHITS executables.
Please copy those files into the PHITS binary executable directory (phits/bin) by renaming
the file tophits_MacIfort => phits***_mac.exe
phits_MacIfort_OMP => phits***_mac_openmp.exe
where *** is the PHITS version number.
Using the PHITS shell script, the parallelization can be controlled by the specification in the
1st line of the PHITS input file; “$OMP=**”.
4’
Directly use the executables to perform PHITS execution.
The created PHITS executables can be also used alone such as
phits_MacIfort < ***.inp
phits_MacIfort_OMP < ***.inp
where ***.inp is the PHITS input file.

36