This is an example of the use of modules in a subroutine of a Finite Element Program (my program) in Fortran (every “use” have tens of variables, for example for dimensioning arrays according to the problem):
subroutine brck4(x0, x, d, dpred, &
& matype, datam, ien, lm, x0l, xl, &
& xlint, iprop, dpredl,bl, bnl, dmat, &
& db, strs, strn, cela, imate, &
& signl, ekl, eknl, erf, sbnl, &
& shl, shg, shg0, w, det, mpmat, &
& r , shgm, grad, work, tf, det0, &
& vel, vpred, apred, emass, vl, al )
!
!**** subroutine to compute the residual force vector and consistent
! stifness matrix for the BRCK element
!
! comments with # are the changes from QUAD subroutine
!
use c_consts
use c_dimens
use c_groupd
use c_apoint
use c_antype
use c_gsolve
use c_hhtpar
use c_iounit
use c_stepng
implicit none
real*8 x0(nsd,numnp) !* original undeformed coordinates
real*8 x(nsd,numnp) !* current coordinates
real*8 d(ndof,numnp) !* incremental displacements
real*8 dpred(ndof,numnp) !* predictor values of the displacements
!
integer matype(2,nmat) !* type of material of the material
real*8 datam(ndatam,nmat) !* material data
!
integer ien(nen,numel) !* conectivity array
integer lm(nedof,nen,numel) !* global equation locating matrix
real*8 x0l(nesd,nen) !* initial coordinates of the element
real*8 xl(nesd,nen) !* current coordinates of the element
real*8 xlint(nesd,nint) !* id integration points
integer iprop(numel) !* property user numbers for the elements
real*8 dpredl(nedof,nen) !* predictor/incremental displacements
real*8 bl(nrowsb,nee) !* linear B matix for each integration pt
real*8 bnl(nrowsbnl,nee) !* nonlinear B matrix for each int pt
real*8 dmat(nrowsb,nrowsb) !* material constitutive matrix
real*8 db(nrowsb,nee) !* matrix dmat times matrix bl
real*8 strs(nsig,nint) !* stress tensor in vector form
real*8 strn(nsig,nint) !* strain tensor in vector form
real*8 cela(nrowsb,nrowsb) !* elastic material matrix
integer imate(numel) !* material label for the element
real*8 signl(nsignl,nsignl) !* stresses in special matrix form for bnl
real*8 ekl(nee,nee) !* element linear stiffness matrix
real*8 eknl(nee,nee) !* element nonlinear stifness matrix
real*8 erf(nee) !* element residual force
real*8 sbnl(nrowsbnl,nee) !* nonlinear B matrix times special stress matrix signl
real*8 shl(nrowsh,nen,nint) !* shape fcns derivatives and actual shape fcn (local)
real*8 shg(nrowsh,nen,nint) !* shape fcns derivatives and actual shape fcn (global)
real*8 shg0(nrowsh,nen,nint) !* shape fcns derivatives and actual shape fcn (global)
real*8 w(nint) !* weights for the integration points
real*8 det(nint) !* determinant of jacobian at integr points
integer mpmat(mx1mpmat,numel) !* pointer to the array of mat. data pointers
real*8 r(nint) !* radii at integr. points for axisim. case
real*8 shgm(nrowsh,nen) !* mean (b-bar) shape functions *unused*
real*8 grad(3,3) !* deformation gradient tensor
real*8 work(*) !* a work array
real*8 tf(nptsltf,2,nltf) !* time funcions
real*8 det0(nint) !* initial determinant of jacobian at integr points
real*8 vel(ndof,numnp) !* global nodal velocities
real*8 vpred(ndof,numnp) !* global nodal velocity predictors
real*8 apred(ndof,numnp) !* global nodal accelerations
real*8 emass(nemass,nemass) !* element mass matrix
real*8 vl(nedof,nen) !* element local velocities
real*8 al(nedof,nen) !* element local accelerations
!
real*8 wd !* weight times jacobian
real*8 dens, dampk, dampm !* density and stiffness and mass damping coefficients
real*8 grav(nesd) !* prescribed constant body accelerations (gravities)
real*8 fcela !* factor multiplying elastic matrix (algo damping)
logical lformk !* if true, form stiffness matrix
logical lformm !* if true, form mass matrix
logical lformf !* if true, form residuan force
logical lmountk !* if true, mount stiffness matrix (indep. of lformk)
integer i
!
real*8 gradd(nesd,nen,nint)
real*8 gradtempp(nesd,nen,nint)
!
real*8 eklj(nee,nee), eval(nee), evec(nee,nee), work1(nee), work2(nee)
!
call messages(50,'performing iterative phase tasks for BRCKs ',-1)
!
!** loop on the elements of the group
!
do ielem = 1, numel
!
!** get element material label, element material type and properties material no
!
mat = imate(ielem)
matyp = matype(1,mat)
nprop = iprop(ielem)
!