1 SUB HDDWRB(field$(), err.msg$) 2 ! 3 ! write back flow and pipe diameter information following a Hardy Cross run 4 ! 5 COMMON (FCSERR) err1%, err2% 6 ! TRUTH.B4S 7 .DEFINE .TRUE%=-1% 8 .DEFINE .FALSE%=0% 9 ! 10 ! {HDDDEF.B4S} 11 ! 12 .DEFINE .pipe.chan% = 21% 13 .DEFINE .node.chan% = 22% 14 .DEFINE .loop.chan% = 23% 15 .DEFINE .tf.out.chan% = 24% 16 .DEFINE .log.chan% = 25% 17 ! 18 ! 19 ! Constant definitions 20 ! 21 .DEFINE .eof% = -10% 22 .DEFINE .max.args% = 21% 23 .DEFINE .tf.bufsiz% = 128% 24 .DEFINE .cmd.line.siz% = 128% 25 .DEFINE .node.buf.siz% = 52% 26 .DEFINE .pipe.buf.siz% = 30% 27 .DEFINE .loop.buf.siz% = 42% ! must be (2 * .max.nodes% + 2) 28 ! 29 .DEFINE .max.nodes% = 20% 30 ! 31 ! {HDDMAP} 32 ! 33 ! buffers/maps 34 ! 35 MAP (NODES) node$ = .node.buf.siz% 36 MAP (NODES) n%(4%), ! connected nodes & ! -ve denotes blocked off & ! zero means no node & nodeflow, ! drawoff from node - litres/sec & xnode, ynode,! node coords & elevation, ! reduced level at node (m - AHD)) & resid.head, ! head at the node (m) & procflag% ! bit set means branch "done" 37 ! 38 MAP (PIPES) pipe$ = .pipe.buf.siz% 39 MAP (PIPES) node1%, node2%, diam, length, pipeflow 40 ! 41 ! note - pipeflow is +ve in direction node1 -> node2 42 ! 43 MAP (LOOPS) loop$ = .loop.buf.siz% 44 MAP (LOOPS) loop%, l.node%(.max.nodes%) 45 ! 46 MAP (INBUF) inbuf$ = 128% 47 MAP (CMDBUF) command.buffer$ = .cmd.line.siz% 48 ! 49 COMMON (SETUP) in.put%, input%, pipe.coeff, & node.file.open%, pipe.file.open%, & loop.file.open%, & echo%, first%, ask%, help%, & node.inp%, pipe.inp%, loop.inp%, line.inp%, & heads%, flows%, lo.op%, co.eff%, & loopdata%, results%, spare1%, & debug%, debug1%, debug2%, & more.data%, not.finished% 50 ! 51 ! 52 ! we have a line with loop 53 ! pipe 54 ! diam 55 ! flow 56 ! 57 ! take each line in turn (don't worry if we over-write a record due to the pipe occurring twice) 58 ! the FLOW will be in the direction of the LOOP. We thus have to see which sense the loop is 59 ! in relation to the original pipe as defined by NODE1% and NODE2%, and apply it to the flow 60 ! before writing the flow back to the pipe record. 61 ! 62 pi.pe% = val(field$(2%)) 63 lo.op% = val(field$(1%)) 64 ! 65 ! print "WRB: pi.pe%, lo.op%"; pi.pe%; lo.op% 66 ! 67 CALL GET.(.pipe.chan%, pipe$, pi.pe%) ! get the pipe record into the buffer 68 ! 69 diam = val(field$(4%)) ! over-write the diameter from the LINES record 70 ! 71 CALL GET.(.loop.chan%, loop$, lo.op%) ! get the loop record into the loop buffer 72 ! 73 nod% = 0% 74 ! 75 WHILE l.node%(nod%) 76 n1.index% = nod% IF (l.node%(nod%) = node1%) 77 n2.index% = nod% IF (l.node%(nod%) = node2%) 78 nod% = nod% + 1% 79 NEXT 80 ! 81 IF (((n2.index% - n1.index%) = 1%) OR ((n2.index% = 0%) AND (n1.index% > n2.index%))) & THEN sense% = 1% & ELSE sense% = -1% 82 ! 83 pipeflow = sense% * val(field$(5%)) 84 ! print "loop, pipe, sense, q: "; lo.op%, pi.pe%, sense%, pipeflow 85 ! 86 CALL PUT.(.pipe.chan%, pipe$, pi.pe%) ! write out the pipe record 87 ! 88 SUBEND