source: trunk/SOURCES/lect_datfile.f90 @ 159

Last change on this file since 159 was 4, checked in by dumas, 10 years ago

initial import GRISLI trunk

File size: 1.7 KB
Line 
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
15subroutine lect_datfile(nxx,nyy,Tab,numcol,filename)
16
17implicit none
18integer,intent(in)  :: nxx                    !< dimension along x
19integer,intent(in)  :: nyy                    !< dimension along y
20integer,intent(in)  :: numcol                 !< column number 1->average, 2->minval 3->maxval
21character(len=80),intent(in) :: filename      !< name of the file
22real,dimension(nxx,nyy),intent(out) :: Tab    !< the array that is read and returned
23
24
25integer  :: i,j                !< working integers
26integer  :: lx,ly              !< nxx, nyy read in the file
27real,dimension(3) :: a         !< working tab
28
29open(22,file=trim(filename))
30read(22,*) lx,ly
31
32if ((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
37end if
38
39if (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
46else 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
53else 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
60end if
61
62close(22)
63return
64end subroutine lect_datfile
Note: See TracBrowser for help on using the repository browser.