2022/01/12

How to install the integrated code: TASK
A. Fukuyama
Professor Emeritus, Kyoto University
1. Preparation for macOS
2. In case of macOS major version up
3. Preparation for Ubuntu
4. Introduction to git
5. Install task and related libraries
6. Introduction to the task code
7. Install PETSc

Preparation for macOS (1)• Install Xcode– Xcode: development environment on macOS– Use App Store– Category: Development– Choose and install Xcode• Install Command Line Tools– Command Line Tools: various Unix commands for development– Input command on terminal– xcode-select --install• Install XQartz– Download and install XQartz from https://www.xquartz.org• Install java
– Download and install java fromhttps://www.java.com/en/download/mac download.jsp

Preparation for macOS (2)• Install Macports– Download the latest macports binary from https://www.macports.org– Select tab: Installing MacPorts– Quickstart: download and install MacPorts installer for appropriate
macOS version– MacPorts is mostly installed at /opt/local– Update to the latest Macports◦

sudo port selfupdate◦

sudo port upgrade outdated• Install compiler and related modules– gfortran: sudo port install gcc12– mpich: sudo port install mpich– others: sudo port install gmake cmake imakeIn case of macOS major version-up• macOS major version-up: e.g. 13.3=⇒ 14.0• Update Xcode– Use App Store to update Xcode• Update Command Line Tools– xcode-select --install• Update Macports– Download and install the Macports binary for the new version ofmacOS from https://www.macports.org– It may take a few days before the binary for the new version of macOS becomes available.
– Update the installed ports to the new Macports binary◦

sudo port selfupdate◦

sudo port upgrade outdated

Preparation for Ubuntu
1. Install required modules

sudo apt-get install gfortran-12
sudo apt-get install gcc-12
sudo apt-get install g++-12
sudo apt-get install git
sudo apt-get install xorg-dev
sudo apt-get install valgrind
sudo apt-get install cmakesudo apt-get install python
sudo apt-get install mpichHow to use git (1)• git: version and remote repository control facility• Repositories– local: in your machine– remotes: in remote servers– remotes/origin: in default server: bpsi.nucleng.kyoto-u.ac.jp• Branches– There are several branches for code development◦ master: default, stable version, often rather old◦ develop: latest version, where I am working◦ others: branches for working speciﬁc modules– cd task– git branch: list branch names, local only
– git branch -a: list branch names, local and remote

How to use git (2)• To use develop branch– Create local branch develop and associate it with remote develop– git checkout -t -b develop origin/develop– git branch• Change working branch– git checkout master– git checkout develop• Update working branch: download from remote repository– git pull
◦ Your modiﬁcation is kept, if committed.
◦ If uncommitted modiﬁcation remains, no overwrite.
◦ use git stash to keep away your modiﬁcation.
◦ If there are conﬂicts with your committed modiﬁcation, the conﬂicts are indicated in the ﬁle. Correct them and git pull again.

How to use git (3)• To check your modiﬁcation– git status• To commit your modiﬁcation with message: only local depository
is updated. message is required.
– git commit -a -m’message ’• To list all modiﬁcation– git log

• To show difference from committed repository– git diff [ﬁlename ]• For more detail, visit– https://git-scm.com/documentation

Install TASK (1)• Check availability of git: just command input “git”• Set your identity: To record who changed the code?
– git conﬁg - -global user.name “[your-full-name]”– git conﬁg - -global user.email [your-mail-address]– For example,◦ git conﬁg - -global user.name “Atsushi Fukuyama”◦ git conﬁg - -global user.email fukuyama@nucleng.kyoto-u.ac.jp– Data is saved in $HOME/.gitconﬁg• Create a working directory: any directory name is OK– mkdir git– cd git

Install TASK (2)• Download TASK and necessary libraries for download only
– git clone https://bpsi.nucleng.kyoto-u.ac.jp/pub/git/gsaf.git– git clone https://bpsi.nucleng.kyoto-u.ac.jp/pub/git/bpsd.git– git clone https://bpsi.nucleng.kyoto-u.ac.jp/pub/git/task.git• Download TASK and necessary libraries for download and upload– git clone ssh://username@bpsi.nucleng.kyoto-u.ac.jp/pub/git/gsaf.git– git clone ssh://username@bpsi.nucleng.kyoto-u.ac.jp/pub/git/bpsd.git– git clone ssh://username@bpsi.nucleng.kyoto-u.ac.jp/pub/git/task.git– username@ can be omitted if the usernames at remote and local
are same.

• Three directories are created– gsaf: graphic library– bpsd: data interface library– task: main TASK directory

Install TASK (3)• Install graphic library GSAF
– cd git/gsaf/src– Copy Makeﬁle.arch appropriate for your environment◦ for macOS: cp ../arch/macos-gfortran/Makeﬁle.arch .
◦ for Ubuntu: cp ../arch/ubuntu-gfortran64-static/Makeﬁle.arch .
– Edit Makeﬁle.arch: adjust BINPATH and LIBPATH to available ones
◦ BINPATH: graphic commands are located, should be included in$PATH in ∼/.proﬁle or ./zproﬁle◦ LIBPATH: graphic libraries are located, should be included in library path for compiling applications using the graphic libs.
– make– make install◦ if BINPATH is protected, use “sudo make install”

Install TASK (4)• Check the availability of GSAF library– cd test– make– Applications using GSAF library must be started from X11 window
such as xterm, not from Terminal on macOS.
– ./bsctest– 5: Choose the size of window– c: Continue the run– m– New graphic window opens and marks and lines are drawn.
– To go back to the original window, enter CR.
– If focus does not change, click the original window and check XQartz
preferences.
– e: Close the graphic window– cd ../../..

Install TASK (5)• Use the latest develop branch and setup ﬁles, make.header andmake.mtxp– cd task– git checkout -t -b develop origin/develop– cp make.header.org make.header– Edit make.header to remove comments for target OS and compiler• Compile data exchange library BPSD
– cd ../bpsd– make– cd ../task

Install TASK (6)• Choice of matrix solver conﬁguration– Single processing without MPI: make.mtxp.nompi– Single processing with MPI: make.mtxp.mpi– Multi processing with parallel real matrix solver: make.mtxp.petsc– Multi processing with parallel real and complex solver:make.mtxp.petsc+mumps• Module using parallel matrix solver– Real: fp, ti, pic, t2– Complex: wmx, wf2d, wf2dt, wf2dx, wq• Setup matrix solver library– cd mtxp– cp make.mtxp.XXX make.mtxp– make– cd ..

Install TASK (7)• Compile modules:– cd lib– make– cd ..

• Compile and run TASK module: eq for example– cd eq– make– ./eq
– 5– c– r– g– s, CR, CR, · · ·– x– q

How to use GSAF
• At the beginning of the program– Set graphic resolution (0: metaﬁle output only, no graphics)– commands◦ c: continue◦ f: set metaﬁle name and start saving• At the end of one page drawing– commands◦ c or CR: change focus to original window and continue◦ f: set metaﬁle name and start saving◦ s: start saving and save this page
◦ y: save this page and continue◦ n: continue without saving◦ d: dump this page as a bitmap ﬁle “gsdumpn ”◦ b: switch on/off bell sound◦ q: quit program after conﬁrmation

Graphic Utilities• Utility program– gsview: View metaﬁle– gsprint: Print metaﬁle on a postscript printer– gstoeps: Convert metaﬁle to eps ﬁles of each page
– gstops: Convert metaﬁle to a postscript ﬁle of all pages– gstotgif: Convert metaﬁle to a tgif ﬁle for graphic editor tgif
– gstotsvg: Convert metaﬁle to a svg ﬁle for web browser• Options– -a: output all pages, otherwise interactive mode
– -s ps: output from page ps– -e pe: output until page pe– -p np : output contiguous np pages on a sheet– -b: output without title– -r: rotate page
– -z: gray output

Typical File Name of TASK
• XXcomm.f90: Deﬁnition of global variables, allocation of arrays• XXmain.f90: Main program for standalone use, read XXparm ﬁle• XXmenu.f90: Command input• XXinit.f90: Default values• XXparm.f90: Read input parameters• XXview.f90: Show input parameters• XXprep.f90: Initialization of run, initial proﬁle• XXexec.f90: Execution of run• XXgout.f90: Graphic output• XXfout.f90: Text ﬁle output• XXsave.f90: Binary ﬁle output• XXload.f90: Binary ﬁle input

Typical input command• When input line includes =, interpreted as a namelist input (e.g., rr=6.5)• When the ﬁrst character is not an alphabet, interpreted as line input• r: Initialize proﬁles and execute• c: Continue run• p: Namelist input of input parameters• v: Display of input parameters• s: Save results into a ﬁle• l: Load results from a ﬁle• q: End of the program• Order of input parameter setting– Setting at the subroutine XX init in XXinit.f90– Read a namelist ﬁle XXparm at the beginning of the program– Setting by the input line

Install PETSc (1)• PETSc: Parallel matrix solver library– blas,lapack: matrix solver tolls– scalapack, metis, parmetis, blacs, superlu: parallel solver tools– MUMPS: Direct matrix solver for real and complex– PETSc: Iterative matrix solver for real or complex• Make PETSc directory and change its owner– sudo mkdir /opt/PETSc– sudo chown /opt/PETSc $USERNAME– cd /opt/PETSc• Download latest PETSc library package by git– First download of PETSc source◦git clone -b release https://gitlab.com/petsc/petsc.git petsc– In order to update PETSc source◦

git pullInstall PETSc (2)• Provide environment variables for PETSC in ∼/.proﬁle or .zproﬁle– export PETSC DIR=/opt/PETSc/petsc– export PETSC ARCH=default• Conﬁgure script in python– Copy default.py to /opt/PETSc/petsc– Provide exec attribute to default.py◦

chmod 755 default.py– Execute conﬁguration script◦(It may take half an hour.)./default.py– Additional libraries are created in default/externalpackages• Make and check PETSc library– make(It may take half an hour.)– make check