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

where to put input data file for reading input parameters?

Rasoul_K_
Beginner
11,255 Views

Sorry if this question is simple but I don't know where to find the answer.

I have put my input data in a file called ERAUL_4.DAT

I have following command in my code to read the data from it:

      DATA IRE /5/

      OPEN (5, FILE = 'ERAUL_4.DAT')
      OPEN (7, FILE = 'outdata4.txt')
      OPEN (8, FILE = 'VERPARAMET.TXT')

      WRITE(7,*)  '1'
      READ(IRE,11) JP(1),JP(2),JP(3),JP(5)                                    
      WRITE(7,211) JP(1),JP(2),JP(3),JP(5)                                     
      WRITE(8,11)  JP(1),JP(2),JP(3),JP(5)                                     
   11 FORMAT(4I5)                                                              
  211 FORMAT(4(I5,', '))

This is a fixed format code.

My project name is called: ConsoleApplication3

I put my input file in the same folder as my project foler (ConsoleApplication3)

Programs runs with no warning.

It seams that it doesn't read the input data becasue I can't get output file.

Am I missing somethiing here?

What is wrong with it?

0 Kudos
29 Replies
mecej4
Honored Contributor III
8,971 Views
Search for the output files by name using Windows Search. If the program ran without any error messages, it must have found the input file. You may have more than one copy of the input file. Input and output files are, by default, located in the current working directory. When you use an IDE such as Visual Studio, the concept of current working directory becomes a little nebulous.
0 Kudos
Rasoul_K_
Beginner
8,971 Views
Dear mecej4 Thanks for your comments. I will search. Could you please guide me to a site where I can get the basics of input and output in Fortran? I had worked with fortran more than 25 years ago and this is the first time I want to RUN it using Visual Studio.
0 Kudos
bmchenry
New Contributor II
8,971 Views
be sure to add error and endof file routings to your code for the OPEN, READ & Write statements and then write a message so you can see if the file is found and opened. In Visual Studio access Project->Properties->Debugging see Working Directory to set to something other than the default Otherwise it will run in either Debug or Release Folders which are sub-directories from your Project location. Help->Intel Visual Fortran... will direct you to the User and Reference Manual which also points to samples which should get you up to speed! look at the
0 Kudos
Rasoul_K_
Beginner
8,971 Views
mecej4 wrote:

Search for the output files by name using Windows Search. If the program ran without any error messages, it must have found the input file. You may have more than one copy of the input file.

Input and output files are, by default, located in the current working directory. When you use an IDE such as Visual Studio, the concept of current working directory becomes a little nebulous.

Searching the output file didn't find it.
0 Kudos
Rasoul_K_
Beginner
8,971 Views
bmchenry wrote:

be sure to add error and endof file routings to your code for the OPEN, READ & Write statements and then write a message so you can see if the file is found and opened.
In Visual Studio access Project->Properties->Debugging
see Working Directory to set to something other than the default
Otherwise it will run in either Debug or Release Folders which are sub-directories from your Project location.
Help->Intel Visual Fortran...
will direct you to the User and Reference Manual which also points to samples which should get you up to speed!

look at the

Dear bmchenry Thanks for your comment. I am aware of putting messages for print so that I can trace them and already did it. You talked about working directories. How can I access its settings to change to a known place for me?
0 Kudos
bmchenry
New Contributor II
8,971 Views
From Visual Studio access Project->XXXX Properties->Debugging (XXXX wll be your project name) set the Working Directory to the directory you want to use.
0 Kudos
Rasoul_K_
Beginner
8,971 Views
I checked Visual Studios site for help on http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28MSDNSTART%29&rd=true but couldn't find anything related to FORTRAN samples or guidelines. Perhaps I should look for something other than key word "FORTRAN" Also in MSDN Forum site, a search with FORTRAN didn't bring anything. The only thing is F#. Is it really different from FORTRAN?
0 Kudos
Rasoul_K_
Beginner
8,971 Views
I find the exe file in: ConsoleApplication3\ConsoleApplication3\bin\Debug Double clicking this exe file just pops up Command line prompt for less than a second and closes up immediately. How can I keep it remain on the screen?
0 Kudos
Rasoul_K_
Beginner
8,972 Views
Dear bmchenry I found the working directory path. IT is as follows: Right click the application name in Solution explorer, go to properties, go to "debug" tab and working directory is under Start Options heading
0 Kudos
bmchenry
New Contributor II
8,979 Views
with Visual Studio open (and Fortran installed) when you select help menu you should see Intel Visual Fortran Composer XE 2013 (or which version you are using) select that menu option and it should present you with the Help viewer OR simply open the Fortran help file below is some screen captures on it also you can use Read(*,*) i believe on a console application to read/pause the program set up a variable to read and then write it to the console to pause and continue integer something1, something2 read(*,*) something1 write(*,*) something1 read(*,*) something2 etc...
0 Kudos
Steven_L_Intel1
Employee
8,979 Views
If you run a program from within Visual Studio, the default directory is the one containing the project file - it is not "nebulous". Typically this is not the directory containing the EXE. With the code as shown, if the file does not exist in the default directory an empty file will be created.
0 Kudos
Rasoul_K_
Beginner
8,979 Views
bmchenry wrote:

with Visual Studio open (and Fortran installed) when you select help menu you should see
Intel Visual Fortran Composer XE 2013 (or which version you are using)
select that menu option and it should present you with the Help viewer OR simply open the Fortran help file
below is some screen captures on it
also you can use
Read(*,*)
i believe on a console application to read/pause the program
set up a variable to read and then write it to the console to pause and continue
integer something1, something2
read(*,*) something1
write(*,*) something1
read(*,*) something2
etc...

Dear Henry What you mentioned in the help menu, exists but it connects to online help. An icon appears in system taskbar referring to http://127.0.0.1:47873/help/0-1540/ms.help?product=VS&productVersion=100&method=f1&query=intel.for.main_cover_xe13&locale=en-US A screenshot is attached. I couldn't get the information I nee regarding READ/Write format from that help.
0 Kudos
Rasoul_K_
Beginner
8,979 Views
This is the help site screenshot
0 Kudos
Rasoul_K_
Beginner
8,979 Views
Steve Lionel (Intel) wrote:

If you run a program from within Visual Studio, the default directory is the one containing the project file - it is not "nebulous". Typically this is not the directory containing the EXE.

With the code as shown, if the file does not exist in the default directory an empty file will be created.

Dear Steve thanks for help and support. There are few files with different extensions like as follows in the project folder: ConsoleApplication3.sln ConsoleApplication3.suo Program.for ConsoleApplication3.fsproj ConsoleApplication3.exe ConsoleApplication3.pdb ConsoleApplication3.XML Which one is the empty file? I suppose debuging will make the exe file, if ther is no error. Am I correct? The execution of exe file will run the code and should read the input file. I have the input put inside the project folder. Then it should produce the output file presumably inside the project folder with the name I have opened but I can't find it. One more question. Is it necessary to compile the code after debugging or debugging will compile the code as well? And in order to run the code is it necessary to double click the exe file inside project folder or VS will run and show the result in OUTPUT tab?
0 Kudos
Rasoul_K_
Beginner
8,979 Views
This is the screen shot.
0 Kudos
mecej4
Honored Contributor III
8,979 Views
I think that you have some confusion between debugging, compiling and the connection between the two. Compiling and linking must be completed without errors in order to produce an EXE. If the Debug Configuration was used, the EXE can be run inside the VS debugger. Whether the Debug or Release configuration was used, the resulting EXE can definitely be run, and may or may not produce run time errors. That you see the ConsoleApplication3.exe file in the same folder as the project files indicates that you do not have the default configuration, probably as a consequence of choosing one or more options in Visual Studio without being aware of the consequences. Furthermore, without a full directory listing in your post it is impossible to tell whether the EXE file that you listed is a vestige of an old compilation, whether it is that file or another, more recent, EXE that exists in a subdirectory and gets run when you choose Debug or Run. IDEs are popular and simplify working, but when things don't work the environment is more complex and it takes more work to pin things down. Perhaps you can discard the present error-ridden project and start with a clean slate.
0 Kudos
Steven_L_Intel1
Employee
8,979 Views
None of the files you show would be the empty file as written by the program. Perhaps the program did not run at all. Either the file would have the name given to it in the program, or it would be something like fort.7 for a file written on unit 7.
0 Kudos
Rasoul_K_
Beginner
8,979 Views
Dear Henry The info at http://127.0.0.1:47873/help/0-1540/ms.help?product=VS&productVersion=100. gives good info regarding read/write. I hope it will solve my issue. Thanks
0 Kudos
Rasoul_K_
Beginner
8,979 Views
Steve Lionel (Intel) wrote:

None of the files you show would be the empty file as written by the program. Perhaps the program did not run at all. Either the file would have the name given to it in the program, or it would be something like fort.7 for a file written on unit 7.

Isn't there any way/procedure to check and be sure that the program is executed or not?
0 Kudos
Steven_L_Intel1
Employee
8,643 Views
It should be somewhat obvious when you ask the program to run whether or not it did run. If you need to check specific parts of the program, set a breakpoint and run under the debugger.
0 Kudos
Reply