Errors in very simple fortran program

b2850624

I am a fortran beginner and writing a very simple program, compiler GNU fortran.

program t1
implicit none
real :: a, b
a=35.4
CHARACTER (LEN=*) :: str = 'This is a test program'
REAL, PARAMETER :: pi = 3.14
WRITE (*,*) a
WRITE (*,*) str
WRITE (*,*) pi
end program

I got error Error: Unexpected data declaration statement at line 3

Error: Symbol 'a' has no IMPLICIT type line 4 and similar for line 8. I am not getting what is going wrong here. Can someone comment?

Vladimir F

Fortran has a strict order. First you declare your data, variables, types, interfaces and then you have your executable code, you cannot mix it. Use the order:

program t1

  implicit none

  real :: a, b
  CHARACTER (LEN=*), parameter :: str = 'This is a test program'
  REAL, PARAMETER :: pi = 3.14

  a=35.4

  WRITE (*,*) a
  WRITE (*,*) str
  WRITE (*,*) pi
end program

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Valgrind reports errors for a very simple C program

What errors did I make in this very simple program on SharpDevelop?

Confusing about a very simple program

Errors compiling very simple boost::spirit grammar

Very Strange Seg Fault on simple program

".then is not a function" from a very simple inquirer program

Segmentation fault (core dumped) (very simple program)

Spring ignoring @Qualifier in very simple program

Error using OCCURS in a very simple COBOL program

Very simple practice program won't compile

C + JNI Fails to execute a very simple program

Lightweight release of a very simple Qt program

A very simple program based on YOUTUBE-DL

Very Simple Program Crashing Python 3.5 and spyder

Simple c++ program gets compilation errors

Fortran program producing different errors with the same input parameters

Trying to write a very simple program involving a password (java)

simple smack jabber program taking very long to connect on android

Memory leak detected in a very simple program. What to do?

Seems very hard to find out the time complexity of this simple program

Simple program but so very stuck- Loops in Ruby

very simple program to draw a filled rectangle .. why it does not work ?

Very very Simple Application

Very simple Fortran code produces error when compiled with gfortran + fpe trap flags

Why is my simple C++ program giving me errors.

"PROCEDURE attribute conflicts with INTENT attribute" when compiling simple Fortran program with module

C# Async Await, refactored a very simple exercise program but gave different behavior

I am trying to make a very simple program that converts decimal to binaries but I need to write them reversed

How to make a very simple user-interface program to open 2 files on click