CSUBR file = NIJX1.SG               **** Part 1  of the NIJX subroutines
C-----------------------------------------------------------------------
**** Computer specific subroutines  ****           Update:  27 Sep. 1999
**** Note: before compiling, concatenate:   NIJX = NIJX1 + NIJX2   !!!!!
* List of subroutines given in this file: DDTIME, DATIME, KEYSWI, FILINX
C+----------------------------------------------------------------------
CSUBROUTINE DDTIME (IHR, IMIN, IYR, IMON, IDAY, NUMDAY, ICPU)
C-----------------------------------------------------------------------
C Subroutine to call system routines for date, time en cpu-time.
C Output, all integer numbers.            Example: 24 Feb, 1996, 2:15 pm
C   IHR    hours, time of the day (0 - 24 h)                          14
C   IMIN   minutes past the hour  (0 - 59 min)                        15
C   IYR    year,  present date    (> 1995)                          1996
C   IMON   month, present date    (1 - 12)                             2
C   IDAY   day,   present date    (1 - 31)                            24
C   ICPU   CPU time in msec used since initiation                      0
C   NUMDAY day-number as yynnn (yy=year, nnn=number) OPTIONAL      96055
C Either (IYR and IMON and IDAY) .OR. NUMDAY  are needed.
C Note:  set IYR=0  and  NUMDAY=0  if no time routine is available
C This subroutine is computer dependent ===== it is not in FORTRAN77 ANS
C Subroutine DDTIME is only used by the subroutine DATIME  (given below)
C+----------------------------------------------------------------------
      SUBROUTINE DDTIME (IHR, IMIN, IYR, IMON, IDAY, NUMDAY, ICPU)
      DIMENSION TARRAY(2), IARRAY(3)
C  three dummy statements in case this time routine is not good for you:
C     IYR=0
C     NUMDAY=0
C     RETURN
***
C        Here follow the time routines for the Silicon Graphics computer
C        call time of the day: IARRAY(1)=IHR, (2)=MIN, (3)=sec
      CALL ITIME (IARRAY)
      IHR = IARRAY(1)
      IMIN = IARRAY(2)
C        call day of the year
      CALL IDATE( IMON, IDAY, IYEAR )
      IYR = IYEAR + 1900
C        get cpu time: CPUTIME = TARRAY(1) + TARRAY(2)    in seconds
      CPUTIM = ETIME( TARRAY ) * 1000.0
      ICPU = NINT ( CPUTIM )
C        set dummy NUMDAY because IYR,IMON,IDAY are available
      NUMDAY=0
      RETURN
C        END OF SUBR DDTIME
      END
C+----------------------------------------------------------------------
CSUBROUTINE DATIME (I1, I2, I3)
C-----------------------------------------------------------------------
C This subroutine calls the computer dependent routine: ==>  DDTIME  <==
C Subroutine DATIME retained for compatibility reasons:  do not modify !
C Subroutine to get the system date and the CPU time in msec.  Output:
C   I1   time of the day as hhmm (hh=hours, mm=minutes)
C   I2   CPU time in msec used since initiation
C   I3   day-number as yynnn (yy=year, nnn=number)
C I1 = I2 = I3 = 0 implies that no valid clock value is available
C Subroutine DATIME is only used by the subroutines KEDATE and KETIME .
C+----------------------------------------------------------------------
      SUBROUTINE DATIME (I1, I2, I3)
      DIMENSION L(12)
      DATA L / 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /
C           call computer dependent time routine:
      CALL DDTIME (IHR, IMIN, IYR, IMON, IDAY, NUMDAY, ICPU)
C        get time of the day:
      I1 = IHR*100 + IMIN
C        get cpu time
      I2 = ICPU
C        get day of the year
      I3 = NUMDAY
C        get day of the year: count number of days this year
      IF (IYR .GT. 1995) THEN
         IF ( MOD(IYR,4) .EQ. 0 ) L(2) = 29
         IDAG = IDAY
         NM = IMON - 1
         IF ( NM .NE. 0 ) THEN
            DO 20 I = 1, NM
   20       IDAG = IDAG + L(I)
            ENDIF
         I3 = (IYR-1900) * 1000 + IDAG
         ENDIF
      RETURN
C        END OF SUBR DATIME
      END
CSUBROUTINE KEYSWI
C-----------------------------------------------------------------------
C Subr. for 'local' KEYS and SWITCH settings, and 'local' specialities !
C SG3 version: KEYS(11)=IATX==> =3 for SPF, =4 for SCHAKAL, =5 for both.
C    Switches are defaulted .FALSE. and may be changed at any time:
C SWITCH(1) = NIJMEG = .TRUE. on execution in Nijmegen: see NIJX1.FORIBM
C SWITCH(2) = MOLEN  = .TRUE. for MOLEN users: see -------> NIJX1.FORVAX
C SWITCH(3), SWITCH(4), SWITCH(5) and SWITCH(6) are free.
C    KEYS() are defaulted = 0  and several are still free.
C KEYSWI is called once at the beginning of each program, and it is
C called again at any STOP (including at an error stop).
***  Note 1: if you wish us to implement some special private features
C    for you, please, write to us. These private features then will be
C    activated by these SWITCHes or KEYS.
***  Note 2: you can implement your own routine at the beginning and at
C    the end of the execution of any program. E.g. see NIJX1.FORCYB.
***  Note 3: we will be very happy to help !
C+----------------------------------------------------------------------
      SUBROUTINE KEYSWI
C     ------ /SYSTA/ and /SYSTB/ interface with supervisor.
      COMMON /SYSTA/ IFILE(20), IFSTAT(20), ITIME(4),   KEYS(28),
     *               NFNUM,     NLIT,       NCOLN(32),  NCOLL(32),
     *               NFDOT(32), NFDOL(32),  NLUSER(32), FNUM(32),
     *               SWITCH(28)
      LOGICAL        SWITCH
      EQUIVALENCE (IATX, KEYS(11))
      LOGICAL FIRST
      DATA FIRST / .TRUE. /
 
C SG  version: KEYS(11)=IATX==> =3 for SPF, =4 for SCHAKAL, =5 for both.
C === output atoms file for programs PLUTON and SCHAKAL, respectively.
Cxxx
      IF (IATX .EQ. 0) IATX = 5
Cxxx
 
      IF (FIRST) THEN
C        switch FIRST = .TRUE. for first entry, reset to .FALSE.
         FIRST = .FALSE.
C           things to be done at start for each program
      ELSE
         FIRST = .TRUE.
C           things to be done at STOP for each program
         ENDIF
      RETURN
C        END OF SUBROUTINE KEYSWI
      END
CSUBROUTINE FILINX (FNAME)
C-----------------------------------------------------------------------
C Subroutine for 'local' file definitions.
C This subroutine is called prior to opening any file (input or output).
C The file name for an input or output file is defaulted by FORTRAN in :
C      CHARACTER FNAME *64
C The DIRDIF standard is : up to six characters: all letters as CAPITALS
C This may be modified to suit your needs.
C In this subroutine all CAPITALS are converted to lower case letter !!!
C    Note: the CCODE (in CAP) is present in CCODE:
C SG3 version: CCNAME=.FALSE. set for short file names: lower case .
C SG3 version: CCNAME=.TRUE.  concatenation of CCODE with file names
C+----------------------------------------------------------------------
      SUBROUTINE FILINX (FNAME)
      CHARACTER *64 FNAME
C     ------ /SYSTA/ and /SYSTB/ interface with supervisor.
      COMMON /SYSTA/ IFILE(20), IFSTAT(20), ITIME(4),   KEYS(28),
     *               NFNUM,     NLIT,       NCOLN(32),  NCOLL(32),
     *               NFDOT(32), NFDOL(32),  NLUSER(32), FNUM(32),
     *               SWITCH(28)
      LOGICAL        SWITCH
      COMMON /SYSTB/ PROGNM,    PROSNM,     CCODE,      TITLE,
     *               CHIN,      LIT(32),    CHOUT
      CHARACTER      PROGNM *8, PROSNM *6,  CCODE *6,   TITLE *64,
     *               CHIN *80,  LIT *6,     CHOUT *72
      LOGICAL CCNAME
      CHARACTER *14 CCCC
C procedure inverted from SUBROUTINE KERC2U
      CHARACTER * 1  LUC(26), LLC(26)
      DATA LUC / 'A','B','C','D','E', 'F','G','H','I','J',
     +           'K','L','M','N','O', 'P','Q','R','S','T',
     +           'U','V','W','X','Y', 'Z'                  /
      DATA LLC / 'a','b','c','d','e', 'f','g','h','i','j',
     +           'k','l','m','n','o', 'p','q','r','s','t',
     +           'u','v','w','x','y', 'z'                  /
 
C SG3 version: alternat.: concatenation of CCODE with file names?
C SG3 version: CCNAME=.FALSE. : set for short file names: lower case .
C SG3 version: CCNAME=.TRUE.  : concatenation of CCODE with file names
C                               changing  'fname' to 'ccode.fname'.
C For instance CCNAME=.FALSE.  : 'ATOMS' is changed into: 'atoms'
C For instance CCNAME=.TRUE.   : 'ATOMS' is changed into: 'ccode.atoms'
C Here we activate CCNAME = .TRUE.  on next line:
      CCNAME = .TRUE.
 
C        convert SCHAKL to sch
      IF (FNAME(1:6) .EQ. 'SCHAKL') THEN
C           Convert 'fname' to 'ccode.fname' ?
         IF (CCNAME) THEN
            FNAME = 'SCH'
            GOTO 100
            ENDIF
         FNAME = 'atom.sch'
         RETURN
         ENDIF
 
  100 I7 = 7
      IF (FNAME(1:6) .EQ. 'DDJOB ' .OR. FNAME(1:6) .EQ. 'DDSYST' .OR.
     *    FNAME(1:6) .EQ. 'DDHELP' .OR. FNAME(1:6) .EQ. 'ORBASE' .OR.
     *    FNAME(1:6) .EQ. 'DDCON ' .OR. FNAME(1:6) .EQ. 'DDLIC ' .OR.
     *    FNAME(1:6) .EQ. 'ORUSER' ) GOTO 113
* rm ddconfig
      IF (FNAME(1:8) .EQ. 'DDCONFIG') THEN
         FNAME = 'ddconfig'
         RETURN
         ENDIF
 
C        Convert 'fname' to 'ccode.fname' ?
      IF (CCNAME) THEN
         CCCC = CCODE
         DO 111 I=1,7
         IF (CCCC(I:I) .EQ. ' ') GOTO 112
  111    CONTINUE
C          the first blank is at position I=7 or less
  112    CCCC(I:I) = '.'
         I = I + 1
         CCCC(I:14) = FNAME(1:7)
         FNAME = CCCC
         I7 = 14
         ENDIF
 
C        convert CAPs to lower case letters
  113 DO 120 I = 1, I7
      IF (FNAME(I:I) .EQ. ' ') GOTO 120
      CALL KEREQ1 (FNAME(I:I), LUC, 26, KEND)
      IF (KEND .GT. 0) FNAME(I:I) = LLC(KEND)
  120 CONTINUE
      RETURN
C        END OF SUBROUTINE FILINX   /  last subroutine of  NIJX1
      END
