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

Reading user input from the console

dave_buckley
Beginner
1,845 Views

We are converting our applications from CVF6 to IVF11.

There area number of console based exes that read user input from prompts that are presented to the users in the console. Currently the code is reading and writing from Units 5 and 6. However under IVF11, it doesn't seem to understand the key for the read statements from unit 5.

I have been searching the forums and help documentation to see it IVF supports standard unit reads/writes but haven't been able to find difinitive information on it.

Here is a section of sample code that is in question:

write(6,* ) 'Enter Filename'

read(5,15) fileName

15format(a)

write(6,*) 'Filename = ',fileName

If the data is keyed in and is used, execution seems to be still under the read statement but a new line is shown in the console window. If you then user, then execution continues beyod the read statement.

I have found the references to functionslike GETCHARQQor GETSTRINGQQ to get user input. However was still looking to see if IVF would somehow still support the direct reads from unit 5.

Thanks

Dave

0 Kudos
11 Replies
Steven_L_Intel1
Employee
1,845 Views

There is no difference between CVF and IVF for standard things such as reading and writing from/to the console. I don't know why is relevant here.

Can you show us a small but complete program that demonstrates the behavior you describe?

0 Kudos
dave_buckley
Beginner
1,845 Views

Not sure either on the key.Just happened across it under debug when using random keys to see if anything stopped the read execution.

Here is a very basic sample that will re-create this issue.

We don't ever see it get to the echo of the data entered unless we use sequence

program forRead

implicit none

character*260 fileName

write(6,10)

10 format(1x,'Enter FileName: ',$)

read(5,15) fileName

15 format(a)

write(6,20) fileName

20 format(1x,'FileName entered=', A)

stop

end

0 Kudos
Steven_L_Intel1
Employee
1,845 Views

I just tried it using 11.1.054 (Update 4) and it worked normally for me.

C:\Projects>t.exe
Enter FileName: abc.def
FileName entered=abc.def

I just pressed Enter after typing the abc.def. I tried this both from the command line and from within Visual Studio. What prompted you to try using F6?

0 Kudos
dave_buckley
Beginner
1,845 Views

I believe we should be using the same version since we had also recently installed the latest update that was published. We also have another base test machine that is at 11.1.035 that also shows this same misbehaviour.

Here is the output from the about.

Intel Visual Fortran Compiler Integration for Microsoft Visual Studio* 2008, 11.1.3469.2008, Copyright (C) 2002-2009 Intel Corporation

Could there be something in the project options that could be impacting this?

The thing was just a developertrying random keys in frustation to see if something stopped the read. It surely wasn't our first inclination that another key entry would be required to stop the read.

0 Kudos
dave_buckley
Beginner
1,845 Views

Just as a followup this is what we see under execution(WinXP).

The key was pressed a couple of times before using the key(outputs=^Z) and then the key again, then program continues

C:\forRead\Release>forread.exe

Enter FileName: asdf.fdf

^Z

FileName entered=asdf.fdf

Stop - Program terminated.

forrtl: severe (28): CLOSE error, unit 5, file "Unknown"

C:\forread\Release>

0 Kudos
Steven_L_Intel1
Employee
1,845 Views
Please attach a ZIP of the project with the EXE in it that shows the problem.
0 Kudos
dave_buckley
Beginner
1,845 Views

Included in the zip is thefiles to build under VS2008/IVF11.1.054and the release EXE.

Also included are the project files required to build the under CVF6(works).

Thanks

Dave

0 Kudos
Steven_L_Intel1
Employee
1,845 Views

Thanks - this is what I needed. To resolve the problem, right click on the project and select Properties. Then select Fortran > Compatibility. Set the property "Use Other PowerStation Run-Time Behavior" to "No". You may decide to turn off the other PowerStation options unless you know your program needs them.

This is our bug and I will report it to the developers. Thanks for bringing it to our attention.

0 Kudos
Steven_L_Intel1
Employee
1,845 Views
It turns out that this bug was recently reported and fixed - the fix will appear in Update 5, scheduled for the second week of February.
0 Kudos
dave_buckley
Beginner
1,845 Views

Just to confirm then that correction included under update 5 should allow us to use the normal unit 5 reads while still having that option set(YES)?

Thanks for all of your help with this issue!

Dave

0 Kudos
Steven_L_Intel1
Employee
1,845 Views

That is my understanding, yes.

Do you need those options?

0 Kudos
Reply