0

Calling API in Fortran

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?

patrickrossiter's avatar
1
patrickrossiter
asked 2019-04-30 20:05:10 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

0

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.

jcote's avatar
1
jcote
answered 2019-07-02 12:11:59 -0500
edit flag offensive 0 remove flag delete link

Comments

Thanks for your reply, I have just seen this and this was the cause of my issue as well. I was passing an integer for the IB argument, when the routine needed a string.

patrickrossiter's avatar patrickrossiter (2019-11-12 18:01:02 -0500) edit
add a comment see more comments
0

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

perolofl's avatar
3.8k
perolofl
answered 2019-05-01 02:54:52 -0500
edit flag offensive 0 remove flag delete link

Comments

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

patrickrossiter's avatar patrickrossiter (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's avatar perolofl (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's avatar patrickrossiter (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's avatar patrickrossiter (2019-05-05 18:23:57 -0500) edit

What is your email address?

perolofl's avatar perolofl (2019-05-06 01:21:50 -0500) edit
add a comment see more comments

Your Answer

Login/Signup to Answer