source: flexpart.git/src/readlanduse.f90

10.4.1_peseiGFS_025bugfixes+enhancementsdevrelease-10release-10.4.1scaling-bug
Last change on this file was 23547f3, checked in by Ignacio Pisso <ip@…>, 4 years ago

remove tabs from files of the form src/*.f90

  • Property mode set to 100644
File size: 6.0 KB
Line 
1! SPDX-FileCopyrightText: FLEXPART 1998-2019, see flexpart_license.txt
2! SPDX-License-Identifier: GPL-3.0-or-later
3
4subroutine readlanduse
5
6  !*****************************************************************************
7  !                                                                            *
8  !      Reads the landuse inventory into memory and relates it to Leaf Area   *
9  !      Index and roughness length.                                           *
10  !                                                                            *
11  !      AUTHOR: Andreas Stohl, 10 January 1994                                *
12  !                                                                            *
13  !*****************************************************************************
14  !                                                                            *
15  ! Variables:                                                                 *
16  ! i                       loop indices                                       *
17  ! landinvent(1200,600,13) area fractions of 13 landuse categories            *
18  ! LENGTH(numpath)         length of the path names                           *
19  ! PATH(numpath)           contains the path names                            *
20  ! unitland                unit connected with landuse inventory              *
21  !                                                                            *
22  ! -----                                                                      *
23  ! Sabine Eckhardt, Dec 06 - new landuse inventary                            *
24  ! after                                                                      *
25  ! Belward, A.S., Estes, J.E., and Kline, K.D., 1999,                         *
26  ! The IGBP-DIS 1-Km Land-Cover Data Set DISCover:                            *
27  ! A Project Overview: Photogrammetric Engineering and Remote Sensing,        *
28  ! v. 65, no. 9, p. 1013-1020                                                 *
29  !                                                                            *
30  ! LANDUSE CATEGORIES:                                                        *
31  !                                                                            *
32  ! 1   Urban land                                                             *
33  ! 2   Agricultural land                                  *
34  ! 3   Range land                                         *
35  ! 4   Deciduous forest                                           *
36  ! 5   Coniferous forest                                              *
37  ! 6   Mixed forest including wetland                                         *
38  ! 7   water, both salt and fresh                                             *
39  ! 8   barren land mostly desert                                              *
40  ! 9   nonforested wetland                                                *
41  ! 10  mixed agricultural and range land                              *
42  ! 11  rocky open areas with low growing shrubs                               *
43  ! 12  ice                                                                    *
44  ! 13  rainforest                                                             *
45  !                                                                            *
46  !*****************************************************************************
47
48  use par_mod
49  use com_mod
50
51  implicit none
52
53  integer :: ix,jy,i,k,lu_cat,lu_perc
54  integer(kind=1) :: ilr
55  integer(kind=1) :: ilr_buffer(2160000)
56  integer :: il,irecread
57  real :: rlr, r2lr
58
59
60  ! Read landuse inventory
61  !***********************
62  ! The landuse information is saved in a compressed format and written
63  ! out by records of the length of 1 BYTE. Each grid cell consists of 3
64  ! Bytes, which include 3 landuse categories (val 1-13 and 16 percentage
65  ! categories) So one half byte is used to store the Landusecat the other
66  ! for the percentageclass in 6.25 steps (100/6.25=16)
67  ! e.g.
68  ! 4 3  percentage 4 = 4*6.25 => 25% landuse class 3
69  ! 2 1  percentage 2 = 2*6.25 => 13% landuse class 1
70  ! 1 12 percentage 1 = 1*6.26 => 6.25% landuse class 12
71
72  open(unitland,file=path(1)(1:length(1)) &
73       //'IGBP_int1.dat',status='old', &
74  !    +form='UNFORMATTED', err=998)
75       form='UNFORMATTED', err=998, convert='little_endian')
76!  print*,unitland
77  read (unitland) (ilr_buffer(i),i=1,2160000)
78  close(unitland)
79
80  irecread=1
81  do ix=1,1200
82    do jy=1,600
83  ! the 3 most abundant landuse categories in the inventory
84  ! first half byte contains the landuse class
85  ! second half byte contains the respective percentage
86      do k=1,3
87  ! 1 byte is read
88        ilr=ilr_buffer(irecread)
89  !      ilr=0
90        irecread=irecread+1
91  ! as only signed integer values exist an unsigned value is constructed
92        if (ilr.lt.0) then
93           il=ilr+256
94        else
95           il=ilr
96        endif
97  ! dividing by 16 has the effect to get rid of the right half of the byte
98  ! so just the left half remains, this corresponds to a shift right of 4
99  ! bits
100        rlr=real(il)/16.
101        lu_cat=int(rlr)
102  ! the left half of the byte is substracted from the whole in order to
103  ! get only the right half of the byte
104        r2lr=rlr-int(rlr)
105  ! shift left by 4
106        lu_perc=r2lr*16.
107        landinvent(ix,jy,k)=lu_cat
108        landinvent(ix,jy,k+3)=lu_perc
109  !       if ((jy.lt.10).and.(ix.lt.10)) write(*,*) 'reading: ' , ix, jy, lu_cat, lu_perc
110      end do
111    end do
112  end do
113
114  ! Read relation landuse,z0
115  !*****************************
116
117  open(unitsurfdata,file=path(1)(1:length(1))//'surfdata.t', &
118       status='old',err=999)
119
120  do i=1,4
121    read(unitsurfdata,*)
122  end do
123  do i=1,numclass
124    read(unitsurfdata,'(45x,f15.3)') z0(i)
125  end do
126  close(unitsurfdata)
127
128  return
129
130  ! Issue error messages
131  !*********************
132
133998   write(*,*) ' #### FLEXPART ERROR! FILE CONTAINING          ####'
134  write(*,*) ' #### LANDUSE INVENTORY DOES NOT EXIST         ####'
135  stop
136
137999   write(*,*) ' #### FLEXPART ERROR! FILE CONTAINING          ####'
138  write(*,*) ' #### RELATION LANDUSE,z0 DOES NOT EXIST       ####'
139  stop
140
141end subroutine readlanduse
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG