Fortran Error 6404 when running fortran code in visual studio

AI Thread Summary
The discussion revolves around troubleshooting an error encountered while compiling FORTRAN code, specifically related to the use of the intrinsic subroutine `getcwd`, which retrieves the current working directory. The user initially misused `getcwd` as a function that returns a value, while it can be invoked either as a procedure or a function, but not both simultaneously. Suggestions include using the correct invocation style, either as a subroutine with `call GETCWD(DirName, Status)` or ensuring proper prototyping of `getcwd` at the beginning of the subroutine. The conversation also touches on potential compiler issues, particularly with Visual Studio and Intel Fortran Compiler (IVF), and the importance of ensuring that the status variable matches the expected type. The user expresses gratitude for the advice and indicates a willingness to try the proposed solutions.
snow.ball
Messages
2
Reaction score
0
I am trying to compile several libraries of FORTRAN code and getting the error message as can be seen in the screen shot. As I do not have any experience with FORTRAN I am not sure what is wrong in the line highlighted line. Any help would be greatly appreciated! Thanks a lot! :-)
upload_2014-11-18_13-11-7.png
 
Technology news on Phys.org
getcwd (get current working directory) is an intrinsic subroutine, but you have invoked it as if it were a function that returns a value. This is how it should be called:
Code:
getcwd(DirName)
 
The docs for getcwd() indicate that it can return a status but that you have to decide which style of invocation to use.
 
jedishrfu said:
The docs for getcwd() indicate that it can return a status but that you have to decide which style of invocation to use.
Aha! I saw the example on a doc page and didn't notice that getcwd could also be used as a function. Thanks for the correction.
 
hhhmmm...just tried a short program and it worked just fine.

Which compiler are you using? Maybe your compiler does not quite like that call?

Maybe your compiler thinks that what you have is some kind of array, instead of a function call.

I would switch and try the "subroutine" style call instead: " call GETCWD(DirName, Status) ".
 
just found a source where they prototype getcwd even though is an intrinsic...maybe due to the fact that can be called either way?

Go ahead and prototype it at the beginning of the subroutine: "integer*4 :: getcwd" ...you should probably also make sure that status is of the same type or larger.
 
hey guys. sorry just replying now and thank's so much for the suggestions! I will try them all out! btw using visual studio with IVF...
 

Similar threads

Replies
16
Views
2K
Replies
17
Views
6K
Replies
2
Views
2K
Replies
6
Views
3K
Replies
1
Views
3K
Back
Top