C----------------------------------------------------------------------
C     06/06/15      
C----------------------------------------------------------------------

      IMPLICIT   DOUBLE PRECISION (a-h,o-z)


      PARAMETER ( NSamples_in_Hour_Max  = 60*60)    ! 1 sec


      PARAMETER ( NHours_Max     = 6 * 360 * 24,    ! in hours

     +            Number_of_n_Ext_Max = 3,
     +            NHarmonics_Ext_Max = 
     +            Number_of_n_Ext_Max *(Number_of_n_Ext_Max + 2))

      PARAMETER ( Number_of_n_Int_Max = 45,  
     +            NHarmonics_Int_Max = 
     +            Number_of_n_Int_Max *(Number_of_n_Int_Max + 2))


      PARAMETER ( Number_of_n_Max   = 45,
     +            N_Degree          = 50,          ! Must be larger than Number_of_n_Max
     +            NDivide_1_Degree  = 10,

     +            NH_First          =   50,         ! in km
     +            NH_Last           =  900,         ! in km
     +            NDivide_1_km      =    1,


     +            NHarmonics_Max    = 
     +            Number_of_n_Max *(Number_of_n_Max + 2),

     +            nx = 360 * NDivide_1_Degree + 1, 
     +            ny = 180 * NDivide_1_Degree + 1,

     +            nz = (NH_Last - NH_First)*NDivide_1_km + 1) 


      INTEGER          Unit_Input, Unit_Output, Unit_Select
      INTEGER          Unit_Ext_T, Unit_Int_T, Unit_Temp

      CHARACTER*160     File_with_inm_bdt
      CHARACTER*160     File_with_enm_bdt

      DOUBLE PRECISION time_h(NHours_Max) 

      REAL             enm_t(NHarmonics_Ext_Max, NHours_Max)
      REAL             inm_t(NHarmonics_Int_Max, NHours_Max)

      CHARACTER*512 A512_01, A512_02, A512_03, A512_04, A512_05 
      CHARACTER*160 A160

      CHARACTER*9   A9

C----------------------------------------------------------------------
      NHours = 51840

      OPEN(5,
     +     File = '1997_2002_n3_c9.txt') 
      READ(5, *) 
     +     LBlock_Int_T,
     +     NSamples,
     +     NFrequencies_Grid,
     +     Number_of_n_Ext,
     +     Number_of_n_Int

      NHarmonics_Ext = Number_of_n_Ext*(Number_of_n_Ext + 2)

      IF(NHours .NE. NSamples) THEN
        STOP ' NHours NE NSamples' 
      ENDIF 

      DO iS = 1, NHours 
         READ(5, '(E25.16, 3000E14.5)') time_h(iS),
     +   (enm_t(ih_ext, iS), ih_ext = 1, NHarmonics_Ext)
      ENDDO
      CLOSE(5) 

      OPEN(4,
     +     File = '1997_2002_n3_c9_3D_M6.txt') 
      READ(4, *) 
     +     LBlock_Int_T,
     +     NSamples,
     +     NFrequencies_Grid,
     +     Number_of_n_Ext,
     +     Number_of_n_Int

      NHarmonics_Int = Number_of_n_Int*(Number_of_n_Int + 2)

      DO iS = 1, NHours 
         write(*,*) iS
         READ(4, '(E25.16, 3000E14.5)') time_h(iS),
     +   (inm_t(ih_int, iS), ih_int = 1, NHarmonics_Int)
      ENDDO
      CLOSE(4) 

      STOP
      END
