Author Topic: Syntax errors in gfortran  (Read 240 times)

Offline awa5114

  • Single posting newcomer
  • *
  • Posts: 3
Syntax errors in gfortran
« on: November 23, 2017, 08:02:32 pm »
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

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5991
    • My Best Post
Re: Syntax errors in gfortran
« Reply #1 on: November 23, 2017, 08:28:42 pm »
Post a full re-build log on this site or a site that supports the compiler you are using.

http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline awa5114

  • Single posting newcomer
  • *
  • Posts: 3
Re: Syntax errors in gfortran
« Reply #2 on: November 23, 2017, 08:40:17 pm »
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))
 

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5991
    • My Best Post
Re: Syntax errors in gfortran
« Reply #3 on: November 24, 2017, 01:36:27 am »
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.
« Last Edit: November 24, 2017, 02:27:33 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline grem

  • Single posting newcomer
  • *
  • Posts: 1
Re: Syntax errors in gfortran
« Reply #4 on: November 28, 2017, 02:34:40 pm »
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
« Last Edit: November 28, 2017, 02:57:34 pm by grem »