[UP]


Manual Reference Pages  - fortran_name (3)

NAME

fortran_name(3f) - [M_strings:COMPARE] test if string meets criteria for being a fortran name

CONTENTS

Synopsis
Description
Options
Returns
Example

SYNOPSIS

elemental function fortran_name(line) result ((lout))

     character(len=*),intent(in)  :: line
     logical                      :: lout

DESCRIPTION

Determines if a string is an allowed Fortran name. To pass the input string must be composed of 1 to 63 ASCII characters and start with a letter and be composed entirely of alphanumeric characters [a-zA-Z0-9] and underscores.

OPTIONS

LINE input string to test. Leading spaces are significant but trailing spaces are ignored.

RETURNS

LOUT a logical value indicating if the input string passed or failed the test to see if it is a valid Fortran name or not.

EXAMPLE

Sample program

     program demo_fortran_name
     use M_strings, only : fortran_name
     implicit none
     character(len=*),parameter :: names(*)=[character(len=20) ::  &
      & ’_name’,         ’long_variable_name’, ’name_’,         &
      & ’12L’,           ’a__b__c  ’,          ’PropertyOfGas’, &
      & ’3%3’,           ’$NAME’,              ’ ’,             &
      & ’Variable-name’, ’A’,                  ’x@x’ ]
     integer :: i
        write(*,’(i3,1x,a20,1x,l1)’)&
        & (i,names(i),fortran_name(names(i)),i=1,size(names))
     end program demo_fortran_name

Results:
1 _name
2 long_variable_name
3 name_
4 12L
5 a__b__c
6 PropertyOfGas
7 3%3
8 $NAME
9
 
10 Variable-name
 
11 A
12 x@x


fortran_name (3) March 11, 2021
Generated by manServer 1.08 from ab90307d-3b6a-43ae-a097-9d66aa9e6dd8 using man macros.