#include "cfx5ext.h"
dllexport(get_tstep_info)
      SUBROUTINE GET_TSTEP_INFO (CZ, DZ, IZ, LZ, RZ)
      IMPLICIT NONE
C
C Example of obtaining transient info for all zones
C
C ======================================================================
C Include directives
C ======================================================================
C
#include "MMS.h"
#include "cfd_constants.h"
C
C ======================================================================
C Arguments
C ======================================================================
C
C Stacks
      CHARACTER*(1) CZ(*)
      DOUBLE PRECISION DZ(*)
      INTEGER IZ(*)
      LOGICAL LZ(*)
      REAL RZ(*)
C
C ======================================================================
C External functions
C ======================================================================
C
C Function to concatonate an integer on to the end of a string
      CHARACTER*(MXDNAM) CCATI
      EXTERNAL CCATI
C
C ======================================================================
C Local variables
C ======================================================================
C
C Result
      CHARACTER*4 CRESLT
C Zone (domain)
      CHARACTER*(MXDNAM) CZONE
C Path name
      CHARACTER*(MXPNAM) CDRNAM
C
C Number of zones & iterator
      INTEGER NZN, IZN
C Number of timesteps, accumulated timesteps, coefficient loops
      INTEGER NTSTEP, ATSTEP, NCLOOP
C
C Time, accumulated time, timestep value
      REAL DT, TIME_DTEND, RTIME_DTEND
C
C ======================================================================
C Executable statements
C ======================================================================
C
C ----------------------------------------------------------------------
C Obtain and write non zone specific data
C ----------------------------------------------------------------------
C
C Obtain number of timesteps, accumulated timesteps & coefficient loops
      CALL PSHDIR ('/FLOW/SOLUTION', 'STOP', CRESLT)
      CALL PEEKI ('NTSTEP', IONE, NTSTEP, 'STOP', CRESLT, IZ)
      CALL PEEKI ('ATSTEP', IONE, ATSTEP, 'STOP', CRESLT, IZ)
      CALL PSHDIR (CCATI('TSTEP',ATSTEP), 'STOP', CRESLT)
      CALL PEEKI('NCLOOP', IONE, NCLOOP, 'STOP', CRESLT, IZ)
      CALL POPDIR ('STOP', CRESLT)
      CALL POPDIR ('STOP', CRESLT)
C
C Write to standard output
      WRITE(*,*)
      WRITE(*,*) '            TIMESTEP:', NTSTEP
      WRITE(*,*) 'ACCUMULATED TIMESTEP:', ATSTEP
      WRITE(*,*) '    COEFFICIENT LOOP:', NCLOOP
C
C ----------------------------------------------------------------------
C Obtain and write zone specific data
C ----------------------------------------------------------------------
C
C Determine the number of zones (domains)
      CALL PEEKI ('/FLOW/GEOMETRY/NZN', IONE, NZN, 'STOP', CRESLT, IZ)
C
C Loop over all zones
      DO IZN = 1,NZN
         CALL PEEKCA ('/FLOW/GEOMETRY/CZONE',
     &    IZN, CZONE, 'STOP', CRESLT, CZ)
C
C Obtain time, accumulated time & timestep value for this zone
         CDRNAM = '/FLOW/SOLUTION/LATEST/' // CZONE
         CALL PSHDIR (CDRNAM, 'STOP', CRESLT)
         CALL PEEKR ('TIME_DTEND', IONE, TIME_DTEND, 'STOP', CRESLT, RZ)
         CALL PEEKR ('RTIME_DTEND',IONE,RTIME_DTEND, 'STOP', CRESLT, RZ)
         CALL PEEKR ('DT',         IONE, DT, 'STOP', CRESLT, RZ)
         CALL POPDIR ('STOP', CRESLT)
C
C Write to standard output
         WRITE(*,*) '                ZONE:', IZN
         WRITE(*,*) '                  TIME:', RTIME_DTEND
         WRITE(*,*) '      ACCUMULATED TIME:', TIME_DTEND
         WRITE(*,*) '        TIMESTEP VALUE:', DT
      END DO
C
      END
