Skip to main content
  1. About
  2. For Teams
Asked
Viewed 684 times
3

I am writing a Fortran program in which one line is written like this

open(unit=un1,file=filenm,form='unformatted',buffered='yes',status='replace',buffercount=127)

I have defined

character*256 filenm.
un1=11

but still I am getting error

"Syntax error at or near =" in that line..
1
  • 2
    Just as a note, character*256 is outdated. You should use character(len=256) :: filename
    Stefano Borini
    –  Stefano Borini
    2011-10-19 11:42:07 +00:00
    Commented Oct 19, 2011 at 11:42

1 Answer 1

5

The problem lies in the buffered='yes', which is not standard Fortran, but some vendor extension and your compiler does not recognize it. I would just delete it and also delete the buffercount=127 (mentioned in the comment).

Modern compilers and operating systems allow control of these things (external I/O buffering) by other means. For example, using environment variables in gfortran https://gcc.gnu.org/onlinedocs/gfortran/Runtime.html#Runtime

Sign up to request clarification or add additional context in comments.

5 Comments

thanks.. i deleted buffered='yes' as well as buffercount=127 also,so that error is gone but new error "Derived type has not been declared - t_openfilename" has come in line type(T_OPENFILENAME) ofn
Re your error message about the derived type t_openfilename not declared. With just the source code line that causes the error we can only guess. You need to declare that type before it is used. Why is it missing? Are you missing a file that defines it?
thanks for reply.......actually i am from electrical background..i am trying to learn fortran for my project....please tell me any good reference from which i will get the knowledge of "type command"
@user991852 : important, very important: learn Fortran 95, and the distinction between old F77 constructs and new ones. Don't use old constructs. Learn to read them (if you have old code to understand) but don't use them. In particular, never use commons, namelists, or code outside modules. Always use implicit none, and specification of intent in the routine arguments.
References: I recommend the book "Fortran 95/2003 Explained" by Metcalf, Reid and Cohen. For an overview, but probably too brief to learn from: en.wikipedia.org/wiki/Fortran_95_language_features

Your Answer

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.