      COMPLEX FUNCTION C9LGMC (ZIN)
      COMPLEX ZIN, Z, Z2INV
      DIMENSION BERN(11)
      LOGICAL FIRST
      SAVE BERN, NTERM, BOUND, XBIG, XMAX, FIRST
      DATA BERN( 1) /    .08333333333 3333333E0   /
      DATA BERN( 2) /   -.002777777777 7777778E0  /
      DATA BERN( 3) /    .0007936507936 5079365E0 /
      DATA BERN( 4) /   -.0005952380952 3809524E0 /
      DATA BERN( 5) /    .0008417508417 5084175E0 /
      DATA BERN( 6) /   -.001917526917 5269175E0  /
      DATA BERN( 7) /    .006410256410 2564103E0  /
      DATA BERN( 8) /   -.02955065359 4771242E0   /
      DATA BERN( 9) /    .1796443723 6883057E0    /
      DATA BERN(10) /  -1.392432216 9059011E0     /
      DATA BERN(11) /  13.40286404 4168392E0      /
      DATA FIRST /.TRUE./
C***FIRST EXECUTABLE STATEMENT  C9LGMC
      IF (FIRST) THEN
         NTERM = -0.30*LOG(R1MACH(3))
         BOUND = 0.1170*NTERM*(0.1*R1MACH(3))**(-1./(2*NTERM-1))
         XBIG = 1.0/SQRT(R1MACH(3))
         XMAX = EXP (MIN(LOG(R1MACH(2)/12.0), -LOG(12.*R1MACH(1))) )
      ENDIF
      FIRST = .FALSE.
C
      Z = ZIN
      X = REAL (Z)
      Y = AIMAG(Z)
      CABSZ = ABS(Z)
C
      IF (X .LT. 0.0 .AND. ABS(Y) .LT. BOUND) CALL XERMSG ('SLATEC',
     +   'C9LGMC', 'NOT VALID FOR NEGATIVE REAL(Z) AND SMALL ' //
     +   'ABS(AIMAG(Z))', 2, 2)
      IF (CABSZ .LT. BOUND) CALL XERMSG ('SLATEC', 'C9LGMC',
     +   'NOT VALID FOR SMALL ABS(Z)', 3, 2)
C
      IF (CABSZ.GE.XMAX) GO TO 50
C
      IF (CABSZ.GE.XBIG) C9LGMC = 1.0/(12.0*Z)
      IF (CABSZ.GE.XBIG) RETURN
C
      Z2INV = 1.0/Z**2
      C9LGMC = (0.0, 0.0)
      DO 40 I=1,NTERM
        NDX = NTERM + 1 - I
        C9LGMC = BERN(NDX) + C9LGMC*Z2INV
 40   CONTINUE
C
      C9LGMC = C9LGMC/Z
      RETURN
C
 50   C9LGMC = (0.0, 0.0)
      CALL XERMSG ('SLATEC', 'C9LGMC', 'Z SO BIG C9LGMC UNDERFLOWS', 1,
     +   1)
      RETURN
C
      END
