next up previous contents index
Next: A.2 Available Routines Up: A.1 Supplying the Source Previous: A.1 Supplying the Source   Contents   Index

Subsections

A.1.1 Building Shared Libraries

External shared libraries can be build in many ways. Describing all available manners is not the aim of this section. This is a description on how to build a shared library with the supported compiler using the command line. To create a shared library from source using the supported fortran compiler ifort use the following command:

ifort < flags> -o usrlib {sourcefile(s)} {lib(s)}

Where:

ifort
indicates the supported fortran compiler.

< flags>
indicates the compiler flags. For the ifort compiler, these flags can be found in the file uss.flags in the lib directory of the DIANA installation.

-o usrlib
indicates the file name of the compiled shared library file. The file name must contain the extension .dll on MS-Windows systems and .so on Linux systems.

{sourcefile(s)}
indicates the file name(s) of the source file(s) for the compiled shared library file.

{lib(s)}
indicates the names of the required programmer's service libraries [§A.3]. These libraries can be found in the lib directory of the DIANA installation.

To ensure that the correct system libraries are used the following command must be given on MS-Windows platforms after generating the shared library:

mt.exe -manifest usrlib.manifest -outputresource:usrlib;2

Example.

First of all we need to provide the source code. In this example we use a Fortran-90 source file that contains two user-supplied routines.

    (Fortran)


      SUBROUTINE ELSEUS( EPS, NSTR, SE )                         
!DEC$ ATTRIBUTES DLLEXPORT::ELSEUS
!                                                                       
! PURPOSE : User supplied tangential [SE] - matrix
!
      INTEGER          NSTR
      DOUBLE PRECISION EPS(*), SE(NSTR,*)
!
      DOUBLE PRECISION YOUNG
!
      YOUNG = 1.D3
      DO 100, I=1,NSTR
      DO 100, J=1,NSTR
  100 SE(J,I) = 0.0D0
!
      IF ( NSTR.EQ.4 ) THEN
         SE(1,1) = YOUNG + 2000.D0 * YOUNG * EPS(1)
         SE(2,2) = YOUNG + 2000.D0 * YOUNG * EPS(2)
         SE(3,3) = YOUNG + 2000.D0 * YOUNG * EPS(3)
         SE(4,4) = 0.5 * YOUNG
      END IF
!
      END                                                               
      SUBROUTINE ELSGUS( EPS, NSTR, TSIG )
!DEC$ ATTRIBUTES DLLEXPORT::ELSGUS
!                                                                       
! PURPOSE : USER SUPPLIED TOTAL STRESSES
!
      INTEGER          NSTR
      DOUBLE PRECISION EPS(NSTR) , TSIG(NSTR)
!
      DOUBLE PRECISION YOUNG
!
      YOUNG = 1.D3
      IF ( NSTR.EQ.4 ) THEN
         TSIG(1) = YOUNG * EPS(1) + 1000.D0 * YOUNG * EPS(1) ** 2
         TSIG(2) = YOUNG * EPS(2) + 1000.D0 * YOUNG * EPS(2) ** 2
         TSIG(3) = YOUNG * EPS(3) + 1000.D0 * YOUNG * EPS(3) ** 2
         TSIG(4) = 0.5 * YOUNG * EPS(4)
      END IF
!
      END


Please note the "!DEC$ ATTRIBUTES DLLEXPORT" lines in both routines. Without those lines the user supplied routines will not be visible to DIANA on MS-Windows platforms.

For generation of the uscou1.dll shared library file from the sourcefile elseus.f90 containing two user-supplied subroutines, ELSEUS and ELSGUS, on a Windows 64-bit platform the following command has to be given in the DIANA Command Box:

ifort < flags> .../lib/uss.flags -o uscou1.dll elseus.f90 .../lib/lbcx40.lib

Where < flags> indicates the compiler flags, i.e. the content of .../lib/uss.flags and ... indicates the directory of the DIANA installation. To ensure that the correct system libraries are being used the following command must be given on a MS-Windows platform in the DIANA Command Box:

mt.exe -manifest uscou1.dll.manifest -outputresource:uscou1.dll;2


next up previous contents index
Next: A.2 Available Routines Up: A.1 Supplying the Source Previous: A.1 Supplying the Source   Contents   Index
DIANA-10.2 User's Manual - Analysis Procedures
First ed.

Copyright (c) 2017 by DIANA FEA BV.