hexagon logo

In a C++ version of a DLL code, I am trying to store some packages of property parameters as a linked list using the “Struct Node” concept. However, I only see iflag value either 3 or 0 when I print it. Is there any reason that I do not see iflag = 1?

In a C++ version of a DLL code for an Adams model, I am trying to store some packages of property parameters as a linked list using the “Struct Node” concept, in such a way that each node to be devoted to one package of input parameter.
To do so, it is required to move to the *next node for storing any new package of input values. This needs me to know when the iflag equals 1 under the GSE_DERIVE function!
 However, I only see iflag value either 3 or 0 when I print it. Is there any reason that I do not see iflag = 1 at all under GSE_DERIV?
Please see below the execution results of this part of the code:
void Gse_deriv(const struct sAdamsGSE* gse, double time, int dflag, int iflag, int ns, double* XDot)
{
                               printf("\n////////////////////////////////////////////////iflag = %d", iflag);
}

Attached Files (1)
Parents
  • Saving & reading data between usersubs is one of the most common issues.
    First of all forget about logic and skip the imagination that every usersub is called in every iteration in a fixed order.
    This is not the case and it may even happen that routines are not called at all in an iteration (learned it the hard way when trying to let a varsub calculate everything for a gfosub)
    The important thing is that ADAMS needs to know that your usersub is depending on system states. This is ther trigger for re-evaluating it when system staes chaged.
     
    IFLAG is by far not sufficient to do distinguish between solver phases.
    My solution of the past was to have own global variables or external files tracking whether a routine was called the first time or not.
    Things like write a flag to a file (or variable), if var007 was called with time>0 and mode>xxx. The "reading" subroutine then just checked my own flag and if it was true, it was reading the information.
     
    Meanwhile MSC introduce some more elegant stuff like the CBKSUB.
    In a nutshell this gives you MUCH better information what's going on in the solver and have these events trigger your own procedures.
    Have a read into: Adams Basic Package > Adams Solver > Welcome to Adams Solver Subroutines > User-Written Subroutines > CBKSUB
    You'll find examples in
    <topdir>/solver/c_usersubs/cbksub.c
    <topdir>/solver/usersubs/cbksub.f
     
     
     
Reply
  • Saving & reading data between usersubs is one of the most common issues.
    First of all forget about logic and skip the imagination that every usersub is called in every iteration in a fixed order.
    This is not the case and it may even happen that routines are not called at all in an iteration (learned it the hard way when trying to let a varsub calculate everything for a gfosub)
    The important thing is that ADAMS needs to know that your usersub is depending on system states. This is ther trigger for re-evaluating it when system staes chaged.
     
    IFLAG is by far not sufficient to do distinguish between solver phases.
    My solution of the past was to have own global variables or external files tracking whether a routine was called the first time or not.
    Things like write a flag to a file (or variable), if var007 was called with time>0 and mode>xxx. The "reading" subroutine then just checked my own flag and if it was true, it was reading the information.
     
    Meanwhile MSC introduce some more elegant stuff like the CBKSUB.
    In a nutshell this gives you MUCH better information what's going on in the solver and have these events trigger your own procedures.
    Have a read into: Adams Basic Package > Adams Solver > Welcome to Adams Solver Subroutines > User-Written Subroutines > CBKSUB
    You'll find examples in
    <topdir>/solver/c_usersubs/cbksub.c
    <topdir>/solver/usersubs/cbksub.f
     
     
     
Children
No Data