include include # RPRINTX -- print reseau mask coordinates in appropriate grid layout # # D. Giaretta, 01-Aug-1987 Original SPP version # Phil Hodge, 28-Feb-1990 Add option to print simple 2-col list. procedure t_rprintx() char input[SZ_FNAME] # input reseau file, without whitespace char entry[SZ_R_PATTERN] # first entry/pattern bool plain # plain 2-col output? #-- pointer rp # reseau file structure pointer rentp # current entry structurs pointer rs_open() # reseau file open structure pointer rs_template(), rlist # res entry template pointers int rs_readr(), rs_list() # reading res entries int nowhite() # strip whitespace int pagewidth # curent pagewidth int envgeti() bool clgetb() errchk rs_open, rs_template, rs_list, rs_readr errchk clgeti, envgeti begin rp = NULL # get terminal line length pagewidth = envgeti("ttyncols") call clgstr( "input", input, SZ_FNAME) if ( nowhite ( input, input, SZ_FNAME ) == 0 ) call error( 0, "input file must be given") call clgstr( "entry", entry, SZ_R_PATTERN) plain = clgetb ("plain") # open file rp = rs_open( input, READ_ONLY, 0) # get space for res. info call rs_alloc( rp, TY_REAL, rentp) # expand template rlist = rs_template( rp, entry) # loop over required entries while ( rs_readr( rp, rentp, EOS, rs_list(rlist) ) != RES_F_NONEXTENTRY) { # print the new entry call xrsm_print( rp, rentp, input, pagewidth, plain, Memr[RES_XPT(rentp)], Memr[RES_YPT(rentp)], Memb[RES_FPT(rentp)] ) } # close the files call rs_close( rp ) end # XRSM_PRINT -- prints reseau entry coords in grid layout procedure xrsm_print( rp, rentp, input, pagewidth, plain, resx, resy, nullres ) pointer rp # i: res. file pointer pointer rentp # i: res entry pointer char input[SZ_FNAME] # i: name of reseau file int pagewidth # i: page width bool plain # i: plain 2-column output? real resx[ARB] # i: x coords real resy[ARB] # i: y coords bool nullres[ARB] # i: is coord null? #-- int nrows, ncols char msg1[SZ_RES_MESS], msg2[SZ_RES_MESS] char msg3[SZ_RES_MESS] char datetime[SZ_R_TIME] int i, j, k, m int nt1, nt2 int inc begin ncols = RES_ENT_NCOLS(rentp) nrows = RES_ENT_NROWS(rentp) if (plain) { # Print the X & Y coordinates in one pair of columns. call printf ("# table `%s', entry `%s'\n") call pargstr (input) call pargstr (RES_ENT_ENTRY(rentp)) do k = 1, ncols*nrows { call printf ("%15.4f %15.4f\n") call pargr (resx[k]) call pargr (resy[k]) } return # done } # set up headers for printing call sprintf( msg1, SZ_RES_MESS, " File %s \n \n") call pargstr( input ) call rs_cnvtime( rentp, datetime, SZ_R_TIME) call sprintf( msg2, SZ_RES_MESS, " Run entry: %s , dated %s , history* %s *\n \n") call pargstr( RES_ENT_ENTRY(rentp) ) call pargstr( datetime ) call pargstr( RES_ENT_TRACKING(rentp) ) call sprintf( msg3, SZ_RES_MESS, " Size Field: %8.2f %8.2f %8.2f %8.2f \n \n") call pargr( RES_ENT_SFIELD1(rentp)) call pargr( RES_ENT_SFIELD2(rentp)) call pargr( RES_ENT_SFIELD3(rentp)) call pargr( RES_ENT_SFIELD4(rentp)) # calculate page parameters nt1 = 1 inc = min((pagewidth - 13)/13, RES_ENT_NCOLS(rentp)) nt2 = nt1+inc-1 # Now print positions in tabular form while (nt1 .le. ncols){ # start newpage call printf("\f") call printf( msg1) call printf( msg2) call printf( msg3) call printf( " COLUMN ") for (i = nt1; i<= nt2 ; i=i+1){ call printf( "%13d") call pargi(i) } call printf("\n") call printf( " ROW \n") for (j=1 ; j<=nrows ; j=j+1){ call printf( " LINE ") call printf("%4d") call pargi(j) for (k = nt1; k<= nt2 ; k=k+1){ m = (j-1)*ncols + k if (!nullres[m]){ call printf(" %12.2f") call pargr(resy[m]) }else{ call printf(" . ") } } call printf("\n") call printf( " SAMPLE ") for (k = nt1; k<= nt2 ; k=k+1){ m = (j-1)*ncols+k if (!nullres[m]){ call printf(" %12.2f") call pargr(resx[m]) }else{ call printf(" . ") } } call printf("\n") call printf("\n") } nt1 = nt2 + 1 nt2 = min(nt2 + inc, ncols) } end