Project

General

Profile

uncompress_file_300m0.F90

File used by make_uncompress_files.sh - stéphanie faroux, 03/08/2018 03:19 PM

 
1
IMPLICIT NONE
2

    
3
integer*4,parameter :: ncol=43200, nlin=16800
4
integer*2,dimension(ncol*3) :: lread
5
integer*4,dimension(ncol*3) :: lread2
6
integer*1,dimension(ncol*3) :: lwrite
7
integer*1,dimension(ncol) :: lread_verif
8
integer*4 :: j, j2, i, k, icnt0, ideb
9
integer*4 :: icpt
10
integer*4,dimension(nlin*3) :: icpt2
11

    
12
open(11,file='filein',form='unformatted',access='stream')              
13
open(13,file='filein_2',form='unformatted',access='direct',recl=ncol*3)        
14

    
15
read(11) icpt2
16

    
17
! boucle sur les lignes
18
do j=1,nlin
19

    
20
  do j2 = 1,3
21

    
22
    ! lecture du lai
23
    lread(:) = 0
24
    read(11) lread(1:icpt2((j-1)*3+j2))
25
    lread2(:) = lread(:)
26
    do k = 1,icpt2((j-1)*3+j2)
27
      if (lread2(k)<0) lread2(k) = 32768*2 + lread2(k)
28
    enddo
29

    
30
    icpt = 0
31

    
32
    i = 1
33

    
34
    ! boucle sur les colonnes
35
    do 
36
   
37
      ! si on a dépassé la dernière colonne, on sort de la boucle
38
      if (icpt>=ncol*3) exit
39

    
40
      ! si la valeur est valide
41
      if (lread2(i)<4000) then
42

    
43
        ! on la met dans lwrite à l'indice icpt
44
        icpt = icpt + 1
45
        lwrite(icpt) = lread2(i)-floor(lread2(i)/100.)*100.
46
        ! on incrémente i
47
        i = i+1
48

    
49
      else
50

    
51
        do k = 1,lread2(i)-4000
52
          icpt = icpt + 1
53
          if (icpt>ncol*3) exit
54
          lwrite(icpt) = 0
55
        enddo
56

    
57
        i = i+1
58

    
59
      endif
60

    
61
    enddo
62

    
63
    write(13,rec=(j-1)*3+j2) lwrite(:)
64

    
65
  enddo
66

    
67
enddo
68

    
69
close(11)
70
close(13)
71
  
72

    
73
END