Précédent   Forum du club des développeurs et IT Pro > Autres langages > Autres langages > Fortran
Fortran Forum d'entraide sur la programmation en Fortran. Avant de poster -> FAQ Fortran
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 04/01/2012, 17h52   #1
mayoub
Invité de passage
 
Homme
Ingénieur mécanique
Inscription : janvier 2012
Messages : 3
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Ingénieur mécanique
Secteur : Industrie

Informations forums :
Inscription : janvier 2012
Messages : 3
Points : 0
Points : 0
Par défaut code fortran ne pouvant pas lire un fichier txt

Bonjour,

C'est mon premier message sur le forum, je suis ingénieur mécanique et j'ai un petit code de calcul analytique qui doit lire un fichier d'entrée .txt et faire le calcul. C'est un code que j'ai récupéré et celui qui l'a fait est parti il y a longtemps. J'ai refait le fichier d'entrée .txt puisque il est introuvable.
Voilà j'ai mis la routine d'entrée Read_file, et le fichier texte.
La message d'erreur est : le fichier est corrompu !!

Merci beaucoup de votre aide

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
61
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
90
91
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
136
137
138
139
140
141
142
143
144
    subroutine READ_FILE ( file_name, ANALYS, OMEGAS, DISPIR, DISPOR, BEARAN, BEAREF, IR_setting, OR_setting, FILTER, ERROR)
    
    implicit none
       
    character(len = 64), intent(in)     :: file_name
    real(8)                             :: DISPIR, DISPOR
    integer                             :: ERROR
    integer, dimension(1,5)             :: ANALYS
    logical, dimension(1,8)             :: FILTER
    real(8), dimension ( : , : ), allocatable :: IR_setting, OR_setting
    real(8), dimension(1,2)             :: OMEGAS
    real(8), dimension(1,5)             :: BEARAN, BEAREF
    
    character(len = 6)                  :: STR
    integer                             :: i, num_line 
    integer, dimension(1,8)             :: LABEL
    
    OPEN(1, FILE = file_name, ERR = 301, STATUS = 'OLD', ACTION = 'READ')
    
    i = 0
    FILTER = .false.
    LABEL  = 0
    do WHILE (.NOT. EOF(1))
    
        i = i + 1

        read( 1, FMT = '(a6)', ERR = 302) STR
        
        if ( STR == 'ANALYS' ) then
            if (FILTER(1,1) == .true.) goto 302
            LABEL(1,1)  = i
            FILTER(1,1) = .true.
        end if
        
        if ( STR == 'OMEGAS' ) then
            if (FILTER(1,2) == .true.) goto 302
            LABEL(1,2)  = i
            FILTER(1,2) = .true.
        end if
        
        if ( STR == 'DISPIR' ) then
            if (FILTER(1,3) == .true.) goto 302
            LABEL(1,3)  = i
            FILTER(1,3) = .true.
        end if
        
        if ( STR == 'DISPOR' ) then
            if (FILTER(1,4) == .true.) goto 302
            LABEL(1,4)  = i
            FILTER(1,4) = .true.
        end if
        
        if ( STR == 'BEARAN' ) then
            if (FILTER(1,5) == .true.) goto 302
            LABEL(1,5)  = i
            FILTER(1,5) = .true.
        end if
        
        if ( STR == 'BEAREF' ) then
            if (FILTER(1,6) == .true.) goto 302
            LABEL(1,6)  = i
            FILTER(1,6) = .true.
        end if
        
        if ( STR == 'IR_SET' ) then
            if (FILTER(1,7) == .true.) goto 302
            LABEL(1,7)  = i
            FILTER(1,7) = .true.
        end if
        
        if ( STR == 'OR_SET' ) then
            if (FILTER(1,8) == .true.) goto 302
            LABEL(1,8)  = i
            FILTER(1,8) = .true.
        end if
        
    enddo
    
    if (LABEL(1,1) == 0 .AND. LABEL(1,2) == 0) goto 302    
    rewind(1)
    
    do i = 1, LABEL(1,1)-1 ; read(1,*) ; end do
    read( 1, *, ERR = 302) STR, ANALYS(1,1:5) 
    rewind(1)
    
    do i = 1, LABEL(1,2)-1 ; read(1,*) ; end do
    read( 1, *, ERR = 302) STR, OMEGAS(1,1:2) 
    rewind(1)
    
    if (LABEL(1,3) /= 0) then ;
        do i = 1, LABEL(1,3)-1 ; read(1,*) ; end do
        read( 1, *, ERR = 302) STR, DISPIR
        rewind(1)
    else ; DISPIR = 0.d0
    end if
    
    if (LABEL(1,4) /= 0) then ;
        do i = 1, LABEL(1,4)-1 ; read(1,*) ; end do
        read( 1, *, ERR = 302) STR, DISPOR
        rewind(1)
    else ; DISPOR = 0.d0
    end if
    
    if (LABEL(1,5) /= 0)then ;
        do i = 1, LABEL(1,5)-1 ; read(1,*) ; end do
        read( 1, *, ERR = 302) STR, BEARAN(1,1:5)
        rewind(1)
    else ; BEARAN = 0.d0
    end if
    
    if (LABEL(1,6) /= 0)then ;
        do i = 1, LABEL(1,6)-1 ; read(1,*) ; end do
        read( 1, *, ERR = 302) STR, BEAREF(1,1:5)
        rewind(1)
    else ; BEAREF = 0.d0
    end if
    
    num_line = ANALYS(1,2)
    allocate(IR_setting(num_line,17))
    if (LABEL(1,7) /= 0) then ;
        do i = 1, LABEL(1,7) ; read(1,*) ; end do
        do i = 1, num_line ; read( 1, *, ERR = 302) IR_setting(i,1:17) ; end do
        rewind(1)
    else ; IR_setting = 0.d0
    end if
    
    num_line = ANALYS(1,3)
    allocate(OR_setting(num_line,17))
    if (LABEL(1,8) /= 0) then ;
        do i = 1, LABEL(1,8) ; read(1,*) ; end do
        do i = 1, num_line ; read( 1, *, ERR = 302) OR_setting(i,1:17) ; end do
        rewind(1)
    else ; OR_setting = 0.d0
    end if
    

    CLOSE (1) ; return
    
301 ERROR = 1 ; return ! File not founded
302 ERROR = 2 ; close(1) ; return ! File have bad structure
   
    end subroutine READ_FILE

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
fichier texte :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
ANALYS 
13 2 3 4 5

OMEGAS 
0 0

DISPIR 
1 

DISPOR 
1

BEARAN 
1 2 3 4 5

BEAREF 
1 2 3 4 5

IR_SET 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

OR_SET 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
mayoub est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 22h13   #2
Sylvain Bergeron
Modérateur
 
Inscription : août 2006
Messages : 781
Détails du profil
Informations personnelles :
Localisation : Canada

Informations forums :
Inscription : août 2006
Messages : 781
Points : 1 028
Points : 1 028
Le problème est que les blocs IR_SET et OR_SET manquent de lignes. Ils doivent avoir autant de lignes que les valeurs de ANALYS(2) et (3) respectivement.

En passant, ta routine utilise le unit 1 pour le fichier : c'est une mauvaise idée. Il est toujours plus prudent d'utiliser des units > 10.

Finalement, je ne sais pas d'où vient ton code source, ni quel a été son évolution, mais la stratégie utilisée me semble inutilement compliquée. Le code suivant a la même fonctionnalité, mais est nettement plus lisible (à mon avis) :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
61
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
90
91
92
93
94
95
96
97
98
99
100
101
    subroutine READ_FILE ( file_name, ANALYS, OMEGAS, DISPIR, DISPOR, BEARAN, BEAREF, IR_setting, OR_setting, FILTER, ERROR)

    implicit none

    character(len = *), intent(in)      :: file_name
    real(8)                             :: DISPIR, DISPOR
    integer                             :: ERROR
    integer, dimension(1,5)             :: ANALYS
    logical, dimension(1,8)             :: FILTER
    real(8), dimension ( : , : ), allocatable :: IR_setting, OR_setting
    real(8), dimension(1,2)             :: OMEGAS
    real(8), dimension(1,5)             :: BEARAN, BEAREF
    
    character(len = 6)                  :: Str
    integer                             :: i, num_line 
    integer                             :: k

    DISPIR = 0.d0
    DISPOR = 0.d0
    BEARAN = 0.d0
    BEAREF = 0.d0
    IR_setting = 0.d0
    OR_setting = 0.d0
    
    OPEN(1, FILE = file_name, iostat = k, STATUS = 'OLD', ACTION = 'READ')
    if (k /= 0) then
       Error = 1
       return
    endif
    
    FILTER = .false.
    i = 0
    Error = 2
    do
        i = i + 1

        read( 1, FMT = '(a)', iostat = k) Str
        if (k < 0) exit ! EOF
        if (k > 0) return ! Error = 2

        select case(Str)
        case('ANALYS')
            if (FILTER(1,1)) return ! Error = 2
            FILTER(1,1) = .true.
            backspace(1)
            read(1,*, iostat = k) Str, ANALYS(1,1:5)
            if (k /= 0) return ! Error = 2
            allocate(IR_setting(ANALYS(1,2),17))
        case('OMEGAS')
            if (FILTER(1,2)) return ! Error = 2
            FILTER(1,2) = .true.
            backspace(1)
            read(1,*, iostat = k) Str, OMEGAS(1,1:2)
            if (k /= 0) return ! Error = 2
        case('DISPIR')
            if (FILTER(1,3)) return ! Error = 2
            FILTER(1,3) = .true.
            backspace(1)
            read(1,*, iostat = k) Str, DISPIR
            if (k /= 0) return ! Error = 2
        case('DISPOR')
            if (FILTER(1,4)) return ! Error = 2
            FILTER(1,4) = .true.
            backspace(1)
            read(1,*, iostat = k) Str, DISPOR
            if (k /= 0) return ! Error = 2
        case('BEARAN')
            if (FILTER(1,5)) return ! Error = 2
            FILTER(1,5) = .true.
            backspace(1)
            read(1,*, iostat = k) Str, BEARAN(1,1:5)
            if (k /= 0) return ! Error = 2
        case('BEAREF')
            if (FILTER(1,6)) return ! Error = 2
            FILTER(1,6) = .true.
            backspace(1)
            read(1,*, iostat = k) Str, BEAREF(1,1:5)
            if (k /= 0) return ! Error = 2
        case('IR_SET') 
            if (FILTER(1,7)) return ! Error = 2
            FILTER(1,7) = .true.
            do i = 1, ANALYS(1,2)
               read( 1, *, iostat = k) IR_setting(i,1:17)
               if (k /= 0) return ! Error = 2
            end do
        case('OR_SET') 
            if (FILTER(1,8)) return ! Error = 2
            FILTER(1,8) = .true.
            do i = 1, ANALYS(1,3)
               read( 1, *, iostat = k) OR_setting(i,1:17)
               if (k /= 0) return ! Error = 2
            end do
        end select

    enddo
    
    if ((.not. FILTER(1,1)) .AND. (.not. FILTER(1,2))) return ! Error = 2
    Error = 0
    close(1)
    end subroutine READ_FILE
Sylvain Bergeron est actuellement connecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 22h21   #3
Sylvain Bergeron
Modérateur
 
Inscription : août 2006
Messages : 781
Détails du profil
Informations personnelles :
Localisation : Canada

Informations forums :
Inscription : août 2006
Messages : 781
Points : 1 028
Points : 1 028
J'ai oublié de noter que les blocs ANALYS à BEAREF supportent que les valeurs soient à droite de l'étiquette sur la même ligne. C'est cette possibilité qui exige dans le code de relire jusqu'à LABEL(n) - 1 et qui m'a obligé dans ma version à utiliser le backspace. Les blocs IR_SET et OR_SET doivent avoir les valeurs sur les lignes suivantes. Ton fichier txt pourrait donc avoir la forme :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
ANALYS 13 2 3 4 5
OMEGAS 0 0
DISPIR 1 
DISPOR 1
BEARAN 1 2 3 4 5
BEAREF 1 2 3 4 5

IR_SET 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

OR_SET 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Sylvain Bergeron est actuellement connecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2012, 14h06   #4
mayoub
Invité de passage
 
Homme
Ingénieur mécanique
Inscription : janvier 2012
Messages : 3
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Ingénieur mécanique
Secteur : Industrie

Informations forums :
Inscription : janvier 2012
Messages : 3
Points : 0
Points : 0
Merci beaucoup Sylvain de ta réponse,

Je vais l'essayer et je tiens au courant.
Justement moi je trouvais que c compliqué pour rien, c'est un ancien stagiaire
de mon responsable qu'il l'a fait.
mayoub est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2012, 14h32   #5
mayoub
Invité de passage
 
Homme
Ingénieur mécanique
Inscription : janvier 2012
Messages : 3
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Ingénieur mécanique
Secteur : Industrie

Informations forums :
Inscription : janvier 2012
Messages : 3
Points : 0
Points : 0
Ca ne marche toujours pas, puisque je suis encore débutant en fortran, je vais ajouter les deux autres parties et le prog principale pour le calcul.
Les résultats doivent s'afficher dans un fichier texte genre : Output.txt

Merci beaucoupppppppp


Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
61
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
90
91
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
136
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
166
167
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
205
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
248
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
279
280
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
324
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
358
359
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
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
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
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
!  SUBROUTINE: Calculation_Fitting
!
!****************************************************************************
    
    subroutine Calculation_Fitting (OMEGA, N, SETTING, STUDY, DISP, F_NAME)

    implicit none
    
    character(len=64),intent(in):: F_NAME
    integer, intent(in)         :: N
    logical, intent(in)         :: STUDY     
    real(8), dimension(N,17)    :: SETTING
    real(8), dimension(1,6)     :: DISP, Cr_max, Fr_max
    real(8)                     :: OMEGA, Pi
    
    integer                     :: i, j
    real(8)                     :: SIGMA
    real(8), dimension(2,1)     :: P
    real(8), dimension(N,7)     :: TEMP_SETTING
    real(8), dimension(N-1,6)   :: PCONT, ADJUS
    
    real(8), dimension(N,6)     :: INT_STRESSR, INT_STRESST, INT_VON_MISES
    real(8), dimension(N,6)     :: OUT_STRESSR, OUT_STRESST, OUT_VON_MISES
    
    real(8), dimension(N,6)     :: INT_DEFORR, INT_DEFORT, INT_DEFORA
    real(8), dimension(N,6)     :: OUT_DEFORR, OUT_DEFORT, OUT_DEFORA
    
    real(8), dimension(N,6)     :: RINT, ROUT, UINT, UOUT    
    
    !****************************************************************************
    
    ! Convertions
    
    Pi    = 4.d0 * datan(1.d0)
    OMEGA = OMEGA * Pi / 30.d0
    
    ! Thermal dilatation calculation
   
    do i = 1, N
        do j = 7, 16
            SETTING(i,j) = SETTING(i,j)/2.d0
        end do
    end do
    
    ! Init Cases
    
    RINT = 0.d0
    ROUT = 0.d0
    
    do i = 1, N
    
        SIGMA     = SETTING(i,11)    
        RINT(i,2) = SETTING(i,7) + 0.5d0 * (SETTING(i,8) + SETTING(i,9))    ! Rtheo_moy
        RINT(i,3) = SETTING(i,7) + SETTING(i,8)                             ! Rtheo_inf
        RINT(i,1) = SETTING(i,7) + SETTING(i,9)                             ! Rtheo_sup
        RINT(i,5) = SETTING(i,7) + SETTING(i,10)                            ! Rprob_moy
        RINT(i,6) = RINT(i,5)    - 3.d0*SIGMA                               ! Rprob_inf
        RINT(i,4) = RINT(i,5)    + 3.d0*SIGMA                               ! Rprob_sup
        
        SIGMA     = SETTING(i,16)
        ROUT(i,2) = SETTING(i,12) + 0.5d0 * (SETTING(i,13) + SETTING(i,14)) ! Rtheo_moy
        ROUT(i,1) = SETTING(i,12) + SETTING(i,13)                           ! Rtheo_inf
        ROUT(i,3) = SETTING(i,12) + SETTING(i,14)                           ! Rtheo_sup
        ROUT(i,5) = SETTING(i,12) + SETTING(i,15)                           ! Rprob_moy
        ROUT(i,4) = ROUT(i,5)    - 3.d0*SIGMA                               ! Rprob_inf
        ROUT(i,6) = ROUT(i,5)    + 3.d0*SIGMA                               ! Rprob_sup
        
    end do
    
    ! Adjustment calculation
    
    do i = 1, N-1
        do j = 1,6         
            ADJUS(i,j) = RINT(i+1,j) - ROUT(i,j)  
        end do 
    end do
   
       
    ! For each case, Contact pressures calculation.
        
    do j = 1 ,6
        
        do i = 1, N
            TEMP_SETTING(i,1:3) = SETTING(i,1:3)
            TEMP_SETTING(i,4)   = RINT(i,j)
            TEMP_SETTING(i,5)   = ROUT(i,j)
            TEMP_SETTING(i,6:7) = SETTING(i,5:6)
        end do
        
        call CONTACT_PRESSURE_CALCUL ( OMEGA, N, TEMP_SETTING, ADJUS(:,j), PCONT(:,j) )
                
        do i = 1, N
            
            if (i == 1) then 
                P(1,1) = 0.d0
            else
                P(1,1) = PCONT(i-1,j)
            end if
            
            if (i == N) then 
                P(2,1) = 0.d0
            else
                P(2,1) = PCONT(i,j)
            end if
            
            
            call DISPLACEMENT_CALCUL ( OMEGA, TEMP_SETTING(i,4), TEMP_SETTING(i,:), P, UINT(i,j) )
            call DISPLACEMENT_CALCUL ( OMEGA, TEMP_SETTING(i,5), TEMP_SETTING(i,:), P, UOUT(i,j) )
            
            call DEFORMATION_CALCUL  ( OMEGA, TEMP_SETTING(i,4), TEMP_SETTING(i,:), P, INT_DEFORA(i,j), INT_DEFORR(i,j), INT_DEFORT(i,j) )            
            call DEFORMATION_CALCUL  ( OMEGA, TEMP_SETTING(i,5), TEMP_SETTING(i,:), P, OUT_DEFORA(i,j), OUT_DEFORR(i,j), OUT_DEFORT(i,j) ) 
            
            call STRESS_CALCUL ( TEMP_SETTING(i,:), INT_DEFORR(i,j), INT_DEFORT(i,j), INT_STRESSR(i,j), INT_STRESST(i,j), INT_VON_MISES(i,j) )            
            call STRESS_CALCUL ( TEMP_SETTING(i,:), OUT_DEFORR(i,j), OUT_DEFORT(i,j), OUT_STRESSR(i,j), OUT_STRESST(i,j), OUT_VON_MISES(i,j) )
            
            if (i >= 2) then;
                
                if (i == 2) then;
                    
                    Fr_max(1,j) = abs(2*Pi*TEMP_SETTING(i,4)*SETTING(i,17)*(1.d0 + OUT_DEFORA(i,j) )*SETTING(i,4)*P(1,1))
                
                else; if ( abs(2*Pi*TEMP_SETTING(i,4)*SETTING(i,17)*(1.d0 + OUT_DEFORA(i,j) )*SETTING(i,4)*P(1,1)) < Fr_max(1,j) ) then;
                
                    Fr_max(1,j) = abs(2*Pi*TEMP_SETTING(i,4)*SETTING(i,17)*(1.d0 + OUT_DEFORA(i,j) )*SETTING(i,4)*P(1,1))
            
                    end if   
                end if
            end if
            
            if (i >= 2) then;
                
                if (i == 2) then;
                    
                    Cr_max(1,j) = abs(2*Pi*TEMP_SETTING(i,4)**(2.d0)*SETTING(i,17)*(1.d0 + OUT_DEFORA(i,j) )*SETTING(i,4)*P(1,1))
                
                else; if ( abs(2*Pi*TEMP_SETTING(i,4)**(2.d0)*SETTING(i,17)*(1.d0 + OUT_DEFORA(i,j) )*SETTING(i,4)*P(1,1)) < Cr_max(1,j) ) then;
                
                    Cr_max(1,j) = abs(2*Pi*TEMP_SETTING(i,4)**(2.d0)*SETTING(i,17)*(1.d0 + OUT_DEFORA(i,j) )*SETTING(i,4)*P(1,1))
            
                    end if   
                end if
            end if
            
          
            
        end do
        
        if (STUDY == 0) DISP(1,j) = UINT(1,j)
        if (STUDY == 1) DISP(1,j) = UOUT(N,j)
                
    end do
    
    ! Typing of results
    
    OPEN(1, FILE = F_NAME, ERR = 200, STATUS = 'OLD', ACCESS = 'APPEND', ACTION = 'WRITE')
    
    if (STUDY == 0)  WRITE(1,('(/,A,$,2/)')) ' $OUTER_RING_SETTING '
    if (STUDY == 1)  WRITE(1,('(/,A,$,2/)')) ' $INNER_RING_SETTING '
    
    
    WRITE (1,('(/,5x,A,$,/)')) ' $GEOMETRY ' 
    do i = 1, N; WRITE (1,500) i,RINT(i,1:6),ROUT(i,1:6); end do
    
    WRITE (1,('(/,5x,A,$,/)')) ' $INTERFACE ' 
    do i = 1, N-1; WRITE (1,500) i,ADJUS(i,1:6),PCONT(i,1:6); end do
    
    WRITE (1,('(/,5x,A,$,/)')) ' $DISPLACEMENT ' 
    do i = 1, N; WRITE (1,500) i,UINT(i,1:6),UOUT(i,1:6); end do
    
    WRITE (1,('(/,5x,A,$,/)')) ' $AXIAL_DEFORMATION ' 
    do i = 1, N; WRITE (1,500) i,INT_DEFORA(i,1:6),OUT_DEFORA(i,1:6); end do
    
    WRITE (1,('(/,5x,A,$,/)')) ' $RADIAL_DEFORMATION ' 
    do i = 1, N; WRITE (1,500) i,INT_DEFORR(i,1:6),OUT_DEFORR(i,1:6); end do
    
    WRITE (1,('(/,5x,A,$,/)')) ' $TANGENTIAL_DEFORMATION ' 
    do i = 1, N; WRITE (1,500) i,INT_DEFORT(i,1:6),OUT_DEFORT(i,1:6); end do
    
    WRITE (1,('(/,5x,A,$,/)')) ' $RADIAL_STRESS ' 
    do i = 1, N; WRITE (1,500) i,INT_STRESSR(i,1:6),OUT_STRESSR(i,1:6); end do   
    
    WRITE (1,('(/,5x,A,$,/)')) ' $TANGENTIAL_STRESS ' 
    do i = 1, N; WRITE (1,500) i,INT_STRESST(i,1:6),OUT_STRESST(i,1:6); end do
    
    WRITE (1,('(/,5x,A,$,/)')) ' $VON_MISES_STRESS ' 
    do i = 1, N; WRITE (1,500) i,INT_VON_MISES(i,1:6),OUT_VON_MISES(i,1:6); end do
    
    WRITE (1,('(/,5x,A,$,/)')) ' $FORCE_MAX ' 
    WRITE (1,501) Fr_max(1,1:6)
    
    WRITE (1,('(/,5x,A,$,/)')) ' $COUPLE_MAX ' 
    WRITE (1,501) Cr_max(1,1:6)
   
    WRITE (1,('(/,A,$,5/)')) ' $END of record ! '
    
    CLOSE(1)
    
    ! STAMPS

500 format (i,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4)
501 format (13x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4)
    
200 end subroutine Calculation_Fitting
    
!  SUBROUTINE: U_CALCUL
!
!  with : 
!           - U(r, Pint, Pext) = _H._P + F ; _P = (Pint, Pext)
!           - PIECE = [ YOUNG, POISSON, DENSITY, RINT, ROUT ]
!

    
    subroutine U_CALCUL ( OMEGA, R, PIECE, H , F, T )
    
    implicit none
    
    real(8)     :: RINT_MIN, Thickness_MIN 
    common /RDATA/ RINT_MIN, Thickness_MIN
     
    real(8), intent(in) :: OMEGA, R
    real(8), dimension(7), intent(in) :: PIECE
    
    real(8), intent(out) :: F,T
    real(8), dimension(2,1), intent(out) :: H
        
    real(8) :: A, B, C, D, E, G, J, K
    
    T = R * PIECE(6)*PIECE(7)
    
    if ( PIECE(4) > RINT_MIN ) then ;
        
        A = PIECE(5)**(2.d0) - PIECE(4)**(2.d0)
        B = PIECE(5)**(4.d0) - PIECE(4)**(4.d0)
        C = PIECE(5)**(2.d0) * PIECE(4)**(2.d0)
        
        D = 1 + PIECE(2)
        E = 1 - PIECE(2)
        G = 1 / PIECE(1)
        J = 3 + PIECE(2)
        K = J * D*E * PIECE(3) * OMEGA**(2.d0) * G / 8
    
        H(1,1) =   G / A * ( E*R*PIECE(4)**(2.d0) + C*D/R )
        H(2,1) = - G / A * ( E*R*PIECE(5)**(2.d0) + C*D/R )
        F      =   K / A * ( B*R/D + A*C/E/R - A*R**(3.d0)/J )
        
    
    else ;
        
        A = PIECE(5)**(2.d0)
        B = PIECE(5)**(4.d0)
        
        D = 1 + PIECE(2)
        E = 1 - PIECE(2)
        G = 1 / PIECE(1)
        J = 3 + PIECE(2)
        K = J * D*E * PIECE(3) * OMEGA**(2.d0) * G / 8
        
        H(1,1) =   0.d0
        H(2,1) = - G / A * ( E*R*PIECE(5)**(2.d0) )
        F      =   K / A * ( B*R/D - A*R**(3.d0)/J )
        
    end if
    
    end subroutine U_CALCUL
    
    
!****************************************************************************
!
!  SUBROUTINE: CONTACT_PRESSURE_CALCUL
!
!****************************************************************************
    
    subroutine CONTACT_PRESSURE_CALCUL ( OMEGA, N, SETTING, ADJUS, PCONT )
    
    implicit none
        
    real(8), intent(in)                 :: OMEGA
    integer, intent(in)                 :: N
    real(8), dimension(N,5), intent(in) :: SETTING
    
    real(8), dimension(N-1, 1)          :: B, PCONT, ADJUS
    real(8), dimension(N-1, N-1)        :: A, INV_A
        
    integer                 :: i
    real(8)                 :: F, T
    real(8), dimension(2,1) :: H
    
    A = 0.d0
    B = 0.d0
      
    do i = 1, N-1
        
        call U_CALCUL ( OMEGA, SETTING(i,5), SETTING(i,:), H , F, T )
        
        A(i,i) = A(i,i) + H(2,1)
        B(i,1) = B(i,1) + F + T
        if ( i-1 > 0 ) then
            A(i,i-1) = A(i,i-1) + H(1,1)
        end if
             
        call U_CALCUL ( OMEGA, SETTING(i+1,4), SETTING(i+1,:), H , F, T )
        
        A(i,i) = A(i,i) - H(1,1)
        B(i,1) = B(i,1) - F - T
        if ( i < N-1 ) then
            A(i,i+1) = A(i,i+1) - H(2,1)
        end if
        
    end do
    
    do i = 1, N-1
        
        
        if (ADJUS(i,1) - B(i,1) <= 0) then
            B(i,1) = ADJUS(i,1) - B(i,1)
        else
            B(i,1) = 0
        end if
        
    end do
        
    call lui( N-1, A, INV_A)
    
    PCONT(:,1) = matmul( INV_A, B(:,1) )
    
    end subroutine CONTACT_PRESSURE_CALCUL
    

!****************************************************************************
!
!  SUBROUTINE: DISPLACEMENT_CALCUL
!
!****************************************************************************
    
    subroutine DISPLACEMENT_CALCUL ( OMEGA, R, PIECE, P, DISP )
    
    implicit none
        
    real(8), intent(in)                 :: OMEGA, R
    real(8), dimension(1,7), intent(in) :: PIECE
    real(8), dimension(2,1), intent(in) :: P
    
    real(8), intent(out)                :: DISP
    
    real(8), dimension(2,1)             :: H
    real(8)                             :: F,T
    
    call U_CALCUL ( OMEGA, R, PIECE, H , F, T)
    
    DISP = dot_product(H(:,1),P(:,1)) + F + T
    
    end subroutine DISPLACEMENT_CALCUL
    
!****************************************************************************
!
!  SUBROUTINE: DEFORMATION_CALCUL
!
!****************************************************************************
    
    subroutine DEFORMATION_CALCUL ( OMEGA, R, PIECE, P, DEFORA, DEFORR, DEFORT )
    
    real(8)     :: RINT_MIN, Thickness_MIN 
    common /RDATA/ RINT_MIN, Thickness_MIN
     
    real(8), intent(in)                 :: OMEGA, R
    real(8), intent(out)                :: DEFORA, DEFORR, DEFORT
    real(8), dimension(7), intent(in)   :: PIECE
    real(8), dimension(2,1), intent(in) :: P
    
    real(8)                 :: dFdr, Fr
    real(8), dimension(2,1) :: dHdr, Hr, P_TEMP 
        
    real(8) :: A, B, C, D, E, G, J, K
    
    if ( PIECE(4) > RINT_MIN ) then ;
        
        A = PIECE(5)**(2.d0) - PIECE(4)**(2.d0)
        B = PIECE(5)**(4.d0) - PIECE(4)**(4.d0)
        C = PIECE(5)**(2.d0) * PIECE(4)**(2.d0)
        
        D = 1 + PIECE(2)
        E = 1 - PIECE(2)
        G = 1 / PIECE(1)
        J = 3 + PIECE(2)
        K = J * D*E * PIECE(3) * OMEGA**(2.d0) * G / 8
    
        dHdr(1,1) =   G / A * ( E*PIECE(4)**(2.d0) - C*D/R**(2.d0) )
        dHdr(2,1) = - G / A * ( E*PIECE(5)**(2.d0) - C*D/R**(2.d0) )
        dFdr      =   K / A * ( B/D - A*C/E/R**(2.d0) - 3*A*R**(2.d0)/J )
        
        Hr(1,1) =   G / A * ( E*PIECE(4)**(2.d0) + C*D/R**(2.d0) )
        Hr(2,1) = - G / A * ( E*PIECE(5)**(2.d0) + C*D/R**(2.d0) )
        Fr      =   K / A * ( B/D + A*C/E/R**(2.d0) - A*R**(2.d0)/J )
        
        P_TEMP = P
        DEFORR = dot_product( dHdr(:,1), P_TEMP(:,1) ) + dFdr   + PIECE(6)*PIECE(7)
        DEFORT = dot_product( Hr(:,1), P_TEMP(:,1) )   + Fr     + PIECE(6)*PIECE(7)
        DEFORA = - PIECE(2) * (DEFORR + DEFORT) / (1 - PIECE(2))+ PIECE(6)*PIECE(7)
    
    else ;
        
        A = PIECE(5)**(2.d0)
        B = PIECE(5)**(4.d0)
        
        D = 1 + PIECE(2)
        E = 1 - PIECE(2)
        G = 1 / PIECE(1)
        J = 3 + PIECE(2)
        K = J * D*E * PIECE(3) * OMEGA**(2.d0) * G / 8
        
        dHdr(1,1) =   0.d0
        dHdr(2,1) = - G / A * ( E*PIECE(5)**(2.d0))
        dFdr      =   K / A * ( B/D - 3*A*R**(2.d0)/J )
        
        Hr(1,1) =   0.d0
        Hr(2,1) = - G / A * ( E*PIECE(5)**(2.d0))
        Fr      =   K / A * ( B/D - A*R**(2.d0)/J )
        
        P_TEMP(1,1) = 0.d0
        P_TEMP(2,1) = P(2,1)
        DEFORR = dot_product( dHdr(:,1), P_TEMP(:,1) ) + dFdr   + PIECE(6)*PIECE(7)
        DEFORT = dot_product( Hr(:,1), P_TEMP(:,1) )   + Fr     + PIECE(6)*PIECE(7)
        DEFORA = - PIECE(2) * (DEFORR + DEFORT) / (1 - PIECE(2))+ PIECE(6)*PIECE(7)
        
    end if
    
    end subroutine DEFORMATION_CALCUL

!****************************************************************************
!
!  SUBROUTINE: STRESS_CALCUL
!
!   - PIECE = [ YOUNG, POISSON, DENSITY, RINT, ROUT ]
!
!****************************************************************************
    
    subroutine STRESS_CALCUL ( PIECE, DEFORR, DEFORT, STRESSR, STRESST, VON_MISES )
    
    implicit none
    
    real(8), intent(in)               :: DEFORR, DEFORT
    real(8), intent(out)              :: STRESSR, STRESST, VON_MISES
    real(8), dimension(7), intent(in) :: PIECE
    
    real(8) :: TRACE
    real(8), dimension(2,1) :: DEFOR, STRESS
    real(8), dimension(2,2) :: HOOK
    
    DEFOR(1,1)  = DEFORR - PIECE(6)*PIECE(7) ;  DEFOR(2,1)  = DEFORT - PIECE(6)*PIECE(7) ;
    
    
    HOOK(1,1) = 1 ; HOOK(2,2) = HOOK(1,1) ; HOOK(1,2) = PIECE(2) ; HOOK(2,1) = HOOK(1,2) ;
    HOOK = PIECE(1)/(1 - PIECE(2)**(2.d0)) * HOOK
    
    STRESS = matmul( HOOK, DEFOR )
    STRESSR = STRESS(1,1) ; STRESST = STRESS(2,1) ;
    
    TRACE = STRESSR + STRESST
    VON_MISES = dsqrt( ((3.d0)/(2.d0)) * ( (STRESSR-TRACE/3.d0)**(2.d0) + (STRESST-TRACE/3.d0)**(2.d0) ) )
    
    end subroutine STRESS_CALCUL
    
!****************************************************************************
!
!  SUBROUTINE: RA_CALCUL_TYPE_13
!
!****************************************************************************
    
    subroutine RA_CALCUL_TYPE_13 ( N, Y, RR, RA )
    
    implicit none
    
    integer :: i, N
    real(8), intent(in) :: Y
    real(8), dimension(1,6) :: RA
    real(8), dimension(1,6), intent(in) :: RR
    
    do i = 1, N
    
        RA(1,i) = 1.25d0 * Y * RR(1,i)
        
    end do
    
    end subroutine RA_CALCUL_TYPE_13
    
!****************************************************************************
!
!  SUBROUTINE: RA_CALCUL_TYPE_11
!
!****************************************************************************
    
    subroutine RA_CALCUL_TYPE_11 ( N, RWi, BWi, RWo, BWo, Db, RR, RA )
    
    implicit none
    
    integer :: i, N
    real(8) :: A, J0, alpha_0, alpha
    real(8), dimension(1,N) :: RA
    real(8), dimension(1,N), intent(in) :: RR
    real(8), intent(in) :: RWi, BWi, RWo, BWo, Db
    
    A       = RWi + RWo - Db
    J0      = abs(BWo - BWi - 2.d0*Db)
    alpha_0 = dacos( 1.d0 - (J0/(2.d0*A)) )

    do i = 1, N
    
        alpha = dacos(1.d0 - ( (J0+RR(1,i))/(2.d0*A)) )
        RA(1,i) = A * ( dsin(alpha) - dsin(alpha_0) )
        
    end do

    end subroutine RA_CALCUL_TYPE_11
    


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
!_/
!_/         Inversion d'une matrice carrée réelle par décomposition LU
!_/                                   
!_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
subroutine lui(n,rm,rm1)
implicit none
!
integer, intent(in) 			:: n
real*8, dimension(n,n) 			:: rm
real*8, dimension(n,n), intent(out) ::rm1
integer, dimension(n) 			:: indx
integer 					:: it1
real*8 					:: r
!
! Décomposition LU : A = LU
call ludcmp(n,rm,indx,r)
!
! Résolution des système d'équations L.Y = RV2 et U.RV3 = Y
rm1 = 0.d0
do it1 = 1,n
    rm1(it1,it1) = 1.d0
    call lubksb(n,rm,indx,rm1(1:n,it1))
enddo
!
end subroutine lui
!-----------------------------------------------------------------------------------------
subroutine ludcmp(n,rm,indx,r)
implicit none
!
! Soit 'rm' une matrice (NxN), cette routine la remplace par sa décomposition LU. 'indx'
! est un vecteur de sortie de taille N qui enregistre les permutations effectuees par 
! pivot partiel. En sortie 'r' a pour valeur +/-1 dépendant du fait que le nombre de 
! permutations effectuées était pair ou impair.
!
integer, intent(in)                     :: n
real*8, dimension(n,n), intent(inout)   :: rm
integer, dimension(n), intent(out)      :: indx
real*8, intent(out)                     :: r
real*8, dimension(n)                    :: rv
real*8                                  :: epsi, tim
integer                                 :: it, imax
!
epsi = epsilon(epsi)
tim = tiny(tim)
r = 1.d0
rv = maxval(dabs(rm),dim=2)
if (any(dabs(rv) <= epsi)) then
    write(*,10)
    pause
    stop
endif
rv = 1.0d0/rv
do it = 1,n
	imax = (it-1) + maxloc(rv(it:n)*dabs(rm(it:n,it)),dim=1)
	if (it /= imax) then
		call swap(n,rm(imax,:),rm(it,:))
		r = -r
		rv(imax) = rv(it)
	end if
	indx(it) = imax
	if (dabs(rm(it,it)) <= epsi) rm(it,it) = tim
	rm(it+1:n,it) = rm(it+1:n,it)/rm(it,it)
	rm(it+1:n,it+1:n) = rm(it+1:n,it+1:n) - &
	                    spread(rm(it+1:n,it),dim=2,ncopies=size(rm(it,it+1:n)))* &
	                    spread(rm(it,it+1:n),dim=1,ncopies=size(rm(it+1:n,it)))
end do
10 format("La matrice a inverser est singuliere.")
return
end subroutine ludcmp
!-----------------------------------------------------------------------------------------
subroutine lubksb(n,rm,indx,rv)
implicit none
!
! Résoud le système de N équations linéaires RM.X = RV. Ici la matrice 'rm' de taille
! NxN est définie par sa décomposition LU comme fournie par la routine 'ludcmp'. 'rv' est le
! vecteur du second membre de taille N (en input) et aussi le vecteur de la solution X 
!(en output). 'rm' et 'indx' ne sont pas modifiés pas cette routine
!
integer, intent(in)                 :: n
real*8, dimension(n,n), intent(in)  :: rm
integer, dimension(n), intent(in)   :: indx
real*8, dimension(n), intent(inout) :: rv
integer                             :: it1, it2, it3
real*8                              :: epsi, sum
!
it2 = 0
epsi = epsilon(epsi)
do it1=1,n
	it3=indx(it1)
	sum=rv(it3)
	rv(it3)=rv(it1)
	if (it2 /= 0) then
		sum=sum-dot_product(rm(it1,it2:it1-1),rv(it2:it1-1))
	else if (dabs(sum) > epsi) then
		it2=it1
	end if
	rv(it1)=sum
end do
do it1=n,1,-1
	rv(it1) = (rv(it1)-dot_product(rm(it1,it1+1:n),rv(it1+1:n)))/rm(it1,it1)
end do
end subroutine lubksb
!-----------------------------------------------------------------------------------------
subroutine swap(n,rv1,rv2)
integer, intent(in)                 :: n
real*8, dimension(n), intent(inout) :: rv1,rv2
real*8, dimension(n)                :: dum
!
dum = rv1
rv1 = rv2
rv2 = dum
!
end subroutine swap

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Programme principal

!****************************************************************************
!
!  PROGRAM: Analytical_Fitting
!
!  PURPOSE:  Entry point for the console application.
!
!****************************************************************************

    program Analytical_Fitting

    implicit none
    
    ! Varibles GLOBALS
    
    real(8) :: RINT_MIN, Thickness_MIN 
    common /RDATA/ RINT_MIN, Thickness_MIN
    
    ! Variables
    
    integer                             :: num_args, i, ERROR
    character(len=2)                    :: arg_label
    character(len=64)                   :: arg_value, F_NAME_IN, F_NAME_OUT, file_name
    
    real(8)                             :: DISPIR, DISPOR
    integer, dimension(1,5)             :: ANALYS
    logical, dimension(1,8)             :: FILTER
    real(8), dimension(:,:),allocatable :: IR_setting, OR_setting
    real(8), dimension(1,2)             :: OMEGAS
    real(8), dimension(1,5)             :: BEARAN, BEAREF
    
    real(8),dimension(1,6)              :: IR_disp, OR_disp, RR_analytical, RA_analytical
    real(8),dimension(1,1)              :: RR_finite_ele, RA_finite_ele
    
    interface
    !**********************************************************************************************************
        subroutine READ_FILE ( file_name, ANALYS, OMEGAS, DISPIR, DISPOR, BEARAN, BEAREF, IR_setting, OR_setting, FILTER, ERROR )
                implicit none
                character(len = 64), intent(in)     :: file_name
                real(8)                             :: DISPIR, DISPOR
                integer                             :: ERROR
                integer, dimension(1,5)             :: ANALYS
                logical, dimension(1,8)             :: FILTER
                real(8), dimension(:,:),allocatable :: IR_setting, OR_setting
                real(8), dimension(1,2)             :: OMEGAS
                real(8), dimension(1,5)             :: BEARAN, BEAREF
        end subroutine READ_FILE
    !**********************************************************************************************************   
    end interface
    
    ! Initialisation
    
    RINT_MIN      = 0.1d0
    Thickness_MIN = 0.5d0
    
    F_NAME_IN     = ''
    F_NAME_OUT    = ''
    
    num_args = command_argument_count()
    
    if (num_args == 0) then ;
        
            WRITE (*,'(A,$,/)') ' - Indicate INPUT  file name : '
            READ  (*,*) F_NAME_IN  
            WRITE (*,'(A,$,/)') ' - Indicate OUTPUT file name: '
            READ  (*,*) F_NAME_OUT
            
    else ; 
    
            DO i = 1, num_args, 2
            
              CALL getarg(i,   arg_label)
              CALL getarg(i+1, arg_value)
              
              if      (arg_label == '-i') then ;    F_NAME_IN     = arg_value  
              else if (arg_label == '-o') then ;    F_NAME_OUT    = arg_value
              else if (arg_label == '-r') then ;    read(arg_value,502) RINT_MIN
              else if (arg_label == '-t') then ;    read(arg_value,502) Thickness_MIN
              end if
    
            END DO
            

    end if
    
    if (F_NAME_IN == F_NAME_OUT .OR. F_NAME_IN == '' .OR. F_NAME_OUT == '') goto 200
    
    OPEN (2, FILE = F_NAME_OUT, ERR = 200, STATUS = 'REPLACE', ACTION = 'WRITE')
    CLOSE(2)
    
    ERROR = -1
    call READ_FILE ( file_name, ANALYS, OMEGAS, DISPIR, DISPOR, BEARAN, BEAREF, IR_setting, OR_setting, FILTER, ERROR )
    if(ERROR == 1) goto 201  
    if(ERROR == 2) goto 202
    
    ! ********************* Calculation of RR *********************
    
    if ( FILTER(1,7) == .True. ) call Calculation_Fitting (OMEGAS(1,1), ANALYS(1,2), IR_setting, 1, IR_disp, F_NAME_OUT)
    if ( FILTER(1,8) == .True. ) call Calculation_Fitting (OMEGAS(1,2), ANALYS(1,3), OR_setting, 0, OR_disp, F_NAME_OUT)
    
    if ( FILTER(1,7) == .True. .AND. FILTER(1,8) == .True. ) then ;   
        RR_analytical = IR_disp - OR_disp 
    end if
    
    if ( ANALYS(1,4) /= 0 .AND. ANALYS(1,5) /= 0 ) then ;
        RR_finite_ele = DISPIR - DISPOR  
    end if
    
    if ( ANALYS(1,4) == 0 .AND. ANALYS(1,5) /= 0 .AND. FILTER(1,7) == .True. ) then ;
        RR_finite_ele = - DISPOR + IR_disp(1,ANALYS(1,5))
    end if
    
    if ( ANALYS(1,4) /= 0 .AND. ANALYS(1,5) == 0 .AND. FILTER(1,8) == .True. ) then ;
       RR_finite_ele = DISPIR - OR_disp(1,ANALYS(1,4))
    end if
    
    ! ********************* Calculation of RA *********************
 
    OPEN(2, FILE = F_NAME_OUT, ERR = 200, STATUS = 'OLD', ACCESS = 'APPEND', ACTION = 'WRITE')
 
    ! ********************* Calculation of RA *********************
    
    if ( FILTER(1,7) == .True. .AND. FILTER(1,8) == .True. .AND. FILTER(1,5) == .True. ) then ;
        
        if (ANALYS(1,1) == 11) then ;
            call RA_CALCUL_TYPE_11 ( 6, BEARAN(1,1), BEARAN(1,2), BEARAN(1,3), BEARAN(1,4), BEARAN(1,5), RR_analytical, RA_analytical )
            WRITE (2,('(/,A,$,/)')) ' $ANALYTICAL_REDUCTION '
            WRITE (2,500) RR_analytical(1,1:6), RA_analytical(1,1:6)
        end if
        
        if (ANALYS(1,1) == 13) then ;
            call RA_CALCUL_TYPE_13 ( 6, BEARAN(1,1), RR_analytical, RA_analytical )
            WRITE (2,('(/,A,$,/)')) ' $ANALYTICAL_REDUCTION '
            WRITE (2,500) RR_analytical(1,1:6), RA_analytical(1,1:6)
        end if
        
    end if
        
    if ( ( ANALYS(1,4) == 0 .AND. ANALYS(1,5) /= 0 .AND. FILTER(1,6) == .True. .AND. FILTER(1,7) == .True. ) .OR. &
         ( ANALYS(1,4) /= 0 .AND. ANALYS(1,5) == 0 .AND. FILTER(1,6) == .True. .AND. FILTER(1,8) == .True. ) .OR. &
         ( ANALYS(1,4) /= 0 .AND. ANALYS(1,5) /= 0 .AND. FILTER(1,6) == .True. ) ) then ;
         
        if (ANALYS(1,1) == 11) then ;
            call RA_CALCUL_TYPE_11 ( 1, BEAREF(1,1), BEAREF(1,2), BEAREF(1,3), BEAREF(1,4), BEAREF(1,5), RR_finite_ele, RA_finite_ele )
            WRITE (2,('(/,A,$,/)')) ' $EF_REDUCTION '
            WRITE (2,501) RR_finite_ele(1,1), RA_finite_ele(1,1)
        end if
        
        if (ANALYS(1,1) == 13) then ;
            call RA_CALCUL_TYPE_13 ( 1, BEAREF(1,1), RR_finite_ele, RA_finite_ele )
            WRITE (2,('(/,A,$,/)')) ' $EF_REDUCTION '
            WRITE (2,501) RR_finite_ele(1,1), RA_finite_ele(1,1)
        end if
    
    end if
    
    
    
    CLOSE(2)
    goto 100
    
    !**************************************************************************
    
    ! ERRORS
    
200 WRITE (*,('(/,A,$,/)')) ' - ERROR : Le nom du fichier en INPUT ou en OUTPUT est incorrect ! '; goto 100
201 WRITE (*,('(/,A,$,/)')) ' - ERROR : Le fichier specifie en INPUT est introuvable ! ' ; goto 100 
202 WRITE (*,('(/,A,$,/)')) ' - ERROR : Le fichier est corrompu ! ' ; goto 100

    ! STAMPS

500 format (/,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4,x,ES12.4)
501 format (/,x,ES12.4,x,ES12.4)
502 format (f4.4)
    
    ! END of programm

100 end program Analytical_Fitting
mayoub est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2012, 16h29   #6
Sylvain Bergeron
Modérateur
 
Inscription : août 2006
Messages : 781
Détails du profil
Informations personnelles :
Localisation : Canada

Informations forums :
Inscription : août 2006
Messages : 781
Points : 1 028
Points : 1 028
Citation:
Envoyé par mayoub Voir le message
Ca ne marche toujours pas, (...)
Tu devras être plus précis dans ton diagnostic. Quel est le message d'erreur ? Peux-tu ajouter des affichages de résultats intermédiaires avant l'arrêt pour préciser le problème ?
Sylvain Bergeron est actuellement connecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/10/2012, 00h34   #7
elssa
Invité de passage
 
Femme
Inscription : octobre 2012
Messages : 2
Détails du profil
Informations personnelles :
Sexe : Femme

Informations forums :
Inscription : octobre 2012
Messages : 2
Points : 1
Points : 1
Par défaut fortran, lecture d'un fichier texte

Bonjour,
je rouvre ce sujet, puisque je me trouve dans la meme situation. Je suis debutante sur Fortran.
J'aimerais lire un fichier texte pour cela j'ai commence a creer un subroutine dans fortran de mon programme principale.
Cette subroutine sert a lire les donnees d'entrees.
Mon fichier texte se presente de la facon suivante, un mot de dix lettres pour nommer la donnee qui suit. Puis on saute une ligne et j'ai un scalaire, un vecteur ou une matrice sur la nouvelle ligne:

AAAAABBBBB
5
CCCCCDDDDD
50
32
49
22
89
EEEEEFFFFF
10.0 20.0 30.0
40.0 50.0 60.0
70.0 80.0 90.0
10.1 20.1 30.1
40.1 50.1 60.1


Pouvez-vous m'expliquer d'apres cette exemple, comment proceder pour lire seulement les valeurs et pas les tritres, et associer cette valeur a un nom.
Voila mon programme sur fortran. J'ai beaucoup d'erreur. sI quelqu'un pouvez m'aider pour corriger mes erreurs! merciii

Subroutine input (AAAAABBBBB, CCCCCDDDDD, EEEEEFFFFF, Error, filename, filter)
[Error 31 Compilation Aborted (code 1)]

implicit none
c declaration des variables
integer, intent(out) :: AAAAABBBBB
integer, dimension( NOMvariable1, 1), intent(out) :: CCCCCDDDDD
real, dimension(NOMvariable1,3), intent(out) :: EEEEEFFFFF
character(len=*), intent(in) :: filename
integer :: unitfile
logical, dimension(14,1) :: filter
character(len=10) :: inp
integer :: k
integer :: i
integer :: Error
unitfile = 20



open(20, file='filename', action='read', form='formatted', status='old')
c
if (k /= 0) then
Error = 1
print*, 'traitment error '
return
endif
c
FILTER = .false.
i = 0
Error = 2
do
i = i + 1
c
c
c lire le fichier
read(20, FMT=*, iostat=k)inp
if (k < 0) exit
if (k > 0) return ! Error = 2
c
select case(inp)
case('AAAAABBBBB')
if (filter(1,1))return
filter(1,1) = .true.
do i = 1
read(20, *, iostat=k)inp, AAAAABBBBB(i,1) ! lire la valeur sans le titre
print*, 'AAAAABBBBB = ',AAAAABBBBB ! imprimer a l'ecran la valeur scalaire
if (k /= 0) return
end do
AAAAABBBBB = NOMvariable1 ! nommer la valeur scalaire

case('CCCCCDDDDD')
if (filter(2,1)) return
filter(2,1) = .true.
do i=1
[error #6404: This name does not have a type, and must have an explicit type. [DOI] ]
read (20, *, iostat=k)inp, CCCCCDDDDD(i:NOMvariable1,1)
[ error #6410: This name has not been declared as an array or a function. [CCCCCDDDDD]]
[error #6358: Constants and expressions are invalid in read-only I/O lists. [NBSTRUCMOD]]

print*, 'CCCCCDDDDD = ',CCCCCDDDDD
if (k /= 0) return
end do
[error #6099: An ENDDO statement occurred without a corresponding DO or DO WHILE statement.]
CCCCCDDDDD = NOMvariable2
[error #6404: This name does not have a type, and must have an explicit type. [NOMvariable2]]


case('EEEEEFFFFF')
if (filter(3,1)) return
filter(3,1) = .true.
do i=1
read (20, *, iostat=k)inp, EEEEEFFFFF(i:NOMvariable1,:)
print*, 'EEEEEFFFFF = ',EEEEEFFFFF
if (k /= 0) return
end do
EEEEEFFFFF = NOMvariable3

end select
enddo
Error = 0
close(20)
end subroutine input
elssa est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/11/2012, 06h55   #8
jyloup
Candidat au titre de Membre du Club
 
Inscription : avril 2009
Messages : 31
Détails du profil
Informations forums :
Inscription : avril 2009
Messages : 31
Points : 12
Points : 12
Par défaut prloblème similaire

Bonjour
je complète ce post car j'ai aussi un problème similaire :
distinguer dans un fichier texte les différentes type de variables (réels, chaines de caractères) et sélectionner uniquement les variables du type qui nous intéressent.
Mon fichier (résultat d'une procédure) est une suite de réels et de mots "NaN" : mais je voudrais récupérer que les réels qui ne sont pas NaN :

4552.0
NaN
54.6533
NaN
3.567

La réponse à ce post pourrait beaucoup m'aider.
jyloup est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/03/2013, 18h37   #9
__dardanos__
Membre confirmé
 
Homme arnaud
Ingénieur développement logiciels
Inscription : janvier 2013
Messages : 158
Détails du profil
Informations personnelles :
Nom : Homme arnaud
Localisation : France

Informations professionnelles :
Activité : Ingénieur développement logiciels
Secteur : Conseil

Informations forums :
Inscription : janvier 2013
Messages : 158
Points : 273
Points : 273
Bonjour.

Pour répondre à elssa, il est difficile de proposer une procédure générale puisque le nombre de valeurs numériques à lire varie d'une ligne à l'autre.

Le format étant particulier, il faut écrire une fonction spécifique qui traite le fichier ligne par ligne. Au mieux il y a parfois la possibilité de traiter un ensemble de lignes de la même manière (à l'aide d'une boucle sur ces lignes, et seulement ces lignes). Pour les lignes de titre, il est plus simple de faire un simple read(20,*), et de passer ainsi à la ligne suivante.


Ce que demande jyloup est plus facile car le fichier ne contient qu'une seule donnée par ligne.
Le plus simple est de pré-traiter le fichier avant de le lire. Sur LINUX par exemple, avec un grep et des expressions régulières.

Si on veut faire un traitement tout-fortran, il suffit de tester si la ligne à traiter contient une valeur numérique, et si c'est bien le cas, on peut alors l'extraire.
Je joins pour l'exemple un programme qui traite un fichier colonne file.in :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
61
62
program supprimer_nan
    implicit none
    character(len=30) :: ligne
    real(kind=8) :: var
    integer :: ios, nb_nan=0

    interface
        function is_numeric ( chaine )
            implicit none
            character(len=*), intent(in) :: chaine
            logical :: is_numeric
        end function is_numeric
    end interface

    open(unit=11,file='file.in',status='old')
    do
        read(11,*,iostat=ios) ligne
        if (ios/=0) exit
        if (is_numeric(ligne)) then
            read(ligne,*) var
            print '(e14.6)', var
        else
            nb_nan = nb_nan + 1
        endif
    enddo
    close(11)
    print '(a,i5)', "Nombre de valeurs non-numeriques : ", nb_nan
    
end program supprimer_nan

function is_numeric ( chaine )
    implicit none
    character(len=*), intent(in) :: chaine
    logical :: is_numeric
    real(kind=8) :: x
    integer :: e
    
    ! nécessaire car NaN est considéré comme numérique !!!
    call minuscule(chaine)
    if (chaine == 'nan') then
        is_numeric = .false.
        return
    endif
    
    read(chaine,*,iostat=e) x
    is_numeric = (e == 0)
end function is_numeric

subroutine minuscule ( chaine )
    implicit none
    character(len=*), intent(inout) :: chaine
    integer :: i, i_a_maj, i_a_min, i_z_maj, i_c
    i_a_maj = ichar("A")
    i_a_min = ichar("a")
    i_z_maj = ichar("Z")
    do i = 1, len_trim(chaine)
        i_c = ichar( chaine(i:i) )
        if ( (i_c >= i_a_maj) .and. (i_c <= i_z_maj) ) then
            chaine(i:i) = char( i_c - i_a_maj + i_a_min )
        endif
    enddo
end subroutine minuscule
__dardanos__ est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 04h12.


 
 
 
 
Partenaires

Hébergement Web