- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Trying to move a legacy code from Visual Studio 2003 and Fortran 9 to Visual Studio 2017 and Fortran 18. Code is a combination of C# and Fortran; some Fortran routines run just fine. Built to .Net 4.5. Compiler options between 9 and 2018 are as close as I can get them. Builds from 2003 only work up to Windows 7, builds from 2017 only run on Windows 10.
While trying to debug an error that causes a crash in the compiled code, ran into this beforehand: "Dummy character variable 'VAR3' has length 1 which is greater than actual variable length 0"
Code is roughly:
subroutine SETOPTIONS(VAR1,VAR2,VAR3,VAR4,VAR5,VAR6,VAR7) !DEC$ ATTRIBUTES DLLEXPORT::SETOPTIONS implicit none INTEGER VAR1 CHARACTER *1 VAR2,VAR3,VAR5,VAR6 REAL *4 VAR4 CHARACTER *40 VAR7 COMMON /COPTS/ CVAR1,CVAR2,CVAR3,CVAR4 INTEGER CVAR1 CHARACTER *1 CVAR2,CVAR3,CVAR5,CVAR6 REAL *4 CVAR4 CHARACTER *40 CVAR7 WRITE(6,*) 'SETOPTIONS' CVAR1 = VAR1 CVAR2 = VAR2 CVAR3 = VAR3 CVAR4 = VAR4 CVAR5 = VAR5 CVAR6 = VAR6 CVAR7 = VAR7
end subroutine SETOPTIONS
Both the input variable VAR3 and the output CVAR3 have the same type, and length. Before it executes the line to set CVAR3 = VAR3, watch knows that VAR3 is character with length one and it holds the correct value while CVAR3 is character with length 1 and is empty/space. Changing variable names has no effect. I can hard code CVAR3 to the value and everything else in the subroutine works. There are other variables, such as CVAR2 and VAR2, with the same types and lengths with no issues. Code hasn't changed from the working legacy version to this one.
Ideas? Thanks.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Snippets and paraphrases of code are rarely helpful in diagnosing problems. The error you report is one that Intel Fortran 9 did not check. The compiler now checks the incoming actual argument against the declared length of the dummy. Since you say C# is involved, I'd guess that the C# code is not passing the character lengths at the end of the argument list as Fortran expects. To tell the compiler not to look for the lengths, you would need to add a "!DEC$ ATTRIBUTES REFERENCE :: variablename" for each of the character arguments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page