Quantcast
Channel: Intel® Fortran Composer XE
Viewing all articles
Browse latest Browse all 1424

Dllexport Function in Subroutine

$
0
0

Hello,

following Code is okay. But I am not sure how to export/import that routines!? The subroutine calls the function.

subroutine RandomFibers(nFib, r, nCellsY, nCellsZ, initW, initH)
    !DEC$ ATTRIBUTES DLLEXPORT, ALIAS: 'RandomFibers' ::RandomFibers
    implicit none
    real, dimension (nFib) ::  fibCoY, fibCoZ, ranR
    integer i, j, k, counter, nFib, nFibCell, nCellsY, nCellsZ, nRestFib
    real(8) y, z, rad, delta, dwide, dheight, initW, initH

    ! parameter for ploting
    real, dimension (nCellsY) ::  yMin, yMax
    real, dimension (nCellsZ) ::  zMin, zMax
    real r
    ! calculate and round number of fibers per Cell
    nFibCell = (nFib / ( nCellsY * nCellsZ))

    ! calculate boundaries (dwide / dheight) of cell from initial RVE size
    dwide = delta(nCellsY, initW)
    dheight = delta(nCellsZ, initH)


    !calculate random fiber coordinates in the boundaries of each cell
    call random_seed
    do i=1, nFib
        call RANDOM_NUMBER(y)
        call RANDOM_NUMBER(z)
        call RANDOM_NUMBER(rad)
        fibCoY(i) = 0.0 + y * (initW - 0.0)
        fibCoZ(i) = 0.0 + z * (initH - 0.0)
        !ranR(counter) = (rad - 0.5) * r / 20.0 + r !calculate random fiber radiu
    end do
end subroutine RandomFibers


function delta(nCells, initLeng)
    !DEC$ ATTRIBUTES DLLEXPORT, ALIAS: 'delta' ::delta
    implicit none
    integer nCells
    real(8) initLeng, delta
    delta = (initLeng - 0.0) / nCells
end function

execute program:

program run

    !DEC$ ATTRIBUTES DLLIMPORT, ALIAS: 'delta' ::delta

    !DEC$ ATTRIBUTES DLLIMPORT, ALIAS: 'RandomFibers' ::RandomFibers

    implicit none
    integer nFib, nCellsY, nCellsZ
    real(8) initW, initH, dy, dz
    real, dimension (11) ::  yLeft, yRight
    real, dimension (11) ::  zBottom, zTop
    real r
    nFib = 900

    r = 0.2
    nCellsY = 30
    nCellsZ = 30
    initW = 20.0
    initH = 20.0

    Call RandomFibers(nFib, r, nCellsY, nCellsZ, initW, initH)

end program run

 


Viewing all articles
Browse latest Browse all 1424

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>