### 18.9.5. Junction Box Example 5: Transient Information

This is an example of how to obtain transient data from within a User Fortran junction box routine. In a junction box routine, it is necessary to loop over all zones (domains). For a single domain problem, there will be only one zone, but the approach shown is more general, because it is possible to set a different timestep in each domain. The code shown first obtains and prints out non-zone-specific transient data, and then loops over all zones and obtains zone-specific transient data. Standard CFX memory management system routines, such as `PSHDIR`, `POPDIR`, `PEEKI` and `PEEKR`, are used to move around the data-structures and obtain the required data.

To use these files, it will first be necessary to modify the file run.ccl so that the shared library path is set to the correct location on your filesystem. The User Fortran will then need to be compiled as follows:

    cfx5mkext -name transinfo transinfo.F

The case may be run once as follows:

    cfx5solve -def transient.def -ccl run.ccl.

A restart may be carried out from the first run in order to complete additional time-steps and demonstrate how the accumulated timesteps count and value operates:

    cfx5solve -def transient_001.res -ccl run.ccl

This routine transinfo.F is supplied in the `CFXROOT`/examples/UserFortran/ directory of your CFX installation.

    #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

Release 18.2 - © ANSYS, Inc. All rights reserved.