The requirement is to create a file that will be used to hold the output of several programs, but this file must be in a directory that is used by several people. Clearly the file name must be related to the username. Also it is necessary to take into account the difference in the syntax of directory names on VMS and Unix systems.
PROGRAM NEWFIL IMPLICIT NONE INCLUDE 'SAE_PAR' INTEGER STATUS ! The global status value CHARACTER * ( 32 ) NAME ! The name of the current user CHARACTER * ( 80 ) FILNAM ! The name of the file to be created CHARACTER * ( 15 ) SYSNAME ! The name of the operating system CHARACTER * ( 1 ) DUMMY1 CHARACTER * ( 1 ) DUMMY2 CHARACTER * ( 1 ) DUMMY3 CHARACTER * ( 1 ) DUMMY4 * Set STATUS since this is is not an ADAM program. STATUS = SAI__OK * Get the username. CALL PSX_GETENV( 'USER', NAME, STATUS ) * Get the system name. CALL PSX_UNAME( SYSNAME, DUMMY1, DUMMY2, DUMMY3, DUMMY4, STATUS ) * Create the file. IF( STATUS .EQ. SAI__OK ) THEN IF( SYSNAME .EQ. 'VMS' ) THEN FILNAM = 'COMMON_AREA:' // NAME // '.DAT' ELSE FILNAM = '/usr/common/' // NAME // '.DAT' END IF OPEN( UNIT=1, FILE=FILNAM, STATUS='NEW' ) CLOSE( UNIT=1 ) ELSE PRINT *,'Could not get username' END IF ENDAlthough the PSX routines are designed to be used with other Starlink routines in the ADAM environment and use the concept of inherited status, they can just as easily be used in a stand alone program like the one above provided that the status is set correctly before calling the first routine. This is important since the PSX routine will exit immediately if STATUS is not set to the value of the symbolic constant SAI__OK.
PSX POSIX interface routines