- Fortran Tutorial
- Fortran - Home
- Fortran - Overview
- Fortran - Environment Setup
- Fortran - Basic Syntax
- Fortran - Data Types
- Fortran - Variables
- Fortran - Constants
- Fortran - Operators
- Fortran - Decisions
- Fortran - Loops
- Fortran - Numbers
- Fortran - Characters
- Fortran - Strings
- Fortran - Arrays
- Fortran - Dynamic Arrays
- Fortran - Derived Data Types
- Fortran - Pointers
- Fortran - Basic Input Output
- Fortran - File Input Output
- Fortran - Procedures
- Fortran - Modules
- Fortran - Intrinsic Functions
- Fortran - Numeric Precision
- Fortran - Program Libraries
- Fortran - Programming Style
- Fortran - Debugging Program
- Fortran Resources
- Fortran - Quick Guide
- Fortran - Useful Resources
- Fortran - Discussion
Fortran - Location Functions
The following table describes the location functions:
Function | Description |
---|---|
maxloc(array, mask) | It returns the position of the greatest element in the array array, if mask is included only for those which fulfil the conditions in mask, position is returned and the result is an integer vector. |
minloc(array, mask) | It returns the position of the smallest element in the array array, if mask is included only for those which fulfil the conditions in mask, position is returned and the result is an integer vector. |
Example
The following example demonstrates the concept:
program arrayLocation implicit none real, dimension(1:6) :: a = (/ 21.0, 12.0,33.0, 24.0, 15.0, 16.0 /) Print *, maxloc(a) Print *, minloc(a) end program arrayLocation
When the above code is compiled and executed, it produces the following result:
3 2
fortran_arrays.htm
Advertisements