public function StringReverse(string) result(rev)
Return a string that has all characters in reverse order
Arguments:
string String to be reversed
Result:
Reversed string
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
character(len=*)
|
|
|
|
:: |
string |
|
Return Value
character(len=LEN)
Variables
Type |
Visibility | Attributes |
|
Name |
| Initial | |
integer(kind=short),
|
public |
|
:: |
i |
|
|
|
integer(kind=short),
|
public |
|
:: |
length |
|
|
|
Source Code
FUNCTION StringReverse &
( string ) &
RESULT (rev)
IMPLICIT NONE
! Function arguments
! Scalar arguments with intent(in):
CHARACTER(LEN=*) :: string
! Local scalars:
CHARACTER(LEN=LEN(string)) :: rev
INTEGER (KIND = short) :: i
INTEGER (KIND = short) :: length
!------------end of declaration------------------------------------------------
length = LEN(string)
DO i = 1,length
rev(i:i) = string(length - i + 1 : length - i + 1)
END DO
END FUNCTION StringReverse