input_case nil$ % Fortran form output % ------------------- % load_package gentran; % code GENeration and TRANslation load_package scope; % Source Code Optimization PackagE % The last command loads both gentran and scope fortlinelen!*:=60$ % output line length maxexpprintlen!*:=300$ % max output expression length j:=3$ b:=x+y$ gentran a(j):=b$ % translation of assignment to Fortran gentran a(j):=:b$ % generation of right-hand side gentran a(j)::=b$ % substitution of index in left-hand side gentran a(j)::=:b$ % both for i:=1:5 do gentran a(i)::=:i$ gentran for i:=1:5 do a(i)::=:i$ gentran am:=mat((x1,x2),(x3,x4))$ % matrix assignment gentranout "prog.for",t$ % program output to prog.for and terminal gentran << b:=:(x+y+z)^6; % intermediate variables are generated if x>0 then y:=x else y:=-x; % translation of if-statement literal "c calculating the sum",cr!*; s:=for i:=1:5 sum a(i); literal " write (6,1) s",cr!*, "1 format(1x,f10.5)",cr!*; subr(s) % procedure call >>$ % translation of a procedure with a loop gentran procedure exp1(x,eps)$ begin s:=1; u:=x; i:=1; repeat <> until abs(u)>$ gentran a:=:(sin(x)^2+cos(x)^2)^4$ gentran b:=:(sin(x)^2+cos(x)^2)^5$ makedecs$ % optimization on acinfo; % number of operations before and after optimization delaydecs$ gentran declare <>$ delayopts$ gentran a:=:(sin(x)^2+cos(x)^2)^4$ gentran b:=:(sin(x)^2+cos(x)^2)^5$ makeopts$ makedecs$ off acinfo; gentranin "prog.tem"$ % program template gentranshut "prog.for"$ % closing prog.for % Pascal form output gentranlang!*:='pascal$ delaydecs$ gentran declare <>$ gentran a:=:(x+y)^2$ makedecs$ end;