News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Syntax errors in gfortran

Started by awa5114, November 23, 2017, 08:02:32 PM

Previous topic - Next topic

awa5114

I have this function

   logical function IsDelimiter(c) result(res)
        implicit none
        character, intent(in):: c

        res =     c == ' ' &
             .or. c == ',' &
             .or. c == '(' &
             .or. c == ')' &
             .or. c == '[' &
             .or. c == ']' &
             .or. c == '{' &
             .or. c == '}' &
             .or. c == '''' &
             .or. c == '"' &
             .or. c == ';' &
             .or. c == ':'

        end function IsDelimiter

Using ifort it compiles fine. Using CB I have errors:

||=== Build: Debug in Project (compiler: GNU Fortran Compiler) ===|
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for|467|Error: Unclassifiable statement  |
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for|468|Error: Invalid character in name  |
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for|469|Error: Invalid character in name  |
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for|470|Error: Invalid character in name  |
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for|471|Error: Invalid character in name  |
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for|472|Error: Invalid character in name  |
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for|473|Error: Invalid character in name  |
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for|474|Error: Invalid character in name  |
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for|475|Error: Invalid character in name  |
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for|476|Error: Invalid character in name  |
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for|477|Error: Invalid character in name  |
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for|478|Error: Invalid character in name  |
||=== Build failed: 12 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|


How can I get this to compile with no errors? I don't want to change the code since I have dozens of other files that use the same syntax. Is there an additional build option or something I can use to make this go away?

Thanks

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

awa5114

Here's the full log... I suspect it has something to do with line continuation or ampersand


-------------- Clean: Debug in Project (compiler: GNU Fortran Compiler)---------------

Cleaned "Project - Debug"

-------------- Build: Debug in Project (compiler: GNU Fortran Compiler)---------------

mingw32-gfortran.exe -Jobj\Debug\ -ffree-line-length-none -ffixed-line-length-none -Wall  -g     -c D:\TEMP\TRUNK-MINGW\ALL_CB\String.for -o obj\Debug\String.o
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for:467.8:
        res =     c == ' ' &
        1
Error: Unclassifiable statement at (1)
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for:468.14:
             .or. c == ',' &
              1
Error: Invalid character in name at (1)
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for:469.14:
             .or. c == '(' &
              1
Error: Invalid character in name at (1)
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for:470.14:
             .or. c == ')' &
              1
Error: Invalid character in name at (1)
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for:471.14:
             .or. c == '[' &
              1
Error: Invalid character in name at (1)
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for:472.14:
             .or. c == ']' &
              1
Error: Invalid character in name at (1)
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for:473.14:
             .or. c == '{' &
              1
Error: Invalid character in name at (1)
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for:474.14:
             .or. c == '}' &
              1
Error: Invalid character in name at (1)
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for:475.14:
             .or. c == '''' &
              1
Error: Invalid character in name at (1)
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for:476.14:
             .or. c == '"' &
              1
Error: Invalid character in name at (1)
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for:477.14:
             .or. c == ';' &
              1
Error: Invalid character in name at (1)
D:\TEMP\TRUNK-MINGW\ALL_CB\String.for:478.14:
             .or. c == ':'
              1
Error: Invalid character in name at (1)
Process terminated with status 1 (0 minute(s), 0 second(s))
12 error(s), 0 warning(s) (0 minute(s), 0 second(s))


stahta01

#3
I think you need to find a FORTRAN support site.
Edit: Or as I suggested before a support site for your FORTRAN compiler.

The "build log" gave me no information to help you; maybe someone else can see a problem.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

grem

#4
Hello.

You use ".for" fortran-extension for you files, so gfortran (CodeBlocks "default" fortran compiller) suppose it has fixed syntax format.

To avoid this default behaviour you could add "-ffree-form" compiller flag for your project
(menu "Project" - "Build Options" - "Compiler settings" - "Other compiller options")
otherwise all files with ".for" extension must use fixed syntax form with keeping appropriate rules of positioning symbols.

E.g. symbols of line continuation "&" must be placed in 6th position
and positions 1-5 of line must be used only for statement labels or stay blank.

See as reference (Fortran 77 Basics): https://web.stanford.edu/class/me200c/tutorial_77/03_basics.html