SUBROUTINE INIERSCA(KBIASCOR)
!**********************************************************************
!     PURPOSE INITIALISATION OF YOMERSCA
!**********************************************************************

!    KBIASCOR (Input)   Type of speed bias correction applied (1 used until
!                       CY21R3,  2 used from CY21R4)

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

USE PARERSCA , ONLY : JPSAT    ,JPCELL   ,JPASCAT ,JPACELL   ,&
 & JPANT    ,JPVIT   ,JPPHI    ,JPTETA   ,JPSPL   ,JPHEAD    ,&
 & JPSPEEDMAX
USE YOMERSCA , ONLY : A180     ,A270     ,A360     ,ARAD     ,&
 & SIGMAX   ,XKPMAX   ,XMISMAX ,XLFRMAX  ,MBIT     ,EXPP     ,&
 & EXPPINV  ,ACMOD4   ,VALTT    ,BIAS     ,BIASBM  ,BIASABM  ,&
 & VALSPL   ,XSPL     ,TAB      ,V0       ,DV       ,&
 & XPHI0    ,DPHI     ,TETA0    ,DTETA    ,RSCAMDI  ,&
 & MSCAMDI  ,NKNOTSP7 ,RKNOTS   ,RSPLCOEFF,RSPLEND  ,&
 & ERS_SPEED_BIASCOR  ,ASCAT_SPEED_BIASCOR
USE YOMANCS  , ONLY : NCMBYTES ,NMDI     ,RMDI
USE YOMLUN   , ONLY : NULOUT     ,NSCASPE  ,NSCASIG  ,NSCATAB
USE YOMMKODB , ONLY : L_SCAT_BIASSIG


IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KBIASCOR 
! LOCAL VARIABLES

REAL(KIND=JPRB) :: ZVALTT(JPANT,JPCELL)

INTEGER(KIND=JPIM) :: JSAT, JHEAD, JJSAT, JANT, JJANT, JCELL, JSPL
INTEGER(KIND=JPIM) :: JJCELL, J, IUNIT, IBUFLIN, IBUFLOUT, IRET, ISPL

character(len= 10) ::  CL_FORT_FILE
character(len=  1) ::  CLMODE
CHARACTER(LEN= 80) ::  CLHEADER
CHARACTER(LEN=  4) ::  CLSAT
CHARACTER(LEN=  7) ::  CLASCAT
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"

! 1. COMPUTATIONAL CONSTANTS
IF (LHOOK) CALL DR_HOOK('INIERSCA',0,ZHOOK_HANDLE)
A180=180._JPRB
A270=270._JPRB
A360=360._JPRB
ARAD= ATAN(1.0_JPRB)/45._JPRB

! 2. QUALITY CONTROL CONSTANTS

SIGMAX= 20._JPRB
XKPMAX= 10._JPRB
XMISMAX=1000._JPRB
XLFRMAX= 0._JPRB
!!LI  MBIT=10
MBIT=6

! 3. INVERSION CONSTANTS

EXPP=0.625_JPRB
EXPPINV=1.6_JPRB

! 4. CMOD4/5 COEFFICIENTS

! 4.1 BASIC COEFFICIENTS
!     AND INCIDENCE DEPENDENT SIGMA0 BIAS CORRECTION (Cmod_Zad)

ACMOD4(1)=-2.301523_JPRB
ACMOD4(2)=-1.632686_JPRB
ACMOD4(3)=0.76121_JPRB
ACMOD4(4)=1.156619_JPRB
ACMOD4(5)=0.595955_JPRB
ACMOD4(6)=-0.293819_JPRB
ACMOD4(7)=-1.015244_JPRB
ACMOD4(8)=0.342175_JPRB
ACMOD4(9)=-0.500786_JPRB
ACMOD4(10)=0.01443_JPRB
ACMOD4(11)=0.002484_JPRB
ACMOD4(12)=0.07445_JPRB
ACMOD4(13)=0.004023_JPRB
ACMOD4(14)=0.14881_JPRB
ACMOD4(15)=0.089286_JPRB
ACMOD4(16)= -0.006667_JPRB
ACMOD4(17)=3._JPRB
ACMOD4(18)=-10._JPRB

BIAS(17)=1.075_JPRB
BIAS(18)=1.075_JPRB
BIAS(19)=1.072_JPRB
BIAS(20)=1.069_JPRB
BIAS(21)=1.066_JPRB
BIAS(22)=1.056_JPRB
BIAS(23)=1.030_JPRB
BIAS(24)=1.004_JPRB
BIAS(25)=0.979_JPRB
BIAS(26)=0.967_JPRB
BIAS(27)=0.958_JPRB
BIAS(28)=0.949_JPRB
BIAS(29)=0.941_JPRB
BIAS(30)=0.934_JPRB
BIAS(31)=0.927_JPRB
BIAS(32)=0.923_JPRB
BIAS(33)=0.930_JPRB
BIAS(34)=0.937_JPRB
BIAS(35)=0.944_JPRB
BIAS(36)=0.955_JPRB
BIAS(37)=0.967_JPRB
BIAS(38)=0.978_JPRB
BIAS(39)=0.988_JPRB
BIAS(40)=0.998_JPRB
BIAS(41)=1.009_JPRB
BIAS(42)=1.021_JPRB
BIAS(43)=1.033_JPRB
BIAS(44)=1.042_JPRB
BIAS(45)=1.050_JPRB
BIAS(46)=1.054_JPRB
BIAS(47)=1.053_JPRB
BIAS(48)=1.052_JPRB
BIAS(49)=1.047_JPRB
BIAS(50)=1.038_JPRB
BIAS(51)=1.028_JPRB
BIAS(52)=1.016_JPRB
BIAS(53)=1.002_JPRB
BIAS(54)=0.989_JPRB
BIAS(55)=0.965_JPRB
BIAS(56)=0.941_JPRB
BIAS(57)=0.929_JPRB
BIAS(58)=0.929_JPRB

! 4.2 BEAM DEPENDENT SIGMA0 BIAS CORRECTION

IF (L_SCAT_BIASSIG) THEN
        
! OPEN SIGMA0 BIAS CORRECTION FILE

! 4.2.1 ERS

   OPEN(NSCASIG,FORM='FORMATTED',FILE='ers_s0.cor',ERR=420)

! READ THE FILE

   DO JSAT=1,JPSAT
     READ(NSCASIG,'(3X,I1)',ERR=421,END=422)JJSAT
     DO JANT=1,JPANT
       READ(NSCASIG,'(I1)',ERR=421,END=422)JJANT
       READ(NSCASIG,'(10F7.3)',ERR=421,END=422)&
        & (BIASBM(JANT,JCELL,JSAT),JCELL=1,JPCELL)  
     ENDDO
   ENDDO

   CLOSE(NSCASIG)

! 4.2.2 ASCAT

   OPEN(NSCASIG,FORM='FORMATTED',FILE='ascat_s0.cor',ERR=420)

! READ THE FILE

   DO JSAT=1,JPASCAT
     READ(NSCASIG,'(A7)',ERR=421,END=422)CLASCAT
     JJSAT=0
     IF(CLASCAT(7:7) == 'A') JJSAT=1
     IF(CLASCAT(7:7) == 'B') JJSAT=2
     IF(CLASCAT(7:7) == 'C') JJSAT=3
     IF(JJSAT /= JSAT) GOTO 423

     DO JANT=1,JPANT
       READ(NSCASIG,'(I1)',ERR=421,END=422)JJANT
       READ(NSCASIG,'(10F7.3)',ERR=421,END=422)&
        & (BIASABM(JANT,JCELL,JSAT),JCELL=1,JPACELL)  
     ENDDO
   ENDDO

   CLOSE(NSCASIG)

ELSE

   BIASBM(:,:,:) =1._jprb
   BIASABM(:,:,:)=1._jprb
   WRITE(NULOUT,'(''NO SIGMA0 BIAS CORRECTION FOR ers AND ascat'')')

ENDIF

GOTO 424

! TREAT FILE HANDLING ERRORS

420 CONTINUE
WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
WRITE(NULOUT,'(''COULD NOT OPEN SIGMA0 BIAS CORRECTION FILE'')')
CALL ABOR1('SUBROUTINE INIERSCA')
421 CONTINUE
WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
WRITE(NULOUT,'(''COULD NOT READ SIGMA0 BIAS CORRECTION FILE'')')
CALL ABOR1('SUBROUTINE INIERSCA')
422 CONTINUE
WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
WRITE(NULOUT,'(''UNEXPECTED EOF ON SIGMA0 BIAS CORRECTION FILE'')')
CALL ABOR1('SUBROUTINE INIERSCA')
423 CONTINUE
WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
WRITE(NULOUT,'(''WRONG ORDER IN ASCAT SIGMA0 CORRECTION FILE'')')
CALL ABOR1('SUBROUTINE INIERSCA')
424 CONTINUE

! 4.3 WIND SPEED BIAS CORRECTION

! 4.3.1 ERS

if (kbiascor == 0) then
        ASCAT_SPEED_BIASCOR(:,:,:)=0._jprb
        WRITE(NULOUT,'(''NO WIND SPEED BIAS CORRECTION FOR ers AND ascat'')')
        GOTO 433
endif

! OPEN WIND SPEED BIAS CORRECTION FILE
        
OPEN(NSCASPE,FORM='FORMATTED',FILE='ers_sp.cor',ERR=430)

! READ THE FILE

WRITE(NULOUT,'(''ERS SPEED BIAS CORRECTION METHOD='',I2)') KBIASCOR

if (kbiascor == 1) then
  READ(NSCASPE,'(10(F6.3,1X))',ERR=430,END=432)(VALSPL(JSPL),JSPL=1,JPSPL)
  DO JSAT=1,JPSAT
    READ(NSCASPE,'(3X,I1)',ERR=430,END=432)JJSAT
    DO JCELL=1,JPCELL
      READ(NSCASPE,'(I2)',ERR=430,END=432)JJCELL
      READ(NSCASPE,'(5(E13.5,1X))',ERR=430,END=432)&
       & (XSPL(JSPL,JCELL,JSAT),JSPL=1,JPSPL+5)  
    ENDDO
  ENDDO
elseif (kbiascor == 2) then

!  Read in new Spline bias correction coefficients (CY21R3-)

  DO JSAT=1,JPSAT
    DO JHEAD=1,JPHEAD
      READ(NSCASPE,'(A)') CLHEADER
    ENDDO
    READ(NSCASPE,'(A4,I1)') CLSAT, JJSAT
    IF (JJSAT /= JSAT) THEN
      WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
      WRITE(NULOUT,'(''SATELLITES IN SPEED BIAS CORRECTION FILE NOT ORDERED'')')
      WRITE(NULOUT,'(''FOUND JJSAT='',I5,'' EXPECTED VALUE='',I5)')&
       & JJSAT,JSAT  
      CALL ABOR1('SUBROUTINE INIERSCA')
    ENDIF
    DO JCELL=1,JPCELL
      READ(NSCASPE,'(2I5)',ERR=430,END=432) JJCELL,NKNOTSP7
      IF (JJCELL /= JCELL) THEN
        WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
        WRITE(NULOUT,'(''DATA ON SPEED BIAS CORRECTION FILE NOT ORDERED'')')
        WRITE(NULOUT,'(''FOUND JJCELL='',I5,'' EXPECTED VALUE='',I5)')&
         & JJCELL,JCELL  
        CALL ABOR1('SUBROUTINE INIERSCA')
      ENDIF
      IF (.NOT. ALLOCATED(RKNOTS)) THEN
        ALLOCATE( RKNOTS(NKNOTSP7,JPCELL,JPSAT),&
         & RSPLCOEFF(NKNOTSP7,JPCELL,JPSAT),&
         & RSPLEND(JPCELL,JPSAT) )  
      ENDIF
      READ(NSCASPE,'(2E18.9)',ERR=430,END=432)&
       & (RKNOTS(JSPL,JJCELL,JJSAT),RSPLCOEFF(JSPL,JJCELL,JJSAT), &
       & JSPL=1,NKNOTSP7)  
      READ(NSCASPE,'(E18.9)',ERR=430,END=432) RSPLEND(JJCELL,JJSAT)
    ENDDO
  ENDDO

elseif (kbiascor == 3) then

!  Bias correction used for ERA40 and since CY28R1

  DO JSAT=1,JPSAT
    DO JHEAD=1,JPHEAD
      READ(NSCASPE,'(A)') CLHEADER
    ENDDO
    READ(NSCASPE,'(A4,I1)') CLSAT, JJSAT
    IF (JJSAT /= JSAT) THEN
      WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
      WRITE(NULOUT,'(''SATELLITES IN SPEED BIAS CORRECTION FILE NOT ORDERED'')')
      WRITE(NULOUT,'(''FOUND JJSAT='',I5,'' EXPECTED VALUE='',I5)')&
       & JJSAT,JSAT  
      CALL ABOR1('SUBROUTINE INIERSCA')
    ENDIF
    DO JCELL=1,JPCELL
      READ(NSCASPE,'(I5)',ERR=430,END=432) JJCELL
      IF (JJCELL /= JCELL) THEN
        WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
        WRITE(NULOUT,'(''DATA ON SPEED BIAS CORRECTION FILE NOT ORDERED'')')
        WRITE(NULOUT,'(''FOUND JJCELL='',I5,'' EXPECTED VALUE='',I5)')&
         & JJCELL,JCELL  
        CALL ABOR1('SUBROUTINE INIERSCA')
      ENDIF
      READ(NSCASPE,'(I5,F10.3)',ERR=430,END=432)&
       & (ISPL,ERS_SPEED_BIASCOR(JSPL,JJCELL,JJSAT), JSPL=0,JPSPEEDMAX)  
    ENDDO
  ENDDO

else

  WRITE(NULOUT,'(''0WRONG NBIASCOR SPECIFIED FOR ers BIAS CORRECTION'')')
  CALL ABOR1('SUBROUTINE INIERSCA')

endif

CLOSE(NSCASPE)

! 4.3.2 ASCAT

! OPEN WIND SPEED BIAS CORRECTION FILE
OPEN(NSCASPE,FORM='FORMATTED',FILE='ascat_sp.cor',ERR=430)

! READ THE FILE

DO JSAT=1,JPASCAT
  DO JHEAD=1,JPHEAD
    READ(NSCASPE,'(A)') CLHEADER
  ENDDO
  READ(NSCASPE,'(A7)',ERR=432)CLASCAT
  JJSAT=0
  IF(CLASCAT(7:7) == 'A') JJSAT=1
  IF(CLASCAT(7:7) == 'B') JJSAT=2
  IF(CLASCAT(7:7) == 'C') JJSAT=3

  IF (JJSAT /= JSAT) THEN
    WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
    WRITE(NULOUT,'(''SATELLITES IN SPEED BIAS CORRECTION FILE NOT ORDERED'')')
    WRITE(NULOUT,'(''FOUND JJSAT='',I5,'' EXPECTED VALUE='',I5)')&
     & JJSAT,JSAT
    CALL ABOR1('SUBROUTINE INIERSCA')
  ENDIF
  DO JCELL=1,JPACELL
    READ(NSCASPE,'(I5)',ERR=430,END=432) JJCELL
    IF (JJCELL /= JCELL) THEN
      WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
      WRITE(NULOUT,'(''DATA ON SPEED BIAS CORRECTION FILE NOT ORDERED'')')
      WRITE(NULOUT,'(''FOUND JJCELL='',I5,'' EXPECTED VALUE='',I5)')&
       & JJCELL,JCELL
      CALL ABOR1('SUBROUTINE INIERSCA')
    ENDIF
    READ(NSCASPE,'(I5,F10.3)',ERR=430,END=432)&
     & (ISPL,ASCAT_SPEED_BIASCOR(JSPL,JJCELL,JJSAT), JSPL=0,JPSPEEDMAX)
  ENDDO
ENDDO



GOTO 433

! TREAT FILE HANDLING ERRORS

430 CONTINUE
WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
WRITE(NULOUT,'(''COULD NOT OPEN WIND SPEED BIAS CORRECTION FILE'')')
CALL ABOR1('SUBROUTINE INIERSCA')
432 CONTINUE
WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
WRITE(NULOUT,'(''UNEXPECTED EOF ON WIND SPEED BIAS CORRECTION FILE'')')
CALL ABOR1('SUBROUTINE INIERSCA')
433 CONTINUE

! 5. THEORETICAL VALUES FOR INCIDENCE ANGLE

ZVALTT(1,1)=24.7000_JPRB
ZVALTT(2,1)=17.9000_JPRB
ZVALTT(1,2)=27.2000_JPRB
ZVALTT(2,2)=19.8000_JPRB
ZVALTT(1,3)=29.5000_JPRB
ZVALTT(2,3)=21.7000_JPRB
ZVALTT(1,4)=31.8000_JPRB
ZVALTT(2,4)=23.500_JPRB
ZVALTT(1,5)=34.0000_JPRB
ZVALTT(2,5)=25.2000_JPRB
ZVALTT(1,6)=36.1000_JPRB
ZVALTT(2,6)=26.9000_JPRB
ZVALTT(1,7)=38.1000_JPRB
ZVALTT(2,7)=28.600_JPRB
ZVALTT(1,8)=40.0000_JPRB
ZVALTT(2,8)=30.3000_JPRB
ZVALTT(1,9)=41.9000_JPRB
ZVALTT(2,9)=31.8000_JPRB
ZVALTT(1,10)=43.700_JPRB
ZVALTT(2,10)=33.4000_JPRB
ZVALTT(1,11)=45.4000_JPRB
ZVALTT(2,11)=34.9000_JPRB
ZVALTT(1,12)=47.0000_JPRB
ZVALTT(2,12)=36.4000_JPRB
ZVALTT(1,13)=48.6000_JPRB
ZVALTT(2,13)=37.8000_JPRB
ZVALTT(1,14)=50.1000_JPRB
ZVALTT(2,14)=39.2000_JPRB
ZVALTT(1,15)=51.5000_JPRB
ZVALTT(2,15)=40.6000_JPRB
ZVALTT(1,16)=52.9000_JPRB
ZVALTT(2,16)=41.9000_JPRB
ZVALTT(1,17)=54.3000_JPRB
ZVALTT(2,17)=43.1000_JPRB
ZVALTT(1,18)=55.5000_JPRB
ZVALTT(2,18)=44.4000_JPRB
ZVALTT(1,19)=56.8000_JPRB
ZVALTT(2,19)=45.6000_JPRB
DO J=2,JPCELL
  VALTT(1,J)=(ZVALTT(1,J) + ZVALTT(1,J-1))/2.0_JPRB
  VALTT(2,J)=(ZVALTT(2,J) +ZVALTT(2,J-1))/2.0_JPRB
  VALTT(3,J)=VALTT(1,J)
ENDDO
VALTT(1,1) =(3._JPRB*ZVALTT(1,1)-ZVALTT(1,2))/2.0_JPRB
VALTT(2,1) = (3._JPRB*ZVALTT(2,1)-ZVALTT(2,2))/2.0_JPRB
VALTT(3,1) =VALTT(1,1)
VALTT(1,JPCELL+1)=(3._JPRB*ZVALTT(1,JPCELL)-ZVALTT(1,JPCELL-1))/2.0_JPRB
VALTT(2,JPCELL+1)=(3._JPRB*ZVALTT(2,JPCELL)-ZVALTT(2,JPCELL-1))/2.0_JPRB
VALTT(3,JPCELL+1)=VALTT(1,JPCELL+1)

! 6. TABLE OF SIGMA  DEFINITION
! 6.1 DIMENSIONING
! 6.2 STEP DEFINITION

V0=1.0_JPRB
DV=0.5_JPRB
XPHI0=0.0_JPRB
DPHI=5._JPRB
TETA0=15._JPRB
DTETA=1.0_JPRB

! 6.3 IUNIT NUMBER FOR THE FILE WITH THE TABLE

IUNIT= NSCATAB

write(CL_FORT_FILE,'(a,i2)') 'fort.',IUNIT
WRITE(NULOUT,'(''0SUBROUTINE INIERSCA'')')
IRET   = 0
CLMODE = 'r'

CALL PBOPEN(IUNIT,CL_FORT_FILE,CLMODE,IRET)
IF(IRET /= 0)                      THEN
  WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
  WRITE(NULOUT,'('' COULD NOT OPEN CMOD4 TABLE FILE'')')
  WRITE(NULOUT,'('' RETURN CODE: '',I10)') IRET
  WRITE(NULOUT,'('' FILE UNIT  :'',I10)')  IUNIT
  WRITE(NULOUT,'('' FILE NAME  : '',A)')   CL_FORT_FILE
  CALL ABOR1('SUBROUTINE INIERSCA')
ELSE
  WRITE(NULOUT,'('' CMOD4 TABLE FILE OPENED'')')
  WRITE(NULOUT,'('' FILE UNIT  :'',I10)')  IUNIT
  WRITE(NULOUT,'('' FILE NAME  : '',A)')   CL_FORT_FILE
ENDIF

! READ THE TABLE

IBUFLIN  = (JPVIT*JPPHI*JPTETA) * NCMBYTES
IBUFLOUT = IBUFLIN
IRET     = 0
CALL PBREAD(IUNIT,TAB,IBUFLIN,IRET)
#ifdef LITTLE
   CALL swap8bytes(tab, IBUFLIN/NCMBYTES)
#endif
IF(IRET < -1)                      THEN
  WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
  WRITE(NULOUT,'('' COULD NOT READ CMOD4 TABLE FILE'')')
  WRITE(NULOUT,'('' RETURN CODE: '',I10)') IRET
  WRITE(NULOUT,'('' FILE UNIT  : '',I10)') IUNIT
  WRITE(NULOUT,'('' FILE NAME  : '',A)')   CL_FORT_FILE
  CALL ABOR1('SUBROUTINE INIERSCA')
ELSEIF(IRET == -1)                 THEN
  WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
  WRITE(NULOUT,'('' UNEXPECTED EOF ON CMOD4 TABLE FILE'')')
  WRITE(NULOUT,'('' RETURN CODE: '',I10)') IRET
  WRITE(NULOUT,'('' FILE UNIT  : '',I10)') IUNIT
  WRITE(NULOUT,'('' FILE NAME  : '',A)')   CL_FORT_FILE
  CALL ABOR1('SUBROUTINE INIERSCA')
ELSE
  IF(IBUFLOUT /= IBUFLIN) THEN
    WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
    WRITE(NULOUT,'('' CMOD4 TABLE LEN. NOT CONSISTENT'')')
    CALL ABOR1('SUBROUTINE INIERSCA')
  ENDIF
  WRITE(NULOUT,'('' CMOD4 TABLE FILE READ'')')
  WRITE(NULOUT,'('' FILE UNIT  :'',I10)')  IUNIT
  WRITE(NULOUT,'('' FILE NAME  : '',A)')   CL_FORT_FILE
  IBUFLOUT = IRET / NCMBYTES
ENDIF

IRET   = 0
CALL PBCLOSE(IUNIT,IRET)
IF(IRET /= 0)                      THEN
  WRITE(NULOUT,'(''0ERROR IN SUBROUTINE INIERSCA'')')
  WRITE(NULOUT,'('' COULD NOT CLOSE THE FILE'')')
  WRITE(NULOUT,'('' RETURN CODE: '',I10)') IRET
  WRITE(NULOUT,'('' FILE UNIT  : '',I10)') IUNIT
  WRITE(NULOUT,'('' FILE NAME  : '',A)')   CL_FORT_FILE
  CALL ABOR1('SUBROUTINE INIERSCA')
ELSE
  WRITE(NULOUT,'('' CMOD4 TABLE FILE CLOSED'')')
  WRITE(NULOUT,'('' FILE UNIT  :'',I10)')  IUNIT
  WRITE(NULOUT,'('' FILE NAME  : '',A)')   CL_FORT_FILE
ENDIF

! 7. Missing value
RSCAMDI=RMDI
MSCAMDI=NMDI
!     RSCAMDI=9999.
!     MSCAMDI=9999
IF (LHOOK) CALL DR_HOOK('INIERSCA',1,ZHOOK_HANDLE)
END SUBROUTINE INIERSCA
