* Help Replace USEROPEN Macro w/ Fortran
@ 1996-08-30 4:00 speck
1996-09-03 4:00 ` Steve Lionel
0 siblings, 1 reply; 2+ messages in thread
From: speck @ 1996-08-30 4:00 UTC (permalink / raw)
I'm trying to replace an old macro USEROPEN routine with a Fortran routine.
The Fortran open statement which calls (via USEROPEN) the old macro routine
is:
open (UNIT=logical_unit_num, FILE=file_name, STATUS='OLD',
# SHARED, READONLY, iostat=ios1, USEROPEN=open_old_chan)
The macro routine attempts to open the file. If successful, it determines
the channel number and places it into common, so that the afore-mentioned
Fortran routine can access the channel number. My Fortran replacement
routine, shown below, is opening the file and placing the same channel
number into common as the macro routine. However, when I try to perform
a SYS$CRMPSC (create mapped section) which uses the channel number,
the macro version of open_old_chan results in a smooth error-free run, but
the Fortran version of open_old_chan results in SYS$CRMPSC returning -1
as the address in the map space. Any ideas, based upon inspecting the
code below, as to what is wrong with the Fortran?
First, here is the macro routine open_old_chan, with comments to
elucidate the function of the routine:
_____________________ BEGIN MACRO LISTING
.TITLE OPEN_OLD_CHAN
;****
; %T PROLOG
;
; Module Name:
; ------------
; Open_Old_Chan
;
; Keyphrase:
; ----------
; Open a channel to an existing file
;
; Description:
; ------------
; This module is designed to be used as the USEROPEN routine in a FORTRAN
; OPEN statement. It opens an existing file specified in the OPEN
; statement and returns the channel number assigned via
; a common block. When this module is used to open the file, no FORTRAN
; I/O may be performed on the file. All I/O must be performed using
; $QIOs.
;
; Source File Name:
; -----------------
; OPENOLDCHAN
;
; Argument List:
; --------------
; FAB /Input-Output /See RMS manuals
; File access block
;
; Function Value Returned:
; ------------------------
; I*4 /System service completion code returned from $OPEN
;
; Global Data Referenced (see DD for complete definitions):
; ---------------------------------------------------------
; CHANNEL /Common block containing the channel number assigned to the file
; CHAN /Write
;
; File and Device Access (see DD for complete definitions):
; ---------------------------------------------------------
; Arbitrary file specified in FAB /Opened
;
; Local Data:
; -----------
; NONE
;
; Modules Called:
; ---------------
; $OPEN (VAX/VMS Library)
; $FAB_STORE (VAX/VMS Library)
;
; Comments:
; ---------
; NONE
;
; History:
; --------
; Version Date Author Description
; 3 18-DEC-1986 BAO Added file sharing field (SHR) user
; interlock argument (UPI) - definitely
; required under VMS 4.4.
; 2 04-AUG-1983 W Implementation complete (Build 1)
;
; PDL:
; ----
; %S CALL Open_Old_Chan
;
; Set file open options to user-open and contiguous-best-try
; CALL $OPEN to open the file
; IF an error occurred THEN
; RETURN the status code from $OPEN
; ENDIF
; Get the channel number assigned to the file from the FAB and /
; store it in CHANNEL.CHAN
; RETURN success
;****
\f
;
;FORTRAN Named Common - used to return the channel number
;
.PSECT CHANNEL PIC,GBL,SHR,NOEXE,OVR,LONG
CHAN: .WORD
;
;
.PSECT CODE PIC,SHR,NOWRT,LONG
.ENTRY OPEN_OLD_CHAN,^M<R2>
;
;Set up the FAB
;
MOVL 4(AP),R2 ;move FAB address into R2
;use the $FAB_STORE macro to modify the File Access Block of the file
;FAB is in R2, use FOP (File processing options of):
; UFO - user file open (needed for section files), cannot use the
; $CONNECT macro to allow FORTRAN IO to it anymore
; CBT - contigous best try,
;use SHR (File sharing) option UPI - user interlock. Required since FOP UFO
; option specified.
;
;
$FAB_STORE FAB=R2,FOP=<UFO,CBT>,SHR=<UPI>
;
;Open the file
;
$OPEN FAB=R2
BLBS R0,10$
RET
;
;Return the channel number to the FORTRAN main program
;by moving it to the common block
;
10$: MOVW FAB$L_STV(R2),CHAN
;
; move a normal status to R0
MOVL #SS$_NORMAL,R0
RET
.END
_____________________ END MACRO LISTING
And here is the Fortran (without comments) with which I'm trying to replace it:
integer*4 function open_old_chan(fab, rab, lun)
implicit none
include '($FABDEF)' ! File Access Block Structure
include '($RABDEF)' ! Record Access Block Structure
include '($SYSSRVNAM)' ! System service name declarations
include '($SSDEF)'
record /FABDEF/ fab, /RABDEF/ rab
integer*4 lun
integer*2 chan
common /channel/ chan
! set the UFO and CBT bits
fab.fab$l_fop = fab$v_ufo .OR. fab$v_cbt
! set the UPI bit
fab.fab$b_shr = fab$v_upi
! open the file, return on error
open_old_chan = sys$open(fab)
if (open_old_chan .eq. 0) then
chan = 0
return
endif
! Read channel number into common block
chan = fab.fab$l_stv
open_old_chan = SS$_NORMAL
return
end
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: Help Replace USEROPEN Macro w/ Fortran
1996-08-30 4:00 Help Replace USEROPEN Macro w/ Fortran speck
@ 1996-09-03 4:00 ` Steve Lionel
0 siblings, 0 replies; 2+ messages in thread
From: Steve Lionel @ 1996-09-03 4:00 UTC (permalink / raw)
In article <1996Aug30.122330@stsci.edu>, speck@stsci.edu writes:
|>I'm trying to replace an old macro USEROPEN routine with a Fortran routine.
|>
|>And here is the Fortran (without comments) with which I'm trying to replace it:
..
|> ! set the UFO and CBT bits
|> fab.fab$l_fop = fab$v_ufo .OR. fab$v_cbt
Should be:
fab.fab$l_fop = fab.fab$l_fop .OR. fab$m_ufo .OR. fab$m_cbt
|>
|> ! set the UPI bit
|> fab.fab$b_shr = fab$v_upi
Should be:
fab.fab$b_shr = fab.fab$b_shr .OR. fab$m_upi
|>
|> ! open the file, return on error
|> open_old_chan = sys$open(fab)
|>
|> if (open_old_chan .eq. 0) then
Should be:
if (.not. open_old_chan) then
Try these corrections and see if things improve. The fab$v_ symbols are
bit offset numbers, not masks. Alternatively, you could use the IBSET
intrinsic.
--
Steve Lionel mailto:lionel@quark.zko.dec.com
Fortran Development http://www.digital.com/info/slionel.html
Digital Equipment Corporation
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062-2698 "Free advice is worth every cent"
For information on Digital Fortran, see http://www.digital.com/info/hpc/fortran/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-09-03 4:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-08-30 4:00 Help Replace USEROPEN Macro w/ Fortran speck
1996-09-03 4:00 ` Steve Lionel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox