(let ((vs (call-with-input-file fname (lambda (ip) (let* ((raddeg (/ 45.0 (atan 1.0))) (degrad (/ raddeg)) (alf1 (* degrad (/ 360.0 (* u NS1)))) (alfmax (* NS1 alf1)) (ndata 0) (atol 1.0e-4) (alfs (map (lambda (n) (list (max 0.0 (- (* n alf1) (* 0.5 alf1) atol)) (min alfmax (+ (* n alf1) (* 0.5 alf1) atol)))) (iota (+ NS1 1)))) (vals (make-vector (* 2 NS1 nsteps u) 0.0))) (let floop ((line (peek-char ip)) (idx 0)) (if (eof-object? line) vals (begin (read-line ip) (set! ndata (string->number (read-line ip))) (do ((line1 (read-line ip) (read-line ip))) ((or (not (string? line1)) (string=? line1 "11502,all_nodal_force")) vals) (let* ((fs (split-string (nosp line1) '(#\,))) (nums (map string->number fs)) (x (list-ref nums 1)) (y (list-ref nums 2)) (tol 1e-3) (alf2 (atan y x)) (nn1 (position (lambda (d) (and (>= alf2 (car d)) (<= alf2 (cadr d)))) alfs)) (nn (if (= nn1 NS1) 0 nn1)) (fact (if (= nn1 NS1) -1.0 1.0)) (r (sqrt (+ (* x x) (* y y)))) (idx3 (+ (* 2 nn) idx)) (idx4 (+ idx3 1))) (if (<= (* 1000.0 r) rmax) (begin (vector-set! vals idx3 (+ (vector-ref vals idx3) (* fact (list-ref nums 4)))) (vector-set! vals idx4 (+ (vector-ref vals idx4) (* fact (list-ref nums 5))))) #f))) (floop (peek-char ip) (+ idx (* 2 u NS1)))))))))))