📄 f2c.ps
字号:
10 R f( data, the)2 369(For numeric variables initialized by character)5 1825 2 720 4732 t10 CW f(-W)2942 4732 w10 R f( num-)1 264(option speci\256es the \(machine-dependent!\))3 1686 2 3090 4732 t( option takes a numeric argument, as in)7 1577( This)1 229( discussed in \2476.)3 664(ber of characters per word and is further)7 1616 4 720 4852 t10 CW f(-W8)4832 4852 w10 R f(;)5012 4852 w(such an option must be listed either separately or at the end of a string of other options, as in)19 3690 1 720 4972 t9 CW f(f2c -C++RPW8 *.f)2 864 1 1008 5132 t10 B f(5. TRANSLATION DETAILS)2 1299 1 720 5372 t10 I f(F 2c)1 163 1 970 5528 t10 R f(is based on the ancient)4 960 1 1172 5528 t10 I f(f)2171 5528 w10 R f( compiler produced a C parse-tree,)5 1449( That)1 247(77 Fortran compiler of [6].)4 1129 3 2215 5528 t( compiler has)2 550( The)1 211( converted into input for the second pass of the portable C compiler \(PCC\) [9].)14 3227(which it)1 332 4 720 5648 t( it provided us)3 578( Thus,)1 276( of many current Fortran compilers.)5 1430(been used for many years and is the direct ancestor)9 2036 4 720 5768 t( converter)1 401( The)1 205( base of Fortran knowledge and a nearly complete C representation.)10 2702(with a solid)2 469 4 720 5888 t10 I f(f 2c)1 138 1 4522 5888 t10 R f(is a copy)2 355 1 4685 5888 t(of the)1 241 1 720 6008 t10 I f(f)997 6008 w10 R f( program being)2 634(77 Fortran compiler which has been altered to print out a C representation of the)14 3365 2 1041 6008 t( program)1 371(converted. The)1 631 2 720 6128 t10 I f(f 2c)1 138 1 1755 6128 t10 R f(is a)1 144 1 1926 6128 t10 I f(horror)2103 6128 w10 R f( are only)2 363( Users)1 284( and hacked unmercifully.)3 1063(, based on ancient code)4 960 4 2370 6128 t(supposed to look at its C output, not at its appalling inner workings.)12 2712 1 720 6248 t10 R f(Here are some examples that illustrate)5 1552 1 970 6404 t10 I f(f 2c)1 138 1 2552 6404 t10 R f( short but)2 390( starters, it is helpful to see a)7 1178( For)1 194('s translations.)1 588 4 2690 6404 t(complete example:)1 757 1 720 6524 t10 I f(f 2c)1 138 1 1502 6524 t10 R f(turns the Fortran inner product routine)5 1534 1 1665 6524 t10 R f(October 8, 1991)2 646 1 2544 7560 tcleartomarkshowpagesaveobj restore%%EndPage: 7 8%%Page: 8 9/saveobj save defmark9 pagesetup10 R f(- 8 -)2 166 1 2797 480 t9 CW f(FUNCTION DOT\(N,X,Y\))1 1026 1 1332 820 t(INTEGER N)1 486 1 1332 920 t(REAL X\(N\),Y\(N\))1 756 1 1332 1020 t(DOT = 0)2 378 1 1332 1120 t(DO 10 I = 1, N)5 756 1 1332 1220 t( = DOT + X\(I\)*Y\(I\))4 972(10 DOT)1 486 2 1116 1320 t(END)1332 1420 w10 R f(into)720 1622 w9 CW f( 0:07:02\).)1 594(/* dot.f -- translated by f2c \(version of 28 August 1991)10 3024 2 1008 1804 t(You must link the resulting object file with the libraries:)9 3186 1 1170 1904 t( that order\))2 648( \(in)1 324(-lF77 -lI77 -lm -lc)3 1026 3 1440 2004 t(*/)1008 2104 w(#include "f2c.h")1 864 1 1008 2304 t(doublereal dot_\(n, x, y\))3 1296 1 1008 2504 t(integer *n;)1 594 1 1008 2604 t(real *x, *y;)2 648 1 1008 2704 t({)1008 2804 w(/* System generated locals */)4 1566 1 1224 2904 t(integer i__1;)1 702 1 1224 3004 t(real ret_val;)1 702 1 1224 3104 t(/* Local variables */)3 1134 1 1224 3304 t(static integer i;)2 918 1 1224 3404 t(/* Parameter adjustments */)3 1458 1 1224 3604 t(--y;)1224 3704 w(--x;)1224 3804 w(/* Function Body */)3 1026 1 1224 4004 t(ret_val = \(float\)0.;)2 1080 1 1224 4104 t(i__1 = *n;)2 540 1 1224 4204 t(for \(i = 1; i <= i__1; ++i\) {)8 1566 1 1224 4304 t(/* L10: */)2 540 1 1008 4404 t(ret_val += x[i] * y[i];)4 1242 1 1440 4504 t(})1224 4604 w(return ret_val;)1 810 1 1224 4704 t(} /* dot_ */)3 648 1 1008 4804 t10 R f( by f2c'' comment and a)5 1048(The translated C always starts with a ``translated)7 2040 2 720 5106 t10 CW f(#include)3847 5106 w10 R f(of)4366 5106 w10 CW f(f2c.h)4488 5106 w10 R f(.)4788 5106 w10 I f(F 2c)1 163 1 4877 5106 t10 R f( an underscore to the external name)6 1418(forces the variable and procedure names to lower-case and appends)9 2697 2 720 5226 t10 CW f(dot)4860 5226 w10 R f( parameter adjustments ``)3 1041( The)1 213(\(to avoid possible con\257icts with library names\).)6 1955 3 720 5346 t10 CW f(--x)3929 5346 w10 R f('' and ``)2 342 1 4109 5346 t10 CW f(--y)4451 5346 w10 R f('' account)1 409 1 4631 5346 t( labels are retained in comments for orienteering purposes.)8 2342( Unused)1 356(for the fact that C arrays start at index 0.)9 1622 3 720 5466 t( into references to the local variable)6 1483(Within a function, Fortran references to the function name are turned)10 2837 2 720 5586 t10 CW f(ret_val)720 5706 w10 R f( the)1 150( Unless)1 325(, which holds the value to be returned.)7 1549 3 1140 5706 t10 CW f(-R)3192 5706 w10 R f(option is speci\256ed,)2 757 1 3339 5706 t10 I f(f 2c)1 138 1 4123 5706 t10 R f(converts the return)2 752 1 4288 5706 t(type of)1 291 1 720 5826 t10 CW f(real)1047 5826 w10 R f(function values to)2 740 1 1324 5826 t10 CW f(doublereal)2101 5826 w10 R f( using the C ``op='' operators leads to greater)8 1920(. Because)1 419 2 2701 5826 t(ef\256ciency on some machines,)3 1199 1 720 5946 t10 I f(f 2c)1 138 1 1950 5946 t10 R f(looks for opportunities to use these operators, as in the line ``)11 2502 1 2118 5946 t10 CW f(ret_val)4620 5946 w(+= ...)1 360 1 720 6066 t10 R f('' above.)1 379 1 1080 6066 t10 I f(F 2c)1 163 1 970 6235 t10 R f( of evaluation)2 567(generally dispenses with super\257uous parentheses: ANSI C speci\256es a clear order)10 3307 2 1166 6235 t(for \257oating-point expressions, and)3 1401 1 720 6355 t10 I f(f 2c)1 138 1 2156 6355 t10 R f(uses the ANSI C rules to decide when parentheses are required to)11 2712 1 2328 6355 t( compilers are free to violate parenthe-)6 1605( Non-ANSI)1 497(faithfully translate a parenthesized Fortran expression.)5 2218 3 720 6475 t(ses; by default,)2 614 1 720 6595 t10 I f(f 2c)1 138 1 1365 6595 t10 R f( to foil pernicious non-)4 936(does not attempt to break an expression into several statements)9 2570 2 1534 6595 t( for example, the Fortran)4 995( Thus,)1 275(ANSI C compilers.)2 769 3 720 6715 t9 CW f(x = a*\(b*c\))2 594 1 1278 6897 t(y = \(a*b\)*c)2 594 1 1278 6997 t10 R f(becomes)720 7199 w10 R f(October 8, 1991)2 646 1 2544 7560 tcleartomarkshowpagesaveobj restore%%EndPage: 8 9%%Page: 9 10/saveobj save defmark10 pagesetup10 R f(- 9 -)2 166 1 2797 480 t9 CW f(x = a * \(b * c\);)6 864 1 1224 820 t(y = a * b * c;)6 756 1 1224 920 t10 R f(The)720 1100 w10 CW f(-kr)912 1100 w10 R f(and)1129 1100 w10 CW f(-krd)1310 1100 w10 R f(options cause)1 554 1 1587 1100 t10 I f(f 2c)1 138 1 2179 1100 t10 R f(to use temporary variables to force correct evaluation order with)9 2685 1 2355 1100 t(non-ANSI C compilers.)2 952 1 720 1220 t10 R f(Fortran I/O is complicated; like)4 1296 1 970 1376 t10 I f(f)2301 1376 w10 R f(77,)2345 1376 w10 I f(f 2c)1 138 1 2505 1376 t10 R f(converts a Fortran I/O statement into calls on the Fortran)9 2362 1 2678 1376 t(I/O library)1 426 1 720 1496 t10 I f(libI77)1173 1496 w10 R f( Fortran)1 321(. For)1 216 2 1412 1496 t10 CW f(read)1976 1496 w10 R f(s and)1 210 1 2216 1496 t10 CW f(write)2453 1496 w10 R f( to)1 104(s, there is generally one call to start the statement, one)10 2183 2 2753 1496 t( the Fortran declarations)3 973( Given)1 294(end it, and one for each item read or written.)9 1776 3 720 1616 t9 CW f(integer count\(10\))1 918 1 1332 1776 t(real val\(10\))1 648 1 1332 1876 t10 R f(the Fortran)1 441 1 720 2056 t9 CW f(read\(*,*\) count, val)2 1080 1 1332 2216 t10 R f(is turned into some header lines:)5 1296 1 720 2396 t9 CW f( = 3;)2 270( _3)1 130(static integer c_)2 918 3 1008 2556 t( = 10;)2 324( _10)1 184(static integer c_)2 918 3 1008 2656 t( = 4;)2 270( _4)1 130(static integer c_)2 918 3 1008 2756 t(. . .)2 270 1 1008 2856 t(/* Builtin functions */)3 1242 1 1224 2956 t(integer s_rsle\(\), do_lio\(\), e_rsle\(\);)3 1998 1 1224 3056 t(. . .)2 270 1 1008 3156 t(/* Fortran I/O blocks */)4 1296 1 1224 3256 t( = { 0, 5, 0, 0, 0 };)8 1134( _1)1 130(static cilist io_)2 918 3 1224 3356 t10 R f(and the executable lines)3 956 1 720 3536 t9 CW f(s_rsle\(&io_ _1\);)1 832 1 1008 3696 t( \(char *\)&count[0], \(ftnlen\)sizeof\(integer\)\);)3 2430( _10,)1 238( &c_)1 216(do_lio\(&c_ _3,)1 724 4 1008 3796 t( \(char *\)&val[0], \(ftnlen\)sizeof\(real\)\);)3 2160( _10,)1 238( &c_)1 216(do_lio\(&c_ _4,)1 724 4 1008 3896 t(e_rsle\(\);)1008 3996 w10 R f(Implicit Fortran do-loops, e.g.)3 1205 1 720 4176 t9 CW f(read\(*,*\) \(count\(i\), val\(i\), i = 1, 10\))6 2106 1 1332 4336 t10 R f(get turned into explicit C loops:)5 1270 1 720 4516 t9 CW f(s_rsle\(&io_ _4\);)1 832 1 1008 4676 t(for \(i = 1; i <= 10; ++i\) {)8 1458 1 1008 4776 t( \(char *\)&count[i - 1], \(ftnlen\)sizeof\(integer\)\);)5 2646( _1,)1 184( &c_)1 216(do_lio\(&c_ _3,)1 724 4 1224 4876 t( \(char *\)&val[i - 1], \(ftnlen\)sizeof\(real\)\);)5 2376( _1,)1 184( &c_)1 216(do_lio\(&c_ _4,)1 724 4 1224 4976 t(})1008 5076 w(e_rsle\(\);)1008 5176 w10 R f(The Fortran)1 478 1 720 5356 t10 CW f(end=)1227 5356 w10 R f(and)1496 5356 w10 CW f(err=)1669 5356 w10 R f( as they require tests to be)6 1067(speci\256ers make the resulting C even less readable,)7 2035 2 1938 5356 t( example,)1 388(inserted. For)1 530 2 720 5476 t9 CW f(read\(*,*,err=10\) count, val)2 1458 1 1332 5636 t(10 continue)1 702 1 1062 5736 t10 R f(becomes)720 5916 w10 R f(October 8, 1991)2 646 1 2544 7560 tcleartomarkshowpagesaveobj restore%%EndPage: 9 10%%Page: 10 11/saveobj save defmark11 pagesetup10 R f(- 10 -)2 216 1 2772 480 t9 CW f( _1\);)1 238( = s_rsle\(&io_)2 756(i_ _1)1 238 3 1224 820 t( != 0\) {)3 432( _1)1 130(if \(i_)1 324 3 1224 920 t(goto L10;)1 486 1 1440 1020 t(})1224 1120 w( \(char *\)&count[0], \(ftnlen\)sizeof\(integer\)\);)3 2430( _10,)1 238( &c_)1 216( _3,)1 184( = do_lio\(&c_)2 702(i_ _1)1 238 6 1224 1220 t( != 0\) {)3 432( _1)1 130(if \(i_)1 324 3 1224 1320 t(goto L10;)1 486 1 1440 1420 t(})1224 1520 w( \(char *\)&val[0], \(ftnlen\)sizeof\(real\)\);)3 2160( _10,)1 238( &c_)1 216( _4,)1 184( = do_lio\(&c_)2 702(i_ _1)1 238 6 1224 1620 t( != 0\) {)3 432( _1)1 130(if \(i_)1 324 3 1224 1720 t(goto L10;)1 486 1 1440 1820 t(})1224 1920 w( = e_rsle\(\);)2 648(i_ _1)1 238 2 1224 2020 t(L10:)1008 2120 w(;)1224 2220 w10 R f(A Fortran routine containing)3 1146 1 970 2400 t10 I f(n)2141 2400 w10 CW f(entry)2216 2400 w10 R f(statements is turned into)3 975 1 2541 2400 t10 I f(n)3542 2400 w10 S f(+)3632 2400 w10 R f(2 C functions, a big one contain-)6 1313 1 3727 2400 t(ing the translation of everything but the)6 1630 1 720 2520 t10 CW f(entry)2383 2520 w10 R f(statements, and)1 624 1 2716 2520 t10 I f(n)3373 2520 w10 S f(+)3463 2520 w10 R f(1 little ones that invoke the big one.)7 1482 1 3558 2520 t( to the big one to tell it where to begin; the big one starts with a)16 2676(Each little one passes a different integer)6 1644 2 720 2640 t( instance, the Fortran)3 843( For)1 189(switch that branches to the code for the appropriate entry.)9 2300 3 720 2760 t9 CW f(function sine\(x\))1 864 1 1332 2920 t(data pi/3.14159265358979324/)1 1512 1 1332 3020 t(sine = sin\(x\))2 702 1 1332 3120 t(return)1332 3220 w(entry cosneg\(y\))1 810 1 1332 3320 t(cosneg = cos\(y+pi\))2 972 1 1332 3420 t(return)1332 3520 w(end)1332 3620 w10 R f(is turned into the big procedure)5 1251 1 720 3800 t9 CW f( x, y\))2 324( _,)1 130(doublereal sine_0_\(n_)1 1134 3 1008 3960 t( _;)1 130(int n_)1 324 2 1008 4060 t(real *x, *y;)2 648 1 1008 4160 t({)1008 4260 w(/* Initialized data */)3 1188 1 1224 4360 t(static real pi = \(float\)3.14159265358979324;)4 2376 1 1224 4560 t(/* System generated locals */)4 1566 1 1224 4760 t(real ret_val;)1 702 1 1224 4860 t(/* Builtin functions */)3 1242 1 1224 5060 t(double sin\(\), cos\(\);)2 1080 1 1224 5160 t( {)1 108(switch\(n_ _\))1 616 2 1224 5360 t(case 1: goto L_cosneg;)3 1188 1 1440 5460 t(})1440 5560 w(ret_val = sin\(*x\);)2 972 1 1224 5760 t(return ret_val;)1 810 1 1224 5860 t(L_cosneg:)1008 6060 w(ret_val = cos\(*y + pi\);)4 1242 1 1224 6160 t(return ret_val;)1 810 1 1224 6260 t(} /* sine_ */)3 702 1 1008 6360 t10 R f(and the little invoking procedures)4 1343 1 720 6540 t10 R f(October 8, 1991)2 646 1 2544 7560 tcleartomarkshowpagesaveobj restore%%EndPage: 10 11%%Page: 11 12/saveobj save defmark12 pagesetup10 R f(- 11 -)2 216 1 2772 480 t9 CW f(doublereal sine_\(x\))1 1026 1 1008 820 t(real *x;)1 432 1 1008 920 t({)1008 1020 w(return sine_0_\(0, x, \(real *\)0\);)4 1728 1 1224 1120 t(})1224 1220 w(doublereal cosneg_\(y\))1 1134 1 1008 1420 t(real *y;)1 432 1 1008 1520 t({)1008 1620 w(return sine_0_\(1, \(real *\)0, y\);)4 1728 1 1224 1720 t(})1224 1820 w10 R f(Fortran)720 2002 w10 CW f(common)1039 2002 w10 R f(regions are turned into C)4 993 1 1424 2002 t10 CW f(struct)2442 2002 w10 R f( example, the Fortran declarations)4 1361(s. For)1 253 2 2802 2002 t9 CW f(common /named/ c, d, r, i, l)6 1512 1 1332 2164 t(complex c\(10\))1 702 1 1332 2264 t(double precision d\(10\))2 1188 1 1332 2364 t(real r\(10\))1 540 1 1332 2464 t(integer i\(10\))1 702 1 1332 2564 t(logical m\(10\))1 702 1 1332 2664 t(if \(m\(i\(2\)\)\) d\(3\) = d\(4\)/d\(5\))4 1566 1 1332 2864 t10 R f(result in)1 325 1 720 3046 t9 CW f(struct {)1 432 1 1008 3208 t(complex c[10];)1 756 1 1224 3308 t(doublereal d[10];)1 918 1 1224 3408 t(real r[10];)1 594 1 1224 3508 t(integer i[10];)1 756 1 1224 3608 t(logical m[10];)1 756 1 1224 3708 t(} named_;)1 486 1 1008 3808 t(#define named_1 named_)2 1188 1 1008 4008 t(. . .)2 270 1 1008 4108 t(if \(named_1.m[named_1.i[1] - 1]\) {)4 1836 1 1224 4308 t(named_1.d[2] = named_1.d[3] / named_1.d[4];)4 2322 1 1440 4408 t(})1440 4508 w10 R f(Under the)1 396 1 720 4690 t10 CW f(-p)1141 4690 w10 R f(option, the above)2 691 1 1286 4690 t10 CW f(if)2002 4690 w10 R f(statement becomes more readable:)3 1377 1 2147 4690 t9 CW f(. . .)2 270 1 1008 4852 t(#define c \(named_1.c\))2 1134 1 1008 4952 t(#define d \(named_1.d\))2 1134 1 1008 5052 t(#define r \(named_1.r\))2 1134 1 1008 5152 t(#define i \(named_1.i\))2 1134 1 1008 5252 t(#define m \(named_1.m\))2 1134 1 1008 5352 t(. . .)2 270 1 1008 5452 t(if \(m[i[1] - 1]\) {)4 972 1 1224 5552 t(d[2] = d[3] / d[4];)4 1026 1 1440 5652 t10 R f(If the above)2 476 1 720 5834 t10 CW f(common)1221 5834 w10 R f(block were involved in a)4 987 1 1606 5834 t10 CW f(block data)1 600 1 2618 5834 t10 R f(subprogram, e.g.)1 671 1 3243 5834 t9 CW f(block data)1 540 1 1332 5996 t(common /named/ c, d, r, i, l, m)7 1674 1 1332 6096 t(complex c\(10\))1 702 1 1332 6196 t(double precision d\(10\))2 1188 1 1332 6296 t(real r\(10\))1 540 1 1332 6396 t(integer i\(10\))1 702 1 1332 6496 t(logical m\(10\))1 702 1 1332 6596 t(data c\(1\)/\(1.0,0e0\)/, d\(2\)/2d0/, r\(3\)/3e0/, i\(4\)/4/,)4 2808 1 1332 6696 t(* m\(5\)/.false./)1 1026 1 1278 6796 t(end)1332 6896 w10 R f(then the)1 345 1 720 7078 t10 CW f(struct)1116 7078 w10 R f(would begin ``)2 640 1 1527 7078 t10 CW f(struct named_1_ {)2 1072 1 2167 7078 t10 R f('', and)1 287 1 3239 7078 t10 I f(f 2c)1 138 1 3578 7078 t10 R f(would issue a more elaborate)4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -