M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE

Similar documents
Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

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

Unix Processes. What is a Process?

Lab 2: Linux/Unix shell

Introduction To. Barry Grant

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

Introduction to UNIX Shell Exercises

Introduction to Linux

5/20/2007. Touring Essential Programs

EECS2301. Lab 1 Winter 2016

System Administration

Part 1: Basic Commands/U3li3es

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

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

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:

Linux Tutorial #6. -rw-r csce_user csce_user 20 Jan 4 09:15 list1.txt -rw-r csce_user csce_user 26 Jan 4 09:16 list2.

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Command-line interpreters

Chap2: Operating-System Structures

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

Linux Command Line Interface. December 27, 2017

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

Perl and R Scripting for Biologists

The Unix Shell. Pipes and Filters

The Unix Shell & Shell Scripts

UNIX Quick Reference

bash, part 3 Chris GauthierDickey

Command Line Interface Techniques

Recap From Last Time:

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Introduction to Linux

BGGN 213 Working with UNIX Barry Grant

Useful Unix Commands Cheat Sheet

Introduction to the Linux Command Line January Presentation Topics

Introduction to UNIX. Introduction. Processes. ps command. The File System. Directory Structure. UNIX is an operating system (OS).

Introduction to UNIX. CSE 2031 Fall November 5, 2012

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

CST Algonquin College 2

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Assignment clarifications

Mills HPC Tutorial Series. Linux Basics II

CSCI 2132 Software Development. Lecture 4: Files and Directories

ScazLab. Linux Scripting. Core Skills That Every Roboticist Must Have. Alex Litoiu Thursday, November 14, 13

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Chapter 9. Shell and Kernel

Getting started with Hugs on Linux

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

Computer Systems and Architecture

CENG 334 Computer Networks. Laboratory I Linux Tutorial

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

Introduction to Linux

(a) About Unix. History

Review of Fundamentals

Introduction to UNIX. Introduction EECS l UNIX is an operating system (OS). l Our goals:

LOG ON TO LINUX AND LOG OFF

CSC UNIX System, Spring 2015

Processes and Shells

Sperimentazioni I LINUX commands tutorial - Part II

Introduction to Linux Organizing Files

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

CS370 Operating Systems

Introduction to UNIX Command Line

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

Std: XI CHAPTER-3 LINUX

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Computer Systems and Architecture

Exploring UNIX: Session 3

Exploring UNIX: Session 5 (optional)

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 2

Introduction to Linux Part 2b: basic scripting. Brett Milash and Wim Cardoen CHPC User Services 18 January, 2018

Week 2 Lecture 3. Unix

Lec 1 add-on: Linux Intro

Welcome to Linux. Lecture 1.1

System Programming. Introduction to Unix

First steps on Linux and programming

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

UNIX Quick Reference

Introduction: What is Unix?

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

SOFTWARE ARCHITECTURE 3. SHELL

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

CS 25200: Systems Programming. Lecture 11: *nix Commands and Shell Internals

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

Introduction to Linux

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

Recap From Last Time: Setup Checklist BGGN 213. Todays Menu. Introduction to UNIX.

UNIX Essentials Featuring Solaris 10 Op System

Unix Basics. Systems Programming Concepts

Shells and Shell Programming

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

Common File System Commands

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

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

Basic Linux Command Line Interface Guide

Files

Transcription:

M2PGER 2013-2014 FORTRAN programming General introduction Virginie DURAND and Jean VIRIEUX 1

Why learning programming??? 2

Why learning programming??? ACQUISITION numerical Recording on magnetic supports MODELLING Empirical or theoretical from our understandings of natural phenomenons 3

Why learning programming??? ACQUISITION numerical Recording on magnetic supports MODELLING Empirical or theoretical from our understandings of natural phenomenons IMPORTANT to master the processing line acquisition modelling To know how to modify the programs at your disposal to do the job asked. 4

Computer environment CPU : processor controlling the whole system Main memory : enable the temporary memorization of the data during program execution External mass storage : storage of informations on the long range (hard disk, CD-ROM,...) 5

Integrated tools Excel, Matlab, Scilab, Octave,... Allow easy and quick data handling Enable quick test of an idea BUT They are slow They can have some difficulties during heavy applications Because each step is analysed by the computer each time it is met!! Solution : avoid this repeated analysis!!! (compiled tools) Cycle Steps/Compilation+Link editing /Execution 6

Languages Why using a programming language?? 7

Languages Why using a programming language?? Language = practical way to give instructions to a computer Language setting Key words Handleable tools Syntax rules Logical structures Programming is writing a text observing language rules, and likely to solve a given problem 8

Languages Sequential language (declarative programming) Program = series of instructions brought together in blocks There are some conditional jumps ==> back to an instruction block if the condition is true C, ADA, FORTRAN 9

Languages Object-oriented language Program built with relations Relations : define objects and links between objects ==> user defines properties, the language makes the deductions C++, ADA, smalltalk 10

Why fortran? Archetypal scientific language since 1957 Portability on various architectures Allows quick executions 11

Program edition, Compilation et link editing, Execution 1. Edition Steps definition 3. Execution 2. Compilation Link editing 12

Program edition, Compilation et link editing, Execution Compilation : translation of the program in binary Link editing : process allowing to create runnable (executable) files from the objects files (intermediate files) Link editor links object files with the environment 13

1. Edition toto.f90 program toto do i = 1,100 write(*,*) i enddo stop end 3. Execution./toto 2. Compilation gfortran -c toto.f90 ==> toto.o Link editing gfortran -o toto toto.o 14

Basic Unix (shell) 15

What? Shell definition and aim Interface for the system user Command interpreter Why? Interactive use : command line Programming (script conception) File handling Automate tasks 16

Various types of shell (cf P.Fuchs) Bourne shell(/bin/sh) : Shell standard The most compact and the easiest It is on all systems Bourne again shell (/bin/bash) Extensive version of Bourne shell C shell (/bin/csh) 17

How to travel in the directories pwd : displays the current directory path from your home Absolute or relative path : ex : If I am in toto and I want to go in tata, 2 possibilities : cd../tata = relative path cd ~/tata = absolute path (+++ if we have to go back up a lot, be carefull if you move your file) 18

Permission modifications Chmod -u permission file u = user Permission : r read 4 +/- w write 2 +/- x run 1 +/- chmod +r+w+x file <==> chmod 777 file 19

Shell in command line interface 2 states: Work Inactivity : - waits for orders, executes them, waits for a new order - display a prompt : [durandv@lgit-1197]$ 20

Interpretation and execution of the Ex : ls -l file commands To interpret a line, Bash splits it up in words : 1 st word = command name : ls Then the arguments of the command = data processed by the command : file Options will change the behaviour of the command : - name_option : -l End of the command : or «;» if several commands on the same line Next line 21

How does shell find the commands?? Example : I write «Hello» shell will look at places : (1) Is «Hello» an integrated command? If yes : execution If no --> (2) (2) Reads the content of a variable, PATH (points out the path of the command) (3)In PATH : /usr/bin look for: /usr/bin/hello (4) /bin /bin/hello (5) If (2) negative error message : Hello:command not found 22

Arguments and options Argument = series of characters given to a command ---> tells how to behave Options = special case of arguments ---> all kind of informations Metacharacter = character with an other signification than its literal one. ex : replace other characters : * = any character/group of characters? = 1 character «\»: - prevent the special interpretation of a character (\* --> write *) - at the end of a line ==> command continues at the next line 23

Command history Shell keeps an history of the commands ===> history number command history arrows : back up/go down in the history Recall of a command :!x : run again the command N x in the history!! : run again the last command!cp : run again the last command beginning with cp 24

Process Run a programm is create a process Process = execution of a series (more or less long) of instructions (program, script,...) Unix commands listing the processes : pstree, ps, ps -l, ps aux Ex : ps gives: [durandv@lgit-1197]$ ps PID TTY TIME CMD 3195 pts/1 00:00:00 bash 3366 pts/1 00:00:00 okular 3375 pts/1 00:00:00 ps 25

State of a process (cf P.Fuchs) Foreground process (fg) : shell waits for the death of the son process to take the hand again In abstentia, each command is run fg Background process (bg) : We keep the hand in the shell To run in bg : name_command & Usefull to run a long process Rq : if we want to be able to close the shell during a pgm is running : nohup program!!!! put the errors in a file!!!! 26

Commands acting on a process state (cf P.Fuchs) jobs : lists the jobs of a shell and their state Option -l gives the PID Allocates a n x of job, that you can recall with %x Kill : kills a process kill %1 : kills the process n 1 kill -9 PID : kills the process Ctrl-Z : stops the job Ctrl-C : kills the job 27

owner PID Ressources top command Process name 28

Flux Flux = flow of data coming in and out of the processes (or programs) : Standard input (stdin) : keyboard Standard output (stdout) : screen Error output (stderr) : Screen [durandv@lgit-1197]$ cat Bonjour Bonjour Commande cat without argument Bonjour is written with the keyboard (stdin) Bonjour is displayed on the screen (stdout) 29

Flux redirection A > file : stdout of A is put in file overwritting its content or creating it A >> file : stdout of A is put at the end of file A 2 > file : stderr is put in file (overwritting, creation) A < file : executes A with the content of file in stdin A B : executes A then sends stdout(a) in stdin(b) Ex : ls -l sort : gives the list of the files sorted 30

Some filter commands head file : displays the 1 st lines of file tail file : displays the last lines of file grep expression file : displays all the lines of file with expression sort file : sorts each line of file wc -l fichier : displays the nbr of lines of file (option - c : nbr of characters, -w : nbr of words) cat file1 file2... : concatenation of file1, file2,... 31

Variables Access to the content of a variable : $var Ex : echo $HOME --> display the content of the variable HOME Some environment variables (contain the user environment tuning) PATH : stores the access path to find the command asked by the user USER : stores the name of the user HOSTNAME : stores the name of the machine... 32

Shell programming Script = text file, series of commands Execution of the script : each command is analyzed and translated in machine language!!! Comment your program!!! Make the script runnable!! chmod +x file.sh Write where and which interpreter on the 1 st line : #!/bin/bash In an other line # = comment 33

Summary Main commands to travel in the directories 34

Summary Main commands to travel in the directories (cd, mkdir, cp, rm,...) 35

Summary Main commands to travel in the directories (cd, mkdir, cp, rm,...) How to change the permission of a file 36

Summary Main commands to travel in the directories (cd, mkdir, cp, rm,...) How to change the permission of a file Never forget to organize your work space! 37

Summary Main commands to travel in the directories (cd, mkdir, cp, rm,...) How to change the permission of a file Never forget to organize your work space! Remember to open your 3 windows when programming in fortran 3 steps : 38

Summary Main commands to travel in the directories (cd, mkdir, cp, rm,...) How to change the permission of a file Never forget to organize your work space! Remember to open your 3 windows when programming in fortran 3 steps : Writing the program Compiling and link editing gfortran -c toto.f90, gfortran -o toto toto.o Execution 39