
Michael Metcalf and John Reid, The F Programming Language, Oxford University Press (1996). Adams, Programmer's Guide to F, Unicomp (1996). Print *, "properties of b =", b,bstar,b*bstar,f Print *, "real part of a (converted to integer) =", dī = exp(arg) ! done in two lines for ease of reading onlyīstar = conjg(b) ! complex conjugate of b Print *, "a =", a ! note that a has less precision than b ! If one of part has a kind, the other part must have same kind ! A complex constant is written as two real numbers, separated by The following program illustrates the way complex variables are defined and used. Note the use of the write statement to build a character string for numeric and character components.įortran 90 is uniquely suited to handle complex variables. Open (unit=1,file=file_name,action="write",status="replace") ! assign number.dat to file_name using write statement ! test program to open n files and write data The result, stringbeans, may be assigned to a character variable.Ī useful example of concatenation is given in the following program. For example, the concatenation of the character constants string and beans is written as The only instrinsic operator for character expressions is the concatenation operator //. Volume = (2**d)*volume ! only considered positive octant Real (kind = double) :: sum_series, newterm, relative_changeĬall integrate(lower_r2 + x**2, remaining_d - 1) ! illustrate use of kind parameter and named do loop The following program illustrates the use of a kind parameter and a named do construct: Real :: sum_series, newterm, relative_change In the next program example, the do loop is exited by satisfying a test. Also note that exponentiation is done using the operator **. The block of statements inside a loop is indented for clarity.īecause the product n*n is done using integer arithmetic, it is better to convert n to a real variable before the multiplication is done. In this case the do statement specifies the first and last values of n n increases by unity (default).
#True basic programming language series#
! add the first 100 terms of a simple series Note the use of the (unformatted) read statement and how character strings are printed.į uses a do construct to have the computer execute the same statements more than once. We next introduce syntax that allows us to enter the desired values of m and a from the keyboard. The asterisk (*) following print is the default format. Statements are written on lines which may contain up to 132 characters. Some names such as product are reserved and cannot be used as names.Ĭomments begin with a ! and can be included anywhere in the program. All keywords (words that are part of the language and cannot be redefined.) are written in lower case. The case is significant, but two names that differ only in the case of one or more letters cannot be used together. Real numbers are written as 2.0 rather than 2. The types of all variables must be declared. The names of all variables must be between 1 and 31 alphanumeric characters of which the first must be a letter and the last must not be an underscore. Integer numerical variables and floating point numerical variables are distinguished. The first statement must be a program statement the last statement must have a corresponding end program statement. The features of F included in the above program include: Program product in Chapter 2 of Gould and Tobochnik. We first give an example of an F program. In the following, we will assume that the reader is familiar with a programming language such as True BASIC.

Instructions for running F on Unix workstations and on the Power Macintosh are available. F is a subset of Fortran 90 that includes only its modern features, is compact, and is easy to learn. Some of the most important features of Fortran 90 include recursive subroutines, dynamic storage allocation and pointers, user defined data structures, modules, and the ability to manipulate entire arrays.įortran 90 is compatible with Fortran 77 and includes syntax that is no longer considered desirable. The latest standard, Fortran 90, includes extensions that are familiar to users of C. Fortran (FORmula TRANslation) was introduced in 1957 and remains the language of choice for most scientific programming.
