ERROR: NUMERIC CONSTANT REQUIRED AT THE DATA STATMENT

50 views
Skip to first unread message

Yasin Worke Mohammed

unread,
Jul 9, 2018, 8:53:21 AM7/9/18
to gg95
Dear All,

I tried to compile a fortran program attached here with. I could not understand my problem in detecting the error stated as

Numerical Constant required in the data  statement. what I want the subroutine Name to do  was to pass seven files to the main program . the first file is an input file to read from and the other files are file names the program supposed to write the outputs. so can any one help me.

I tried to compile using the free software g95_mingw  available on the internet.
my machines  OS is windows 8. 

thanks
NAME.f95

Robert Funnell

unread,
Jul 9, 2018, 9:46:58 AM7/9/18
to Yasin Worke Mohammed, gg95
Maybe because your o1, o2 etc. aren't declared as Character?

ziggy76

unread,
Jul 9, 2018, 11:59:45 AM7/9/18
to gg95
Hello,

If you don't explicitely declare your variables, Fortran gives an implicit type. For a variable with an identifier begining with the letter 'o' it is REAL*4.
So, just add
CHARACTER*4 o1, o2, o3, o4, o5, o6, o7
 and it will compile.
I advise you to add the IMPLICIT NONE statement at the beginning of your subroutine to avoid this type of problem.

If you are beginning a new project, you should use the more modern syntax of fortran :
CHARACTER(LEN=7) :: FILE1
REAL(KIND=4) :: x


Regards.

Yasin Worke Mohammed

unread,
Jul 11, 2018, 7:30:18 AM7/11/18
to gg...@googlegroups.com
Thank you for your assistance it works

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "gg95" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gg95+uns...@googlegroups.com.
To post to this group, send email to gg...@googlegroups.com.
Visit this group at https://groups.google.com/group/gg95.
For more options, visit https://groups.google.com/d/optout.

Yasin Worke Mohammed

unread,
Jul 11, 2018, 7:30:18 AM7/11/18
to gg...@googlegroups.com
Thanks for your assistance and detailed advice. It works

Regards 
Yasin Worke


Sent from my iPhone

On Jul 9, 2018, at 6:59 PM, ziggy76 <meu...@coria.fr> wrote:

jfh

unread,
Jul 11, 2018, 10:27:41 PM7/11/18
to gg95
And you can get bitten by REAL(KIND=4) :: x because some compilers don't have a real kind called 4. Those that do usually mean 4 bytes, which is often default real aka single precision. You can get that portably with REAL(KIND(1.0)):: x; REAL(KIND(1D0)) would give double precision. Even better in most people's opinion is to use an integer parameter and selected_real_kind to get at least a requested number of significant digits, e.g.

INTEGER,PARAMETER :: SP=selected_real_kind(6), DP=selected_real_kind(15)
REAL(SP) :: x
REAL(DP) :: y     
Reply all
Reply to author
Forward
0 new messages