Computational Physics Operating systems

Similar documents
System Programming. Unix Shells

ROOT. Introduction. Spring 2010 Lecture 5. S. Lehti and V.Karimäki. COMPUTING METHODS IN HIGH ENERGY PHYSICS (page 1)

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Computational Physics Operating systems

ROOT: An object-orientated analysis framework

Unix Shell Environments. February 23rd, 2004 Class Meeting 6

UNIX shell scripting

5/8/2012. Specifying Instructions to the Shell Chapter 8

Chapter 9. Shell and Kernel

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

5/20/2007. Touring Essential Programs

ROOT Trips & Tricks. Ole Hansen. Jefferson Lab. Hall A & C Analysis Workshop June 26 27, 2017

Lecture I: Basics REU Root Duke Jen Raaf

Introduction to Shell Scripting

Computational Physics Compiling a C++ program

The Online Unix Manual

Implementation of a simple shell, xssh

UNIX Kernel. UNIX History

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

Unix Shells and Other Basic Concepts

Introduction to ROOT and application to data analysis at the LHC

EECS2301. Lab 1 Winter 2016

Getting Started with ROOT

Computational Physics

ACS Unix (Winter Term, ) Page 21

Assignment clarifications

How-to tb_recon. A refresher course in obtaining, compiling, and running centella PLUS! How-to read in both raw & recon files at the same time!!!

What is the Shell. Whenever you login to a Unix system you are placed in a program called the shell. All of your work is done within the shell.

System Programming. Session 6 Shell Scripting

Writing Shell Scripts part 1

HPCC - Hrothgar. Getting Started User Guide User s Environment. High Performance Computing Center Texas Tech University

EE516: Embedded Software Project 1. Setting Up Environment for Projects

Standard. Shells. tcsh. A shell script is a file that contains shell commands that perform a useful function. It is also known as shell program.

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts

ROOT Analysis FrameWork (II) Basics. Qipeng Hu March 22, 2015

Lecture 8. Introduction to Shell Programming. COP 3353 Introduction to UNIX

Implementation of a simple shell, xssh

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

Vi & Shell Scripting

Lecture 7. Simulations and Event Generators. KVI Root-course, April Gerco Onderwater, KVI p.1/18

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

15-122: Principles of Imperative Computation

CSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science

Lab Week02 - Part I. Shell Commands. Professional Training Academy Linux Series

Introduction to the Shell

CSE II-Sem)

CptS 360 (System Programming) Unit 2: Introduction to UNIX and Linux

Lecture # 2 Introduction to UNIX (Part 2)

Introduction to Linux. Fundamentals of Computer Science

CHAPTER 3 SHELL PROGRAMS: SCRIPTS

Introduction to Linux Basics

LOG ON TO LINUX AND LOG OFF

CERN UNIX User Guide Version 1.02 CN/DCI/164. Tracey Appleby, Harry Renshall, Judy Richards, Alan Silverman

Introduction: What is Unix?

Exercise 1: Basic Tools

CISC 220 fall 2011, set 1: Linux basics

Linux at the Command Line Don Johnson of BU IS&T

CS Unix Tools. Lecture 3 Making Bash Work For You Fall Hussam Abu-Libdeh based on slides by David Slater. September 13, 2010

Unix Handouts. Shantanu N Kulkarni

What is UNIX? A Little Bit about UNIX and User Interfaces. Adapted from Practical Unix and Programming Hunter College

Unix Introduction to UNIX

Basic Unix Command. It is used to see the manual of the various command. It helps in selecting the correct options

SOFTWARE ARCHITECTURE 3. SHELL

Work Effectively on the Command Line

Lecture #10 - Interactive Korn Shell (Chapter 11)

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

IoT with Intel Galileo Gerardo Carmona. makerobots.tk

Shell Scripting. With Applications to HPC. Edmund Sumbar Copyright 2007 University of Alberta. All rights reserved

McGill University School of Computer Science Sable Research Group. *J Installation. Bruno Dufour. July 5, w w w. s a b l e. m c g i l l.

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Review. Preview. Linux System Roadmap (Libraries)

Practical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015

PROGRAMMING PROJECT ONE DEVELOPING A SHELL

CN/DCI/ 164 Version 2.2 August 1st, CERN UNIX User Guide. Editor: Alan Silverman

Operating System Interaction via bash

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 1

Introduction to UNIX Shell Exercises

Scripting Languages Course 1. Diana Trandabăț

UNIX System Programming Lecture 3: BASH Programming

Using Environment Modules on the LRZ HPC Systems

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell:

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

Operating Systems, Unix Files and Commands SEEM

CS246 Spring14 Programming Paradigm Notes on Linux

Essential Unix (and Linux) for the Oracle DBA. Revision no.: PPT/2K403/02

Computational Physics

MVAPICH MPI and Open MPI

HOW TO INSTALL ZIM 8.50 HP-UX, AIX, LINUX AND UNIXWARE

COMP 4/6262: Programming UNIX

Introduction to Linux

UNIX Concepts COMPSCI 386

Shell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala

Shell script. Shell Scripts. A shell script contains a sequence of commands in a text file. Shell is an command language interpreter.

System Administration

No Food or Drink in this room. Logon to Windows machine

StarQuest Client Access for UNIX. User s Guide

Project 1: Implementing a Shell

Linux & Shell Programming 2014

Transcription:

Computational Physics numerical methods with C++ (and UNIX) 2018-19 Fernando Barao Instituto Superior Tecnico, Dep. Fisica email: fernando.barao@tecnico.ulisboa.pt Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (1) Computational Physics Operating systems UNIX (linux) Fernando Barao, Phys Department IST (Lisbon) Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (2)

UNIX shell the shell, the command line interface, is a program like any other one it takes commands from the user and transmit to the operating system the corresponding actions most shell commands are actually small programs, accepting options and arguments example: ls -l <dirname> unix shells bash: the default shell on most linux systems csh: C shell (similar to C programming language) ksh: korn shell tcsh: enhanced but compatible with C shell to find your current shell: echo $SHELL to find your available shells: cat /etc/shells Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (3) environment variables UNIX shell (cont.) variables that are defined for the current shell and are inherited by any child shells or processes we can used them to pass information into processes by convention, they are usually defined using capital letters > env list all environment variables or > printenv Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (4)

UNIX shell (cont.) set environment variables # bash shell > export VARNAME=value # c-shel > setenv VARNAME value Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (5) UNIX shell (cont.) some common environment variables SHELL TERM terminal USER current user logged in PWD current working dir PATH list of directories that will be check when looking for commands HOME user home directory LD_LIBRARY_PATH list of directories where shareable libs are located Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (7)

file sequence UNIX shell initialization bash shell non-login session Korn shell C Shell Bourne Shell ---------- ------- ------------ /etc/environment /etc/environment /etc/environment /etc/security/environ /etc/security/environ /etc/security/environ /etc/profile /etc/csh.cshrc /etc/profile /etc/csh.login $HOME/.profile $HOME/.cshrc $HOME/.profile $HOME/.kshrc $HOME/.login /etc/environment and /etc/security/environ files are executed regardless of what shell is run $HOME/.login and /etc/csh.login (csh) and $HOME/.profile and /etc/profile (ksh and bsh) get executed only at login you can force at any moment your current session to read the configuration file read configuration file source ~/.profile Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (9) Computational Physics ROOT A data analysis graphics tool with a C++ interpreter Fernando Barao, Phys Department IST (Lisbon) Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (13)

ROOT - start root command help > root --help # get help Usage: root [-l] [-b] [-n] [-q] [dir] [[file:]data.root] [file1.c... filen.c] Options: -b : run in batch mode without graphics -n : do not execute logon and logoff macros as specified in.rootrc -q : exit after processing command line macro files -l : do not show splash screen -x : exit on exception dir : if dir is a valid directory cd to it before executing -? : print usage -h : print usage --help : print usage -config : print./configure options -memstat : run with memory usage monitoring start root > root -l quit root >.q Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (14) ROOT - browser Your directories and ROOT files (root objects) can be browsed by instantiating the TBrowser class [0] TBrowser *b = new TBrowser() Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (15)

ROOT - init Reset all ROOT parameters before running any C++ macro and define the graphics options [0] groot->reset(); [1] groot->setstyle("plain"); [2] gstyle->setoptstat(1111); // =0 to reset [3] gstyle->setopttitle(0); // supress title box [4] gstyle->setoptfit(1111); // print fit results [5] gstyle->setpalette(1); // better than default Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (16) ROOT - running macros A C++ function is known as a macro in ROOT. Let s make a macro that we name hadd for adding two histograms. hadd.c void hadd() { groot->setstyle("plain"); gstyle->setoptstat(0); TCanvas *c = new TCanvas(); TH1F *hg = new TH1F("hg","histogram gauss", 100,1.,9.); for (int i=0; i<5000; i++) {hg->fill(grandom->gaus(5,1.));} TH1F *he = new TH1F("he","histogram expo", 100,1.,9.); for (int i=0; i<5000; i++) {he->fill(grandom->exp(1.));} TH1F *hsum = new TH1F(*hg); //dereference hg pointer hsum->add(he,1.); } he->getyaxis()->setrangeuser(0.,200.); he->setfillcolor(9); he->drawcopy(); hg->setfillcolor(kred); hg->drawcopy("same"); hsum->setmarkerstyle(20); hsum->setmarkercolor(3); hsum->setmarkersize(1.2); hsum->draw("esame"); //draw with errors Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (17)

ROOT - running macros (cont.) The macro can be run at the unix prompt: > root -l hadd.c It can also be run with the CINT interpreter: > root -l root [0].x hadd.c It can also be loadded in CINT interpreter: > root -l root [0].L hadd.c root [1] hadd() Running macro hadd.c within a macro { groot->loadmacro("hadd.c"); hadd(); // calling function } Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (18) ROOT - running macros (cont.) Macros can be compiled with ACLIC (automatic compiler of libraries for CINT) The compiled code runs much faster and language error checks easier! The compilation process produces a shared library (.so) that can be used in ROOT The shared library must be loaded before using user functions or classes > root -l root [0].L hadd.c+ root [1] gsystem->load("hadd_c.so") root [2] hadd() Notice that the include files of all functions being used in the code have to be added to the macro #include "TROOT.h" #include "TCanvas.h" #include "TH1F.h" #include "TRandom.h" //grandom #include "TStyle.h" //gstyle void hadd() {... } Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (19)

ROOT - running macros (cont.) Remarks: the directory path name cannot be used with.l. In case of need replace it by: root [0] gsystem->cd("directory_path") root [0] gsystem->compilemacro("hadd.c") If include files belonging to specific directories need to be include add their dir path through: root [0].include "-I$HOME/dir_path" or within a macro: groot->processline(".include my/include/dir"); or still: gsystem->addincludepath(" -I/my/include/dir"); Computational Physics 2018-19 (Phys Dep IST, Lisbon) Fernando Barao (20)