# The PARAMETER Attribute

In many places, one just wants to assign a name to a particular value. For example, keep typing 3.1415926 is tedious. In this case, one could assign a name, say PI, to 3.1415926 so that one could use PI rather than 3.1415926. To assign a name to a value, one should do the following:
• Add PARAMETER in front of the double colon (::) and use a comma to separate the type name (i.e., REAL) and the word PARAMETER
• Following each name, one should add an equal sign (=) followed by an expression. The value of this expression is then assigned the indicated name.
• After assigning a name to a value, one can use the name, rather than its value throughout the program. The compiler would convert that name to its corresponding value.
• It is important to note that the name assigned to a value is simply an alias of the value. Therefore, that name is not a variable.
• After assigning a name to a value, that name can be used in a program, even in subsequent type statements.

### Examples:

• In the example blow, Limit is a name for the integer value 30, while Max_Count is a name for the integer value 100:
```INTEGER, PARAMETER :: Limit = 30, Max_Count = 100
```
• In the example below, E is a name for the real value 2.71828, while PI is a name for the real value 3.141592:
```REAL, PARAMETER :: E = 2.71828, PI = 3.141592
```
• In the example below, Total and Count are names for 10 and 5, respectively. The name, Sum, is defined to be the product of the values of Total and Count and hence Sum is the name for the value 50(=10*5).
```INTEGER, PARAMETER :: Total = 10, Count = 5, Sum = Total*Count
```
• In the example below, Name is a name for the string 'John' and State is a name for the string "Utah"
```CHARACTER(LEN=4), PARAMETER :: Name = 'John', State = "Utah"
```
It is important to know when assigning a name to a string:
• If the string is longer, truncation to the right will happen. In the following case, since the length of the string "Smith" is 5 while the length of Name is 4, the string is truncated to the right and the content of Name is "Smit"
```CHARACTER(LEN=4), PARAMETER :: Name = 'Smith'
```
• If the string is shorter, spaces will be added to the right. Since the string "LA" is of length 2 while the name City is of length 4, two spaces will be padded to the right and the content of City becomes "LA "
```CHARACTER(LEN=4), PARAMETER :: City = "LA"
```
• This is where the assumed length specifier comes in. That is, Fortran allows the length of character name to be determined by the length of s string. In the example below, names Name and City are declared to have assumed length. Since the lengths of 'John' and "LA" are 4 and 2, the length of the names Name and City are 4 and 2, respectively.
```CHARACTER(LEN=*), PARAMETER :: Name = 'John', City = "LA"
```