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

Converting a program from CVF 6.6 to IVF 11.1

CHARAF-EDDINE_A_
Beginner
1,142 Views

Hello everybody,

I am converting a program from CVF 6.6 to IVF 11.1 and I am looking for an equivalent to this part of the code below :

1. What library should I call instead of MSFLIB ? Should I modify the functions used in the program FULLPATHQQ, ... ?

2. This program is used to open a data file named "inputData.txt", if this file does not exist in the correct directory, the line 15 (err=9001) call a window which allow to search fo a file manually (the same "open with" window that we have generally in all programs).

3. How can I change lines 15,16 ?

Thank you

  1.     USE msflib
  2.     CHARACTER($MAXPATH) pathin
  3.     CHARACTER($MAXPATH) filein
  4.     CHARACTER(2) drive
  5.     CHARACTER($MAXPATH) dir,workdir
  6.     CHARACTER($MAXPATH) namein
  7.     CHARACTER(4) ext
  8.     INTEGER*4 leng1,leng2,leng3
  9.     LOGICAl(4) result
  10.     ienter=1  
  11.     OPEN (ienter,FILE='inputData.txt',status='old',err=9001)
  12.     call Function
  13.     goto 1
  14.         
  15. 9001    open(ienter,file='',status='old',err=9000)
  16.     INQUIRE(ienter,name=filein)
  17.     leng1=FULLPATHQQ(filein,pathin)
  18.     IF(leng1.EQ.0)STOP
  19.     IF(leng1.GT.0)THEN
  20.         leng2=SPLITPATHQQ(pathin,drive,dir,namein,ext)
  21.         IF(leng2.EQ.0)THEN
  22.               WRITE(*,*) 'Can''t split path'
  23.             STOP
  24.         ENDIF
  25.     ELSE
  26.         WRITE(*,*)'Can''t get full path'
  27.         STOP
  28.     ENDIF
  29.     
  30.     RETURN
  31. 9000    WRITE(*,*) 'Reading error'
0 Kudos
8 Replies
GVautier
New Contributor III
1,142 Views

Hello

The module is IFPORT

USE IFPORT

 

 

0 Kudos
Mark_Lewy
Valued Contributor I
1,142 Views

Re:2 you might want to use the /fpscomp:filesfromcmd option (set Fortran->Compatibility->Use Filenames from Command Line (Powerstation) = Yes in the VS IDE) to replicate the behaviour of Microsoft Fortran PowerStation, which would either use a command line argument or prompt for a filename if file='' in an open statement.

0 Kudos
CHARAF-EDDINE_A_
Beginner
1,142 Views

First of all, thank you.

I have tested by including the IFPORT, but I didn't succed in getting the 'open file window' (picture below).

I think the problem is due to my old WORKSPACE which I have changed (I have just picked up the code from the old project). In order to explain more, in the old project (CVF 6.6), thanks to the workspace settings (which I don't know how to set), the line number 15 {OPEN (ienter,FILE='inputData.txt',status='old',err=9001) } call the "Open file window".

I wish I was clear !

 

 

0 Kudos
Steven_L_Intel1
Employee
1,142 Views

First - using IFPORT is the replacement for MSFLIB here in order to get the declaration of FULLPATHQQ.

To get the file selection dialog with this program, you need to build it as a QuickWin program, just as in CVF, and as noted need to set the "Files from command line" compatibility option. I suggest as an alternative look at the GetOpenFileName sample we provided - this will work in any program type.

0 Kudos
dboggs
New Contributor I
1,142 Views

I have requested this before but I feel compelled to repeat it: Why can't the file selection dialog work in any project type (whenever an "illegal" filename is used in the OPEN statement), and why can't it be the default and not require setting an obscure compatibility option?

I know it was argued that making such a change might break some existing programs, but that is hard to appreciate since the compiler response has always been to interrupt the program, request user input, and then continue. That's the sort of default response that would be expected in a DOS OS, but not in Windows.

0 Kudos
Steven_L_Intel1
Employee
1,142 Views

For a non-QuickWin program, the behavior is to look on the command line used to run the program, NOT prompt the user,  for the filename. That's the way it's supposed to work and if we changed it, it would break many applications. Use GetOpenFileName if you want the dialog all the time.

0 Kudos
Anthony_Richards
New Contributor I
1,142 Views

Follow Steve's suggestion and look at the GetOpenFileName example found in the WIN32 zipped sample directory.

I suggest you change the code to a subroutine called (for example)

SUBROUTINE FINDMYFILE(FILEIN,STATUS,FLAGS)

with FILEIN supplied on input to the routine as the character buffer intended to hold the found full-path filename,

and modify the sample code to return the STATUS and the OFN%FLAGS VALUE as well as the full-path found filename in FILEIN.
A selected file should then be in FILEIN if the STATUS value is tested to be non-zero.

It is up to you whether you want to add bells and whistles such as changing the default search directory to that of the found file to save
time in subsequent searches.

It may be wise to add a call to COMMDLGEXTENDEDERROR() inside the routine if the status flag is non-zero so that you can then discover what went wrong.See the attached file COMDLGERR.

0 Kudos
mecej4
Honored Contributor III
1,142 Views

dboggs wrote:

... but that is hard to appreciate since the compiler response has always been to interrupt the program, request user input, and then continue. 

That is true for programs being run interactively. There are many programs that are run in batch mode (or under the control of scripts). For such programs there is no user standing by to provide user input. When a program attempts something improper or impossible, the program is aborted and a condition code is set. The script may retrieve the condition code and take appropriate action.

Changing the default action (for attempting to open a file with an invalid name) to waiting for user input would cause these batch programs and scripts to hang.

0 Kudos
Reply