[MAP Logo]

Materials Algorithms Project
Program Library



Subroutine MAP_UTIL_BOUND

  1. Provenance of code.
  2. Purpose of code.
  3. Specification.
  4. Description of subroutine's operation.
  5. References.
  6. Parameter descriptions.
  7. Error indicators.
  8. Accuracy estimate.
  9. Any additional information.
  10. Example of code
  11. Auxiliary subroutines required.
  12. Keywords.
  13. Download source code.
  14. Links.

Provenance of Source Code

N.A. Chester,
Phase Transformations Group,
Department of Materials Science and Metallurgy,
University of Cambridge,
Cambridge, U.K.

Added to MAP: July 1999.

Top | Next

Purpose

To write an error message indicating a variable lies outside the specified limits and to read in a new value.

Top | Next | Prev

Specification

Language:FORTRAN
Product form:Source code

SUBROUTINE MAP_UTIL_BOUND(A,B,C)

DOUBLE PRECISION A,B,C

Top | Next | Prev

Description

The subroutine prints out a statement to say that the value of the input variable does not lie within a specified range. It then prints out the values of the upper and lower limits and requests and reads in a new value for the variable. This process is repeated until a value has been obtained which does lie within the specified range.

Top | Next | Prev

References

None.

Top | Next | Prev

Parameters

Input parameters

A - real
A is the value of the input variable.

B - real
B is the lower limit of the range of allowed values for A.

C - real
C is the upper limit of the range of allowed values for A.

Output parameters

A - real
A is a new value for the input variable which does lie within the specified range.

Top | Next | Prev

Error Indicators

This subroutine calls MAP_UTIL_REED which uses the FORTRAN ERR specifier to detect an incorrect input data value.

Top | Next | Prev

Accuracy

Not applicable.

Top | Next | Prev

Further Comments

None.

Top | Next | Prev

Example

1. Program text

      DOUBLE PRECISION T,RLOW,RHIGH
      RLOW  = 0.0D0
      RHIGH = 100.0D0
      T = 25.0D0
      WRITE(*,*)'Input value for water temperature (deg. C):'
      READ (*,*) T 
      IF (T.LT.RLOW.OR.T.GT.RHIGH) CALL MAP_UTIL_BOUND(T,RLOW,RHIGH)
      T = T + 273.15
      WRITE(*,1) T
      STOP
    1 FORMAT('The water temperature is ',F7.2,' Kelvin.')
      END

2. Program data

 Input value for water temperature (deg. C):
-10
             Input value out of bounds
             The limits are   0.0000D+00 to   0.1000D+03

Input new value:
10

3. Program results

The water temperature is  283.15 Kelvin.

Top | Next | Prev

Auxiliary Routines

Subroutines
MAP_UTIL_REED

Top | Next | Prev

Keywords

input, range, limits, error, real

Top | Next | Prev

Download

Download source code

Top | Prev


MAP originated from a joint project of the National Physical Laboratory and the University of Cambridge.

MAP Website administration / map@msm.cam.ac.uk

Top | Index | MAP Homepage Valid HTML 3.2!