Path: utzoo!mnetor!uunet!husc6!hao!gatech!purdue!i.cc.purdue.edu!j.cc.purdue.edu!pur-ee!uiucdcs!uxc.cso.uiuc.edu!uicsrd.csrd.uiuc.edu!hoefling From: hoefling@uicsrd.csrd.uiuc.edu Newsgroups: comp.sys.apollo Subject: Fooling Fortran Message-ID: <11400004@uicsrd.csrd.uiuc.edu> Date: 15 Jan 88 18:04:00 GMT Lines: 44 Nf-ID: #N:uicsrd.csrd.uiuc.edu:11400004:000:1607 Nf-From: uicsrd.csrd.uiuc.edu!hoefling Jan 15 12:04:00 1988 All I wanted to do was pass a value to the csh status variable from an Apollo Fortran program. Like a C program would do for "exit(n);". The manuals had nothing on the subject. The (800) 2APOLLO help line was baffled (actually they suggested I write a file containing the status code, then cat it once I was back in the shell, but I didn't care for that solution). So, in playing around, we came up with a still-pretty-cruddy solution, but one which hid the cruddiness inside the program, so I don't mind it so much. For those interested, here's the Fortran code: integer x,y,z pointer /z/ x equivalence (z,y) y = 8 call exit(x) end This returns the value 8 to the status variable in csh, which you can see by "echo $status". Apparently, "call exit" passes the argument by reference (puts the arg address on the stack), while the exit routine is expecting the *value* to be on the stack. What results if you don't play the above tricks is that the status variable gets what is apparently the address of the argument. So that's why we had to trick Fortran into believing that the address of the variable x was actually the status return code value (8 in this case). If anyone knows of a cleaner way of doing this, I would love to hear of it. Jay Hoeflinger University of Illinois at Urbana-Champaign Center for Supercomputing Research and Development UUCP: {ihnp4,uunet,convex}!uiucuxc!uicsrd!hoefling ARPANET: hoefling%uicsrd@uxc.cso.uiuc.edu CSNET: hoefling%uicsrd@uiuc.csnet BITNET: hoefling@uicsrd.csrd.uiuc.edu (217) 244-0288