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

Problem with read and pause statements in Fortran 2021/VS 2022

RonH
Beginner
1,073 Views

There appears to be a problem with the latest fortran compiler or visual studio when executing read and pause statements that wait for input from the keyboard.

I am using
Intel Fortran Compiler Classic for apps running on IA-32, ver. 2021.5.0, Package ID: w_oneAPI_2022.0.0.3663
     with
MS Visual Studio Community 2022(64bits), ver. 17.0.4

I compiled in debug a short standard graphics program which includes the following two statements:

     read(5,'(i1)'),i
     pause

The failure for the read(5,'(i1)'),i statement is:
     Microsoft Visual C++ Runtime Library
     Debug Assertion Failed
     Program:...pgms\Ftn Std Graphics pgm\Debug\FtnStd Graphics project.exe
     File:
     minkernel\crts\ucrt\corecrt_internal_string_templates.h
     Line: 218
     Expression: (L"Buffer is too small" && 0)

If I press [ignore] studio returns to the fortran code with a breakpoint after the read statment with the following message:
     Exception Unhandled
     Unhandled exception at 0x004E94B6 in Ftn Std Graphics project.exe:
     An invalid parameter was passed to a function that considers invalid parameters fatal.


If I comment out the read statement, I get the same failure for the pause statement, except for the following lines:
     Line: 179
     Expression: ((destination)) != NULL && ((size_in_elements)) > 0
and
     Unhandled exception at 0x00D94186 in Ftn Std Graphics project.exe:

These failures DO NOT OCCUR when using
Intel Fortran Compiler Classic for apps running on IA-32, ver. 2021.3.0, Package ID: w_oneAPI_2021.3.0.3372
     with
MS Visual Studio Community 2019, ver. 16.10.4

Note that the Intel Fortran Compiler Classic and Intel Fortran Compiler (Beta) Developer Guide and Reference states that "The PAUSE statement is a deleted feature in the Fortran Standard. Intel® Fortran fully supports features deleted in the Fortran Standard."

Is there something wrong with the way VS 2022 implements the C++ runtime library?
Is there a compiler/debug setting that can alleviate this problem?

Thank you

Ron

0 Kudos
2 Replies
mecej4
Honored Contributor III
1,062 Views

Probably the same as or related to this recent thread .

0 Kudos
RonH
Beginner
1,024 Views


Thank you for your reply. I will try the link in the thread you mentioned.

I have tried additional I/O statements using VS Community 2022/w_oneAPI_2022.0.0.3663 with the following results.

Reading from a file:  read(1,'(a20)')  and  read(1,*)  and  read(1,'(f4.2)')  all yield the following error.
     Intel Visual Fortran run-time error
     end-of-file during read,unit 1
     Exception thrown

Getting characters from the keyboard:  result_i4=getc(char)  and  result_i4=getstrqq(buffer_c80)  both yield the following error
     Microsoft Visual C++ Runtime Library
     Debug Assertion Failed
     Expression: (L "Buffer is too small" &&0)
     Exception Unhandled

The statement result_c1=getcharqq( ) DOES work.

With one exception, these statements WORK on VS Community 2019 with w_oneAPI_2021.3.0.3372. The exception is result_i4=getsrtqq(buffer_c80). Though this statement DOES NOT create an error, it DOES NOT do anything.

Next I will try loading the w_oneAPI_2021.3 into MS Community 2022 using the link mentioned in the other thread.

Thanks again

Ron

0 Kudos
Reply