1 | !> \file lect_datfile.f90 |
---|
2 | !! Module pour la lecture des donnees |
---|
3 | !< |
---|
4 | |
---|
5 | !> SUBROUTINE: lect_datfile |
---|
6 | !! lecture of a ZBL file (starting from bottom left) |
---|
7 | !! \author ... |
---|
8 | !! \date ... |
---|
9 | !! @param nxx dimension along x |
---|
10 | !! @param nyy dimension along y |
---|
11 | !! @param numcol column number |
---|
12 | !! @param filename |
---|
13 | !! @return Tab the value of Tab(nxx,nyy): Warning it is a real |
---|
14 | |
---|
15 | subroutine lect_datfile(nxx,nyy,Tab,numcol,filename) |
---|
16 | |
---|
17 | implicit none |
---|
18 | integer,intent(in) :: nxx !< dimension along x |
---|
19 | integer,intent(in) :: nyy !< dimension along y |
---|
20 | integer,intent(in) :: numcol !< column number 1->average, 2->minval 3->maxval |
---|
21 | character(len=80),intent(in) :: filename !< name of the file |
---|
22 | real,dimension(nxx,nyy),intent(out) :: Tab !< the array that is read and returned |
---|
23 | |
---|
24 | |
---|
25 | integer :: i,j !< working integers |
---|
26 | integer :: lx,ly !< nxx, nyy read in the file |
---|
27 | real,dimension(3) :: a !< working tab |
---|
28 | |
---|
29 | open(22,file=trim(filename)) |
---|
30 | read(22,*) lx,ly |
---|
31 | |
---|
32 | if ((lx.ne.nxx).or.(ly.ne.nyy)) then |
---|
33 | write(6,*) 'wrong dimension of the file', filename |
---|
34 | write(6,*) 'in the file',lx,ly |
---|
35 | write(6,*) 'should be',nxx,nyy |
---|
36 | STOP |
---|
37 | end if |
---|
38 | |
---|
39 | if (numcol.eq.1) then |
---|
40 | do j=1,nyy |
---|
41 | do i=1,nxx |
---|
42 | read(22,*) a(1) |
---|
43 | Tab(i,j)=a(numcol) |
---|
44 | end do |
---|
45 | end do |
---|
46 | else if (numcol.eq.2) then |
---|
47 | do j=1,nyy |
---|
48 | do i=1,nxx |
---|
49 | read(22,*) a(1),a(2) |
---|
50 | Tab(i,j)=a(numcol) |
---|
51 | end do |
---|
52 | end do |
---|
53 | else if (numcol.eq.3) then |
---|
54 | do j=1,nyy |
---|
55 | do i=1,nxx |
---|
56 | read(22,*) a(1),a(2),a(3) |
---|
57 | Tab(i,j)=a(numcol) |
---|
58 | end do |
---|
59 | end do |
---|
60 | end if |
---|
61 | |
---|
62 | close(22) |
---|
63 | return |
---|
64 | end subroutine lect_datfile |
---|