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.
Introduction to the Omega Server CSE Overview Intro to Omega Basic Unix Command Files Directories Printing C and C++ compilers GNU Debugger.
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Computational physics PY2050 Course Details:
© 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.
CS 110 Intro to Computer Science I Sami Rollins Fall 2006.
Guide To UNIX Using Linux Third Edition
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
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.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Chapter Introduction to Computers and Programming 1.
1 Day 3 Directories Files Moving & Copying. 2 Case Sensitive First thing to learn about UNIX is that everything is case sensitive. Thus the files: –enda.
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”
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
Unix Basics Chapter 4.
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.
Creating your first C++ program
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.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Reading None.
Introduction to UNIX Geraint Vaughan. What is UNIX? Command-line operating system (not point- and click) Designed for ‘experts’ Lots of different variants.
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.
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.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Application Software System Software.
More Unix Naomi Altman. Directories Directory = folder mkdir - makes a new directory rmdir - removes an empty directory cd mydirectory - moves you into.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
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.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
General Computer Science for Engineers CISC 106 Lecture 03 James Atlas Computer and Information Sciences 6/15/2009.
Chapter 1: Introduction to Computers and Programming.
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
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:
Tutorial Six Linux Basics CompSci Semester Two 2016.
Class Projects and Environment
Fundamentals of Programming I Overview of Programming
CS1010: Intro Workshop.
Tutorial Six Recap & Linux Basics CompSci Semester Two 2016.
Operating Systems and Using Linux
Operating Systems and Using Linux
C Programming Lecture Series
Computer Science I CSC 135.
Operating Systems and Using Linux
Operating Systems and Using Linux
Operating Systems Lecture 5.
Operating Systems and Using Linux
Programming Fundamentals Lecture #3 Overview of Computer Programming
Operating Systems and Using Linux
Operating Systems and Using Linux
Operating Systems and Using Linux
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 Everything on the computer is mediated by the operating system 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 Red Hat, SuSE, Ubunto... There are no Linux viruses (as of yet) so no virus checkers 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 commands kate starts the text editor kate ls list files in the current directory pwd what directory am I in cd change directory cd.. move up a directory cp copy a file cp -r recursive copy so you can copy directorys mkdir make directory rmdir remove directory rm remove file (Note on the command line there is no recycle bin!)

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, kate.... It doesn't matter which one you use, but some are easier than others, start with jedit. 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 kate – 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

Where to get extra information free c books

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

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