| 1 |
C Copyright(C) 1999-2020 National Technology & Engineering Solutions |
| 2 |
C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 3 |
C NTESS, the U.S. Government retains certain rights in this software. |
| 4 |
C |
| 5 |
C See packages/seacas/LICENSE for details |
| 6 |
|
| 7 |
C======================================================================= |
| 8 |
SUBROUTINE OPNFIL (IUNIT, INOUT, FFORM, IDAPAR, IERR) |
| 9 |
C======================================================================= |
| 10 |
C --*** OPNFIL *** (ETCLIB) Open a file |
| 11 |
C -- Written by Amy Gilkey - revised 04/20/88 |
| 12 |
C -- |
| 13 |
C --OPNFIL opens an input or output file. The file name is retrieved |
| 14 |
C --with a call to EXNAME. The file is rewound after open. |
| 15 |
C -- |
| 16 |
C --Parameters: |
| 17 |
C -- IUNIT - IN - the file unit number |
| 18 |
C -- INOUT - IN - |
| 19 |
C -- 'I' if input file (status = "old") |
| 20 |
C -- 'O' if output file (status = "new") |
| 21 |
C -- 'S' if scratch file (status = "scratch") |
| 22 |
C -- 'U' if opened with status = "unknown" |
| 23 |
C -- FFORM - IN - the file type: |
| 24 |
C -- 'F' if formatted file |
| 25 |
C -- 'U' if unformatted file |
| 26 |
C -- 'L' if formatted, no carriage control file |
| 27 |
C -- IDAPAR - IN - direct access parameters: |
| 28 |
C -- (1) = number of words in record; 0 if not direct access |
| 29 |
C -- (2) = number of records |
| 30 |
C -- IERR - OUT - the open error status (0 = no error) |
| 31 |
|
| 32 |
C --Routines Called: |
| 33 |
C -- EXNAME - (SUPES) Get filename from unit |
| 34 |
C -- LENSTR - (STRLIB) Get string length |
| 35 |
|
| 36 |
CHARACTER INOUT |
| 37 |
CHARACTER FFORM |
| 38 |
INTEGER IDAPAR(2) |
| 39 |
|
| 40 |
CHARACTER*1024 FILNAM |
| 41 |
CHARACTER*11 FORM |
| 42 |
CHARACTER*7 STAT |
| 43 |
CHARACTER*8 CDUM |
| 44 |
|
| 45 |
IERR = 999 |
| 46 |
CALL EXNAME (IUNIT, FILNAM, LNAM) |
| 47 |
|
| 48 |
IF (FFORM .EQ. 'U') THEN |
| 49 |
FORM = 'UNFORMATTED' |
| 50 |
ELSE |
| 51 |
FORM = 'FORMATTED' |
| 52 |
END IF |
| 53 |
LFORM = LENSTR (FORM) |
| 54 |
|
| 55 |
IF (INOUT .EQ. 'I') THEN |
| 56 |
STAT = 'OLD' |
| 57 |
ELSE IF (INOUT .EQ. 'O') THEN |
| 58 |
STAT = 'NEW' |
| 59 |
ELSE IF (INOUT .EQ. 'U') THEN |
| 60 |
STAT = 'UNKNOWN' |
| 61 |
ELSE IF (INOUT .EQ. 'S') THEN |
| 62 |
STAT = 'SCRATCH' |
| 63 |
ELSE |
| 64 |
IERR = -999 |
| 65 |
GOTO 10 |
| 66 |
END IF |
| 67 |
LSTAT = LENSTR (STAT) |
| 68 |
|
| 69 |
NINREC = IDAPAR(1) |
| 70 |
IF (NINREC .EQ. 0) THEN |
| 71 |
OPEN (UNIT=IUNIT, FILE=FILNAM(:LNAM), FORM=FORM(:LFORM), |
| 72 |
& STATUS=STAT(:LSTAT), IOSTAT = IERR) |
| 73 |
IF (IERR .NE. 0 .AND. INOUT .EQ. 'I') THEN |
| 74 |
call screrr(iunit, filnam, lnam, '...', '...') |
| 75 |
END IF |
| 76 |
ELSE |
| 77 |
NRECS = IDAPAR(2) |
| 78 |
CALL EXPARM (CDUM, CDUM, IDUM, KSCU, KNSU, IDAU) |
| 79 |
IF (IDAU .EQ. 0) THEN |
| 80 |
NICE = 512 |
| 81 |
ELSE |
| 82 |
NICE = (512 * KNSU - KNSU + 1) / KSCU |
| 83 |
END IF |
| 84 |
NBLKS = (NINREC + NICE-1) / NICE |
| 85 |
NINREC = NBLKS * NICE |
| 86 |
IF (IDAU .EQ. 0) THEN |
| 87 |
LREC = (NINREC * KSCU + KNSU-1) / KNSU |
| 88 |
ELSE |
| 89 |
LREC = NINREC |
| 90 |
END IF |
| 91 |
|
| 92 |
IF (INOUT .EQ. 'S') THEN |
| 93 |
STAT = 'unknown' |
| 94 |
LSTAT = LENSTR (STAT) |
| 95 |
END IF |
| 96 |
NSIZE = NINREC * NRECS |
| 97 |
OPEN (UNIT=IUNIT, FILE=FILNAM(:LNAM), FORM=FORM(:LFORM), |
| 98 |
& ACCESS='DIRECT', RECL=LREC, |
| 99 |
& STATUS=STAT(:LSTAT), ERR=10) |
| 100 |
|
| 101 |
END IF |
| 102 |
|
| 103 |
IERR = 0 |
| 104 |
10 CONTINUE |
| 105 |
RETURN |
| 106 |
END |