- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hello,
I normally use microsoft visual studio on Microsoft. However, I will have to use xcode on mac osx from now on. I am not able to read data from a .dat file. I normally use the following code:
filename='input.dat'
write(*,1000) filename
1000 format(' ','The input file name is: ',A)
open(unit=3, file=filename, status='old', action='read',&
iostat=status)
if(status.eq.0) then
do
read(3,'(F25.16)',iostat=st1) TolSSSA
if (st1.eq.0) exit
end do
When I use the code above, it gives me the following error:
Error opening file: IOSTAT = 29
I don't think .dat files are compatible with MAC. What should I use then? I have so much data in the input file. It might be difficult to read it all if I change the extension of my input file.
Thank you,
Emre
링크가 복사됨
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
IOSTAT 29 is "file not found". Make sure input.dat is in your current working directory or specify a full path name in your open() call. You may also be running into case sensitivity issues you wouldnt see in windows. Make sure the file is actually called "input.dat" and not "Input.dat" or "INPUT.DAT" or some other mixed-case name.
By the way, the extension ".dat" has no bearing on the contents of the file and changing that will not have an effect (aside from making sure the correct filename is listed in code). The only compatibility issues with fortran data files would be endianness (you are using intel chips on both systems in question, so that is not the issue) and fortran record cruft (this would only be an issue reading the file with something other than fortran). You should not have a problem reading the file in OSX, just doublecheck your paths and name.
And since you ask for alternatives to fortran data files, if your data is scientific in nature you could look into formats like hdf5 or netcdf. Do note that while working with these files can be quite a bit more involved than standard fortran OPEN/READ/WRITE to work with initially, they are more flexible and can handle metadata. These formats are very well suited to gridded data (or n-dimensional arrays in general). The resulting files are portable across platform and language.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hello,
Thank you very much for your reply. Both my code File.f90 and the input file input.dat are in the same folder. I tried to simplify the problem and attached the file. This time, it doesn't give error but it never comes to the end of the file. It just doesn't let me attach the dat file.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Just above the "Start Upload" button, there is a list of accepted file extensions. Since .dat is not one of those, either add .txt to the file name or zip (or use tar -zcf {filename}.tgz {list of files} ) all the files together before uploading.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I am not sure what is the default folder in Xcode when running a program - try putting in the full path to the file as a start. Or you could as a test change the STATUS='OLD' to STATUS='UNKNOWN' and then use INQUIRE to find out what the full path is, giving you a clue as to where it put the file.
This has nothing to do with the data file itself.