C Library Functions  - 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=20),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                F
     >  2 long_variable_name   T
     >  3 name_                T
     >  4 12L                  F
     >  5 a__b__c              T
     >  6 PropertyOfGas        T
     >  7 3%3                  F
     >  8 $NAME                F
     >  9                      F
     > 10 Variable-name        F
     > 11 A                    T
     > 12 x@x                  F


Nemo Release 3.1 fortran_name (3) July 22, 2023
Generated by manServer 1.08 from 37da6089-fd70-437d-b2c0-2182817dd8c6 using man macros.