Ask Your Question
0

Calling API in Fortran

asked 2019-04-30 20:05:10 -0500

patrickrossiter gravatar image

Hi there, I am writing a user written model in Fortran and want to use one of the API routines in the model (specifically, MDLIND). When I include the following code:

CALL MDLIND(I, IB, 'EXC', 'STATE', IVAL, IERR)

I am unable to compile the code because of an unresolved external symbol. However I do not know where the API routines are defined and what file to include. Can anyone help?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2019-07-02 12:11:59 -0500

jcote gravatar image

We have been experiencing the same problem, and finally found the issue. The error we found was associated with the data types being passed to the MDLIND subroutine. In particular, the second argument, IB in your code, must be a character string, per the API documentation. When we, by mistake, passed the routine an integer for the second argument, the linker (cload4) produces the error message you referred to in your email, an "unresolved external symbol". Every time I saw this, I assumed that the linker could not find the routine MDLIND, but in reality it cannot find that function coupled with those argument types. When we changed the second argument to a character string, it linked properly, and functions correctly.

As a note, one needs to be careful when dealing with equipment ID's in PSSE. Many times you can be lazy with the distinction between a numerical ID, say 1, versus the character ID, say '1'. PSSE will internally convert the numerical IDs to character string IDs, such as when read in from the UI, a read or dyre file, etc. However, when using an alphabetic ID, the use of quotes is preferred if not required. Obviously, when using the API functions, the data types must match the function definitions.

Hope this helps.

edit flag offensive delete link more
0

answered 2019-05-01 02:54:52 -0500

perolofl gravatar image

Have you declared it as external, i.e. EXTERNAL MDLIND?

edit flag offensive delete link more

Comments

Yes, I have used the following line for that but it is still unresolved. EXTERNAL BADMID, DOCUHD, MDLIND

patrickrossiter gravatar imagepatrickrossiter ( 2019-05-01 22:36:51 -0500 )edit

Strange, are you using Environment Manager? I tried to compile and link and it works without problem.

perolofl gravatar imageperolofl ( 2019-05-02 00:41:42 -0500 )edit

Thanks for your help. I am using the EM. What are you including in your .F file? I am only using INCLUDE 'COMON4.INS'. I have previously had a feeling that my EM is not set up correctly but I am finding it hard to diagnose.

patrickrossiter gravatar imagepatrickrossiter ( 2019-05-02 00:57:01 -0500 )edit

Would you be able to send me the file that you were able to successfully compile?

patrickrossiter gravatar imagepatrickrossiter ( 2019-05-05 18:23:57 -0500 )edit

What is your email address?

perolofl gravatar imageperolofl ( 2019-05-06 01:21:50 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

Stats

Asked: 2019-04-30 20:05:10 -0500

Seen: 66 times

Last updated: Jul 02