C   07/06/96 606071856  MEMBER NAME  MODUL    (S4)          FORTRAN
  ->  SUBROUTINE modul(MODE,ISW)
C
C ->  PROGRAM MODUL  FOR ........................................
C
C
C ->  USAGE OF PROGRAM MODUL
C     =======================
C     THIS PROGRAM MODUL CAN BE CALLED IN THE MAIN PROGRAM AFTER GOREC
C     FOR EACH RECORD AND AT JOB END.
C
C     THE ARGUMENTS MODE AND ISW HAVE THE FOLLOWING MEANING -
C
C               MODE = 0   PROCESS EACH EVENT
C
C               MODE = 1   PROCESS EVENT, IF PROGRAM MODUL NOT YET
C                          APPLIED  *)
C
C               MODE = 2   PROCESS EVENT, IF CURRENT VERSION OF PROGRAM
C                          MODUL NOT YET APPLIED *)
C
C               ISW  = 0   PRODUCTION MODE (NO INTERNAL PRINTOUT)
C
C ->            ISW  = ... (depending on modul)
C
C
C
C
C
C     *) IF A RECORD IS PROCESSED WITH A MODUL, THIS FACT IS RECORDED
C     TOGETHER WITH THE PROGRAM VERSION-NR AND THE DATE OF PROCESSING
C     IN A BANK BOOK, BELONGING TO THAT RECORD. THIS INFORMATION IS
C     USED TO DECIDE, WETHER A PROGRAM MODUL HAS BEEN APPLIED TO THE
C     RECORD. THIS CAN NOT WORK OF COURSE FOR DATA PROCESSED BEFORE
C     THE INTRODUCTION OF THIS SYSTEM, IN THIS CASE ALL EVENTS WILL
C     BE PROCESSED FOR MODE =2 AND =3.
C
C     THE RETURN CODE (SEE BELOW) HAS THE FOLLOWING MEANING
C
C             JRETCD = 0   NO PROCESSING POSSIBLE
C
C ->          JRETCD = ... depending on modul
C
C ->  REQUIREMENT (INPUT DATA) - ......  (NAMES OF BANKS)
C
C ->  RESULT (OUTPUT DATA)     - ......  (NAMES OF BANKS)
C
C
C     STRUCTURE OF THIS PROGRAM
C     =========================
C     THE ARGUMENT ISW IS COPIED TO THE COMMON VARIABLE JSW.
C     IT CAN BE USED TO INDICATE E.G. A TEST MODE OR SIMILAR CONDITIONS.
C     IT SHOULD BE =0 FOR PRODUCTION, BUT IT IS NOT USED BY THE
C     GENERAL STEERING SUBROUTINE.
C     THE VARIABLE IVRCUR IS SET TO THE CURRENT VERSION-NR OF THE
C     PROGRAM MODUL. THIS SHOULD BE THE DATE OF INTRODUCTION AS AN
C     INTEGER IN THE FORM YYMMDD, E.G.
C         810827   FOR   27. AUGUST 1981.
C
C     THEN THE GENERAL STEERING SUBROUTINE GSTEER IS CALLED WITH
C         'MODULNAME'   = NAME OF PROGRAM MODUL (2A4, LEFT ADJUSTED)
C              IVRCUR   = CURRENT VERSION NR
C               MODE    = TAKEN FROM ARGUMENT
C
C     THE STEERING ROUTINE RETURNS IN THE COMMON/STEERC/ THE FOLLOWING
C     VARIABLES -
C              JGOTO    =  1, 2, 3, 4, 5 OR 6
C               NRUN    =  CURRENT RUN NR
C               LRUN    =  PREVIOUS RUN NR
C             JRETCD    =  0 (PROCESSING RETURN CODE, SEE BELOW)
C                JSW    =  COPY OF ARGUMENT ISW
C
C     IF NO BANK ('HEAD',0) CAN BE FOUND BY THE STEERING ROUTINE, OR
C     FOR A SPECIAL RECORD JGOTO WILL BE =6.
C     THE VARIABLE JGOTO IS THEN USED IN A COMPUTED GOTO-STMNT, TO
C     BRANCH TO THE VARIOUS STEPS IN THE PROGRAM.
C                 STEP
C            (1)  INITIALIZE PROGRAM MODUL
C            (2)  INITIALIZE FOR NEW RUN NRUN
C            (3)  PROCESS EVENT (DELETE FIRST OUTPUT BANKS, IF EXISTING)
C            (4)  END OF RUN LRUN
C            (5)  END OF JOB
C            (6)  RETURN TO CALLING PROGRAM
C
C
C     JGOTO = 1   (1) (2) (3)             (6)
C             2       (2) (3)             (6)
C             3           (3)             (6)
C             4               (4) (2) (3) (6)
C             5               (4) (5)     (6)
C             6                           (6)
C
C     (JGOTO WILL BE NEVER =2, BUT THIS NUMBER IS INCLUDED TO HAVE
C     A NICE NUMBERING OF STEPS)
C
C
C     THE RETURN CODE JRETCD CAN BE SET IN STEP (3) TO ANY VALUE
C     BETWEEN 1 AND 10. IF PROCESSSING IS NOT POSSIBLE DUE TO SOME
C     REASON, IT SHOULD REMAIN 0. A STATISTIC IS PRINTED AT THE
C     END FOR ALL PROGRAM MODULS.
C
C
C
      COMMON/BCS/IW(1)
      COMMON/STEERC/JGOTO,NRUN,LRUN,JRETCD,JSW
C
C     THE CURRENT VERSION-NR IS ...
 ->               IVRCUR=810827
C     ... AND SHOULD BE CHANGED FOR EACH CHANGE OF THE PROGRAM MODUL.
C
      JSW=ISW
  ->  CALL GSTEER('modulnam',IVRCUR,MODE)
      GOTO (1000,2000,3000,4000,4000,6000),JGOTO
C                              =
C     IF(JGOTO-3) 1000,3000,1         TO AVOID COMPUTED GOTO
C   1 IF(JGOTO-5) 4000,5000,6000      (168/E)
C
C     (1)  INITIALIZE PROGRAM MODUL
C
C     HERE THE PROGRAM IS INITIALIZED.
C
 1000 CONTINUE
  ->  ....
C
C     (2)  INITIALIZE FOR NEW RUN (NRUN)
C
C     FETCH CALIBRATION CONSTANTS FROM THE RUN LIBRARY, OR CHECK, THAT
C     THE CORRECT CONSTANTS ARE THERE. RESET COUNTERS, IF A STATISTIC IS
C     DONE FOR EACH RUN.
C
 2000 CONTINUE
  ->  ....
C
C     (3)  PROCESS EVENT
C
C     FIRST OUTPUT BANKS FROM THIS MODUL, IF EXISTING, SHOULD BE
C     DELETED. DURING PROCESSING THE VARIABLE JRETCD CAN BE SET TO
C     ANY VALUE BETWEEN 1 AND 10 (INITIALLY IS IS 0). IT SHOULD REMAIN 000013700
C     IF PROCESSING IS NOT POSSIBLE, BECAUSE NO INPUT BANKS EXIST.THE
C     VARIABLE JRETCD IS ONLY USED FOR THE STATISTIC PRINTOUT AT JOB
C     END. FINALLY THE NAMES OF THE OUTPUT BANKS SHOULD BE ADDED TO THE
C     SPECIAL LIST BY   CALL BSAW(NN,'NAMES...'). CREATED INTERMEDIATE
C     SHOULD BE DELETED.
C
 3000 CONTINUE
  ->  ....
      GOTO 6000
C
C     (4)  END OF RUN (LRUN)
C
C     HERE SOME STATISTIC MAY BE PRINTED FOR THE PREVIOUS RUN. IN CASE
C     OF PROGRAM MODULS, IN WHICH CALIBRATION CONSTANT ARE DETERMINED,
C     IT SHOULD BE CHECKED, WETHER THE DATA ARE SUFFICIENT ACCURATE
C     TO BE VALID FOR A CERTAIN RUN REGION (CHECK, WETHER JGOTO = 5
C     ALREADY INDICATES END OF JOB). CALIBRATION DATA SHOULD BE STORED
C     IN A BANK ON THE RUNLIBRARY OR AN EQUIVALENT PRIVATE LIBRARY.
C
 4000 CONTINUE
  ->  ....
      IF(JGOTO.EQ.4) GOTO 2000
C
C     (5)  END OF JOB
C
C     HERE SOME FINAL STATISTIC FOR THE MODUL MAY BE PRINTED.
C
 5000 CONTINUE
  ->  ....
C
C     (6)  RETURN TO CALLING PROGRAM
C
 6000 RETURN
      END
