Help with Fortran 77 - File Opening Questions

  • Context: Fortran 
  • Thread starter Thread starter Bruno Solheid
  • Start date Start date
  • Tags Tags
    Fortran
Click For Summary
SUMMARY

This discussion focuses on file opening techniques in Fortran 77, specifically addressing file paths and status options. Users are instructed to use the 'open' statement with appropriate syntax for both Windows and Unix/Linux systems. The status options available include 'new', 'old', and 'unknown', which dictate how the file is treated upon opening. Example code snippets demonstrate the correct usage of file paths and reading/writing data.

PREREQUISITES
  • Understanding Fortran 77 syntax and structure
  • Familiarity with file handling concepts in programming
  • Knowledge of operating system file path conventions (Windows vs. Unix/Linux)
  • Basic experience with reading and writing data in programming languages
NEXT STEPS
  • Explore Fortran 77 file I/O operations in detail
  • Learn about error handling in Fortran 77 file operations
  • Investigate the differences between Fortran 77 and modern Fortran standards
  • Study best practices for managing file paths in cross-platform applications
USEFUL FOR

This discussion is beneficial for Fortran developers, students learning file handling in Fortran 77, and programmers transitioning from other languages who need to understand file operations in Fortran.

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
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 8 ·
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 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K