I am currently working on implementing a material model in an Abaqus UMAT. The code is structured like this
MODULE FUNCTIONS
CONTAINS
FUNCTION GET_A(...) RESULT (A)
IMPLICIT NONE
! ... some variable declarations
DOUBLE PRECISION :: A
! ... some code
END FUNCTION
FUNCTION GET_B(...) RESULT (B)
IMPLICIT NONE
! ... some variable declarations
DOUBLE PRECISION, DIMENSION(n) :: B
DOUBLE PRECISION :: DUMMY_VAR, GET_A
DUMMY_VAR = GET_A(...)
! ... some code
END FUNCTION
END MODULE FUNCTIONS
SUBROUTINE UMAT(...)
! ... a lot of definitions
! ... a lot of code
END SUBROUTINE UMAT
I don't think it matters, but the imaginary function 'GET_B' is supposed to return an array. If a function does not depend on another function, I can call it from the UMAT without a problem. If I try to run the schematic UMAT from above I will get a compiler error similar to
UMAT.obj : error LNK2019: unresolved external symbol get_a referenced in function functions_mp_get_b.R
I read somewhere, that I am not supposed to declare the type of 'GET_A' within 'GET_B'. When I do that and change the code to
MODULE FUNCTIONS
CONTAINS
FUNCTION GET_A(...) RESULT (A)
IMPLICIT NONE
! ... some variable declarations
DOUBLE PRECISION :: A
! ... some code
END FUNCTION
FUNCTION GET_B(...) RESULT (B)
IMPLICIT NONE
! ... some variable declarations
DOUBLE PRECISION, DIMENSION(n) :: B
DOUBLE PRECISION :: DUMMY_VAR
DUMMY_VAR = GET_A(...)
! ... some code
END FUNCTION
END MODULE FUNCTIONS
SUBROUTINE UMAT(...)
! ... a lot of definitions
! ... a lot of code
END SUBROUTINE UMAT
the error changes to
UMAT.f(some_line): error #6404: This name does not have a type, and must have an explicit type. [GET_A] DUMMY_VAR = GET_A(...)
What can I do to call 'GET_A' from 'GET_B' (both functions are in the some module)? Do I need to put the return type of a function before the 'FUNCTION' statement? Since I am used to using the 'RESULT (...)' statement, I usually declare the type in the function body. If it helps to post the full code here, I will do so. I just thought that putting a schematic code here will help to cause too much confusion.
Edit: I uploaded the full code to this repository on git, where I also added the .log file for the precise error. I hope somebody can help me with this.
subroutine UMAT
, do youuse FUNCTIONS
oruse FUNCTIONS, only: GET_B
? Or do you just callGET_B
? If you aren'tuse
ing the module, it might be able to recognizeGET_B
, but unable to determine the interface of the internal call toGET_A
. $\endgroup$use FUNCTIONS
in thesubroutine UMAT
, but the problem seems to be unrelated to the subroutine, but rather stands on its own in themodule FUNCTIONS
. I had the impression thatGET_B
should be aware of the presence ofGET_A
, since they both are in the same module within the same file. $\endgroup$UMAT_NL.f(221): error #7002: Error in opening the compiled module file. Check INCLUDE paths. [FUNCTIONS] USE FUNCTIONS
. This suggests you have an issue with the compilation and the program doesn't know where to find theFUNCTIONS
module $\endgroup$GET_A
andGET_B
referring toGET_G01G2
andGET_DEPS
respectively? Because inGET_DEPS
, you are callingGET_G1G2
(notice no 0 in the name), which doesn't exist. This causes the module build to fail, which probably causes all the other failures in the log. $\endgroup$