Computational physics PY2050 Course Details:

Slides:



Advertisements
Similar presentations
ARDUINO CLUB Session 1: C & An Introduction to Linux.
Advertisements

Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
Linux, it's not Windows A short introduction to the sub-department's computer systems Gareth Thomas.
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
1 Introduction to UNIX Ke Liu
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Preparation for working in the CSIL Basic LINUX operations.
Getting Started with Linux Douglas Thain University of Wisconsin, Computer Sciences Condor Project October 2000.
16/13/2015 3:30 AM6/13/2015 3:30 AM6/13/2015 3:30 AMIntroduction to Software Development What is a computer? A computer system contains: Central Processing.
Linux+ Guide to Linux Certification, Second Edition
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Guide To UNIX Using Linux Third Edition
Systems Software Operating Systems.
Prof. R. Willingale Department of Physics and Astronomy 2nd Year C+R 2 nd Year C and R Workshop Part of module PA2930 – 2.5 credits Venue: Computer terminal.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
COMPUTER SOFTWARE Chapter 3. Software & Hardware? Computer Instructions or data, anything that can be stored electronically is Software. Hardware is one.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
1 CS 240 Programming in C and UNIX Lecturer: Bob Wilson Office: S Phone:
Computer Systems Week 10: File Organisation Alma Whitfield.
Computational physics PY2050 Course Details:
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
2INC0 Operating Systems Introduction to Linux
Introduction to Interactive Media Interactive Media Tools: Software.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
1 N305 C Programming. 2 Objectives for the Lab ä Learn problem solving strategies ä Achieve intermediate knowledge of C Programming Language ä Gain experience.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
Systems Software Operating Systems. What is software? Software is the term that we use for all the programs and data that we use with a computer system.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Fundamental Programming: Fundamental Programming K.Chinnasarn, Ph.D.
ENEE150 – 0202 ANDREW GOFFIN Introduction to ENEE150.
1 Programming in C Hello World! Soon I will control the world! Soon I will control the world!
Getting started: Basics Outline: I.Connecting to cluster: ssh II.Connecting outside UCF firewall: VPN client III.Introduction to Linux IV.Intoduction to.
Introduction to C Programming Lecture 2. C Tutor Schedule / 3rd Floor Lab b The lab and tutor schedule is available at the following URL:
Basic Unix Commands CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang.
CS2204: Introduction to Unix January 19 th, 2004 Class Meeting 1 * Notes adapted by Christian Allgood from previous work by other members of the CS faculty.
Intro to Programming Environment 1. Today You Will Learn how to connect to a machine remotely with “nomachine NX client” Learn how to create a new “source.
Created by Harry H. Cheng,  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Chapter 2: Getting Started.
Introduction to Programming Using C An Introduction to Operating Systems.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Introduction to UNIX CS 2204 Class meeting 1 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Linux A practical introduction. 1)Background and Getting Started Linux is an operating system with multiple providers Red Hat/CentOS (our version) Ubuntu.
A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? – Quick introduction Documentation – Where to get it, how to use it Text Editors – Know.
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Chapter 1: Introduction to Computers and Programming.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
UNIX U.Y: 1435/1436 H Operating System Concept. What is an Operating System?  The operating system (OS) is the program which starts up when you turn.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
UNIX  Portable (common to many computer architectures), multitasking, multi-user operating system  Introduced by Bell labs in mid-1960’s  Thus, much.
Computational physics PY2050 Course Details:
Bash Scripting CIRC Summer School 2016 Baowei Liu CIRC Summer School 2016 Baowei Liu.
By Jonathan Rinfret UNIX/LINUX By Jonathan Rinfret
Topic 2: Hardware and Software
Class Projects and Environment
Fundamentals of Programming I Overview of Programming
EE516: Embedded Software Project 1
Development Environment
CIRC Winter Boot Camp 2017 Baowei Liu
COSC 350 System Programming
The Linux Operating System
C Programming Lecture Series
Computer Science I CSC 135.
Introduction Paul Flynn
Programming Fundamentals Lecture #3 Overview of Computer Programming
Presentation transcript:

Computational physics PY2050 Course Details:

Course general information 6 Weeks course Week 1 and 2 - Introduction to Linux and C programming Week 3 and 4 - Finding minima of functions Week 5 and 6 - The non-linear pendulum Lab reports are due in one week after you have completed the lab. Collect information as you it do the lab. Name files so you know what they are. Reports should be in the style of a scientific document Try to convey all the information in about 4-6 pages. You should describe the algorithms used, however do not include the code. Send reports to or hand them directly to

Introduction to Linux

What is an OS? The job of the of an operating system is to control the various parts of the computer, such as the cpu, memory, hard drives... At the same time the operating system has to provide a user interface and dispatch access to resources for applications OS Kernel passes low level tasks in supervisor mode Example OS: Windows 95/98/ME/NT/XP, OSX, Linux, UNIX..

How is Linux different to windows? Open source – developers are free to edit and develop the OS Many flavours of Linux... Fewer malware treats small number of users running Linux the malware's lack of root access fast updates Generally Linux requires less cpu power and memory than windows

Equivalent software MS office - Open office, Star office Internet explorer - Firefox, Mozzila, Netscape... Photoshop - gimp MS Outlook - Thunderbird, kmail... Windows media player – mplayer, xmms....

Running Linux without installing? Many distribution provide “Live CD's” including Knoppix Ubuntu and open SuSE Live CD's run the OS from the CD and nothing is installed on your hard disk. This is very useful if you want to continue your lab work at home!

Dual boot computers Modern macs and windows machines can run Linux It is often advantageous to have both Linux and windows on the same computer LinuxMBRWindows

Command line Both Linux and windows can be operated from the command line or the graphical user interface, however Linux is more weighed towards the command line Command line interpreter – the Linux shell (both command line and scripting functionality)

Command line commands CommandAction lslist files in current directory pwdcurrent location on directory tree (working directory) cd dir2go to another directory in location dir2 cd..move up a directory cp file1 file2copy file1 into file2 mkdir new_dirmake directory called new_dir rm file1remove permanently file1 (or directory if used with –r) geditstart text editor gedit &used at the end of a command – send to background and go back to prompt

File system

or cd /home/joe/tmp Change Directory

or cd /home/joe Change directory

Moving

Move Directory

Rename directory

Rename

Copying

Removing

Text editors There are many text editors in linux: jedit, nedit, emacs, vi, pico, nano, gedit.... It doesn't matter which one you use, but some are easier than others. File extensions – windows knows what program a file belongs to from its file extensions e.g. “sheet.xls” windows will know this is an excel file. Linux does not care what a file is called. Programs written in C are text files until compiled

gnuplot - plotting tool

Review of commands ksnapshot - takes a screen grab which can be incorporated into lab reports oowriter – Similar to MS word, lab reports can be written in this gedit – text editor with syntax highlighting for C gnuplot – graph plotting tool ls - list directory content pwd - what directory am I in cp - copy mv - move (also acts as rename) rm – remove (remember there is no recycle bin!)

Introduction to C programming

Computational physics PY2050 Course Details:

Where to get extra information free c books

Some facts about C 3 rd generation (“problem-oriented”) programming language, originally developed in early 1970’s at AT&T Bell Labs probably the most widely used programming languages, e.g. Linux is written in C

Compilers Programs are simply text files (referred to as source code) file extension is usually “.c”, e.g. hello.c To convert to machine code so that the computer can run it the program needs to be compiled gcc hello.c -o hello.exe here we input text file hello.c, and the output file is called hello.exe

Linking Once all the pieces of code are compiled the code is then gathered together (linked) into an executable. Linking allows functions that have already been written to be included into your executable. A set of prebuilt functions is called a library e.g. C comes with a maths library which contains functions like sin, cos, asin, tan, log, log10, ceil, floor.... We can build in the standard maths library as follows: gcc -o myprog myprog.c -lm

Compile and link

Simple program

Closer look at the simple program The program always starts with the function main. Other functions may also be included but main is the first one to be run. The function printf is contained in the library stdio.h

Comments Comments are ignored by the compiler, you should use comments to make notes as to what each section of the code does.

Introducing data types and maths library The cos function is part of the library math.h The linker needs to be told where the library math.h can be found. Every variable must fist be assigned so that the correct amount of memory is allocated.

Variable types data size depends on implementation but these are typical values

Input and output %c - characters %d - integers %f – floats %lf – Long float %s – a string \n – new line Print to screen: printf(“%s %d %f \n”, “red”, 123, ); Read in: printf(“What is your age: “); scanf(“%d ”,&d);

Functions As well as using pre built functions you may write your own function “func” returns the value of sin^2(x)+cos^2(x) You must declare your functions, with the variables sizes they are going to use

Control of flow with logical expressions General form: if( condition 1 ) statement1; else if( condition 2 ) statement2; else if( condition 3 ) statement3; else statement4;

Control of flow with while statement General form: while(expression) statement

For loop syntax: for(initialization; condition for finishing; step) statement

Numerical error