|
|
1.1 ! root 1: .EQ ! 2: delim $$ ! 3: define f2c % "f\|2c" % ! 4: define F2c % "F\^2c" % ! 5: define libF77 % "libF77" % ! 6: define libI77 % "libI77" % ! 7: define LibF77 % "LibF77" % ! 8: define LibI77 % "LibI77" % ! 9: .EN ! 10: .nr PS 24 ! 11: .nr VS 30 ! 12: .nr PO .5i ! 13: .nr LL 7.5i ! 14: .LP ! 15: .ds CH "\s8\(hy \\n(PN \(hy\s0 ! 16: .ce ! 17: $f2c$ (Stu Feldman, Mark Maimone, Norm Schryer) ! 18: ! 19: .nf ! 20: .ta .5i .8i 1.1i ! 21: Convert Fortran 77 to C ! 22: .sp . 5 ! 23: \(** Portably mix C and Fortran ! 24: \(** Use Fortran source in C environments ! 25: ! 26: .fi ! 27: \s20From cs.purdue.edu!peb Mon Jan 29 15:35:20 EST 1990\s0 ! 28: .sp .5 ! 29: BTW, I think f2c has the potential to be the best idea since sliced bread. ! 30: I have tons of Fortran code, but my collaborators use C, now ! 31: we can stop arguing about what language to use and get some work done. ! 32: .sp 1.5 ! 33: .nf ! 34: Seek binary compatibility with VAX f77 ! 35: \(bu big help in testing ! 36: \(bu helped find bugs in $f2c$, $lcc$, $nCC$ ! 37: ! 38: Useful test cases: ! 39: \(bu NBS tests ! 40: \(bu PORT3 ! 41: .bp ! 42: Netlib's "execute f2c" taught us much ! 43: (starting 19 Nov. 1989): ! 44: ! 45: .ce ! 46: \s22\f(CW{echo execute f2c; cat *.f} | mail netlib\fR\s0 ! 47: ! 48: \(bu bugs ! 49: \(bu \f(CW-z\fR (no implicit \f(CWdouble complex\fR) ! 50: \(bu longer names ! 51: \(bu better error messages (as late as today) ! 52: \(bu args on main ! 53: \(bu \f(CWblock data\fR initializing vars not in \f(CWcommon\fR ! 54: \(bu \f(CWdo ... enddo\fR ! 55: \(bu \f(CW!\fR comments ! 56: \(bu \f(CWnamelist\fR ! 57: ! 58: ! 59: \(bx COMMON ! 60: ! 61: \(bx constants (preserved until operated on) ! 62: ! 63: \(bx prototypes ! 64: .bp ! 65: Namelist example: ! 66: .ft CW ! 67: .sp p.5 ! 68: integer m(8) ! 69: real x(10,10) ! 70: namelist /xx/ m, x ! 71: \&. . . ! 72: read(*,xx) ! 73: ! 74: \fRcould read\fP ! 75: ! 76: &xx x(1,1) = 2, ! 77: x(1:3,8:10:2) = 1,2,3,4,5,6 ! 78: m(7:8) = 9,10/ ! 79: ! 80: .ft R ! 81: Recent lesson: many vendors expect non-8x syntax: ! 82: ! 83: .EQ ! 84: delim off ! 85: .EN ! 86: .ft CW ! 87: $xx x(1,1) = 2, ! 88: x(1:3,8:10:2) = 1,2,3,4,5,6 ! 89: m(7:8) = 9,10 $end ! 90: .ft R ! 91: .EQ ! 92: delim $$ ! 93: .EN ! 94: .bp ! 95: Prototypes: ! 96: .sp .5 ! 97: \f(CWf2c -P foo.f\fR ! 98: .sp .5 ! 99: creates both \f(CWfoo.c\fR and \f(CWfoo.P\fR . ! 100: ! 101: Examples of PORT3 prototypes: ! 102: ! 103: .ft CW ! 104: extern C_f cdotc_(complex *ret_val, ! 105: integer *n, complex *dx, ! 106: integer *incx, complex *dy, ! 107: integer *incy); ! 108: ! 109: extern C_f mullr_(complex *ret_val, ! 110: C_fp f, complex *z1, ! 111: complex *z2, complex *z3, ! 112: real *epsz, real *epsf, ! 113: integer *maxitr, integer *iter); ! 114: ! 115: ! 116: f2c.h \fRcontains\f(CW typedef\fRs. ! 117: .bp ! 118: Special comments for \f(CWcommon\fR lengths (read by $f2c$): ! 119: ! 120: .ft CW ! 121: /* comlen a0desp_ 4 */ ! 122: /* comlen a10der_ 36 */ ! 123: /* comlen a10dey_ 480 */ ! 124: .ft R ! 125: ! 126: ! 127: Special comments for references: ! 128: .ft CW ! 129: .ps 16 ! 130: /*:ref: odes1_ 10 11 200 4 3 4 4 4 208 4 210 8 8 */ ! 131: /*:ref: l4ags_ 10 14 4 3 3 3 210 3 4 4 4 3 3 3 3 4 */ ! 132: /* Rerunning f2c -P may change prototypes or declarations. */ ! 133: .ps 24 ! 134: .ft R ! 135: ! 136: ! 137: Untyped \f(CWexternal\fRs ! 138: \(=> need to update prototypes: ! 139: ! 140: .EQ ! 141: delim off ! 142: .EN ! 143: .ft CW ! 144: while :; do ! 145: f2c -Ps f.[fP] ! 146: case $? in 4) ;; *) break;; esac ! 147: done ! 148: .ft R ! 149: ! 150: \(bx Several PORT3 bugs found. ! 151: .bp ! 152: Can't always infer types correctly: ! 153: ! 154: .ft CW ! 155: subroutine grok(f,g,h) ! 156: external f, g, h ! 157: logical g ! 158: call foo(1,g) ! 159: call foo(2,f) ! 160: call zap(1,f) ! 161: call zap(2,h) ! 162: call zot(f(3)) ! 163: end ! 164: .ft R ! 165: ! 166: Infer \f(CWf_\fR and \f(CWh_ to be \f(CWlogical\fR, ! 167: then find \f(CWf_\fR must be \f(CWreal\fR. ! 168: \f(CW-!it\fR turns such inferences off. ! 169: .bp ! 170: .ft CW ! 171: subroutine zap(n,f) ! 172: external f ! 173: if (n .le. 1) call zap1(f) ! 174: if (n .ge. 2) call zap2(f) ! 175: end ! 176: .ft R ! 177: ! 178: ! 179: ! 180: ! 181: 9 Jan. 1990 \- 30 Jan. 1990 (13:00): ! 182: ! 183: ! 184: 210 requests from 184 people ! 185: for ``\f(CWall from f2c/src\fR'' ! 186: 9 copies today ! 187: ! 188: ! 189: 695 requests from 627 people ! 190: for ``\f(CWindex from f2c\fR'' ! 191: 22 copies today
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.