Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

C Character variable

JohnNichols
Valued Contributor III
594 Views
!----------------------------------------------------------
!  St7APIDemo.f90
!----------------------------------------------------------
!  This example demonstrates the Visual Fortran link to
!  the Strand7/Straus7 API. The program loads St7API.DLL,
!  opens a requested file and then runs the linear static
!  solver.
!
!  To successfully run this program, the location of
!  the dynamic link library "ST7API.DLL" must be added to
!  the Windows PATH environment variable.
!
!  This program was successully compiled and run using:
!  - Intel Visual Fortran 10.0
!  - Compaq Visual Fortran 6.6.0
!----------------------------------------------------------

PROGRAM Tyr

!  Use the API interface and constants modules
   USE St7APICall
   USE St7APIConst
   IMPLICIT NONE

!  Declaration of local variables
   INTEGER(4) :: iNode,nNode,nBeam,nPlate,nBrick,nMax,iErr
   REAL(8) :: XYZ(3)
   LOGICAL :: Loaded
   CHARACTER(kMaxStrLen) :: fName,sAuthor,sTitle

!  Load the API
   CALL LoadSt7API(Loaded)
   IF (Loaded) then
      WRITE(*,*) "ST7API.DLL loaded successfully."
   ELSE
      WRITE(*,*) "Cannot load ST7API.DLL."
      WRITE(*,*) "Press <Enter>"
      READ(*,*)
      STOP
   ENDIF

!  Initialise the API
   iErr = St7Init()
   IF (iErr == ERR7_NoError) THEN
      WRITE(*,*) "API initialisation successful."
   ELSE
      WRITE(*,*) "Error initialising the API."
      WRITE(*,*) "Press <Enter>"
      READ(*,*)
      STOP
   ENDIF

!  Open a user-selected ST7 file
   WRITE(*,100) 
100 Format( "Enter ST7 file name:",\)
   READ(*,*) fName

   iErr = St7OpenFile(1,"mesh1.st7"C,"b:\\temp"C)

Strand7 is a FEM program from Australia.  I now have my large Dutch Bridge models running, and I want to use the Strand7 API to get out the results.  The sample program passes the filename as shown with line58, how do I translate variable fname to the C form,  not done this in my whole life,  I understand the basic theory, but not the actual step.  If I just run in file name mesh1.st7, it says file not found.

Thanks

John

0 Kudos
2 Replies
Steve_Lionel
Honored Contributor III
572 Views

trim(fname)//char(0) will do it. Fortran 2023 will include an intrinsic that will do this for you.

0 Kudos
JohnNichols
Valued Contributor III
541 Views

Thank you that worked perfectly.  I had tried a couple of suggestions in Fortran Discourse, but they did not seem to want to work.  

 

0 Kudos
Reply