Fortran Help with Fortran 77 - File Opening Questions

  • Thread starter Thread starter Bruno Solheid
  • Start date Start date
  • Tags Tags
    Fortran
Click For Summary
Opening files in Fortran 77 requires specifying the correct file path and status. The file should be located in the appropriate directory, which varies based on the operating system. For Windows, the file path uses backslashes (e.g., c:\proj\f77\testopen.dat), while Unix or Linux systems require slashes (e.g., /usr/myname/f77/test.dat). The file status can be set to 'new', 'old', or 'unknown', among other options. Example code demonstrates how to open a file, read data, and write to it, highlighting the importance of using the correct syntax for file operations in Fortran 77.
Bruno Solheid
Messages
1
Reaction score
0
Hi, I have some doubts about how to open files in fortran 77.
The file must to be inside some particular directory?
Sorry about my english.
 
Technology news on Phys.org
If you are using Windows, try the following code. If you are using Unix or Linux, change the back-slash to slash, and use the appropriate directory name, for example:
/usr/myname/f77/test.dat
The status could be 'new', 'old', 'unknown', and there are other options.

Code:
C      open(10, file='testopen.dat',status='unknown')
C      open(10, file='..\testopen.dat',status='unknown')
       open(10, file='c:\proj\f77\testopen.dat',status='unknown')
C      read(10,*)x
C      read(10,*)y
C      print *,x,y
C      rewind 10
      write(10,*)10.0
      write(10,*)12.0
      print *,10.0,12.0
      stop
      end
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
Replies
8
Views
2K
  • · Replies 17 ·
Replies
17
Views
7K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K