06 October 2023 0 1K Report

Hi, I am currently trying to build a fortran and c++ interface by implementing a function inside an abaqus usersubroutine and calling a c++ function in the middle.

The user subroutine I am using is VUAMP and it calls a C++ function in the middle.

Here is the code I've constructed.

--------------------------------------------------------VUAMP

subroutine vuamp(ampName, time, ampValueOld, dt,nprops,props, nSvars, svars, lFlagsInfo,&

nSensor, sensorValues, sensorNames, jSensorLookUpTable,&

ampValueNew,&

lFlagsDefine,&

AmpDerivative, AmpSecDerivative, AmpIncIntegral)

USE, INTRINSIC :: ISO_C_BINDING

include 'vaba_param.inc'

parameter (iStepTime = 1,&

iTotalTime = 2,&

nTime = 2)

parameter (iInitialization = 1,&

iRegularInc = 2,&

ikStep = 3,&

nFlagsInfo = 3)

parameter (iComputeDeriv = 1,&

iComputeSecDeriv = 2,&

iComputeInteg = 3,&

iStopAnalysis = 4,&

iConcludeStep = 5,&

nFlagsDefine = 5)

dimension time(nTime), lFlagsInfo(nFlagsInfo),&

lFlagsDefine(nFlagsDefine),&

sensorValues(nSensor),&

sVars(nSvars)

character*80 sensorNames(nSensor)

character*80 ampName

dimension jSensorLookUpTable(*)

common /OUTFORCE/ FORCE

real*8 :: FORCE

common /OUTVELOCITY/ kdisp

real*8 :: kdisp

!***************************************************************

! C++ INTERFACE

!***************************************************************

!

INTERFACE

FUNCTION add(a, b) BIND(C, NAME="add")

USE, INTRINSIC :: ISO_C_BINDING

REAL(C_DOUBLE) :: add

REAL(C_DOUBLE), VALUE :: a, b

END FUNCTION add

END INTERFACE

REAL(C_DOUBLE) kktime, kkdisp

!

!***************************************************************

lFlagsDefine(iComputeDeriv) = 1

lFlagsDefine(iComputeSecDeriv) = 1

displacement = vGetSensorValue('SENSOR', jSensorLookUpTable, sensorValues)

if (ampName(1:3) == 'AAA') then

if (lFlagsInfo(iInitialization) == 1) then

ampValueNew = ampValueOld

svars(1) = 0.0

svars(2) = 0.0

else

time=time(iStepTime)

ktime=time(1)

kdisp=displacement

kktime = REAL(ktime, KIND=C_DOUBLE)

kkdisp = REAL(kdisp, KIND=C_DOUBLE)

!***************************************************************

! C++ FUNCTION

!***************************************************************

FORCE=add(kktime, kkdisp)

!***************************************************************

ampValueNew = 0.0d0

svars(1)=displacement

end if

end if

return

end

--------------------------------------------------------VUAMP end

--------------------------------------------------------C++

// test7.cpp : Defines the exported functions for the DLL application.

//

#include "stdafx.h"

extern "C" {

__declspec(dllexport) double __cdecl add(double a, double b) {

return a + b;

}

}

--------------------------------------------------------C++ end

i also creating a DLL file to utilize that C++ function and including it in the same folder.

then compile the inp file and fortran code like

[abq6121 job=VDLOAD_VUAMP_0920.inp user=vdload_from_vuamp.for int]

but some error occurs...

LINK : fatal error LNK1181: cannot open input file 'test7.lib'

Abaqus Error: Problem during linking - Single Precision Abaqus/Explicit User Subroutines.

This error may be due to a mismatch in the Abaqus user subroutine arguments.

These arguments sometimes change from release to release, so user subroutines

used with a previous release of Abaqus may need to be adjusted.

Abaqus/Analysis exited with errors

how can i solve and is there any point i missed?

More Kim Eubin's questions See All
Similar questions and discussions