util_fctp.f90 43.2 KB
Newer Older
capdevil's avatar
capdevil committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
!25/11/02: passage en F90 pour scat_sem .... Yahooo
!08/04/97:
!nouvelle version real*4 pour ww, q et g!mais real*4 pour les fctps
!    .(utilisable ave!les sorties de minosa3!)
!21/03/97 introduction des parametres NCM et NCM6
!la lecture des fctp est un peu bizard pour gagner du temps
!
!----------------------------------------------------------------------
module util_fctp
!----------------------------------------------------------------------
  use def_gparam
  use earth_modele
  implicit none
  public :: open_fctp,readS,readT,read_interpS,read_interpT,get_Lmax,get_Nmax &
           ,get_eigenw,get_1Dmodel,mode_existe,get_fmaxc,get_tref,euler,close_fctp &
capdevil's avatar
   
capdevil committed
16
           ,get_1Dmodelb,write_modeT_ascii, write_modeS_ascii,open_fctp1,get_minmaxN
capdevil's avatar
capdevil committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  private
  integer   :: LLmaxS,NNmaxS,LLmaxT,NNmaxT,nkS,nkT,nb_discT,nb_discS
  integer,parameter   :: unitfctpS=155,unitfctpT=154
  real(DP), dimension(:,:), allocatable :: omtabS,qtabS,gctabS
  integer , dimension(:,:), allocatable :: irecS
  real(DP), dimension(:)  , allocatable :: rayS,discS_rad,discT_rad
  integer , dimension(:)  , allocatable :: discS_index,discT_index
  real(DP), dimension(:,:), allocatable :: omtabT,qtabT,gctabT
  integer , dimension(:,:), allocatable :: irecT
  real(DP), dimension(:)  , allocatable :: rayT
  type(modele) :: modele1D
!
  logical :: files_open=.false.,modele1D_read=.false. &
            ,files_openS=.false.,files_openT=.false.
!====================================================================
contains
!====================================================================
!-------------------------------------------------------------------- 
      SUBROUTINE open_fctp(fichierfctpS,fichierfctpT,model1Dfile,rad_recepteur)
!
!
!     fichierfctp: character*90, nom du fichier de fonction propre
!                  sans extension
!     unitfctp   : entier, unite logique du fichier de fctp desiree
!
!    irec(0:LLmax,0:NNmax) :tableaux d'entier des numeros de record
!                           des foctions propres
!    omtab(0:LLmax,0:NNmax):tableau de real*8,  w en rad/s
!    qtab(0:LLmax,0:NNmax) :tableau de real*8, attenuations
!    gctab(0:LLmax,0:NNmax):tableau de real*8, vitesses de groupe
!    nocean                :entier, nb de couches de l'ocean
!    nk                    :entier , nombre de couches du model
!    ray(NCM)              :tableau de real*4, couches du model
!--------------------------------------------------------------------
        use global_main_param, only: RA
        use earth_modele
        IMPLICIT NONE
!
      character(len=90), intent(in) :: fichierfctpS,fichierfctpT
      character(len=90), optional, intent(in) :: model1Dfile
      real(DP), optional, intent(out) :: rad_recepteur
!
      character(len=90) :: fichierdirect,fichierinfo,ext
      real(DP) :: ww,qq,gc,wdiff      
capdevil's avatar
   
capdevil committed
61
      integer  ::  LEN,unitinfo,indicepointeur,n,l,ibid,i,nocean,ier,k,iversion
capdevil's avatar
capdevil committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
      logical ::  flag
      real(SP), dimension(:)  , allocatable :: ray_tmp,ray_tmp2
!
!on Lit d'abord le fichier Spheroidaux
!
	unitinfo=73
      ext='.direct '
      call extension(fichierfctpS,fichierdirect,ext)
      ext='.info'
      call extension(fichierfctpS,fichierinfo,'.info ')
!
      inquire(file=fichierdirect,EXIST=flag)
      if (.not.flag) then
         print*,'le fichier',fichierdirect,'n''existe pas???'
         stop
      endif
      inquire(file=fichierinfo,EXIST=flag)
      if (.not.flag) then
         print*,'le fichier',fichierinfo,'n''existe pas???'
         stop
      endif
      call get_len(fichierdirect,LEN)
      open(unitfctpS,file=fichierdirect,status='old',access='direct' &
               ,recl=LEN)
      open(unitinfo,file=fichierinfo)
      read(unitfctpS,rec=1)ibid,ibid,ibid,nocean,nkS
      allocate(rayS(nkS),ray_tmp(nkS))
!reading raius and track for discontinuities
capdevil's avatar
   
capdevil committed
90
91
      read(unitfctpS,rec=1)ibid,ibid,ibid,nocean,nkS,(ray_tmp(i),i=1,nkS),iversion,RA
      if (iversion/=4) STOP 'The program expect minosy version >= 0.4 !!'
capdevil's avatar
capdevil committed
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
!km SP ->m DP
      rayS(:)=dble(ray_tmp(1:nkS))*RA 
      if (present(rad_recepteur)) rad_recepteur=rayS(nkS-nocean)-0.1
      nb_discS=0
      do i=1,nkS-1
         if (abs(rayS(i)-rayS(i+1))<1e-8)  nb_discS=nb_discS+1
      enddo  
      allocate(discS_index(0:nb_discS+1),discS_rad(0:nb_discS+1))
      discS_index(0)=0
      discS_index(nb_discS+1)=nkS
      discS_rad(0)  =rayS(1)
      discS_rad(nb_discS+1) =rayS(nkS)
      k=0
      do i=1,nkS-1
         if (abs(rayS(i)-rayS(i+1))<1e-8) then
            k=k+1
            discS_index(k)=i
            discS_rad  (k)=rayS(i)
         endif
      enddo  
      deallocate(ray_tmp)
!scaning for LLmax and NNmax:
      LLmaxS=0;NNmaxS=0
 10   read(unitinfo,*,END=99) n,l,ww,qq,gc,indicepointeur,wdiff,flag
         if (l>LLmaxS) LLmaxS=l
         if (n>NNmaxS) NNmaxS=n
         goto 10 
 99   continue
      allocate(irecS(0:LLmaxS,0:NNmaxS),omtabS(0:LLmaxS,0:NNmaxS)  &
              ,qtabS(0:LLmaxS,0:NNmaxS),gctabS(0:LLmaxS,0:NNmaxS), stat=ier  )
      irecS(:,:)=0
      if (ier/=0) then
         print*,'LLmaxS=',LLmaxS
         print*,'NNmaxS=',NNmaxS
         print*,(4.+8.*3.)*dble(LLmaxS+1)*dble(NNmaxS+1)/1024./1024.,' Mb'
         stop 'open_fctp: probleme d''allocation memoire'
      endif
      rewind(unitinfo)
!relecture
 11   read(unitinfo,*,END=98) n,l,ww,qq,gc,indicepointeur,wdiff,flag
         irecS (l,n)=indicepointeur
         omtabS(l,n)=ww
         qtabS (l,n)=qq
         gctabS(l,n)=gc
capdevil's avatar
   
capdevil committed
136
         if ((abs(wdiff).gt.1.d-9.and.flag).or.abs(wdiff).gt.1d-3) irecS(l,n)=0
capdevil's avatar
capdevil committed
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
      goto 11 
 98   continue     
      close(unitinfo)
      fichierdirect(:)=' '
      fichierinfo(:)=' '

!
!on Lit ensuite le fichier Toroidaux
!
      call extension(fichierfctpT,fichierdirect,'.direct ')
      call extension(fichierfctpT,fichierinfo,'.info ')
!
      inquire(file=fichierdirect,EXIST=flag)
      if (.not.flag) then
         print*,'le fichier',fichierdirect,'n''existe pas???'
         stop
      endif
      inquire(file=fichierinfo,EXIST=flag)
      if (.not.flag) then
         print*,'le fichier',fichierinfo,'n''existe pas???'
         stop
      endif
      call get_len(fichierdirect,LEN)
      open(unitfctpT,file=fichierdirect,status='old',access='direct' &
                ,recl=LEN)
      open(unitinfo,file=fichierinfo)
      read(unitfctpT,rec=1)ibid,ibid,ibid,nocean,nkT
      allocate(rayT(nkT),ray_tmp(nkT))
!reading raius and track for discontinuities
capdevil's avatar
   
capdevil committed
166
167
      read(unitfctpT,rec=1)ibid,ibid,ibid,nocean,nkT,(ray_tmp(i),i=1,nkT),iversion,RA
      if (iversion/=4) STOP 'The program expect minosy version >= 0.4 !!'
capdevil's avatar
capdevil committed
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
!km SP ->m DP
      rayT(:)=dble(ray_tmp(1:nkT))*RA
      nb_discT=0
      do i=1,nkT-1
         if (abs(rayT(i)-rayT(i+1))<1e-8)  nb_discT=nb_discT+1
      enddo  
      allocate(discT_index(0:nb_discT+1),discT_rad(0:nb_discT+1))
      discT_index(0)=0
      discT_index(nb_discT+1)=nkT
      discT_rad(0)  =rayT(1)
      discT_rad(nb_discT+1) =rayT(nkT)
      k=0
      do i=1,nkT-1
         if (abs(rayT(i)-rayT(i+1))<1e-8) then
            k=k+1
            discT_index(k)=i
            discT_rad  (k)=rayT(i)
         endif
      enddo  
      deallocate(ray_tmp)
!scaning for LLmax and NNmax:
      LLmaxT=0;NNmaxT=0
 110   read(unitinfo,*,END=199) n,l,ww,qq,gc,indicepointeur,wdiff,flag
         if (l>LLmaxT) LLmaxT=l
         if (n>NNmaxT) NNmaxT=n
         goto 110 
 199   continue
      allocate(irecT(0:LLmaxT,0:NNmaxT),omtabT(0:LLmaxT,0:NNmaxT))
      allocate(qtabT(0:LLmaxT,0:NNmaxT),gctabT(0:LLmaxT,0:NNmaxT))
      irecT(:,:)=0 
      rewind(unitinfo)
!relecture
 111   read(unitinfo,*,END=198) n,l,ww,qq,gc,indicepointeur,wdiff,flag
         irecT (l,n)=indicepointeur
         omtabT(l,n)=ww
         qtabT (l,n)=qq
         gctabT(l,n)=gc
capdevil's avatar
   
capdevil committed
205
         if ((abs(wdiff).gt.1.d-9.and.flag).or.abs(wdiff).gt.1d-5) irecT(l,n)=0
capdevil's avatar
capdevil committed
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
      goto 111
 198   continue     
      close(unitinfo)
      fichierdirect(:)=' '
      fichierinfo(:)=' '
!
      if (present(model1Dfile)) then ! on lit aussi le model
         call read_modele(model1Dfile,modele1D)
         modele1D_read=.true.
      endif
!
      files_open=.true.
!----------------------------------------------------------------------------
      end subroutine open_fctp
!----------------------------------------------------------------------------

!-------------------------------------------------------------------- 
      SUBROUTINE open_fctp1(fichierfctp,type)
!
!
!     fichierfctp: character*90, nom du fichier de fonction propre
!                  sans extension
!     unitfctp   : entier, unite logique du fichier de fctp desiree
!
!    irec(0:LLmax,0:NNmax) :tableaux d'entier des numeros de record
!                           des foctions propres
!    omtab(0:LLmax,0:NNmax):tableau de real*8,  w en rad/s
!    qtab(0:LLmax,0:NNmax) :tableau de real*8, attenuations
!    gctab(0:LLmax,0:NNmax):tableau de real*8, vitesses de groupe
!    nocean                :entier, nb de couches de l'ocean
!    nk                    :entier , nombre de couches du model
!    ray(NCM)              :tableau de real*4, couches du model
!--------------------------------------------------------------------
        use global_main_param, only: RA
        use earth_modele
        IMPLICIT NONE
!
      character(len=90), intent(in) :: fichierfctp
      character(len=1), intent(in) :: type
!
      character(len=90) :: fichierdirect,fichierinfo,ext
      real(DP) :: ww,qq,gc,wdiff      
capdevil's avatar
   
capdevil committed
248
      integer  ::  LEN,unitinfo,indicepointeur,n,l,ibid,i,nocean,ier,k,unitfctp,iversion
capdevil's avatar
capdevil committed
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
      logical ::  flag
      real(SP), dimension(:)  , allocatable :: ray_tmp,ray_tmp2
!
!on Lit d'abord le fichier Spheroidaux
!
      unitfctp=118
      unitinfo=73
      if (type=='S') then
         ext='.direct '
         call extension(fichierfctp,fichierdirect,ext)
         ext='.info'
         call extension(fichierfctp,fichierinfo,'.info ')
!
         inquire(file=fichierdirect,EXIST=flag)
         if (.not.flag) then
            print*,'le fichier',fichierdirect,'n''existe pas???'
            stop
         endif
         inquire(file=fichierinfo,EXIST=flag)
         if (.not.flag) then
            print*,'le fichier',fichierinfo,'n''existe pas???'
            stop
         endif
         call get_len(fichierdirect,LEN)
         open(unitfctpS,file=fichierdirect,status='old',access='direct' &
           ,recl=LEN)
         open(unitinfo,file=fichierinfo)
         read(unitfctpS,rec=1)ibid,ibid,ibid,nocean,nkS
         allocate(rayS(nkS),ray_tmp(nkS))
!reading raius and track for discontinuities
capdevil's avatar
   
capdevil committed
279
280
         read(unitfctpS,rec=1)ibid,ibid,ibid,nocean,nkS,(ray_tmp(i),i=1,nkS),iversion,RA
         if (iversion/=4) STOP 'The program expect minosy version >= 0.4 !!'
capdevil's avatar
capdevil committed
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
!km SP ->m DP
         rayS(:)=dble(ray_tmp(1:nkS))*RA 
         nb_discS=0
         do i=1,nkS-1
            if (abs(rayS(i)-rayS(i+1))<1e-8)  nb_discS=nb_discS+1
         enddo
         allocate(discS_index(0:nb_discS+1),discS_rad(0:nb_discS+1))
         discS_index(0)=0
         discS_index(nb_discS+1)=nkS
         discS_rad(0)  =rayS(1)
         discS_rad(nb_discS+1) =rayS(nkS)
         k=0
         do i=1,nkS-1
            if (abs(rayS(i)-rayS(i+1))<1e-8) then
               k=k+1
               discS_index(k)=i
               discS_rad  (k)=rayS(i)
            endif
         enddo
         deallocate(ray_tmp)
!scaning for LLmax and NNmax:
         LLmaxS=0;NNmaxS=0
10       read(unitinfo,*,END=99) n,l,ww,qq,gc,indicepointeur,wdiff,flag
         if (l>LLmaxS) LLmaxS=l
         if (n>NNmaxS) NNmaxS=n
         goto 10 
 99   continue
      allocate(irecS(0:LLmaxS,0:NNmaxS),omtabS(0:LLmaxS,0:NNmaxS)  &
              ,qtabS(0:LLmaxS,0:NNmaxS),gctabS(0:LLmaxS,0:NNmaxS), stat=ier  )
      irecS(:,:)=0
      if (ier/=0) then
         print*,'LLmaxS=',LLmaxS
         print*,'NNmaxS=',NNmaxS
         print*,(4.+8.*3.)*dble(LLmaxS+1)*dble(NNmaxS+1)/1024./1024.,' Mb'
         stop 'open_fctp: probleme d''allocation memoire'
      endif
      rewind(unitinfo)
!relecture
 11   read(unitinfo,*,END=98) n,l,ww,qq,gc,indicepointeur,wdiff,flag
         irecS (l,n)=indicepointeur
         omtabS(l,n)=ww
         qtabS (l,n)=qq
         gctabS(l,n)=gc
capdevil's avatar
   
capdevil committed
324
!         if ((abs(wdiff).gt.1.d-9.and.flag).or.abs(wdiff).gt.1d-5) irecS(l,n)=0
capdevil's avatar
capdevil committed
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
      goto 11 
 98   continue     
      close(unitinfo)
      fichierdirect(:)=' '
      fichierinfo(:)=' '
      files_openS=.true.
!-----------------------------
      else if (type=='T') then
!-----------------------------

!
!on Lit ensuite le fichier Toroidaux
!
      call extension(fichierfctp,fichierdirect,'.direct ')
      call extension(fichierfctp,fichierinfo,'.info ')
!
      inquire(file=fichierdirect,EXIST=flag)
      if (.not.flag) then
         print*,'le fichier',fichierdirect,'n''existe pas???'
         stop
      endif
      inquire(file=fichierinfo,EXIST=flag)
      if (.not.flag) then
         print*,'le fichier',fichierinfo,'n''existe pas???'
         stop
      endif
      call get_len(fichierdirect,LEN)
      open(unitfctpT,file=fichierdirect,status='old',access='direct' &
                ,recl=LEN)
      open(unitinfo,file=fichierinfo)
      read(unitfctpT,rec=1)ibid,ibid,ibid,nocean,nkT
      allocate(rayT(nkT),ray_tmp(nkT))
!reading raius and track for discontinuities
capdevil's avatar
   
capdevil committed
358
359
      read(unitfctpT,rec=1)ibid,ibid,ibid,nocean,nkT,(ray_tmp(i),i=1,nkT),iversion,RA
      if (iversion/=4) STOP 'The program expect minosy version >= 0.4 !!'
capdevil's avatar
capdevil committed
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
!km SP ->m DP
      rayT(:)=dble(ray_tmp(1:nkT))*RA
      nb_discT=0
      do i=1,nkT-1
         if (abs(rayT(i)-rayT(i+1))<1e-8)  nb_discT=nb_discT+1
      enddo  
      allocate(discT_index(0:nb_discT+1),discT_rad(0:nb_discT+1))
      discT_index(0)=0
      discT_index(nb_discT+1)=nkT
      discT_rad(0)  =rayT(1)
      discT_rad(nb_discT+1) =rayT(nkT)
      k=0
      do i=1,nkT-1
         if (abs(rayT(i)-rayT(i+1))<1e-8) then
            k=k+1
            discT_index(k)=i
            discT_rad  (k)=rayT(i)
         endif
      enddo  
      deallocate(ray_tmp)
!scaning for LLmax and NNmax:
      LLmaxT=0;NNmaxT=0
 110   read(unitinfo,*,END=199) n,l,ww,qq,gc,indicepointeur,wdiff,flag
         if (l>LLmaxT) LLmaxT=l
         if (n>NNmaxT) NNmaxT=n
         goto 110 
 199   continue
      allocate(irecT(0:LLmaxT,0:NNmaxT),omtabT(0:LLmaxT,0:NNmaxT))
      allocate(qtabT(0:LLmaxT,0:NNmaxT),gctabT(0:LLmaxT,0:NNmaxT))
      irecT(:,:)=0 
      rewind(unitinfo)
!relecture
 111   read(unitinfo,*,END=198) n,l,ww,qq,gc,indicepointeur,wdiff,flag
         irecT (l,n)=indicepointeur
         omtabT(l,n)=ww
         qtabT (l,n)=qq
         gctabT(l,n)=gc
!         if ((abs(wdiff).gt.1.d-9.and.flag).or.abs(wdiff).gt.1d-5) irecT(l,n)=0
      goto 111
 198   continue     
      close(unitinfo)
      fichierdirect(:)=' '
      fichierinfo(:)=' '
      files_openT=.true.
!
      else
         stop 'open_fctp1: type must be S or T'
      endif
      files_open=.true.
!
!----------------------------------------------------------------------------
      end subroutine open_fctp1
!----------------------------------------------------------------------------
!----------------------------------------------------------------------------
      subroutine close_fctp
!----------------------------------------------------------------------------
        implicit none
        close(unitfctpS)
        close(unitfctpT)
        deallocate(rayS,discS_index,discS_rad,irecS,omtabS,qtabS,gctabS)
        deallocate(rayT,discT_index,discT_rad,irecT,omtabT,qtabT,gctabT)
        files_open=.false.
!----------------------------------------------------------------------------
      end subroutine close_fctp
!----------------------------------------------------------------------------

!----------------------------------------------------------------------------
      subroutine get_Lmax(fmax,LmaxS,LmaxT)
!----------------------------------------------------------------------------
        use def_gparam
        implicit none
        real(DP), intent(in) :: fmax
        integer, intent(out) :: LmaxS,LmaxT
!
        integer :: l
        real(DP) :: wmax
!
        wmax=2._DP*PI*fmax
        LmaxS=-1;LmaxT=-1
!
        if (.not.files_open) stop 'get_lmax: call open_fctp first!'
!on ne cherche que sur le mode fondamentale
        do l=0,LLmaxS
           if (irecS(l,0)/=0.and.omtabS(l,0)<=wmax.and.l>LmaxS) LmaxS=l
        enddo
        do l=1,LLmaxT
           if (irecT(l,0)/=0.and.omtabT(l,0)<=wmax.and.l>LmaxT) LmaxT=l
        enddo
!----------------------------------------------------------------------------
      end subroutine get_Lmax
!----------------------------------------------------------------------------

!----------------------------------------------------------------------------
      subroutine get_fmaxc(Lmax,fmax)
!----------------------------------------------------------------------------
        use def_gparam
        implicit none
        integer, intent(in)  :: Lmax
        real(DP), intent(out):: fmax
        integer :: l
!on ne cherche que sur le mode fondamentale spheroidale        
        if (l>LLmaxS) then
           print*,'get_fmaxc: Attention, l> LLmaxS:',l,LLmaxS
           fmax=omtabS(LLmaxS,0)/2._DP/PI
        else
           l=Lmax+1
           do while(irecS(l,0)==0) 
              l=l-1
              if (l<0) stop 'get_fmaxc: Ca va pas ....!'
           enddo
           fmax=omtabS(l,0)/2._DP/PI
        endif        
!----------------------------------------------------------------------------
      end subroutine get_fmaxc
!----------------------------------------------------------------------------

!----------------------------------------------------------------------------
      subroutine get_eigenw(eigw,qw,LmaxS,NmaxS,LmaxT,NmaxT)
!----------------------------------------------------------------------------
        use def_gparam
        implicit none
        integer, intent(in) :: LmaxS,LmaxT
        integer, dimension(0:), intent(in) :: NmaxS,NmaxT        
        real(DP), dimension(0:,0:,:), intent(out) :: eigw,qw
!
        integer :: l,n
!
        do l=0,LmaxS
           do n=0,NmaxS(l)
              eigw(n,l,1)=omtabS(l,n)
              if (qtabS(l,n)/=0._DP) then
                 qw(n,l,1)  =omtabS(l,n)/(2._DP*qtabS(l,n))
              else
                 qw(n,l,1)  =0.0_DP
              endif
           enddo
        enddo
        do l=1,LmaxT
           do n=0,NmaxT(l)
              eigw(n,l,2)=omtabT(l,n)
              if (qtabT(l,n)/=0._DP) then
                 qw(n,l,2)  =omtabT(l,n)/(2._DP*qtabT(l,n))
              else
                 qw(n,l,2)  =0.0_DP
              endif
           enddo
        enddo
!----------------------------------------------------------------------------
      end subroutine get_eigenw
!----------------------------------------------------------------------------
!----------------------------------------------------------------------------
      subroutine get_Nmax(fmax,NmaxS,NmaxT)
!no
!----------------------------------------------------------------------------
        use def_gparam
        implicit none
        real(DP), intent(in) :: fmax
        integer, dimension(0:), intent(out) :: NmaxS,NmaxT
!
        integer :: l,Lmax,LmaxT,LmaxS,n
        real(DP) :: wmax
!
        wmax=2._DP*PI*fmax
!on recalcul Lmax. Normalement cette operation a deja ete effectue a 
!l'exterieur pour allouer NmaxS et NmaxT
        call get_lmax(fmax,LmaxS,LmaxT)
!
        NmaxS(:)=-1
        NmaxT(:)=-1
        do l=0,LmaxS
           NmaxS(l)=-1
           do n=0,NNmaxS
              if (irecS(l,n)/=0.and.omtabS(l,n)<=wmax.and.n>NmaxS(l)) NmaxS(l)=n
           enddo
        enddo        
        do l=1,LmaxT
           NmaxT(l)=-1
           do n=0,NNmaxT
              if (irecT(l,n)/=0.and.omtabT(l,n)<=wmax.and.n>NmaxT(l)) NmaxT(l)=n
           enddo
        enddo
        NmaxT(0)=0
!----------------------------------------------------------------------------
      end subroutine get_Nmax
!----------------------------------------------------------------------------
capdevil's avatar
   
capdevil committed
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
!----------------------------------------------------------------------------
      subroutine get_minmaxN(s,l,Nmin,Nmax)
!no
!----------------------------------------------------------------------------
        use def_gparam
        implicit none
        integer, intent(in) :: s,l
        integer,  intent(out) :: Nmin,Nmax
!
        integer :: Lmax,LmaxT,LmaxS,n
        real(DP) :: wmax
!

!        NmaxS(:)=-1
!        NmaxT(:)=-1
!        do l=0,LmaxS
        if (s==1.or.s==11.or.s==2.or.s==33) then
           Nmax=-1
           Nmin=100000
           do n=0,NNmaxS
              if (irecS(l,n)/=0) then
                 Nmax=max(Nmax,n)
                 Nmin=min(Nmin,n)
              endif
           enddo
        else    
           Nmax=-1
           Nmin=100000
           do n=0,NNmaxT
              if (irecT(l,n)/=0) then
                 Nmax=max(Nmax,n)
                 Nmin=min(Nmin,n)
              endif
           enddo  
        endif
!----------------------------------------------------------------------------
      end subroutine get_minmaxN
!----------------------------------------------------------------------------
capdevil's avatar
capdevil committed
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
!----------------------------------------------------------------------------
      SUBROUTINE get_len(file,LEN)
!retourne la longueur des records des fichiers de fctps a acces direct
!produit par classeT ou classeS.
!INPUT:
!    file: character*90, nom du fichier a acces direct
!OUTPUT
!    LEN: entier, longueur du record
!----------------------------------------------------------------------------
      IMPLICIT NONE
!
      character*90 file
      integer LEN
      
!
      open(22,file=file,status='old',access='direct',RECL=4)
      read(22,rec=1)len
      close(22)
!
!-----------------------------------------------------------------
      end SUBROUTINE get_len
!-----------------------------------------------------------------
!--------------------------------------------------------------------------
  real function get_tref()
!--------------------------------------------------------------------------
    implicit none
    get_tref=modele1D%tref
!--------------------------------------------------------------------------
  end function get_tref
!--------------------------------------------------------------------------
!-----------------------------------------------------------------
      subroutine get_1Dmodel(rho,Vs,Vp,Qs,NBV,rad)
!-----------------------------------------------------------------
        use def_gparam
        use module_spline
        implicit none
        integer, intent(in) :: NBV
        real(DP), dimension(NBV), intent(in ) :: rad
        real(DP), dimension(NBV), intent(out) :: rho,Vs,Vp,Qs
!
        integer :: i,k,ka,kb,nd,si,kas,kbs
        real(DP), dimension(nkT,nb_discT+1,4)   :: y2
        real(DP)        :: yp1,ypn
!d'abord on cherche l'index de de depart: (si=start_index)
        do i=1,modele1D%nbcou
           if (abs(modele1D%r(i)-rayT(1))/rayT(1)< 1.E-7_DP) si=i
        enddo
        si=si-1
!        print*,'start_index=',si
!
        if (modele1D_read) then
           do nd=1,nb_discT+1
              ka=discT_index(nd-1)+1 
              kb=discT_index(nd)     
              kbs=kb+si
              kas=ka+si
!
              yp1=(modele1D%rho(kas+1)-modele1D%rho(kas  ))/(rayT(ka+1)-rayT(ka  ))
              ypn=(modele1D%rho(kbs  )-modele1D%rho(kbs-1))/(rayT(kb  )-rayT(kb-1))
              call spline(rayT(ka:kb),modele1D%rho(kas:kbs),yp1,ypn,y2(ka:kb,nd,1))                 
!
              yp1=(modele1D%vpv(kas+1)-modele1D%vpv(kas  ))/(rayT(ka+1)-rayT(ka  ))
              ypn=(modele1D%vpv(kbs  )-modele1D%vpv(kbs-1))/(rayT(kb  )-rayT(kb-1))
              call spline(rayT(ka:kb),modele1D%vpv(kas:kbs),yp1,ypn,y2(ka:kb,nd,2))
!                 
              yp1=(modele1D%vsv(kas+1)-modele1D%vsv(kas  ))/(rayT(ka+1)-rayT(ka  ))
              ypn=(modele1D%vsv(kbs  )-modele1D%vsv(kbs-1))/(rayT(kb  )-rayT(kb-1))
              call spline(rayT(ka:kb),modele1D%vsv(kas:kbs),yp1,ypn,y2(ka:kb,nd,3))                 
!
              yp1=(modele1D%qshear(kas+1)-modele1D%qshear(kas  ))/(rayT(ka+1)-rayT(ka  ))
              ypn=(modele1D%qshear(kbs  )-modele1D%qshear(kbs-1))/(rayT(kb  )-rayT(kb-1))
              call spline(rayT(ka:kb),modele1D%qshear(kas:kbs),yp1,ypn,y2(ka:kb,nd,4))                 
!
           enddo
           do i=1,NBV
              nd=locate(discT_rad,nb_discT,rad(i))
              ka=discT_index(nd-1)+1 
              kb=discT_index(nd)     
              kbs=kb+si
              kas=ka+si              
              rho(i)=splint(rayT(ka:kb),modele1D%rho(kas:kbs)   ,y2(ka:kb,nd,1),rad(i))
              vp (i)=splint(rayT(ka:kb),modele1D%vpv(kas:kbs)   ,y2(ka:kb,nd,2),rad(i))
              vs (i)=splint(rayT(ka:kb),modele1D%vsv(kas:kbs)   ,y2(ka:kb,nd,3),rad(i))
              qs (i)=splint(rayT(ka:kb),modele1D%qshear(kas:kbs),y2(ka:kb,nd,4),rad(i))
           enddo
        else
           stop 'get_1Dmodel: le model n''a pas ete lu!'
        endif        
!-----------------------------------------------------------------
      end subroutine get_1Dmodel
!-----------------------------------------------------------------

!-----------------------------------------------------------------
      subroutine get_1Dmodelb(modele_name,rho,vph,vpv,vsh,vsv,eta,qs,NBV,rad)
!-----------------------------------------------------------------
        use def_gparam
        use module_spline
        implicit none
        integer, intent(in) :: NBV
        character(len=*), intent(in) :: modele_name
        real(DP), dimension(NBV), intent(in ) :: rad
        real(DP), dimension(NBV), intent(out) :: rho,vph,vpv,vsh,vsv,eta,qs
!
        integer :: i,k,ka,kb,nd,si,kas,kbs
        real(DP), dimension(nkT,nb_discT+1,7)   :: y2
        real(DP)        :: yp1,ypn
        type(modele) :: mod1D
!d'abord on cherche l'index de de depart: (si=start_index)
         call read_modele(modele_name,mod1D)
        do i=1,mod1D%nbcou
           if (abs(mod1D%r(i)-rayT(1))/rayT(1)< 1.E-7_DP) si=i
        enddo
        si=si-1
!        print*,'start_index=',si
!
        do nd=1,nb_discT+1
           ka=discT_index(nd-1)+1 
           kb=discT_index(nd)     
           kbs=kb+si
           kas=ka+si
!
           yp1=(mod1D%rho(kas+1)-mod1D%rho(kas  ))/(rayT(ka+1)-rayT(ka  ))
           ypn=(mod1D%rho(kbs  )-mod1D%rho(kbs-1))/(rayT(kb  )-rayT(kb-1))
           call spline(rayT(ka:kb),mod1D%rho(kas:kbs),yp1,ypn,y2(ka:kb,nd,1))                 
!
           yp1=(mod1D%vpv(kas+1)-mod1D%vpv(kas  ))/(rayT(ka+1)-rayT(ka  ))
           ypn=(mod1D%vpv(kbs  )-mod1D%vpv(kbs-1))/(rayT(kb  )-rayT(kb-1))
           call spline(rayT(ka:kb),mod1D%vpv(kas:kbs),yp1,ypn,y2(ka:kb,nd,2))
!                 
           yp1=(mod1D%vsv(kas+1)-mod1D%vsv(kas  ))/(rayT(ka+1)-rayT(ka  ))
           ypn=(mod1D%vsv(kbs  )-mod1D%vsv(kbs-1))/(rayT(kb  )-rayT(kb-1))
           call spline(rayT(ka:kb),mod1D%vsv(kas:kbs),yp1,ypn,y2(ka:kb,nd,3))                 
!
           yp1=(mod1D%qshear(kas+1)-mod1D%qshear(kas  ))/(rayT(ka+1)-rayT(ka  ))
           ypn=(mod1D%qshear(kbs  )-mod1D%qshear(kbs-1))/(rayT(kb  )-rayT(kb-1))
           call spline(rayT(ka:kb),mod1D%qshear(kas:kbs),yp1,ypn,y2(ka:kb,nd,4))                 
!
           yp1=(mod1D%vph(kas+1)-mod1D%vpv(kas  ))/(rayT(ka+1)-rayT(ka  ))
           ypn=(mod1D%vph(kbs  )-mod1D%vpv(kbs-1))/(rayT(kb  )-rayT(kb-1))
           call spline(rayT(ka:kb),mod1D%vph(kas:kbs),yp1,ypn,y2(ka:kb,nd,5))
!                 
           yp1=(mod1D%vsh(kas+1)-mod1D%vsv(kas  ))/(rayT(ka+1)-rayT(ka  ))
           ypn=(mod1D%vsh(kbs  )-mod1D%vsv(kbs-1))/(rayT(kb  )-rayT(kb-1))
           call spline(rayT(ka:kb),mod1D%vsh(kas:kbs),yp1,ypn,y2(ka:kb,nd,6))                 
!
           yp1=(mod1D%eta(kas+1)-mod1D%eta(kas  ))/(rayT(ka+1)-rayT(ka  ))
           ypn=(mod1D%eta(kbs  )-mod1D%eta(kbs-1))/(rayT(kb  )-rayT(kb-1))
           call spline(rayT(ka:kb),mod1D%eta(kas:kbs),yp1,ypn,y2(ka:kb,nd,7))                 
!
        enddo
        do i=1,NBV
           nd=locate(discT_rad,nb_discT,rad(i))
           ka=discT_index(nd-1)+1 
           kb=discT_index(nd)     
           kbs=kb+si
           kas=ka+si              
           rho(i)=splint(rayT(ka:kb),mod1D%rho(kas:kbs)   ,y2(ka:kb,nd,1),rad(i))
           vph (i)=splint(rayT(ka:kb),mod1D%vpv(kas:kbs)   ,y2(ka:kb,nd,2),rad(i))
           vsh (i)=splint(rayT(ka:kb),mod1D%vsv(kas:kbs)   ,y2(ka:kb,nd,3),rad(i))
           qs (i)=splint(rayT(ka:kb),mod1D%qshear(kas:kbs),y2(ka:kb,nd,4),rad(i))
           vpv (i)=splint(rayT(ka:kb),mod1D%vpv(kas:kbs)   ,y2(ka:kb,nd,5),rad(i))
           vsv (i)=splint(rayT(ka:kb),mod1D%vsv(kas:kbs)   ,y2(ka:kb,nd,6),rad(i))
           eta(i)=splint(rayT(ka:kb),mod1D%qshear(kas:kbs),y2(ka:kb,nd,7),rad(i))
        enddo
!-----------------------------------------------------------------
      end subroutine get_1Dmodelb
!-----------------------------------------------------------------
!-----------------------------------------------------------------
      subroutine write_modeT_ascii(unit,s,n,l)
!-----------------------------------------------------------------
capdevil's avatar
   
capdevil committed
753
        use global_main_param, only: RA
capdevil's avatar
capdevil committed
754
755
756
        implicit none
        integer, intent(in) :: unit,n,l,s
        real(DP), dimension(2,nkT) :: xdum
capdevil's avatar
   
capdevil committed
757

capdevil's avatar
capdevil committed
758
759
760
761
762
        integer :: i,iflag
        if (.not.files_openT) stop 'write_modeT_ascii: use open_fctp1 with T type first'
        call readT(n,l,xdum,iflag)
        if (s.eq.3) then
           do i=1,nkT
capdevil's avatar
   
capdevil committed
763
              write(unit,*)(RA-rayT(i)),sqrt(float(l*(l+1)))*xdum(1,i)
capdevil's avatar
capdevil committed
764
765
766
           enddo
        else if (s.eq.33) then
           do i=1,nkT
capdevil's avatar
   
capdevil committed
767
              write(unit,*)(RA-rayT(i)),sqrt(float(l*(l+1)))*xdum(2,i)
capdevil's avatar
capdevil committed
768
769
770
771
772
773
774
775
776
           enddo
        endif
!-----------------------------------------------------------------
      end subroutine write_modeT_ascii
!-----------------------------------------------------------------

!-----------------------------------------------------------------
      subroutine write_modeS_ascii(unit,s,n,l)
!-----------------------------------------------------------------
capdevil's avatar
   
capdevil committed
777
        use global_main_param, only: RA
capdevil's avatar
capdevil committed
778
779
        implicit none
        integer, intent(in) :: unit,n,l,s
780
        real(DP), dimension(:,:), allocatable :: xdum
capdevil's avatar
   
capdevil committed
781

capdevil's avatar
capdevil committed
782
783
        integer :: i,iflag
        if (.not.files_openS) stop 'write_modeS_ascii: use open_fctp1 with S type first'
784
785
786
787
788
        if (s>22) then
           allocate(xdum(6,nkS))
        else
           allocate(xdum(4,nkS))
        endif
capdevil's avatar
capdevil committed
789
        call readS(n,l,xdum,iflag)
capdevil's avatar
   
capdevil committed
790
!print*,maxval(abs(xdum)),ubound(xdum)
capdevil's avatar
capdevil committed
791
792
        if (s.eq.1) then
           do i=1,nkS
capdevil's avatar
   
capdevil committed
793
              write(unit,*)(RA-rayS(i)),xdum(1,i)
capdevil's avatar
capdevil committed
794
795
796
           enddo
        else if (s.eq.11) then
           do i=1,nkS
capdevil's avatar
   
capdevil committed
797
              write(unit,*)(RA-rayS(i)),xdum(2,i)
capdevil's avatar
capdevil committed
798
799
800
           enddo
        else if (s.eq.2) then
           do i=1,nkS
capdevil's avatar
   
capdevil committed
801
              write(unit,*)(RA-rayS(i)),sqrt(float(l*(l+1)))*xdum(3,i)
capdevil's avatar
capdevil committed
802
803
804
           enddo
        else if (s.eq.22) then
           do i=1,nkS
capdevil's avatar
   
capdevil committed
805
              write(unit,*)(RA-rayS(i)),sqrt(float(l*(l+1)))*xdum(4,i)
capdevil's avatar
capdevil committed
806
           enddo
807
808
809
810
811
812
813
814
        else if (s.eq.4) then
           do i=1,nkS
              write(unit,*)(RA-rayS(i)),xdum(5,i)
           enddo
        else if (s.eq.44) then
           do i=1,nkS
              write(unit,*)(RA-rayS(i)),xdum(6,i)
           enddo
capdevil's avatar
capdevil committed
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
        endif
!-----------------------------------------------------------------
      end subroutine write_modeS_ascii
!-----------------------------------------------------------------
!-----------------------------------------------------------------
      subroutine read_interpT(n,l,NBV,rad,fctp)
!-----------------------------------------------------------------
        use def_gparam
        use module_spline
        implicit none
        integer, intent(in) :: n,l,NBV
        real(DP), dimension(NBV), intent(in)  :: rad
        real(DP), dimension(2,NBV),intent(out):: fctp
!
        integer :: iflag,i,k,ka,kb,nd
        real(DP), dimension(2,nkT) :: xdum
        real(DP), dimension(nkT,nb_discT+1)   :: y2
        real(DP)  :: yp1,ypn
!
        call readT(n,l,xdum,iflag)
        if (iflag==0) then
           do k=1,2
              do nd=1,nb_discT+1
                 ka=discT_index(nd-1)+1
                 kb=discT_index(nd)
                 yp1=(xdum(k,ka+1)-xdum(k,ka  ))/(rayT(ka+1)-rayT(ka  ))
                 ypn=(xdum(k,kb  )-xdum(k,kb-1))/(rayT(kb  )-rayT(kb-1))
                 call spline(rayT(ka:kb),xdum(k,ka:kb),yp1,ypn,y2(ka:kb,nd))                 
              enddo 
              do i=1,NBV
                 nd=locate(discT_rad,nb_discT,rad(i))
                 ka=discT_index(nd-1)+1
                 kb=discT_index(nd)                
                 fctp(k,i)=splint(rayT(ka:kb),xdum(k,ka:kb),y2(ka:kb,nd),rad(i))
              enddo
           enddo
        else
           fctp(:,:)=0.0_DP
        endif
!-----------------------------------------------------------------
      end subroutine read_interpT
!-----------------------------------------------------------------

!-----------------------------------------------------------------
      subroutine read_interpS(n,l,NBV,rad,fctp)
!-----------------------------------------------------------------
        use def_gparam
        use module_spline
        implicit none
        integer, intent(in) :: n,l,NBV
        real(DP), dimension(NBV)  , intent(in):: rad
        real(DP), dimension(4,NBV),intent(out):: fctp
!
        integer :: iflag,i,k,ka,kb,nd
        real(DP), dimension(4,nkS) :: xdum
        real(DP), dimension(nkS,nb_discS+1) :: y2
        real(DP) :: yp1,ypn
!
        call readS(n,l,xdum,iflag)
        if (iflag==0) then
           do k=1,4
              do nd=1,nb_discS+1
                 ka=discS_index(nd-1)+1
                 kb=discS_index(nd)
                 yp1=(xdum(k,ka+1)-xdum(k,ka  ))/(rayS(ka+1)-rayS(ka  ))
                 ypn=(xdum(k,kb  )-xdum(k,kb-1))/(rayS(kb  )-rayS(kb-1))
                 call spline(rayS(ka:kb),xdum(k,ka:kb),yp1,ypn,y2(ka:kb,nd))
              enddo
              do i=1,NBV
                 nd=locate(discS_rad,nb_discS,rad(i))
capdevil's avatar
capdevil committed
885
!
capdevil's avatar
capdevil committed
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
                 ka=discS_index(nd-1)+1
                 kb=discS_index(nd)                
                 fctp(k,i)=splint(rayS(ka:kb),xdum(k,ka:kb),y2(ka:kb,nd),rad(i))
              enddo
           enddo
        else
           fctp(:,:)=0.0_DP
        endif
!-----------------------------------------------------------------
      end subroutine read_interpS
!-----------------------------------------------------------------

!-----------------------------------------------------------------
      integer function locate(inter,n,x)
!-----------------------------------------------------------------
         use def_gparam
         implicit none      
         integer, intent(in) :: n
         real(DP), dimension(0:n+1), intent(in) :: inter
         real(DP), intent(in) :: x         
!
         integer :: i
         i=0
         if (abs (x-inter(0))/max(x,inter(0)) <1.E-10_DP) then
            i=1
         else if ( abs (x-inter(n+1))/max(x,inter(n+1))  <1.E-10_DP) then
            i=n
         else
            do while (  x < inter(i) .or. x > inter(i+1) )
               i=i+1
               if (i > n) then
                  print*,'i=',i,'n=',n
                  print*,'x=',x
                  print*,'inter=',inter
                  stop 'locate: failed to locate x in inter!'
               endif
            enddo
         endif
         locate=i+1
!-----------------------------------------------------------------
      end function locate
!-----------------------------------------------------------------

!-----------------------------------------------------------------
      subroutine readT(n,l,xdum,iflag)
!lit la fonction propre (n,l) apres ouverture du fichier a acces direct
!par open_fctp
!    
!----------------------------------------------------------------
      use def_gparam
      implicit none
      integer, intent(in) :: l,n
      integer, intent(out):: iflag
      real(DP), dimension(2,nkT), intent(out) ::  xdum
!
      real(DP) :: WW,QQ,GC
capdevil's avatar
   
capdevil committed
942
      real(DP), dimension(nkT*6) :: tt
capdevil's avatar
capdevil committed
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
      integer ::  i,nn,ll,nvec,nb
!    
!nve!est la longueur necessaire pour atteindre la profondeur
!desire pour w wt w':
      if (.not.files_open) stop 'readT: call open_fctp first!'
      nb=nkT
      nvec=int(nb*2)
      if (l<=LLmaxT.and.n<=NNmaxT) then
         if (irecT(l,n)/=0) then
            read(unitfctpT,rec=irecT(l,n)) nn,ll,WW,QQ,GC,(tt(I),I=1,nvec)
            do i=1,nkT
               xdum(1,i)=dble(tt(2*(nkT-i)+1))
               xdum(2,i)=dble(tt(2*(nkT-i)+2))
            enddo
            iflag=0
         else
            iflag=2
            xdum(:,:)=0.0_DP
         endif
      else
         iflag=1
      endif
!-----------------------------------------------------------------
      end subroutine readT
!-----------------------------------------------------------------

!-----------------------------------------------------------------
      subroutine readS(n,l,xdum,iflag)
!-----------------------------------------------------------------
!lit la fonction propre (n,l) apres ouverture du fichier a acces direct
!par open_fctp
!INPUT:
!    ifd: entier, inite logique du fichier a acces direct
!    irec(0:LLmax,0:NNmax),tableau des numeros de records sortie
!                          de open_fctp
!    n et l, entier
!    nk entier:nombre de couches du model
!    np entier:profondeur jusqu'a laquelle on veut lire ls fctps 
!(de np a nk=surface)
!OUPUT:
!    xdum1..6(NCM),fonction propres et derivees
!Attention les fctps 5 et6 ne sont pas lu, je laisse xdum5 et 6 pour 
!des raisons  de conpatibilites ave!d'autres prog.
!    iflag: 1 pas de pb,
!           0 fin du fichier ( ne devrait jamais arriver)
!          -1 erreur a la lecture
!          -2 l ou n depasse LLmax ou NNmax 
!----------------------------------------------------------------
      use def_gparam
      implicit none
      integer, intent(in) :: l,n
      integer, intent(out):: iflag
995
      real(DP), dimension(:,:), intent(out) ::  xdum
capdevil's avatar
capdevil committed
996
997
!
      real(DP) :: WW,QQ,GC
capdevil's avatar
   
capdevil committed
998
      real(DP), dimension(nkS*6) :: tt
capdevil's avatar
capdevil committed
999
1000
      integer :: nvec,i,nn,ll,nb
!