The Queen's University of Belfast

Parallel Computer Centre
[Next] [Previous] [Top]
Fortran 90 offers over one hundred intrinsic procedures, all of which can be referenced using keyword arguments and many having optional arguments. Intrinsic functions that can only be used with one data type have now been superseded by generic versions.
The intrinsic procedures fall into four distinct categories:
- Elemental procedures
These are specified for scalar arguments, but are also applicable to conforming array arguments applying the procedure element by element.
- Inquiry functions
Inquiry functions return properties of principal arguments that do not depend upon their values.
- Transformational functions
These functions usually have array arguments and an array result whose elements depend on many of the elements in the array.
- Nonelemental Subroutines
The new intrinsic features provided by Fortran are described briefly in this chapter, divided into the four categories given above.
7.1 Elemental Procedures
Numeric
- CEILING(A)
Smallest integer not less than A.
-
- FLOOR(A)
Largest integer not exceeding A.
-
-
- MODULO(A,P)
A modulo P for A and P both real or both integer.
Character
- ACHAR(I)
Character in position I of ASCII collating sequence.
-
- ADJUSTL(STRING)
Adjust left, change leading blanks into trailing blanks.
-
- ADJUSTR(STRING)
Adjust right, change trailing blanks into leading blanks.
-
- IACHAR(C)
Position of character C in ASCII collating sequence.
-
- INDEX(STRING,SUBSTRING[,BACK])
Starting position of SUBSTRING within STRING. If more than one SUBSTRING than position of first (or last if BACK true) is returned.
-
- LEN_TRIM(STRING)
Length of STRING without trailing blanks.
-
- SCAN(STRING,SET[,BACK])
Index of left-most (right-most if BACK true) character nof string that belongs to SET; zero if none belong.
-
- VERIFY(STRING,SET[,BACK])
The position of left-most (or right-most if BACK true) character of STRING that is not in SET. Zero if each character of STRING appears in SET.
-
Bit Manipulation
- BTEST(I,POS)
True if bit POS of integer I has value 1.
-
- IAND(I,J)
Logical AND on all corresponding bits of I and J.
-
- IBCLR(I,POS)
Bit POS of I cleared to zero.
-
- IBITS(I,POS,LEN)
Extract sequence of LEN bits of I starting from bit POS.
-
- IBSET(I,POS)
Bit POS of I set to 1.
-
- IEOR(I,J)
Logical exclusive OR on all corresponding bits of I and J.
-
- IOR(I,J)
Logical inclusive OR on all corresponding bits of I and J.
-
- ISHFT(I,SHIFT)
Value of I with bits shifted SHIFT places to left (right if negative) and zeros shifted in from other end.
-
- ISHFTC(I,SHIFT[,SIZE])
Value of I with circular shift of SIZE right-most bits SHIFT places to the left (right if negative).
-
- NOT(I)
Logical complement of all bits of I.
-
Kind
- SELECTED_INT_KIND(R)
Kind of type parameter for specified exponent range. -1 returned if no such kind is available.
-
- SELECTED_REAL_KIND(P,R)
Kind of type parameter for specified precision and exponent range. -1 returned is precision is unavailable, -2 if range is unavailable and -3 if neither are available.
-
Floating Point Manipulation
- EXPONENT(X)
Exponent part of the model for X.
-
- FRACTION(X)
Fractional part of the model for X.
-
- NEAREST(X,S)
Nearest different machine number in the direction given by the sign of S
-
- RRSPACING(X)
Reciprocal of relative spacing of the model numbers near X.
-
- SCALE(X I)
X2I (real)
-
- SET_EXPONENT(X,I)
Real whose sign and fractional part are those of X, and whose exponent part is I.
-
- SPACING(X)
Absolute spacing of model numbers near X.
-
Logical
- LOGICAL(L[,KIND])
Converts between kinds of logical numbers.
-
- CALL MVBITS(FROM,FROMPOS,LEN,TO,TOPOS)
Copy LEN bits of FROM starting at position FROMPOS to TO, starting at position TOPOS.
-
- ASSOCIATED(POINTER[,TARGET])
True if pointer associated with a target. If target present, then true only if associated with specified target.
-
- BIT_SIZE(I)
Maximum number of bits that may be held in an integer.
-
- KIND(X)
Kind type parameter for X.
-
- PRESENT(A)
True if optional argument A is present.
-
Numeric
- DIGITS(X)
Number of significant digits in the model for X.
-
- EPSILON(X)
Number that is almost negligible compared with 1 in the for numbers like X.
-
- HUGE(X)
Largest number in the model for numbers like X.
-
- MAXEXPONENT(X)
Maximum exponent in the model for numbers like X.
-
- MINEXPONENT(X)
Minimum exponent in the model for numbers like X.
-
- PRECISION(X)
Decimal precision in the model for X.
-
- RADIX(X)
Base of the model for numbers like X.
-
- RANGE(X)
Decimal exponent range in the model that includes integer, real and complex X.
-
- TINY(X)
Smallest positive number in the model for numbers like X.
-
- REPEAT(STRING,NCOPIES)
Concatenates NCOPIES of STRING.
-
- TRANSFER(SOURCE,MOLD[,SIZE])
Same physical representation as SOURCE, but of type MOLD.
-
- TRIM(STRING)
Removes trailing blanks form STRING.
-
- CALL DATE_AND_TIME([DATE][,TIME][,ZONE][VALUES])
Real-time clock reading date and time.
-
- RANDOM_NUMBER(HARVEST)
Random numbers in range
.
-
- RANDOM_SEED([SIZE][,PUT][,GET])
Initialize or restart random number generator.
-
- SYSTEM_CLOCK([COUNT][,COUNT_RATE][COUNT_MAX])
Integer data from real-time clock.
-
7.5 Array Intrinsic Procedures
Reduction
- ALL(MASK[,DIM])
True if all elements true
-
- ANY(MASK[,DIM])
True if any element true
-
- COUNT(MASK[,DIM])
Number of true elements
-
- MAXVAL(ARRAY[,DIM][,MASK])
Maximum element value
-
- MINVAL(ARRAY[,DIM][,MASK])
Minimum element value
-
- PRODUCT(ARRAY[,DIM][,MASK])
Product of array elements
-
- SUM(ARRAY[,DIM][,MASK])
Sum of array element
-
Inquiry
- ALLOCATED(ARRAY)
True if array allocated
-
- LBOUND(ARRAY[,DIM])
Lower bounds of array
-
- SHAPE(SOURCE)
Shape of array (or scalar)
-
- SIZE(ARRAY[,DIM])
Size of array
-
- UBOUND(ARRAY[,DIM])
Upper bounds of array
-
Construction
- MERGE(TSOURCE,FSOURCE,MASK)
Merge arrays subject to mask
-
- PACK(ARRAY,MASK[,VECTOR])
Pack elements into vector subject to mask
-
- SPREAD(SOURCE,DIM,NCOPIES)
Construct an array by duplicating an array section
-
- UNPACK(VECTOR,MASK,FIELD)
Unpack elements of vector subject to mask
-
Reshape
- RESHAPE(SOURCE,SHAPE[,PAD][,ORDER])
Reshape array
-
Array Location
- MAXLOC(ARRAY[,MASK])
Location of maximum element
-
- MINLOC(ARRAY[,MASK])
Location of minimum element
-
Array manipulation
- CSHIFT(ARRAY,SHIFT[,DIM])
Perform circular shift
-
- EOSHIFT(ARRAY,SHIFT[,BOUNDARY][,DIM])
Perform end-off shift
-
- TRANSPOSE(MATRIX)
Transpose matrix
-
Vector and matrix arithmetic
- DOT_PRODUCT(VECTOR_A,VECTOR_B)
Compute dot product
-
- MATMUL(MATRIX_A,MATRIX_B)
Matrix multiplication
-
7.6 Exercises
- Look at the programs char_int.f90, model.f90, mod_int.f90 and convert.f90 and run them.
Notice how these programs use instrinsic functions for certain purposes.
[Next] [Previous] [Top]
All documents are the responsibility of, and copyright, © their authors and do not represent the views of The Parallel Computer Centre, nor of The Queen's University of Belfast.
Maintained by Alan Rea, email A.Rea@qub.ac.uk
Generated with CERN WebMaker