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

FOR_READ and FOR_PRINT

kompute
Beginner
745 Views
Can anyone illustrate how to read and write to a file in another directory instead of the current one using FOR_READ and FOR_PRINT?
0 Kudos
6 Replies
Steven_L_Intel1
Employee
745 Views
Wouldn't it be simpler to OPEN the desired file and specify the unit number you opened in READ and WRITE statements?
0 Kudos
kompute
Beginner
745 Views

I have tried using the following statement but the iostat is 29 which seems to be a file not found error.

open (unit=101,file='C: est est',form='BINARY',
+ status='REPLACE',iostat=ret)

The executable is in directory C: est2 est3 est4.

0 Kudos
Steven_L_Intel1
Employee
745 Views
Take out the iostat and what error gets displayed. Does this file not have a file type? Is C: est est a directory? If so you need a full file specification.
0 Kudos
kompute
Beginner
745 Views

With the iostat removed and C: est est.txt (is a full file specification) for clearer illustration. The following errors are displayed:

=================================================

C:Fortran CompilerIntel Visual FortranV9SamplesConsole1Debug>Console1
forrtl: severe (29): file not found, unit 101, file C: est est.txt
Image PC Routine Line Source
Console1.exe 00451F32 Unknown Unknown Unknown
Console1.exe 0044F1C8 Unknown Unknown Unknown
Console1.exe 00407C3A Unknown Unknown Unknown
Console1.exe 00407867 Unknown Unknown Unknown
Console1.exe 004018E1 Unknown Unknown Unknown
Console1.exe 0040107B _MAIN__ 21 Console1.f90
Console1.exe 004585C0 Unknown Unknown Unknown
Console1.exe 00439F60 Unknown Unknown Unknown
kernel32.dll 7C816FD7 Unknown Unknown Unknown

=================================================

Probably theenvironment is not pathed to the correct directory.

0 Kudos
Steven_L_Intel1
Employee
745 Views
The environment isn't relevant here. You will get this error if the directory C: est does not exist.
0 Kudos
kompute
Beginner
745 Views
oops... my error. Thanks for your help.
0 Kudos
Reply