fortran_name(3f) - [M_strings:COMPARE] test if string meets criteria for being a fortran name (LICENSE:PD)
Synopsis
Description
Options
Returns
Examples
Author
License
elemental function fortran_name(line) result (lout)
character(len=*),intent(in) :: line logical :: lout
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.
LINE input string to test. Leading spaces are significant but trailing spaces are ignored.
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.
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_nameResults:
> 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
John S. Urban
Public Domain
Nemo Release 3.1 | fortran_name (3m_strings) | January 10, 2025 |