4.8.3.98. REG_FILE

The opened file for write can be closed when the simulation is finished, if the used file channels(extension numbers) are set though REG_FILE subroutine. This function is only operated in fortran.

Table 4.241 Function Name

Language type

Subroutine

FORTRAN

call reg_file(openfile, nfile)

Table 4.242 Parameter information

Variable Name

Size

Description

openfile

int

The channels of opened files.

nfile

int

The number of opened files.

Note

If the user puts opened files on the RecurDyn/Solver file register, when the program is abnormally terminated or the user doesn’t close the files, the registered files are automatically closed in the RecurDyn/Solver. When iflag is true, the user should put the files on the file register.

RecurDyn recommends to use GETFINISHFLAG function instead of this function.

Listing 4.107 Fortran code for REG_FILE
 C---- SUB. CONTACT_FORCE
 SUBROUTINE CONTACT_FORCE
 &    (TIME,UPAR,NPAR,PEN,RVEL,JFLAG,IFLAG,RESULT)

 C---- USER STATEMENT
 DOUBLE PRECISION A, DIST
 INTEGER MKID(2), REPFLG, OPENFILE(2)
 LOGICAL ERRFLG

 C---------- INITIALIZE
 ERRFLG = .TRUE.
 OPENFILE(1) = 10000
 OPENFILE(2) = 10001
 IF ( IFLAG ) CALL REG_FILE(OPENFILE,2)
 CALL RD_SYSTEM(REPFLG)
 OPEN

 C--------- FOR REPORT
 WRITE(10000,*) ‘* TIME =’, TIME
 IF ( REPFLG .EQ. 1 ) WRITE(10000,*) ‘* PENETRATION =’, PEN

 C---------- PROGRAM
 CALL SYSFNC(‘DX’,MKID,2,DIST,ERRFLG)
 CALL ERRMES(ERRFLG,’SYSFNC_DX$’,1,’CONTACT$’)
 WRITE(10001,*) ‘* DISTANCE X =’, DIST
 IF ( DIST .EQ. 0.0D0 ) THEN
   ERRFLG = .FALSE.
 ELSE
   A = 100.0D0 / DIST
 ENDIF
 CALL ERRMES(ERRFLG,’DEVIDED BY ZERO$’,1,’CONTACT$’)

 RETURN
 END