warning #5142: Invalid use of $ character in identifier

warning #5142: Invalid use of $ character in identifier

Hello,

we are currently moving old programm code to a newer version of IVF. Based on this we hope to finde possible errors. We check also for warnings.One warning we are getting is shown in the following examble:

!  Program to demonstrate GETDRIVEDIRQQ
USE IFPORT
CHARACTER($MAXPATH) dir
INTEGER(4) length

!  Get current directory
dir = FILE$CURDRIVE
length = GETDRIVEDIRQQ(dir)
IF (length .GT. 0) THEN
  WRITE (*,*) 'Current directory is: '
  WRITE (*,*) dir
ELSE
  WRITE (*,*) 'Failed to get current directory'
END IF
END

The compliation is producing twice the: warning #5142: Invalid use of $ character in identifier (Based on the compiler option /stand:f95)

The example comes out of the IVF help.

What do we have to change?

Thanks in advance
Frank

8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I believe that neither $MAXPATH nor FILE$CURDRIVE are defined in IFPORT.

You should find them in IFLIB, so add USE IFLIB, or just add

! Drives and Directories
! -----------------------------------------------------------------
      CHARACTER*1 FILE$CURDRIVE
      INTEGER*4   FILE$MAXNAME
      INTEGER*4   $MAXPATH
      PARAMETER (FILE$CURDRIVE = ' ')
      PARAMETER (FILE$MAXNAME = 255)
      PARAMETER ($MAXPATH = 260)

to your code.

$ in a variable name is  non standard fortran GETDRIVEDIRQQ is non standard fortran it is an Intel extention. I would iether ignore the warning or in the options for the project (or file properties) tell it to ignore 5142.

When you want the compiler to consume nonstandard code without complaining, do not use the /stand:xxx option!

Hello,

thanks to all.

@ Anthony Richards
the source code from the given example is taken from the IVF help from the current version. In this way i hope that $MAXPATH is part of IFPORT. Looking at the ifport.f90 file in the intel directory it is.

@ app4619 , mecej4
in the first assumption i hope that intel extention might use standard conform definition. It would be nice if the intel help would indicate non standard definition more directly in the help file.

@all
Looking at the ifport.f90 file in the intel directory any character(len=*) is possible. There is no need to use CHARACTER($MAXPATH).  I have missed this information in the help. I have found it now.

Frank

The use of $ in the names was actually a Microsoft convention from Fortran PowerStation. However, it's quite common in OS-dependent APIs. My usual recommendation in this area is to write a set of jacket routines that contain the platform-specific (and therefore non-standard) code, compile those withoit standards checking, and then call them from the rest of the application. This makes it easier to port - and why ask for standards checking if portability is not a concern?

Steve - Intel Developer Support

Steves' point about 'why' is a valid one but I still personally preffer to have the maximum checking on my code as it enforces good habits and helps eliminate errors.  I segregate 'non-standard' code and switch off certain warning numbers for this code.

Hello Steve,

as app4619 allready said, writing programs as close as possible to the fortran standard is useful and can reduce the number of errors.

For us it is one target to bring up the must of our old programs to the current standard (at least Fortran 95). Moving towards portability is one of our next targets. Due to the fact that intel is not bringing the array viewer up to the current version (including 64bit) one major reason to stay on with IVF is gone.

Frank

Leave a Comment

Please sign in to add a comment. Not a member? Join today