yost@uiucdcsb.UUCP (01/27/85)
I have a problem...I have a package of library routines written in FORTRAN and I'm trying to write C programs that call them. I've gotten everything to work except the following: if I call my main routine "main()" everything compiles but fortran output is directed to the file "fort.6" which is supposed to be connected to the terminal. If I call my main routine "MAIN_" (as, I guess, it would be called in the C intermediate code from the fortran compiler??) the fortran output and input are connected to the terminal. The problem is that I want my main routine to be called "main()" and NOT "MAIN_()". I don't know if you even get argc and argv as parameters with "MAIN_()", but that's beside the point. Any solutions? Any suggestions? Jeff Yost
woods@hao.UUCP (Greg Woods) (02/05/85)
The problem is that you need to initialize the FORTRAN I/O routines. I have never actually attempted this, but at the minumum, you need to call f_init() before attempting any I/O, and f_exit() before exiting. You could look in the file /usr/src/usr.lib/libF77/main.c and see how they do it there. There's lots of other associated garbage in there as well. If your main program is C, and you use this method, do *not* use f77 to link the files, or you will wind up with "MAIN_" as an undefined symbol (f77 calls ld with the "-u MAIN_" flag to force loading of the FORTRAN program). Instead, you will need to use "cc whatevers.o -lwhatevers -lF77 -lI77 -lU77 -lm". --Greg -- {ucbvax!hplabs | allegra!nbires | decvax!noao | harpo!seismo | ihnp4!noao} !hao!woods "...sometimes the light's all shining on me; other times I can barely see..."