2021/02/10

User Manual of the TASK CodeContents
1 What is the TASK code?
1.1 Features of the TASK code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Module structure of the TASK code . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Speciﬁcations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

112
2

2 Install of the TASK code
2.1 To get the TASK code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Compile of the TASK code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.1 Compile of the GSAF library . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.2 Select branch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.3 Set up the conﬁguration ﬁles and common library . . . . . . . . . . . . .
2.2.4 Compile the BPSD library . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.5 Compile a required TASK component . . . . . . . . . . . . . . . . . . . .

22334455

3 Run the TASK code
3.1 Run a TASK component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1.1 Graphic setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1.2 Menu input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Run the tot component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Parameter input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.4 Save graphic data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.5 View and convert the graphic data . . . . . . . . . . . . . . . . . . . . . . . . . .

6667
7788

4 Structure of a typical TASK component
4.1 Support directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Typical ﬁle name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

99101

What is the TASK code?

The TASK (Transport Analyzing System for takamaK) code is a suite of modeling tools for analyzing equilibrium, transport, wave propagation, and velocity distribution function in tokamak
plasmas.
1.1

Features of the TASK code
• Simulation on time evolution of tokamak plasmas– Integrated simulation code suite with modular structure– Analysis of various heating and current drive mechanism– High portability– Extension to three-dimensional helical plasmas– Parallel processing using MPI libraries– Interface to experimental database• Core code suite in Burning Plasma Simulation Initiative1

– Minimum integrated code: all components are exchangeable– Test implementation of BPSD: standard data interface– Uniﬁed user interface:
1.2

Module structure of the TASK code
2D equilibrium
2D equilibrium

Fixed boundaryFree boundary

1D transport
1D transport

Diﬀusive transport
Dynamic transport

WRWM
WF2D
WF3DW1WIDP

3D Geometrical Optics
3D Full wave
3D Full wave
3D Full wave
1D Full wave
1D Full wave
Dispersion

Ray/beam tracing2D FFT, 1D FDM
1D FFT, 2D FEM
3D FEM
MLM, FEM, diﬀerential, FLR integral
FEM, Landau/Cyclotron damping integral
Dielectric tensor

FIT3DNBI

Birth, orbit, deposition

Velocity distribution fn

3D Fokker-Planck equation

Proﬁle data
Common library
Matrix solver
Total code

Initial proﬁle, ﬁle interface
Matrix solver, FFT, spline,
MPI, Direct, Iterative, parallelize
Integrated operation

TASK/EQ
EQU
TR
TX

FP
PLX
LIB
MTXP
TOT
1.3

Speciﬁcations• Language: FORTRAN95– Allocatable array is used as a component of a derived type
– Graphic library requires C compiler and X11 library.
• Compiler:– Intel fortran, gfortran, PGI fortran• Graphic library:– GSAF (available from the same git depository)– X11 library is required for interactive graphic output.
• Data interface library: BPSD (available from the same git depository)• Parallelization: MPI (if available)

2

Install of the TASK code

2.1

To get the TASK code
• Install of git– The version control system “git” is required.
2

– If git is not installed in your computer system yet, you have to install it.
– Git is an open source software and can be downloaded from http://git-scm.com or
installed through many distributions for Linux and Mac OSX. A slightly older version
for Mac OSX is included in Xcode.
– Introduction to git is available from http://git-scm.com/book/en/v2 in various languages and in various forms, HTML, PDF, and ePub.
• Initial setup of git– In order to record the modiﬁcation of the code, git requires user’s name and email
address.
– If you have not set up the git environment yet, you have to run the following commands:
git config --global user.name ‘‘[your-full-name]’’git config --global user.email ‘‘[your-mail-address]’’• Download of the source ﬁles
– Make a git directory and download three repositories in it.
mkdir git
cd gitgit clone https://git@bpsi.nucleng.kyoto-u.ac.jp/pub/git/gsaf.git
git clone https://git@bpsi.nucleng.kyoto-u.ac.jp/pub/git/bpsd.git
git clone https://git@bpsi.nucleng.kyoto-u.ac.jp/pub/git/task.git– The password needed for “git clone ...” is “git”.
– You can download the codes with this procedure, but upload requires a user accounton bpsi.nucleng.kyoto-u.ac.jp. If you have an interest in uploading your contributions,please contact to fukuyama@nucleng.kyoto-u.ac.jp.
– HTTPS connection may require to run the following command,
git config --global http.sslverify false

to accept non-oﬃcial SSL certiﬁcates.
2.2

Compile of the TASK code
• Now you have three directories, GSAF, BPSD, and TASK.
• Then you compile them one by one.

2.2.1

Compile of the GSAF library

1. Move to the source directorycd gsaf/src

2. Copy an appropriate conﬁguration ﬁle to the directory
cp ../arch/XXXX-XXXX/Makefile.arch .

• linux-gfortran64: compile with gfortran and gcc on intel86-64 Linux• linux-ifc64: compile with intel fortran ifort and icc on intel86-64 Linux3• linux-pgf64: compile with PGI fortran pgf64 and cc on intel86-64 Linux• macosxi-gfortran64: compile with gfortran and gcc on Mac-OSX intel• macosxi-ifc64: compile with intel fortran and gcc on Mac-OSX intel• macosxi-pgf64: compile with PGI fortran pgf64 and cc on Mac-OSX intel
3. Set appropriate directories for BINPATH and LIBPATH in Makeﬁle.arch• If /usr/local is writable, use /usr/local/bin and /usr/local/lib.
• If /usr/local is not writable, use $HOME/bin and $HOME/lib
4. Compile the library
make

5. Install the library and the commands
make install

6. Include $LIBPATH in the library searching pathexport LD LIBRARY PATH=/usr/local/lib

7. Test the library installation
cd testmake

8. Run the basic routine test./bsctest

9. Go back to the git directory
cd ../..

2.2.2

Select branch• There are several branches.
– master: default standard branch (updated not frequently, at present less than once ayear)– develop: development branch (updated frequently, sometimes broken in some directories)
git checkout -t -b develop origin/develop
2.2.3

Set up the conﬁguration ﬁles and common library• Copy make.header from make.header.org in the TASK directory
cd taskcp make.header.org make.header• Adjust the content of make.header– Remove the comment mark # in appropriate lines.
4• Compile the common library
cd libmakecd ..

• Some modules, such as FP, WMXX, WFXX, TI, utilize parallel matrix solver to reduce
computation time. For compatibility, now most of modules are coupled with parallel matrix
solver library, mtxp. Therefore mtxp library has to be compiled in given environment.
• The ﬁrst step is to copy mtxp/make.mtxp from mtxp/make.mtxp.org.
cd mtxp
cp make.mtxp.org make.mtxp• Adjust the content of make.mtxp– Remove the comment mark # in appropriate lines:∗ without MPI: no MPI library, band-matrix direct solver or simple iterative solverare available∗ with MPI: MPI library exits, but no parallel solver is available.
∗ with MUMPS: MPI library and parallel direct matrix solver MUMPS are available.
∗ with PETSc: MPI and parallel iterative matrix solver library PETSc are available. PETSc may include MUMPS as well.
– compile the mtxp libraries
make– Go back to the git directory
cd ../..

2.2.4

Compile the BPSD library• Compile in the bpsd directory
cd BPSDmake
cd ..

2.2.5Compile a required TASK component• Move to the required TASK component, e.g. eq, and compile it.
cd eqmake libs
make• If you would like to compile an integrated code, use tot.
5

cd totmake libs
make• If you modify program ﬁles in the directory, use
maketo recompile the code.
• If you modify or update program ﬁles in other directories, such as lib or mtxp, you may
needmake libs

3

Run the TASK code

3.1

Run a TASK component

TASK components start when the component name is entered as a command, for example,
cd eq./eq

3.1.1

Graphic setting

Most of TASK components employ the graphic library GSAF. Therefore at the beginning ofexecution (rigorously speaking, when the subroutine GSOPEN is called), graphic settings areinquired.
The ﬁrst inquiry is the resolution of the graphic output. Enter a one character and hit return.
0: no graphic output; graphic data can be saved in a ﬁle
1: 512x380
2: 640x475
3: 768x570
4: 896x665
5: 1024x760
6-9: obsolete; to be deleted
The second inquiry is to deﬁne output of graphic data.
C: continue without graphic output
F: save graphic data to a ﬁle; the ﬁle name to be used will be asked
O: option setting; paper size, screen title, ﬁle output are inquired
H: help for one character command input at each end of page
Q: quit; terminate the code
Graphic setting can be skipped by deﬁning a environmental variable GSGDP.
export GSGDP=”3c”
6

3.1.2

Menu input

After graphic setting, the TASK component XX show a menu and accept a command input,
one character command or parameter change.
• Typical one character command (the ﬁrst character of a line, both upper- and lower-casework)
P: change parameter as a namelist input with group name XX
V: show input parameters
R: start a run after initialization
C: continue the run
G: graphic output mode
S: save present status data
L: load previously save status data
Q: quit the component• Parameter change– You can change the input parameters listed in XXinit.f90 with a form similar to acomponent of the namelist input; for example
RR=3.D0
PN(1)=0.5D0, PN(2)=0.4D0, PN(3)=0.1D0PN=0.5D0,0.4D0,0.1D0
MODELG=3
KNAMEQ=’eqdata.ITER’– A input line including a character “=” is considered as a parameter change.
3.2

Run the tot component

The “tot” component is a primitive control component which activates main TASK components(EQ, TR, DP, WR, WM, FP) sequentially.
The menu of the tot component accepts two-character commands of the components and aquit commend “Q”. For example “EQ” command run the task/eq component and after quitting
the task/eq component, the tot menu reappears.
The data transfer between components will be made through the BPSD library. At present, however, some of the data transfer is made through ﬁle I/O.
3.3Parameter input

The input parameters and their default values are usually deﬁned in XXinit.f90. The sequenceof parameter setting is as follows.
1. The default parameters are deﬁned in XXinit.f90.
2. At the beginning of executing XX component, if there exists a namelist ﬁle XXparm orXXparm.nl, the component reads the namelist ﬁle. The namelist ﬁle has a form&XX
RR=3.D07

&end3. During the operation of the XX component, input parameters can be changed through themenu interface. The command line input like RR=3.D0 or the namelist input through“P”
command changes the input parameters.
We should note that some of input parameters are deﬁned in a common components, suchas PLX or DP.
3.4

Save graphic data

Entering “G” command for the menu input, the graphic command input is prompted. The
graphic command is a sequence of characters deﬁned for each XX components. “X” commandis to exit the graphic menu and go back to the main menu.
The graphic output is page base. After drawing a page, a key input is waited on the graphicwindow, unless “0” graphic mode is chosen at the beginning of component operation.
Following key inputs are acceptable:
C or Return key : continue operation
F: open graphic ﬁle and start to save following pages
S: save this page, open graphic ﬁle if not yet opened
Y: save this page
N: do not save this page
X: switch on/oﬀ of saving pages
B: switch on/oﬀ the bell sound at the end of drawing page
D: dump a bitmap of this page to a ﬁle and draw it in a new window
K: keep this page without erase and overdraw the next page
O: change options (page size, page title, ﬁle save)
H: help, show this information
Q: quit the component after conﬁrmation
The graphic date is composed of ASCII-text data, and machine-independent. It can beviewed, converted to EPS ﬁle, and printed on a postscript printer. The recommended extensionof the graphic date ﬁle is “.gs”.
3.5

View and convert the graphic data

The graphic data ﬁle of GSAF graphic library can be viewed on the X11 screen, converted toEPS ﬁle, PS ﬁle and SVG ﬁle, printed in a postscript printer.
gsview: view on a X-window screen
gstoeps: convert selected pages to separate EPS ﬁlesgstops: convert selected pages to a combined postscript ﬁle8

gstosvg: convert selected pages to separate SVG ﬁles
gsprint: print on a postscript printerThe available options of these commands areusage: gsxxxx [-atbrcmgz] [-s ps] [-e pe] [-p np] [ﬁlename]-a : show all page-s ps : show from page ps [1]-e pe : show until page pe [999]-p np : combine np pages on a sheet [1]-t : keep original page title-b : no page title-r : rotate ﬁgure, valid for gstops/eps-c : color ﬁgure, valid for gstops/eps (default)-z : gray ﬁgure, valid for gstops/eps-m : monochrome ﬁgure, valid for gstops/eps-g : gouraud shading, valid for gstops/eps
ﬁlename : if not speciﬁed, prompted
The EPS ﬁle using gouraud shading cannot be edited by Adobe Illustrator.
44.1

Structure of a typical TASK component
Support directories

The following directories in a component directory includes:
in/ test input ﬁles XX.in (./XX ¡XX.in ¿XX.out)
parm/ test parameter ﬁles,, XXparm or XXparm.nl
mod/ module ﬁles (generated during compiling fortran ﬁles)Example 1:
copy parm/eqparm.ITER eqparm./eq

Example 2:
copy in/eq.inITER .
./eq ¡eq.inITER ¿eq.outITER
94.2

Typical ﬁle name

The followings are typical ﬁle names of the components:
XXcomm.f90: Deﬁnition of variable module, allocation of arrays
XXmain.f90: Initialization, read paramater ﬁle, call menu, termination.
XXmenu.f90: Process menu input
XXinit.f90: Default values of input parameters
XXparm.f90: Read and view input parameters (may be included in XXinit.f90)
XXprep.f90: Preparation of run (grid, initial proﬁle)XXexec.f90: Execution of run
XXsave.f90: Save run data (may be included in XXﬁle.f90)
XXsave.f90: Load run data (may be included in XXﬁle.f90)
XXgout.f90: Graphic output
XXfout.f90: File output of results

10