write (unit=*,fmt=*) i =, i! will print: i = 3

Size: px
Start display at page:

Download "write (unit=*,fmt=*) i =, i! will print: i = 3"

Transcription

1 I/O (F book, chapters 9, 10 and 15) All I/O in Fortran90 is record-based, typically with record delimiters of some kind. This is in contrast to C, which has stream I/O, with no record delimiters required. First let s look at I/O to the terminal (console I/O). Such output is typically formatted. Formatted means there is a transformation from the internal representation to printed characters (typically ascii). The easiest way to write output is to let the compiler figure out the formatting for you, as follows: integer :: i = 3! stored as in binary write (unit=*,fmt=*) i =, i! will print: i = 3 The unit=* is always preconnected to the terminal, and fmt=* means to use the default formatting. This kind of output is called list-directed. Every write statement creates a single record. For formatted output, the record is automatically terminated by some kind of new line character, typically either CR, LF, or CR-LF, depending on the computer. The unit=6 is also pre-connected to the console, but it is a different unit than *. Unit 6 can be redirected to a file, unit=* cannot.

2 With list-directed output, the compiler choose the format. This is great for quick and simple output, but not so great if you want pretty output, such as tables. Fortran has format specifiers and edit descriptors to control the appearance of output with great precision. I will not go into the intricate details here, but merely summarize the general features. The most useful edit descriptors are aw for character variables iw for integer variables fw.d for real variables ew.d for real variables with exponential format nx for n spaces Where w is the width of output characters, and d is the number of characters after the decimal. For example, real :: a = 4.2 complex :: z = (1.0e-10,-2.0e-5) character(len=32) :: c = '(1x,a,1x,i4,1x,f4.2,1x,2(e14.7))' write (*,c) 'variables:', i, a, z will print: variables: E E-04 If the variable is too long for the w field requested, *** will be printed. Note for characters, you can specify just a instead of aw, and it will figure out what w to use.

3 There is also a generalized edit descriptor, which can be used for any intrinsic type. It is useful for making tables where each column is the same size: character(len=32) :: c = '(1x,5g10.2)' write (*,c) 'variables:', i, a, z will print: variables: E E-04 Another useful edit descriptor is Zw for hexadecimal. This is useful for examining binary data. For example, how exactly is pi internally represented on your computer? real :: pi = write (*,'(Z8)') pi On my Macintosh, the result is: 40490fea

4 Another useful feature is non-advancing I/O. E.g., write (unit=*,fmt='(a)',advance='no') 'enter input:' read (*,*) i will suppress the carriage return and/or line feed at the end of the prompt, so that if I enter 5, the console output looks like: enter input:5 List-directed reads are very convenient and recommended. The following will read from the keyboard: read (unit=*,fmt=*) i, j! converts ascii input to binary Input values should be separated by commas or blanks.

5 Besides writing to the console, one often needs to write to a file. In Fortran, all files are described by an integer unit number, which is connected to a file name with an open statement: For example, to print formatted output to a file: integer : iu = 12 open(unit= iu,file= filename, form= formatted ) where filename is the name of the file you are writing to. You may not connect two units to the same file, or the same file to 2 units. It is also possible to write unformatted (binary) output. One does this by opening a file as unformatted: open(unit= iu,file= filename, form= unformatted ) and then omitting the format specifier in the read statement, as follows: integer :: i = 3 write (unit=iu) i! stored as in binary! will write: in binary The output will be written using the internal binary representation of the data. Since storage of binary numbers is machine dependent, and one generally cannot expect to read such a file on a different computer than the one it was written on.

6 Since Fortran is record based, each write statement determines a record. Thus write (unit=iu) i, j write (unit=iu) k, l! writes first record! writes second record writes two records. Unlike formatted output, where records are terminated with CR or LF characters, unformatted files usually add additional internal information to the file, typically the length of the record before and after each write. The purpose of this is to support partial record reads. For example, after writing the above data, one can read it as follows: rewind iu read (unit=iu) m read (unit=iu) n! will read the value i only! will read the value k only where only the first word of each record is read. One can also skip over a record by just reading nothing read (unit=iu)! skips over this record to next one or go back to a previous record by backspacing: backspace iu! go to previous record The internal information needed to support this is not specified, and each vendor can implement it as they wish. Thus programs compiled by different compilers may produce files which are not compatible, even on the same machine.

7 There is a special record called EOF (End of File) which is written at the end of a file when the file is closed: close(unit=iu) It is possible to detect errors in reading files by using the iostat keyword on a read statement: integer :: ierror read(unit=iu,iostat=ierror) If an error occurs, the variable ierror will be non-zero. Your program can use this feature to determine how many records in a file: integer :: num = 0 do read(unit=iu,iostat=ierror) i if (ierror /= 0) exit num = num + 1 enddo write (*,*) number of records in file =, num Fortran does not have any standard way to ensure that a file is actually written to disk (and not just buffered). However, the following sequence of instructions: end file iu backspace iu often works on many compilers.

8 The kinds of files we have been discussing so far are called sequential files. They were originally magnetic tapes, which had to be read sequentially from one end to another. With disks, however, it is possible to jump to different locations directly. Fortran therefore also supports something called direct access files. Such files require each record to be the same length. One opens such a file as follows: integer :: recordlength open(unit= iu,file= filename, form= formatted, recl=recordlength,access= direct ) where recordlength is the size of each record. One reads such files by specifying a record number, as follows: integer :: rec_num = 1 read (unit=iu,fmt=*,rec=rec_num) i! read first record The units of the record length are bytes for formatted files, but are in unspecified vendor dependent units for unformatted (binary) files. To determine what units to use, one uses a special inquire function. For example to open a direct access file where each record is big enough to write an integer: integer :: i inquire(iolength=recordlength) i open(unit= iu,file= filename, form= unformatted, recl=recordlength,access= direct )

9 One can emulate stream I/O by creating a direct access file with a very large record length, and using with the advance= no keyword, as follows: real, dimension(100) :: data write (unit=iu,fmt='(a)',rec=1,advance='no') data There are many other keywords which one can use when opening files, such as status: old, new, replace, unknown,or scratch action: read, write, or readwrite position: rewind, or append There are also a number of useful inquiry functions. One can inquire whether a file exists, whether it is opened, whether a unit number is connected. For example, logical :: connected inquire(unit=iu,opened=connected) The variable connected will be true if the unit number iu is already connected to a file. All of the file names here are relative to the current directory (or one can specify a full path name). There are no intrinsics to change the current directory or create a directory.

10 In addition to writing to a file, one can write to a character variable, which is known as an internal file, as follows: character(len=80) :: c integer :: i = 3 write (unit=c,fmt=*) i=, i The variable c now contains the string: i= 3. One can also read from an internal file. After execution, the statement: character(len=80) :: d integer :: j read (c,*) d, j will set the string d to the value i=, and the variable j to 3. This allows one to convert from binary to ascii and vice-versa. It is useful to passing formatted information to other procedures, such as to a graphics subroutine for labeling of scientific output.

11 Advanced features (F book, chapter 16) One interesting new feature of Fortran90 is the optional argument in a procedure. Suppose we had an FFT procedure, where we had to reinitialize the sinecosine tables only when the size of the FFT had changed. This could be implemented as follows: subroutine fft(data,direction,initialize) real, dimension(:), intent(inout) :: data integer, intent(in) :: direction logical, intent(in), optional :: initialize... if (present(initialize)) then if (initialize) call init_table(size(data)) endif The present intrinsic is used to test whether an optional argument is actually present. Normally, a forward transform is performed as: real, dimension(128) :: f call fft(f,1)! just perform fft However, if the tables had to be reinitialized, we would add an additional argument. call fft(f,1,.true.)! reinitialize tables and perform fft

12 One feature which makes for better readability is the use of keywords. For example, one can write the fft call as follows: call fft(data=f,direction=1,initialize=.true.) If edifying names are chosen for the subroutine variables, using keywords makes it clearer what the programmer intended. It is possible to use mix keyword variables and positional variables. For example, call fft(f,1,initialize=.true.) is permitted. If keywords are used, they can be in any order. For example, call fft(initialize=.true.,direction=1,data=f) is permitted.

13 Suppose we have two procedures for performing 1d and 2d FFTs: real, dimension(128) :: f real, dimension(32,32) :: g call fft1d(f,1) call fft2d(g,2)! perform 1d fft! perform 2d fft If the types used by the two procedures differ, one can create a single name which is used in both instances: call fft(f,1) call fft(g,2)! perform 1d fft! perform 2d fft where the compiler figures out which name to use at compile time. Such procedures are called generic procedures, and are created as follows: module fft_module interface fft! create generic fft name module procedure fft1d, fft2d end interface contains subroutine fft1d(data,direction,initialize) real, dimension(:), intent(inout) :: data... subroutine fft2d(data,direction,initialize) real, dimension(:,:), intent(inout) :: data... end module fft_module

Some More I O definitions

Some More I O definitions Input and Output Fortran I O Overview Input/output (I O) can be a lot more flexible than just reading typed input form the terminal window and printing it back out to a screen. Fortran allows for multiple

More information

Computational Astrophysics AS 3013 Lecture 6:

Computational Astrophysics AS 3013 Lecture 6: Computational Astrophysics AS 3013 Lecture 6: 1) formated input/output 2) file input/output 3) safety checks FORTRAN 90: formatted input/output list-directed (or default) format READ *, variable list PRINT

More information

ADVANCED INPUT AND OUTPUT FORTRAN PROGRAMMING. Zerihun Alemayehu AAiT.CED Rm E119B

ADVANCED INPUT AND OUTPUT FORTRAN PROGRAMMING. Zerihun Alemayehu AAiT.CED Rm E119B ADVANCED INPUT AND OUTPUT FORTRAN PROGRAMMING Zerihun Alemayehu AAiT.CED Rm E119B SIMPLE INPUT AND OUTPUT READ, WRITE and PRINT statements are called list-directed READ*, a, b, c READ(*,*) a, b, c PRINT*,

More information

FORTRAN 90: Formatted Input/Output. Meteorology 227 Fall 2018

FORTRAN 90: Formatted Input/Output. Meteorology 227 Fall 2018 FORTRAN 90: Formatted Input/Output Meteorology 227 Fall 2018 Formatted Output Two output statements in FORTRAN PRINT and WRITE PRINT format-descriptor, output-list What is a format descriptor? * A character

More information

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 7 Input/Output

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 7 Input/Output ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 7 Input/Output Reading: Bowman, Chapters 10-12 READING FROM THE TERMINAL The READ procedure is used to read from the terminal. IDL

More information

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill 12.010 Computational Methods of Scientific Programming Lecturers Thomas A Herring Chris Hill Review of last lecture Start examining the FORTRAN language Development of the language Philosophy of language:

More information

A. Run-Time Error Messages

A. Run-Time Error Messages Appendix A A. Table A-1 lists possible Fortran run-time I/O errors. Other errors given by the operating system may also occur (refer to the intro(2) and perror(3f) reference pages for details). Each error

More information

Introduction to Modern Fortran

Introduction to Modern Fortran Introduction to Modern Fortran p. 1/?? Introduction to Modern Fortran Advanced I/O and Files Nick Maclaren Computing Service nmm1@cam.ac.uk, ext. 34761 November 2007 Introduction to Modern Fortran p. 2/??

More information

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CoCo Processor - Copyright (c) 1996 Imagine1, Inc.!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CoCo Processor - Copyright (c) 1996 Imagine1, Inc.!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CoCo Processor - Copyright (c) 1996 Imagine1, Inc.!!!!!!!! Imagine1 claims that this software is not a complete implementation!!!!

More information

8-1-1 The open statement

8-1-1 The open statement Fortran Chapter 8 讀 讀 讀 兩 (1) 讀 讀 來 讀 料 (2) 讀 讀 來 讀 (1) 料都 理 來 易 (2) 料 ( ) 讀 省 1 8-1-1 The open statement OPEN(unit = int_expr, file = char_expr, status = char_expr, action = char_expr, iostat = int_var)

More information

Watcom FORTRAN 77. Language Reference. Edition 11.0c

Watcom FORTRAN 77. Language Reference. Edition 11.0c Watcom FORTRAN 77 Language Reference Edition 110c Notice of Copyright Copyright 2000 Sybase, Inc and its subsidiaries All rights reserved No part of this publication may be reproduced, transmitted, or

More information

Edit Descriptors. Decimal form. Fw.d Exponential form Ew.d Ew.dEe Scientific form ESw.d ESw.dEe Engineering form ENw.d ENw.dEe.

Edit Descriptors. Decimal form. Fw.d Exponential form Ew.d Ew.dEe Scientific form ESw.d ESw.dEe Engineering form ENw.d ENw.dEe. Format Edit Descriptors The tedious part of using Fortran format is to master many format edit descriptors. Each edit descriptor tells the system how to handle certain type of values or activity. Each

More information

4. COMPILING AND RUNNING FORTRAN PROGRAMS

4. COMPILING AND RUNNING FORTRAN PROGRAMS 20 4. COMPILING AND RUNNING FORTRAN PROGRAMS 4.1. Introduction Fortran is the most commonly used high-level programming language in science and engineering. Developed in the 1950's, Fortran was essentially

More information

File Input and Output

File Input and Output 5. Input and Output File Input and Output read(i,j) write(i,j) j is the statement number of format statement. i is the I/O unit or logical unit associated with device or file. non-negative integer from

More information

Unit 4. Input/Output Functions

Unit 4. Input/Output Functions Unit 4 Input/Output Functions Introduction to Input/Output Input refers to accepting data while output refers to presenting data. Normally the data is accepted from keyboard and is outputted onto the screen.

More information

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code CS102: Standard I/O Our next topic is standard input and standard output in C. The adjective "standard" when applied to "input" or "output" could be interpreted to mean "default". Typically, standard output

More information

UNIT IV-2. The I/O library functions can be classified into two broad categories:

UNIT IV-2. The I/O library functions can be classified into two broad categories: UNIT IV-2 6.0 INTRODUCTION Reading, processing and writing of data are the three essential functions of a computer program. Most programs take some data as input and display the processed data, often known

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features

More information

PROBLEM SOLVING WITH FORTRAN 90

PROBLEM SOLVING WITH FORTRAN 90 David R. Brooks PROBLEM SOLVING WITH FORTRAN 90 FOR SCIENTISTS AND ENGINEERS Springer Contents Preface v 1.1 Overview for Instructors v 1.1.1 The Case for Fortran 90 vi 1.1.2 Structure of the Text vii

More information

Worksheet 6. Input and Output

Worksheet 6. Input and Output Worksheet 6. Input and Output Most programs (except those that run other programs) contain input or output. Both fortran and matlab can read and write binary files, but we will stick to ascii. It is worth

More information

Programming in C++ 6. Floating point data types

Programming in C++ 6. Floating point data types Programming in C++ 6. Floating point data types! Introduction! Type double! Type float! Changing types! Type promotion & conversion! Casts! Initialization! Assignment operators! Summary 1 Introduction

More information

Programming with Fortran and C. Style and rules Statements Examples Compilers and options

Programming with Fortran and C. Style and rules Statements Examples Compilers and options Programming Programming with Fortran and C Style and rules Statements Examples Compilers and options Before we start coding: Check formulae and algorithms. It takes very long time to develop and to debug

More information

Introduction to Modern Fortran

Introduction to Modern Fortran Introduction to Modern Fortran p. 1/?? Introduction to Modern Fortran I/O and Files Nick Maclaren Computing Service nmm1@cam.ac.uk, ext. 34761 November 2007 Introduction to Modern Fortran p. 2/?? I/O Generally

More information

Python Working with files. May 4, 2017

Python Working with files. May 4, 2017 Python Working with files May 4, 2017 So far, everything we have done in Python was using in-memory operations. After closing the Python interpreter or after the script was done, all our input and output

More information

Lecture-6 Lubna Ahmed

Lecture-6 Lubna Ahmed Lecture-6 Lubna Ahmed 1 Input/output Input/output List directed input/output Formatted (or user formatted) input/output 2 List directed Input/output Statements List directed I/O are said to be in free

More information

c Microsoft, 1977, 1978, 1979

c Microsoft, 1977, 1978, 1979 c Microsoft, 1977, 1978, 1979 Microsoft FORTRAN 80 User's Manual CONTENTS SECTION 1 1.1 1.2 1.3 Compiling FORTRAN Programs 5 FORTRAN-80 Command Scanner..... 5 1.1.1 Format of Commands......... 5 1.1.2

More information

Physical Files and Logical Files. Opening Files. Chap 2. Fundamental File Processing Operations. File Structures. Physical file.

Physical Files and Logical Files. Opening Files. Chap 2. Fundamental File Processing Operations. File Structures. Physical file. File Structures Physical Files and Logical Files Chap 2. Fundamental File Processing Operations Things you have to learn Physical files and logical files File processing operations: create, open, close,

More information

CMPT 102 Introduction to Scientific Computer Programming. Input and Output. Your first program

CMPT 102 Introduction to Scientific Computer Programming. Input and Output. Your first program CMPT 102 Introduction to Scientific Computer Programming Input and Output Janice Regan, CMPT 102, Sept. 2006 0 Your first program /* My first C program */ /* make the computer print the string Hello world

More information

CROSSREF Manual. Tools and Utilities Library

CROSSREF Manual. Tools and Utilities Library Tools and Utilities Library CROSSREF Manual Abstract This manual describes the CROSSREF cross-referencing utility, including how to use it with C, COBOL 74, COBOL85, EXTENDED BASIC, FORTRAN, Pascal, SCREEN

More information

Review Arrays Advanced Input/Output New Data Types Debugging Your Programs

Review Arrays Advanced Input/Output New Data Types Debugging Your Programs OUTLINE 1 REVIEW 2 ARRAYS The Concept Using Arrays 3 ADVANCED INPUT/OUTPUT Format Using Files 4 NEW DATA TYPES Creating Your Own Data Type 5 DEBUGGING YOUR PROGRAMS THE STORY SO FAR... Understand about

More information

Introduction to Fortran Programming. - input / output -

Introduction to Fortran Programming. - input / output - Introduction to Fortran Programming - input / output - read statement Grammar read(unit numbers, Format) Input1, Input2, Substitute "UNIT numbers" into "Input target" according to "format" UNIT=* or 5

More information

Using of FORTRAN 77 FILES

Using of FORTRAN 77 FILES A. Perronnet October 13 2009 Taida Institute for Mathematical Sciences National Taiwan University, Taipei 10617, Taiwan Using of FORTRAN 77 FILES A FILE is necessary when - the data must be retained between

More information

Parallel Fortran Version Release Note

Parallel Fortran Version Release Note Parallel Fortran Version 2.1.3 Release Note 3L Ltd. December 5, 1990 1 Introduction This Release Note accompanies version 2.1.3 of 3L Parallel Fortran for the Inmos transputer, and outlines the changes

More information

Today in CS162. External Files. What is an external file? How do we save data in a file? CS162 External Data Files 1

Today in CS162. External Files. What is an external file? How do we save data in a file? CS162 External Data Files 1 Today in CS162 External Files What is an external file? How do we save data in a file? CS162 External Data Files 1 External Files So far, all of our programs have used main memory to temporarily store

More information

Introduction to FORTRAN. Structured Programming

Introduction to FORTRAN. Structured Programming Introduction to by Dr. Ibrahim A. Assakkaf Spring 2000 Department of Civil and Environmental Engineering University of Maryland Slide No. 1 Control Structures In a structured program, the logical flow

More information

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming) Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming) Learning any imperative programming language involves mastering a number of common concepts: Variables: declaration/definition

More information

Data Capture System for Windows. Documentation. TSW Automation, Inc Robertson Ave. Nashville, TN phone: fax:

Data Capture System for Windows. Documentation. TSW Automation, Inc Robertson Ave. Nashville, TN phone: fax: Data Capture System for Windows Documentation TSW Automation, Inc. 6115 Robertson Ave. Nashville, TN 37209 phone: 615-356-8785 fax: 615-356-8744 1995-1998 All rights reserved. SYSTEM OVERVIEW The Data

More information

Operating System Interaction via bash

Operating System Interaction via bash Operating System Interaction via bash bash, or the Bourne-Again Shell, is a popular operating system shell that is used by many platforms bash uses the command line interaction style generally accepted

More information

Fortran 2003 programming in GEF4510. Fall 2012

Fortran 2003 programming in GEF4510. Fall 2012 Fortran 2003 programming in GEF4510 Fall 2012 1 Course content 1. Fortran historical background, what, why and how 2. A short program converting from Farenheit to centigrades and vice versa 3. The variable

More information

GSE Scale Systems M660 CUSTOM TRANSMIT

GSE Scale Systems M660 CUSTOM TRANSMIT M660 CUSTOM TRANSMIT A custom transmit is a sequence of characters, control codes and parameter values to be transmitted out a communication port to a peripheral device such as a printer, remote display,

More information

An Introduction to Komodo

An Introduction to Komodo An Introduction to Komodo The Komodo debugger and simulator is the low-level debugger used in the Digital Systems Laboratory. Like all debuggers, Komodo allows you to run your programs under controlled

More information

Topic 6: A Quick Intro To C

Topic 6: A Quick Intro To C Topic 6: A Quick Intro To C Assumption: All of you know Java. Much of C syntax is the same. Also: Many of you have used C or C++. Goal for this topic: you can write & run a simple C program basic functions

More information

Interactive MATLAB use. Often, many steps are needed. Automated data processing is common in Earth science! only good if problem is simple

Interactive MATLAB use. Often, many steps are needed. Automated data processing is common in Earth science! only good if problem is simple Chapter 2 Interactive MATLAB use only good if problem is simple Often, many steps are needed We also want to be able to automate repeated tasks Automated data processing is common in Earth science! Automated

More information

Review Functions Subroutines Flow Control Summary

Review Functions Subroutines Flow Control Summary OUTLINE 1 REVIEW 2 FUNCTIONS Why use functions How do they work 3 SUBROUTINES Why use subroutines? How do they work 4 FLOW CONTROL Logical Control Looping 5 SUMMARY OUTLINE 1 REVIEW 2 FUNCTIONS Why use

More information

Introduction to Modern Fortran

Introduction to Modern Fortran Introduction to Modern Fortran p. 1/?? Introduction to Modern Fortran More About I/O and Files Nick Maclaren Computing Service nmm1@cam.ac.uk, ext. 34761 November 2007 Introduction to Modern Fortran p.

More information

2 Making Decisions. Store the value 3 in memory location y

2 Making Decisions. Store the value 3 in memory location y 2.1 Aims 2 Making Decisions By the end of this worksheet, you will be able to: Do arithmetic Start to use FORTRAN intrinsic functions Begin to understand program flow and logic Know how to test for zero

More information

ELEC 242 Using Library Procedures

ELEC 242 Using Library Procedures ELEC 242 Using Library Procedures There are a number of existing procedures that are already written for you that you will use in your programs. In order to use the library procedures that come with the

More information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 07: Data Input and Output Readings: Chapter 4 Input /Output Operations A program needs

More information

UPIC Framework designed to help construct Plasma PIC calculations by student programmers.

UPIC Framework designed to help construct Plasma PIC calculations by student programmers. Frameworks A framework is a unified environment containing all the components needed for writing code for a specific problem domain. Its goal is the rapid construction of new codes by reuse of trusted

More information

June This paper assumes knowledge of the following protocols described in the ARPA Internet Protocol Handbook.

June This paper assumes knowledge of the following protocols described in the ARPA Internet Protocol Handbook. IEN 149 RFC 765 J. Postel ISI June 1980 FILE TRANSFER PROTOCOL INTRODUCTION The objectives of FTP are 1) to promote sharing of files (computer programs and/or data), 2) to encourage indirect or implicit

More information

C for Engineers and Scientists

C for Engineers and Scientists C for Engineers and Scientists An Interpretive Approach Harry H. Cheng University of California, Davis 0.8 0.6 j0(t) j1(t) j2(t) j3(t) 0.4 Bessel functions 0.2 0-0.2-0.4-0.6 1 2 3 4 5 6 7 8 9 10 t Copyright

More information

High Level Classes in UPIC Framework

High Level Classes in UPIC Framework High Level Classes in UPIC Framework The purpose of the High Level Classes is to encapsulate large pieces of code that the programmer does not wish to modify. They also provide a template for constructing

More information

PACKAGE SPECIFICATION HSL 2013

PACKAGE SPECIFICATION HSL 2013 PACKAGE SPECIFICATION HSL 2013 1 SUMMARY Given a rank-one or rank-two allocatable array, reallocates the array to have a different size, and can copy all or part of the original array into the new array.

More information

Basic Fortran I/O Concepts

Basic Fortran I/O Concepts Basic Fortran I/O Concepts LECTURE OUTLINE Free versus Directed I/O Edit Descriptors Carriage Control Numeric Control Character Control Spacing Control Repeat Specifier Read and Write to Files Examples!!

More information

LESSON 5 FUNDAMENTAL DATA TYPES. char short int long unsigned char unsigned short unsigned unsigned long

LESSON 5 FUNDAMENTAL DATA TYPES. char short int long unsigned char unsigned short unsigned unsigned long LESSON 5 ARITHMETIC DATA PROCESSING The arithmetic data types are the fundamental data types of the C language. They are called "arithmetic" because operations such as addition and multiplication can be

More information

Files and Streams Opening and Closing a File Reading/Writing Text Reading/Writing Raw Data Random Access Files. C File Processing CS 2060

Files and Streams Opening and Closing a File Reading/Writing Text Reading/Writing Raw Data Random Access Files. C File Processing CS 2060 CS 2060 Files and Streams Files are used for long-term storage of data (on a hard drive rather than in memory). Files and Streams Files are used for long-term storage of data (on a hard drive rather than

More information

Chapter 7 File Access. Chapter Table of Contents

Chapter 7 File Access. Chapter Table of Contents Chapter 7 File Access Chapter Table of Contents OVERVIEW...105 REFERRING TO AN EXTERNAL FILE...105 TypesofExternalFiles...106 READING FROM AN EXTERNAL FILE...107 UsingtheINFILEStatement...107 UsingtheINPUTStatement...108

More information

FANF. programming language. written by Konstantin Dimitrov. Revision 0.1 February Programming language FANF 1 / 21

FANF. programming language. written by Konstantin Dimitrov. Revision 0.1 February Programming language FANF 1 / 21 programming language FANF written by Konstantin Dimitrov Revision 0.1 February 2014 For comments and suggestions: knivd@me.com Programming language FANF 1 / 21 Table of Contents 1. Introduction...3 2.

More information

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */ Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,

More information

Note on homework for SAS date formats

Note on homework for SAS date formats Note on homework for SAS date formats I m getting error messages using the format MMDDYY10D. even though this is listed on websites for SAS date formats. Instead, MMDDYY10 and similar (without the D seems

More information

Experiment #5. Using BIOS Services and DOS functions Part 1: Text-based Graphics

Experiment #5. Using BIOS Services and DOS functions Part 1: Text-based Graphics Experiment #5 Using BIOS Services and DOS functions Part 1: Text-based Graphics 5.0 Objectives: The objective of this experiment is to introduce BIOS and DOS interrupt service routines to be utilized in

More information

Computers Programming Course 5. Iulian Năstac

Computers Programming Course 5. Iulian Năstac Computers Programming Course 5 Iulian Năstac Recap from previous course Classification of the programming languages High level (Ada, Pascal, Fortran, etc.) programming languages with strong abstraction

More information

Topic 6: A Quick Intro To C. Reading. "goto Considered Harmful" History

Topic 6: A Quick Intro To C. Reading. goto Considered Harmful History Topic 6: A Quick Intro To C Reading Assumption: All of you know basic Java. Much of C syntax is the same. Also: Some of you have used C or C++. Goal for this topic: you can write & run a simple C program

More information

Chapter 1 INTRODUCTION. SYS-ED/ Computer Education Techniques, Inc.

Chapter 1 INTRODUCTION. SYS-ED/ Computer Education Techniques, Inc. Chapter 1 INTRODUCTION SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: Facilities and features of PL/1. Structure of programs written in PL/1. Data types. Storage classes, control,

More information

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 18 I/O in C Standard C Library I/O commands are not included as part of the C language. Instead, they are part of the Standard C Library. A collection of functions and macros that must be implemented

More information

GNU CPIO September by Robert Carleton and Sergey Poznyakoff

GNU CPIO September by Robert Carleton and Sergey Poznyakoff GNU CPIO 2.12 12 September 2015 by Robert Carleton and Sergey Poznyakoff This manual documents GNU cpio (version 2.12, 12 September 2015). Copyright c 1995, 2001-2002, 2004, 2010, 2014-2015 Free Software

More information

The C++ Language. Arizona State University 1

The C++ Language. Arizona State University 1 The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

Old Questions Name: a. if b. open c. output d. write e. do f. exit

Old Questions Name: a. if b. open c. output d. write e. do f. exit Old Questions Name: Part I. Multiple choice. One point each. 1. Which of the following is not a Fortran keyword? a. if b. open c. output d. write e. do f. exit 2. How many times will the code inside the

More information

Chapter 3. Fortran Statements

Chapter 3. Fortran Statements Chapter 3 Fortran Statements This chapter describes each of the Fortran statements supported by the PGI Fortran compilers Each description includes a brief summary of the statement, a syntax description,

More information

Xpert / XLite GPRS232 Serial Interface Block USERS MANUAL. Part No Rev. 3.3 July 27, 2009

Xpert / XLite GPRS232 Serial Interface Block USERS MANUAL. Part No Rev. 3.3 July 27, 2009 Xpert / XLite GPRS232 Serial Interface Block USERS MANUAL Part No. 8800-1164 Rev. 3.3 July 27, 2009 Sutron Corporation 22400 Davis Drive Sterling, VA 20164 703.406.2800 www.sutron.com sales@sutron.com

More information

Subroutines and Functions

Subroutines and Functions Subroutines and Functions Procedures: Subroutines and Functions There are two types of procedures: SUBROUTINE: a parameterized named sequence of code which performs a specific task and can be invoked from

More information

Fortran 90 - A thumbnail sketch

Fortran 90 - A thumbnail sketch Fortran 90 - A thumbnail sketch Michael Metcalf CERN, Geneva, Switzerland. Abstract The main new features of Fortran 90 are presented. Keywords Fortran 1 New features In this brief paper, we describe in

More information

by Pearson Education, Inc. All Rights Reserved. 2

by Pearson Education, Inc. All Rights Reserved. 2 The C++ standard libraries provide an extensive set of input/output capabilities. C++ uses type-safe I/O. Each I/O operation is executed in a manner sensitive to the data type. If an I/O member function

More information

Review More Arrays Modules Final Review

Review More Arrays Modules Final Review OUTLINE 1 REVIEW 2 MORE ARRAYS Using Arrays Why do we need dynamic arrays? Using Dynamic Arrays 3 MODULES Global Variables Interface Blocks Modular Programming 4 FINAL REVIEW THE STORY SO FAR... Create

More information

Segmentation with Paging. Review. Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Segmentation with Page (MULTICS)

Segmentation with Paging. Review. Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Review Segmentation Segmentation Implementation Advantage of Segmentation Protection Sharing Segmentation with Paging Segmentation with Paging Segmentation with Paging Reason for the segmentation with

More information

11. Implementation of sequential file

11. Implementation of sequential file 11. Implementation of sequential file AIM: Department maintains a student information. The file contains roll number, name, division and address. Write a program to create a sequential file to store and

More information

Streams contd. Text: Chapter12, Big C++

Streams contd. Text: Chapter12, Big C++ Streams contd pm_jat@daiict.ac.in Text: Chapter12, Big C++ Streams Objects are Abstracted Wrapper around input/output source/destinations Steps in reading/writing streams- Open: Establish connection between

More information

Data and File Structures Chapter 2. Basic File Processing Operations

Data and File Structures Chapter 2. Basic File Processing Operations Data and File Structures Chapter 2 Basic File Processing Operations 1 Outline Physical versus Logical Files Opening and Closing Files Reading, Writing and Seeking Special Characters in Files The Unix Directory

More information

Bean's Automatic Tape Manipulator A Description, and Operating Instructions. Jeffrey Bean

Bean's Automatic Tape Manipulator A Description, and Operating Instructions. Jeffrey Bean XIV-1 XIV. Bean's Automatic Tape Manipulator A Description, and Operating Instructions Jeffrey Bean 1. General Description BATMAN is a generalized updating program for handling BCD card images on tape,

More information

The following content has been imported from Legacy Help systems and is in the process of being checked for accuracy.

The following content has been imported from Legacy Help systems and is in the process of being checked for accuracy. Processor Debug Old Content - visit altium.com/documentation Modified by Admin on Nov 6, 2013 The following content has been imported from Legacy Help systems and is in the process of being checked for

More information

Chapter 10: File Input / Output

Chapter 10: File Input / Output C: Chapter10 Page 1 of 6 C Tutorial.......... File input/output Chapter 10: File Input / Output OUTPUT TO A FILE Load and display the file named formout.c for your first example of writing data to a file.

More information

11 Console Input/Output

11 Console Input/Output 11 Console Input/Output Types of I/O Console I/O Functions Formatted Console I/O Functions sprintf( ) and sscanf( ) Functions Unformatted Console I/O Functions Summary Exercise 1 As mentioned in the first

More information

Week 3 More Formatted Input/Output; Arithmetic and Assignment Operators

Week 3 More Formatted Input/Output; Arithmetic and Assignment Operators Week 3 More Formatted Input/Output; Arithmetic and Assignment Operators Formatted Input and Output The printf function The scanf function Arithmetic and Assignment Operators Simple Assignment Side Effect

More information

4 Programming Fundamentals. Introduction to Programming 1 1

4 Programming Fundamentals. Introduction to Programming 1 1 4 Programming Fundamentals Introduction to Programming 1 1 Objectives At the end of the lesson, the student should be able to: Identify the basic parts of a Java program Differentiate among Java literals,

More information

Version N 2.0. LaurTec. RS232 Terminal. Debugging Embedded Systems. Author : Mauro Laurenti ID: PJ11004-EN. Copyright Mauro Laurenti 1/33

Version N 2.0. LaurTec. RS232 Terminal. Debugging Embedded Systems. Author : Mauro Laurenti ID: PJ11004-EN. Copyright Mauro Laurenti 1/33 Version N 2.0 LaurTec RS232 Terminal Debugging Embedded Systems Author : Mauro Laurenti ID: PJ11004-EN Copyright 2009-2017 Mauro Laurenti 1/33 License Copyright (C) 2009-2017 Author: Mauro Laurenti Web

More information

Data Types Literals, Variables & Constants

Data Types Literals, Variables & Constants VISUAL BASIC Data Types Literals, Variables & Constants Copyright 2013 Dan McElroy Under the Hood As a DRIVER of an automobile, you may not need to know everything that happens under the hood, although

More information

File Operations. Lecture 16 COP 3014 Spring April 18, 2018

File Operations. Lecture 16 COP 3014 Spring April 18, 2018 File Operations Lecture 16 COP 3014 Spring 2018 April 18, 2018 Input/Ouput to and from files File input and file output is an essential in programming. Most software involves more than keyboard input and

More information

Functions. Using Bloodshed Dev-C++ Heejin Park. Hanyang University

Functions. Using Bloodshed Dev-C++ Heejin Park. Hanyang University Functions Using Bloodshed Dev-C++ Heejin Park Hanyang University 2 Introduction Reviewing Functions ANSI C Function Prototyping Recursion Compiling Programs with Two or More Source Code Files Finding Addresses:

More information

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals Digital Systems COE 202 Digital Logic Design Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals Welcome to COE 202 Course Webpage: http://faculty.kfupm.edu.sa/coe/mudawar/coe202/ Lecture

More information

EDIT - DOS/65 EDITOR VERSION 2.1

EDIT - DOS/65 EDITOR VERSION 2.1 EDIT - DOS/65 EDITOR (Copyright) Richard A. Leary 180 Ridge Road Cimarron, CO 81220 This documentation and the associated software is not public domain, freeware, or shareware. It is still commercial documentation

More information

CS 61C: Great Ideas in Computer Architecture Lecture 2: Introduction to C, Part I

CS 61C: Great Ideas in Computer Architecture Lecture 2: Introduction to C, Part I CS 61C: Great Ideas in Computer Architecture Lecture 2: Introduction to C, Part I Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/ 1 Agenda Everything is a Number

More information

Input / Output Functions

Input / Output Functions CSE 2421: Systems I Low-Level Programming and Computer Organization Input / Output Functions Presentation G Read/Study: Reek Chapter 15 Gojko Babić 10-03-2018 Input and Output Functions The stdio.h contain

More information

Introduction to MATLAB

Introduction to MATLAB Chapter 1 Introduction to MATLAB 1.1 Software Philosophy Matrix-based numeric computation MATrix LABoratory built-in support for standard matrix and vector operations High-level programming language Programming

More information

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments. Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started

More information

Chapter 11 Input/Output (I/O) Functions

Chapter 11 Input/Output (I/O) Functions EGR115 Introduction to Computing for Engineers Input/Output (I/O) Functions from: S.J. Chapman, MATLAB Programming for Engineers, 5 th Ed. 2016 Cengage Learning Topics Introduction: MATLAB I/O 11.1 The

More information

Logic and Computer Design Fundamentals. Chapter 1 Digital Computers and Information

Logic and Computer Design Fundamentals. Chapter 1 Digital Computers and Information Logic and Computer Design Fundamentals Chapter 1 Digital Computers and Information Overview Digital Systems and Computer Systems Information Representation Number Systems [binary, octal and hexadecimal]

More information

NO CALCULATOR ALLOWED!!

NO CALCULATOR ALLOWED!! CPSC 203 500 EXAM TWO Fall 2005 NO CALCULATOR ALLOWED!! Full Name (Please Print): UIN: Score Possible Points Prog Points Part One 33 pts Part Two 30 pts Part Three 20 pts Part Four 25 pts Total 108 pts

More information

Fortran 77 Language Reference Manual

Fortran 77 Language Reference Manual Fortran 77 Language Reference Manual Document Number 007-0710-060 CONTRIBUTORS Written by David Graves and Chris Hogue Production by Julia Lin Cover design and illustration by Rob Aguilar, Rikk Carey,

More information

NEW CEIBO DEBUGGER. Menus and Commands

NEW CEIBO DEBUGGER. Menus and Commands NEW CEIBO DEBUGGER Menus and Commands Ceibo Debugger Menus and Commands D.1. Introduction CEIBO DEBUGGER is the latest software available from Ceibo and can be used with most of Ceibo emulators. You will

More information

Maciej Sobieraj. Lecture 1

Maciej Sobieraj. Lecture 1 Maciej Sobieraj Lecture 1 Outline 1. Introduction to computer programming 2. Advanced flow control and data aggregates Your first program First we need to define our expectations for the program. They

More information