PROGRAM DEM_TO_AVS C C Version 1.0 (Released 6-24-2002 by John Ciolek Jr., AlphaTRAC, Inc.) C C This program converts CAPARS unformatted DEM data files to ascii C AVS format for use with AVS/Express. C C Modification History: C C Created by John Ciolek Jr. from dem_to_grads and surface_to_avs C on 06-24-2002. 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*240 OLD_FILE CHARACTER*15 STRING real MISSING INTEGER STATUS, GET_DEM INTEGER ROW_DATA_1(6000), ROW_DATA_2(6000) INTEGER OUT_COL, OUT_ROW, SUM, COUNT INTEGER SKIP_ROWS, SKIP_COLS, OUTPUT_ROWS, OUTPUT_COLS C C Variables for call to get_domain: C INTEGER IIFIN, JJFIN REAL DXFIN, DYFIN, EDGEW, EDGES C C Variables for the avs output: C CHARACTER*240 BASE CHARACTER*200 RELEV_FILE, SURF_FILE, INTER_FILE CHARACTER*200 X_FILE, Y_FILE CHARACTER*200 RELEV_FLD_FILE, SURF_FLD_FILE, + INTER_FLD_FILE INTEGER I, ROW, COL, ID CHARACTER*120 OUT_STRING REAL X_COORD(MAX_DEM_ROWS*MAX_DEM_COLS), + Y_COORD(MAX_DEM_ROWS*MAX_DEM_COLS) C**************************************************************************** C Part 1 - Get the CAPARS DEM file data. C WRITE(6,*) 'Enter the input DEM file name: ' READ(5,11) OLD_FILE 11 FORMAT(A240) OPEN(UNIT=40, + STATUS='OLD', + FORM='UNFORMATTED', + FILE=OLD_FILE) READ(UNIT=40) DEM_NUM_COLS WRITE(6,601) DEM_NUM_COLS 601 FORMAT(' Number columns: ',I10) READ(UNIT=40) DEM_NUM_ROWS WRITE(6,602) DEM_NUM_ROWS 602 FORMAT(' Number rows: ',I10) READ(UNIT=40) DEM_BASEX WRITE(6,603) DEM_BASEX 603 FORMAT(' Western edge: ',F8.1) READ(UNIT=40) DEM_BASEY WRITE(6,604) DEM_BASEY 604 FORMAT(' Southern edge: ',F9.1) READ(UNIT=40) DEM_INC WRITE(6,605) DEM_INC 605 FORMAT(' spacing increment = ',F11.4) READ(UNIT=40) MISSING READ(UNIT=40) ((DEM_Z(DEM_COL,DEM_ROW), + DEM_COL=1,DEM_NUM_COLS),DEM_ROW=1,DEM_NUM_ROWS) CLOSE(UNIT=40) C C EndPart 1 - Get the CAPARS DEM file data. C**************************************************************************** C**************************************************************************** C Part 2 - Create the AVS field files C C C Setup file names. C WRITE(6,*) 'Enter the output base file name: ' READ(5,501) BASE 501 FORMAT(A240) RELEV_FILE = BASE(1:INDEX(BASE,' ')-1) // '_relev.dat' X_FILE = BASE(1:INDEX(BASE,' ')-1) // '_coords_x.dat' Y_FILE = BASE(1:INDEX(BASE,' ')-1) // '_coords_y.dat' RELEV_FLD_FILE = BASE(1:INDEX(BASE,' ')-1) // '_relev.fld' OPEN(UNIT=45, + FILE=RELEV_FILE, + STATUS='UNKNOWN', + FORM='FORMATTED') WRITE(UNIT=45,*) ((DEM_Z(DEM_COL,DEM_ROW),DEM_COL=1, + DEM_NUM_COLS),DEM_ROW=1,DEM_NUM_ROWS) CLOSE(UNIT=45) OPEN(UNIT=50, + FILE=X_FILE, + STATUS='UNKNOWN', + FORM='FORMATTED') OPEN(UNIT=51, + FILE=Y_FILE, + STATUS='UNKNOWN', + FORM='FORMATTED') C C Determine the x and y coordinate of the center of C each grid cell. C DO ROW=1,DEM_NUM_ROWS DO COL=1,DEM_NUM_COLS ID = (ROW-1)*DEM_NUM_COLS + COL X_COORD(ID) = DEM_BASEX + + (FLOAT(COL) - 0.5) * DEM_INC Y_COORD(ID) = DEM_BASEY + + (FLOAT(ROW) - 0.5) * DEM_INC END DO END DO WRITE(UNIT=50,*) (X_COORD(I),I=1, + DEM_NUM_COLS*DEM_NUM_ROWS) CLOSE(UNIT=50) WRITE(UNIT=51,*) (Y_COORD(I),I=1, + DEM_NUM_COLS*DEM_NUM_ROWS) CLOSE(UNIT=51) C C Create the avs field file. C OPEN(UNIT=61, + FILE=RELEV_FLD_FILE, + STATUS='UNKNOWN', + FORM='FORMATTED') WRITE(UNIT=61,6102) 6102 FORMAT('# AVS/EXPRESS field file') WRITE(UNIT=61,6103) 6103 FORMAT('#') WRITE(UNIT=61,6104) 6104 FORMAT('ndim=2') WRITE(UNIT=61,6105) DEM_NUM_COLS 6105 FORMAT('dim1=',I5.5) WRITE(UNIT=61,6106) DEM_NUM_ROWS 6106 FORMAT('dim2=',I5.5) WRITE(UNIT=61,6108) 6108 FORMAT('nspace=2') WRITE(UNIT=61,6109) 6109 FORMAT('veclen=1') WRITE(UNIT=61,6110) 6110 FORMAT('data=float') WRITE(UNIT=61,6111) 6111 FORMAT('field=irregular') 6101 FORMAT(A120) OUT_STRING = 'coord 1 file=' // + X_FILE(1:INDEX(X_FILE,' ')-1) // + ' filetype=ascii' WRITE(UNIT=61,6101) OUT_STRING OUT_STRING = 'coord 2 file=' // + Y_FILE(1:INDEX(Y_FILE,' ')-1) // + ' filetype=ascii' WRITE(UNIT=61,6101) OUT_STRING OUT_STRING = 'variable 1 file=' // + RELEV_FILE(1:INDEX(RELEV_FILE,' ')-1) // + ' filetype=ascii' WRITE(UNIT=61,6101) OUT_STRING CLOSE(UNIT=61) C C End Part 4 - Create the AVS field files C**************************************************************************** WRITE(6,*) 'Done' END