Gfortran Syntax Error Data Declaration
Contents |
filtered due to spam. Bug24337 - Syntax error in data declaration Summary: Syntax error in data declaration Status:
Unexpected Data Declaration Statement At 1 Fortran
RESOLVED INVALID Alias: None Product: gcc Classification: Unclassified Component: fortran (show unterminated character constant other bugs) Version: 4.1.0 Importance: P2 normal Target Milestone: --- Assignee: Not yet assigned to anyone URL: Keywords:
Syntax Error In Argument List Fortran
Depends on: Blocks: Reported: 2005-10-12 19:05 UTC by Uttam Pawar Modified: 2005-10-12 20:41 UTC (History) CC List: 1 user (show) gcc-bugs See Also: Host: powerpc64_linux Target: powerpc64_linux Build: syntax error in data declaration at (1) powerpc64_linux Known to work: Known to fail: Last reconfirmed: Attachments Add an attachment (proposed patch, testcase, etc.) Note You need to log in before you can comment on or make changes to this bug. Description Uttam Pawar 2005-10-12 19:05:26 UTC $ cat vartest.f90 program test_name integer _var end program $ gfortran -c vartest.f90 In file names.f90:2 integer _var 1 fortran unterminated character constant Error: Syntax error in data declaration at (1) as per the standard, R301 character is alphanumeric character or special character R302 alphanumeric character is letter or digit or inderscore $ gfortran -v Using built-in specs. Target: powerpc64-linux Configured with: /home/gccbuild/gcc_mline_anoncvs/gcc/configure --prefix=/opt/gcc-nightly/mline-20051011 --build=powerpc64-linux --host=powerpc64-linux --target=powerpc64-linux --with-cpu=default32 --with-as=/opt/gcc-nightly/mline-20051011/bin/as --with-ld=/opt/gcc-nightly/mline-20051011/bin/ld --enable-threads=posix --enable-shared --enable-__cxa_atexit --enable-languages=c,c++,f95,java,objc,obj-c++ --enable-checking --with-mpfr=/opt/gcc-nightly/mline-20051011 Thread model: posix gcc version 4.1.0 20051010 (experimental) Comment 1 kargl 2005-10-12 20:41:33 UTC The final committe draft of the Fortran 95 standard (and the final coimmitte draft of Fortran 2003 is essentially the same) has 3.2.1 Names Names are used for various entities such as variables, program units, dummy arguments, named constants, and derived types. R304 name is letter [ alphanumeric-character ] ... Constraint: The maximum length of a name is 31 characters. letter is defined in 3.1.1 gfortran is doing the right thing. I submitted your code the Lahey's conformance checking utility and it claims Compiling program unit test_name at line 1: 1641-S: "SOURCE.F90", line 2, column 15: The first character of name '_var' must not be _. 1110-S: "SOURCE.F9
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and
Fortran Line Continuation
policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24337 a minute: Sign up Unexpected data declaration error in Fortran when creating array up vote 2 down vote favorite 1 I've written a simple test program to demonstrate a data declaration error that I am receiving when compiling some Fortran code. The compile error occurs on a line where I am trying to create an array of arbitrary size. In C http://stackoverflow.com/questions/13630254/unexpected-data-declaration-error-in-fortran-when-creating-array code, I believe that this would be accomplished with a simple malloc, but this type of methodology may not be useful in Fortran. What is going wrong here, and how might I fix it? I am using the gfortran compiler on GNU/Linux, so I think that it would be possible to use all of the supported language features. Here is my test program: program test implicit none integer num1, num2 print *, 'Starting...' num1 = 10 num2 = 11 call sub(num1, num2) print *, 'Done.' end program subroutine sub(num1, num2) integer num1, num2 integer num3 num3 = num1 + num2 - 1 integer A(num3) do i = 1,num3 A(i) = i end do print *, 'Now printing out vector' do i = 1,num3 print *, A(i) end do end subroutine Here is the cmake script being used to compile my simple test program: cmake_minimum_required (VERSION 2.6) project (test Fortran) add_executable( test test.f90 ) # end When compiling this program, I receive the following error: /media/RESEARCH/SAS2-version2/test-Q-filter/test-Fcreation/test.f90:20.16: integer A(num3) 1 Error: Unexpected data declaration statement at (1) /media/RESEARCH/SAS2-version2/test-Q-filter/test-Fcreation/test.f90:23.10: A(i) = i 1 Error: Unexpected
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of http://stackoverflow.com/questions/29355067/syntax-error-in-data-statement this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up syntax error Syntax error in DATA statement up vote 0 down vote favorite I have this code in a Fortran project: ITEGER IV, IY DIMENSION IV(NTAB,IDEPTH) DIMENSION IY(IDEPTH) DATA IV,IY /(IDEPTH*NTAB)*0,IDEPTH*0)/ Attempting to compile the project generates this error: DATA IV,IY /(IDEPTH*NTAB)*0,IDEPTH*0)/ 1 Syntax error in DATA statement at (1). This worked under f77/g77 (gcc 4.1), but a recent upgrade has moved us to gcc unterminated character constant 4.4 and gfortran. Now this code is causing errors but I just can't see the problem. fortran gfortran fortran77 g77 share|improve this question edited Mar 30 '15 at 20:14 Alexander Vogt 13.1k122448 asked Mar 30 '15 at 19:54 brightwellcd 4216 There are multiple typos in your code... Please fix them! –Alexander Vogt Mar 30 '15 at 20:10 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote accepted My guess is that this was an extension to the Standard, which is not supported any more. The FORTRAN 77 Standard, ch. 9.1 states that the repeat value shall be a nonzero, unsigned, integer constant or the symbolic name of such a constant. As such, the IDEPTH*NTAB is not allowed as repeat value. You can circumvent this by using another constant that constitutes the product: PROGRAM test INTEGER IV, IY INTEGER,PARAMETER :: NTAB=1,IDEPTH=1 INTEGER,PARAMETER :: PROD=NTAB*IDEPTH DIMENSION IV(NTAB,IDEPTH) DIMENSION IY(IDEPTH) DATA IV,IY /PROD*0,IDEPTH*0/ END Or, to make it strictly FORTRAN 77 compliant: PROGRAM test INTEGER IV, IY INTEGER NTAB,IDEPTH INTEGER PROD PARAMETER (NTAB=1,IDEPTH=1) PARAMETER (PROD=NTAB*IDEPTH) DIMENSION IV(NTAB,IDEPTH) DIMENSION IY(IDEPTH) DATA IV,IY /PROD*0,IDEPTH*0/ END