CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > CFX

Fortran subroutine

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   March 7, 2005, 19:42
Default Fortran subroutine
  #1
Thomas
Guest
 
Posts: n/a
Hi cfx-users.

I'm using CFX 5.7.1, and I'm trying to get the second derivative of some variables. For that, I'm using a Fortran routine to obtain the derivative of a variable. But I'm facing with problems. My routine looks like this:

#include "cfx5ext.h"

dllexport(grad2p)

SUBROUTINE GRAD2P (NLOC, NRET, NARG, RET, ARGS, CRESLT,

& CZ,DZ,IZ,LZ,RZ)

IMPLICIT NONE

C Calculate magnitude of the additional variable gradient

#include "stack_point.h"

C Result flag

CHARACTER CRESLT*(*)

INTEGER NLOC

INTEGER NARG

INTEGER NRET

REAL ARGS(NLOC,NARG)

REAL RET(NLOC,NRET)

INTEGER IZ(*)

CHARACTER CZ(*)*(1)

DOUBLE PRECISION DZ(*)

LOGICAL LZ(*)

REAL RZ(*)

__stack_point__ pGradrv

C Obtain AV gradient and calculate its magnitude

CALL USER_GETVAR ('mypgrad.Gradient',CRESLT, pGradrv,

& CZ,DZ,IZ,LZ,RZ)

CALL SET_A_magU (RET(1,1), RZ(pGradrv), 3, NLOC)

END

I then I get the following error message when I compile it:

Linking... .\Debug\essai.obj : fatal error LNK1136: invalid or corrupt file Error executing link.exe.

Fortran_routine.exe - 1 error(s), 0 warning(s)

As I'm not so good in Fortran, I don't know where does this error comes from (even by checking the help and some books). So I wonder if someone can help me with that (it would be really kind), or if someone is faced with the same situation by trying to get the second derivative of variables.

I need some help. Thanks Best regards,

Thomas
  Reply With Quote

Old   March 8, 2005, 07:14
Default Re: Fortran subroutine
  #2
Peter
Guest
 
Posts: n/a
hi,

what compiler do you use?

regards

peter
  Reply With Quote

Old   March 8, 2005, 07:46
Default Re: Fortran subroutine
  #3
Thomas
Guest
 
Posts: n/a
Hi.

I'm using Compaq Visual Fortran Standard Edition 6.6.a. (Developper Studio). Regards,

Thomas
  Reply With Quote

Old   March 9, 2005, 01:41
Default Re: Fortran subroutine
  #4
Jeff
Guest
 
Posts: n/a
Thomas,

This file should not be linking. Are you compiling with the cfx5mkext script?

Try: cfx5mkext filename.F

Make sure the file has an uppercase F on the end. The cfx5 script requires the Fortran pre-processor to be run on the file for the included header files. The uppercase F ensures that.

Jeff
  Reply With Quote

Old   March 11, 2005, 10:26
Default Re: Fortran subroutine
  #5
Thomas
Guest
 
Posts: n/a
Hi.

Thank you for this advise Jeff. But now it's an error occuring with the following message:

Error: Syntax error, found END-OF-STATEMENT when expecting one of: ( : % . = => __stack_point__ pGradrv

rror: This statement is positioned incorrectly and/or has syntax errors. __stack_point__ pGradrv

It seems to be the definition of the stack point, but I don't know exactly what's going on? Who can help me? Thanks

Thomas
  Reply With Quote

Old   March 12, 2005, 12:40
Default Re: Fortran subroutine
  #6
Jeff
Guest
 
Posts: n/a
Look at one of the examples. __stack_point__ is a variable type pGradv is the variable. Make sure you've got as space between the type and the variable, as well as being careful with the number of underscores in th type (I may have them wrong above).

Jeff
  Reply With Quote

Old   March 14, 2005, 07:59
Default Re: Fortran subroutine
  #7
Thomas
Guest
 
Posts: n/a
Hey.

Yes of course I looked carefully at the examples, and I think I haven't done any mistakes. But it still doesn't work when I compile it! Is it working for you if you try to compile it?? Thanks,

Thomas
  Reply With Quote

Old   March 14, 2005, 23:00
Default Re: Fortran subroutine
  #8
Jeff
Guest
 
Posts: n/a
I've not had any problem with this. I can't tell exact syntax and columns on these posting because all your lines end up in column 1 on CFD-online. It does look here that there is no space between your type and your variable pGrad. Of course this may not be the case in your actual code.

Last guess is that the compiler you're using is forcing Fortran 95. I've gotten Fortran 95 to work, but the #include has been replaced by something called a DEC directive. If this is the case, your stackpoint.h header file is not being properly included, and your pointer type is then not defined or understood.

Also (I may have mentioned this above) the file name must end in .F (uppercase) to invoke the Fortran pre-processor which compiles the header file.

Those are all I can think of.

Jeff
  Reply With Quote

Old   March 14, 2005, 23:02
Default Re: Fortran subroutine
  #9
Jeff
Guest
 
Posts: n/a
Can you compile one of the examples, or even one of the templates with out a problem?

Jeff
  Reply With Quote

Old   March 17, 2005, 09:09
Default Re: Fortran subroutine
  #10
Claudia
Guest
 
Posts: n/a
Hi,

i tried to compile your file, too. It works. I used Compaq Visual Fortran 6. Did you use cfx5mkext from the command window?

Claudia
  Reply With Quote

Old   March 18, 2005, 08:42
Default Re: Fortran subroutine
  #11
Thomas
Guest
 
Posts: n/a
Hi.

Thank you. As you said, it seems that the include statement is not recognized. And it the same when I compile some example in the tutorials. Nevertheless, when I use cfx5mkext from the command window, it works. So maybe it's ok like this? But my simulation is still not working, but for another problem...

regards, Thomas
  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fortran Subroutine Error sergiorbrett CFX 12 September 3, 2012 07:40
Fortran subroutine (Perl not found) gillou_sk8@hotmail.com CFX 0 June 20, 2008 09:59
error on CFX compile fortran subroutine billpeace CFX 0 May 18, 2006 04:44
FORTRAN Subroutine Neser25 CFX 3 October 20, 2005 14:55
Parallel Processing of Fortran Subroutine Ashwini Mishra CFX 1 November 3, 2004 11:02


All times are GMT -4. The time now is 22:16.