introduction to fortran 90 ebook

102 233 0
introduction to fortran 90  ebook

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Cardiff HPC Training & Education Centre Introduction to Fortran 90 An introduction Course for Novice Programmers Student Notes Rob Davies Cardiff Alan Rea Belfast Dimitris Tsaptsinos SEL - HPC Version 1.0 [...]... INTEGER :: today_date guess = true date = (today_date==5) if today_date has previously been assigned a value and that value is 5 then date holds TRUE., otherwise FALSE The relational operator == may be read as ‘equal to , thus today_date==5 is read as ‘is today_date equal to 5?’ Below are a list of the relational operators together with their meaning: < >= == /= less than, less than or equal to, greater... title=‘An Introduction to Fortran. ’ 3 4 5 define substrings which would specify the character literals below? (a) to (b) Intro (c) Fortran Using the variable title defined above write a program using intrinsic functions, which would: (a) find the location of the string duct (b) find the length of the string (c) extract and concatenate substrings to produce the string Fortran, An Introduction to In all... information to be lost There are a number of intrinsic functions which handle the conversion of data in a reliable and consistent fashion For example, INTEGER :: total=13, num=5, share share = total/num share = INT( total/num ) !total/num=2.6, share=2 !total/num=2.6, share=2 The result of total/num is a real number, therefore this is an example of a REAL being assigned to an INTEGER Note the value assigned to. .. cir_b * 2 20 Fortran 90 student notes !illegal Variables and Statements 2.8 Exercises 1 Write a program which declares variables to hold the following data: (a) an integer set to zero (b) an integer set to minus one (c) 64.0 (d) -1.56x1012 (this should be written as -1.56E12) 2 Check the program by writing out variables to the screen Which of the following are invalid names in Fortran 90 and why? abignumber... compile 16 Fortran 90 student notes Variables and Statements 2.3.2 Type conversion When assigning one variable type to another (or variables of the same type but with different KIND types), care must be taken to ensure data remains consistent When assigning data to different types (e.g assigning reals to integers) or when assigning data to different kind types (e.g assigning a 4 byte INTEGER to a single... T&E Centres 17 An Introduction to Fortran 90 might be interpreted as either ‘add 1 to x and divide the result by 2’ or ‘add one to half of x’ The use of brackets can make this clear: y = 1+(x/2) y = (1+x)/2 Any expression which appears inside brackets is always evaluated first In expressions which contain more than one operator the operations are carried out (working from the left to right in the expression)... evaluates to TRUE., otherwise it evaluates to FALSE For example: LOGICAL :: test test = (5*3>12) EQV (6*2>8) test = (5*3 . standard (Fortran 90) was released in 1991, with a new revision expected within 10 years. An Introduction to Fortran 90 10 Fortran 90 student notes 1.2 ANSI Standard Fortran 90 is a superset of Fortran. Numbers 88 READ and WRITE Statements An Introduction to Fortran 90 iv Fortran 90 student notes 88 READ Statement 89 WRITE Statement 89 OPEN Statement 90 CLOSE statement 90 INQUIRE statement 91 Exercises 93. 77, that is programs written in Fortran 77 may be compiled and run as Fortran 90 programs. However Fortran 90 is more than a new release of Fortran 77. The Fortran 90 standard introduces many new

Ngày đăng: 24/10/2014, 20:52

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan