Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

.dat file in intel fortran

hay198
Beginner
1,804 Views

Hello evry mone; 
in my calculations i need to import some data enrigistred in .dat format ; but one i compile the prog it send a breack point : message ..= " model.exe has triggered a breakpoint. "
the employed instruction: 
open(unit = 8, file = "b_grid.dat", status = "old", action = "read", iostat = openstatus) read(8,*)
b_grid close(8)
So if i tel fortran to skip then any result can't be calculate.

01.jpg02.png please help me  to understand  and solve this problem
thank you

0 Kudos
1 Solution
mecej4
Honored Contributor III
1,710 Views

The IFPORT module provides the (nonstandard) function GETCWD, which can tell you the directory where your program is expecting to find the file that you wish to open for reading.

USE IFPORT
integer :: istat
character(100) :: myDir
...
istat = GETCWD(myDir)
if(istat == 0)print *,myDir
stop 

Once you ascertain the directory, you can place the data file there, or take other steps to reconcile the location of the file with the portion of your code that attempts to open it.

View solution in original post

5 Replies
JohnNichols
Valued Contributor III
1,792 Views

1. check file exists

2. check it is in the correct location 

3. better to use unknown so if you have it on the wrong place it creates one where it should be

4. use err statements in open to tell you actual errors 

hay198
Beginner
1,765 Views

thank you sir; 
i tried this issues but nothing has comming ; i think the problem is instaled in the link of files.  I copied and pasted in the same folder and before I imported the files via the import of visual studio but had the same problem.

0 Kudos
JohnNichols
Valued Contributor III
1,751 Views

1. find the fort.8 file that may have been opened 

2. the error is the files is not in the correct directory 

3. change open to unknown and it will open a blank file in the correct directory move yours there 

Arjen_Markus
Honored Contributor I
1,721 Views

Also note:

  • The extension ".dat" may have a meaning for you, but it ill have a different meaning for other people. There is only a very small number of extensions that are recognised by almost everyone to have a particular meaning. So, putting that extension in the title is pointless ;).
  • The error message is clear enough: your program cannot find the file. The advice by JohnNichols is sound - your program is likely running in a different directory than you think. The screenshot indicates you are running in Visual Studio or the like. Try setting the Debug  properties to control the start-up directory for your program. Also, the directory where it is starting now is indicated in the window with the stack trace.
mecej4
Honored Contributor III
1,711 Views

The IFPORT module provides the (nonstandard) function GETCWD, which can tell you the directory where your program is expecting to find the file that you wish to open for reading.

USE IFPORT
integer :: istat
character(100) :: myDir
...
istat = GETCWD(myDir)
if(istat == 0)print *,myDir
stop 

Once you ascertain the directory, you can place the data file there, or take other steps to reconcile the location of the file with the portion of your code that attempts to open it.

Reply