Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29283 Discussions

pass shorter sting to subroutine > error #7938

andrebrune
Beginner
4,393 Views

I try to compile a F90-Code with the Visual Fortran Composer XE 2011, which worked quiet fine in the Compaq visual fortran environment.

The compiler error I get is

> error #7938: Character length argument mismatch

when executing for example the following code-fragment

[bash]

CALL LINE ('M2',)



 

SUBROUTINE LINE (NAME,)



         CHARACTER NAME*8



END SUBROUTINE [/bash]

So a shorter string as expected is passed to the subroutine. Unfortunately this programming-style is used very often in my big project. I changed the Compiler options

(>Fortran>Run-Time) Check Array and String Bound to No

(>Fortran>Diagnostics) Check Routine Interfaces to No

without any success.

Related problems were discussed in:

http://software.intel.com/en-us/blogs/2009/03/31/doctor-fortran-in-ive-come-here-for-an-argument

http://software.intel.com/en-us/forums/showthread.php?t=64550&wapkw=%28error+%237938%29

Maybe someone has an idea?

0 Kudos
7 Replies
mecej4
Honored Contributor III
4,393 Views
Such usage is prohibited by the Fortran standard. You can fool a compiler into accepting the code, but usually you have to pay the price, especially if the subroutine does something with characters beyond the end of the actual string passed to it.

If your old code does similar things, you should fix it. If it only has incorrect declarations, on the other hand, just don't allow the compiler to check for consistency between actual and dummy argument lists.

Consider the following example.

[fortran]subroutine pmsg(str)
character*8 :: str
str(5:5)='X'
write(*,*)str
return
end subroutine pmsg

program tst
call pmsg('XY')
end program tst
[/fortran]
The behavior of the program is unpredictable, as you can see from the following runs.

S:\> ifort strng.f90
S:\> strng
XY 8

S:\> ifort /debug strng.f90
S:\> strng
forrtl: severe (157): Program Exception - access violation

S:\> ifort /warn strng.f90
S:\> strng
strng.f90(9): error #7938: Character length argument mismatch. ['XY']

Which of these behaviors would you find acceptable with your large program?
0 Kudos
GVautier
New Contributor III
4,393 Views
Hello

Effectively, it was a common source of problems in CVF.

The best solution is to replace all fixed lengths declarations for character arguments in functions and subroutines.

So change
CHARACTERNAME*8
to
CHARACTERNAME*(*)



0 Kudos
andrebrune
Beginner
4,393 Views
Thanks a lot for your answers. I fixed the problem by declaring all variables before they are passed - anoying, but it works.
0 Kudos
andrebrune
Beginner
4,393 Views

next problem: Same project and the error is:

fatal error LNK1104: cant open "dformd.lib" LINK

We use subroutines like

CALL DATE_AND_TIME ( date, time)

which as far as I know are included through

USE DFLIB

How can I solve this link-problems with VisualStudio and the Intel Compiler?

I found a related thread:

http://software.intel.com/en-us/forums/showthread.php?t=42445

but I dont know how to handle with these files. Sorry, I am uncertain in such cases.

Additionally I read about newer libraries in:

http://www.adras.com/Graphics-Lib-Help.t2416-142.html

Do I need the discussed libraries IFQWIN, IFCORE and IFPORT?

0 Kudos
TimP
Honored Contributor III
4,393 Views
No, DATE_AND_TIME doesn't involve any USE declaration. The link error is more likely to mean that you have objects left over from a Compaq or DEC compiler build.
If you are using specific extensions of the Compaq compiler, you will should find the CVF to ifort conversion document useful.
0 Kudos
mecej4
Honored Contributor III
4,393 Views
Do I need the discussed libraries IFQWIN, IFCORE and IFPORT?

We cannot answer this question, since we do not know what is in your code.

It is possible that your sources have unneeded USE statements that were put in as a stop-gap. If so, the linker will as for those libraries not to satisfy needed externals, as is common, but simply to honor directives to link those libraries.

If that is the case, you can use the /NODEFAULTLIB:dformd.lib linker option. If the linking goes through, you then know that any USE statements that correspond to that library are superfluous, and so on.

You can also dump the symbol tables of the .OBJ files to see which ones call for CVF libraries.
0 Kudos
Steven_L_Intel1
Employee
4,393 Views
If you make sure that all objects and libraries you supply are recompiled then the linking error should go away.
0 Kudos
Reply