where to put input data file for reading input parameters?

where to put input data file for reading input parameters?

Imagen de Rasoul K.

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?

publicaciones de 23 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Imagen de mecej4

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.

Imagen de Rasoul K.

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.

Imagen de bmchenry

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

Imagen de Rasoul K.

Cita:

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.

Imagen de Rasoul K.

Cita:

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?

Imagen de bmchenry

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.

Imagen de Rasoul K.

I checked Visual Studios site for help on
http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k...

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?

Imagen de Rasoul K.

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?

Imagen de Rasoul K.

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

Imagen de bmchenry

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...

Adjuntos: 

AdjuntoTamaño
Descargar helpmenu.jpg49.44 KB
Descargar helpmore.jpg151.37 KB
Imagen de Steve Lionel (Intel)

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.

Steve
Imagen de Rasoul K.

Cita:

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...

A screenshot is attached. I couldn't get the information I nee regarding READ/Write format from that help.

Imagen de Rasoul K.

This is the help site screenshot

Adjuntos: 

AdjuntoTamaño
Descargar helpwebsite.jpg121.02 KB
Imagen de Rasoul K.

Cita:

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?

Imagen de Rasoul K.

This is the screen shot.

Imagen de mecej4

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.

Imagen de Steve Lionel (Intel)

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.

Steve
Imagen de Rasoul K.

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

Imagen de Rasoul K.

Cita:

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?

Imagen de Steve Lionel (Intel)

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.

Steve
Imagen de IanH

Cita:

Rasoul K. wrote:...

There are few files with different extensions like as follows in the project folder:
...
ConsoleApplication3.fsproj
...

That is the project settings file for a completely different language (F#). Given other postings - are you sure you are using a Fortran project?

The project settings file for an Intel Visual Fortran project in Visual Studio has a .vfproj extension.

Imagen de Rasoul K.

Cita:

IanH wrote:

Quote:

Rasoul K. wrote:...

There are few files with different extensions like as follows in the project folder:
...
ConsoleApplication3.fsproj
...

That is the project settings file for a completely different language (F#). Given other postings - are you sure you are using a Fortran project?

The project settings file for an Intel Visual Fortran project in Visual Studio has a .vfproj extension.

Dear Ian

Thanks for your reply. You pointed exactly to the problem. I would never find out this by myself.
I opened a project and then copy/pasted the code inside. Mistakenly I have opened a F# project.
Now let me try again and post here what happens.

Inicie sesión para dejar un comentario.