include # rappendx -- append reseau entries from one reseau file to another # # D. Giaretta, 01-Aug-1987 Original SPP version # Phil Hodge, 02-Nov-1990 If output table does not exist, create it. procedure t_rappendx() char input[SZ_FNAME] # input file to take entries char entry[SZ_R_PATTERN] # entry template char output[SZ_FNAME] # output file to append entries #-- pointer rpout, rpin # res. structure pointers pointer rentp # res. entry structure bool rs_check(), streq() pointer rs_open(), rs_template(), rlist int rs_readr(), rs_list() int tbtacc() begin rpin = NULL rpout = NULL call clgstr( "input", input, SZ_FNAME) call clgstr( "entry", entry, SZ_R_PATTERN) call clgstr( "output", output, SZ_FNAME) call tbtext (input, input, SZ_FNAME) # append default extension call tbtext (output, output, SZ_FNAME) if (streq (input, output)) call error (1, "cannot append in place") # Open input & output tables. If the output table does not exist, # create it with the same format as the input. rpin = rs_open (input, READ_ONLY, NULL) if (tbtacc (output) == YES) { # does it exist? rpout = rs_open (output, READ_WRITE, NULL) if ( !rs_check( rpout, RES_NROWS(rpin), RES_NCOLS(rpin) ) ) call error( 0, "reseau tables must have same grid size" ) } else { rpout = rs_open (output, NEW_COPY, rpin) } # get space for coords call rs_alloc( rpin, TY_REAL, rentp) # loop over requested entries rlist = rs_template( rpin, entry) while ( rs_readr( rpin, rentp, EOS, rs_list(rlist) ) != RES_F_NONEXTENTRY ) call rs_write ( rpout, rentp, 0) # write entry out # close the files call rs_close(rpout) call rs_close(rpin) end