PROGRAM CONVERT_F_TO_ASCII C C This program converts FORTRAN unformatted CAPARS v4.0 DEM data C files to ASCII files for conversion from/to UNIX and Linux. C C by John Ciolek Jr. 5-30-2000 from CONVERT_DEM C C IMPLICIT NONE C C The MODEL_PARAMETERS include file must appear before any declarations C since it limits the size of most TRAC arrays. C INCLUDE 'MODEL_PARAMETERS.INC' INCLUDE 'DEM.INC' CHARACTER*80 OLD_FILE, NEW_FILE CHARACTER*15 STRING INTEGER STATUS, MISSING, GET_DEM, I, J WRITE(6,*) 'Enter the old (binary) data file name: ' READ(5,11) OLD_FILE WRITE(6,*) 'Enter the new (ASCII) file name: ' READ(5,11) NEW_FILE C C Read in the data in FORTRAN binary format. C OPEN(UNIT=40, + STATUS='OLD', + FORM='UNFORMATTED', + FILE=OLD_FILE) READ(UNIT=40) DEM_NUM_COLS READ(UNIT=40) DEM_NUM_ROWS READ(UNIT=40) DEM_BASEX READ(UNIT=40) DEM_BASEY READ(UNIT=40) DEM_INC READ(UNIT=40) MISSING READ(UNIT=40) ((DEM_Z(I,J),I=1,DEM_NUM_COLS), + J=1,DEM_NUM_ROWS) CLOSE(UNIT=40) 11 FORMAT(A80) GET_DEM = -1 OPEN(UNIT=37, + FILE=NEW_FILE, + STATUS='NEW', + IOSTAT=STATUS, + FORM='UNFORMATTED') IF (STATUS .EQ. 0) THEN WRITE(UNIT=37,FMT=100,IOSTAT=STATUS) STRING, DEM_NUM_COLS IF (STATUS .NE. 0) GOTO 9999 WRITE(UNIT=37,FMT=100,IOSTAT=STATUS) STRING, DEM_NUM_ROWS IF (STATUS .NE. 0) GOTO 9999 WRITE(UNIT=37,FMT=101,IOSTAT=STATUS) STRING, DEM_BASEX IF (STATUS .NE. 0) GOTO 9999 WRITE(UNIT=37,FMT=103,IOSTAT=STATUS) STRING, DEM_BASEY IF (STATUS .NE. 0) GOTO 9999 WRITE(UNIT=37,FMT=102,IOSTAT=STATUS) STRING, DEM_INC IF (STATUS .NE. 0) GOTO 9999 WRITE(UNIT=37,FMT=100,IOSTAT=STATUS) STRING, MISSING IF (STATUS .NE. 0) GOTO 9999 DO DEM_ROW=DEM_NUM_ROWS,1,-1 WRITE(37,*,IOSTAT=STATUS) (DEM_Z(DEM_COL,DEM_ROW), + DEM_COL=1, DEM_NUM_COLS) IF (STATUS .NE. 0) THEN WRITE(6,*) 'Error writing dem data.' GOTO 9999 END IF END DO GET_DEM = 1 END IF 100 FORMAT(A14,I10) 101 FORMAT(A14,F7.0) 102 FORMAT(A14,F6.2) 103 FORMAT(A14,F8.0) 9999 CLOSE(UNIT=37) END