scientific programming in fortran 2003

100 122 0
scientific programming in fortran 2003

Đ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

[...]... mapping between the indices of the multi-dimensional array in the program and the index used by the compiler to point to an element in memory In order for this mapping to be established, a convention must exist on the ordering of multi-dimensional arrays Fortran uses what is known as column-major ordering In this convention, the innermost index varies fastest For example, for a 2x3 array the layout in. .. of data is called the field Integer Formats Integer formats take the form nIw Here n is the repeat count The I edit descriptor specifies integer type The w is the total number of spaces, including any leading or trailing blanks, that are allocated to the individual integer(s) Examples I10 3I12 Floating-Point Formats There are a number of options for formatting floating-point variables The simplest edit... descriptor, which prints the result in standard scientific notation, with the integer part normalized to have an absolute value greater than or equal to 1 and less than 10 ES15.7 For more detailed control of output, including zero padding, printing initial plus signs as well as minus signs, etc., the interested reader should consult a reference The same differences in behavior between input and output... valid assignment in Fortran 2.2.8 Comments Comments are strings inserted into the code that are ignored by the compiler but may be of use to the programmer and others using the code In free-form Fortran the comment is indicated by the ! symbol All characters following an exclamation point are ignored Programmers are encouraged to make liberal use of comments to explain what the code is doing, to note special... corresponding element of sarr In order for this to be a valid assignment, rarr and sarr must agree in shape and kind 3.5.1 Array Intrinsics Fortran 2003 offers a large number of intrinsic functions that operate on arrays Most of the mathematical intrinsic functions can take array arguments Examples B = cos(A) X = aimag(Z) 21 As is true for arithmetical operators, the arrays must conform, i.e must agree in. .. conversion intrinsics can take an optional integer kind argument but this is usually omitted below Integer Intrinsics mod(i,j) real(i) : returns the real version of the integer argument (casts integer to real) real(i,k) abs(i) : returns the remainder of the division i/j : returns real kind k of integer : absolute value of i max(i,j) : returns the larger of i and j (can take a variable number of arguments) min(i,j)... 15 Floating Point Intrinsics int(a) : returns integer part of floating-point number (cast real to integer) dble(a) : casts real to double precision (equivalent to real(a,k) with appropriate k) real(d) : casts (truncates) double precision to single precision abs(a) : absolute value ceiling(a) : returns the smallest integer greater than or equal to its argument floor(a) : returns the largest integer... anything that would be valid as a Fortran variable name The name occupies the first field and a colon separates it from the body of the statement Examples 100 continue 2100 format(6i) outer: do i=1,20 end do outer 2.4 Intrinsics Many operations are implemented in the form of intrinsic functions These intrinsics are functions that are defined by the compiler; true to its role as a numerical language, Fortran. .. leading blanks removed and the same number of trailing blanks added adjustr(s) : returns string with trailing blanks removed and the same number of leading blanks added repeat(s,n) : concatenates string s to itself n times Return variable should be declared large enough scan(s,c) : returns the integer starting position of string c within string s or zero if it is not found trim(c) : trim trailing blanks... fact that numbers in base 10 must be converted into the binary representation used by the computer Most decimal number s cannot be exactly represented in binary within the number of bits devoted to a floating-point number The Fortran processor parses the data input initially as characters The characters must then be converted to a number, and in particular a binary (or hexadecimal) number On output the

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

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

Tài liệu liên quan