/[MITgcm]/MITgcm/pkg/fizhi/fizhi_init_veg.F
ViewVC logotype

Annotation of /MITgcm/pkg/fizhi/fizhi_init_veg.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.13 - (hide annotations) (download)
Tue Jul 20 16:24:49 2004 UTC (19 years, 11 months ago) by molod
Branch: MAIN
Changes since 1.12: +5 -2 lines
Add logic for byteswapping of input data if needed

1 molod 1.13 C $Header: /u/gcmpack/MITgcm/pkg/fizhi/fizhi_init_veg.F,v 1.12 2004/07/13 21:11:08 molod Exp $
2 molod 1.1 C $Name: $
3    
4 molod 1.6 subroutine fizhi_init_veg(mythid,vegdata,im,jm,Nsx,Nsy,Nxg,Nyg,
5 molod 1.12 . maxtyp,nchp,nchpland,lons,lats,surftype,tilefrac,igrd,ityp,chfr,
6     . chlt,chlon)
7 molod 1.1 C***********************************************************************
8 molod 1.2 C Subroutine fizhi_init_veg - routine to read in the land surface types,
9     C interpolate to the models grid, and set up tile space for use by
10     C the land surface model, the albedo calculation and the surface
11     C roughness calculation.
12 molod 1.1 C
13     C INPUT:
14     C
15     C mythid - thread number (processor number)
16 molod 1.2 C vegdata - Character*40 Vegetation Dataset name
17 molod 1.7 C im - longitude dimension
18     C jm - latitude dimension (number of lat. points)
19 molod 1.4 C Nsx - Number of processors in x-direction
20     C Nsy - Number of processors in y-direction
21 molod 1.1 C maxtyp - maximum allowable number of land surface types per grid box
22 molod 1.6 C nchp - integer per-processor number of tiles in tile space
23 molod 1.7 C lons - longitude in degrees [im,jm,nSx,nSy]
24     C lats - latitude in degrees [im,jm,nSx,nSy]
25 molod 1.1 C
26     C OUTPUT:
27     C
28 molod 1.4 C surftype - integer array of land surface types [im,jm,maxtyp,Nsx,Nsy]
29 molod 1.1 C tilefrac - real array of corresponding land surface type fractions
30 molod 1.4 C [im,jm,maxtyp,Nsx,Nsy]
31 molod 1.1 C igrd - integer array in tile space of grid point number for each
32 molod 1.4 C tile [nchp,Nsx,Nsy]
33 molod 1.1 C ityp - integer array in tile space of land surface type for each
34 molod 1.4 C tile [nchp,Nsx,Nsy]
35 molod 1.1 C chfr - real array in tile space of land surface type fraction for
36 molod 1.4 C each tile [nchp,Nsx,Nsy]
37 molod 1.1 C
38     C NOTES:
39     C Vegetation type as follows:
40     C 1: BROADLEAF EVERGREEN TREES
41     C 2: BROADLEAF DECIDUOUS TREES
42     C 3: NEEDLELEAF TREES
43     C 4: GROUND COVER
44     C 5: BROADLEAF SHRUBS
45     C 6: DWARF TREES (TUNDRA)
46     C 7: BARE SOIL
47     C 8: DESERT
48     C 9: GLACIER
49     C 10: DARK DESERT
50     C 100: OCEAN
51     C***********************************************************************
52     implicit none
53 molod 1.13 #include "PACKAGES_CONFIG.h"
54 molod 1.11 #include "CPP_EEOPTIONS.h"
55 molod 1.5 #include "EEPARAMS.h"
56 molod 1.1
57 molod 1.12 integer mythid,im,jm,maxtyp,nchp,nchpland,Nsx,Nsy,Nxg,Nyg
58 molod 1.4 integer surftype(im,jm,maxtyp,Nsx,Nsy)
59 molod 1.6 integer igrd(nchp,Nsx,Nsy),ityp(nchp,Nsx,Nsy)
60 molod 1.10 _RL tilefrac(im,jm,maxtyp,Nsx,Nsy)
61     _RL lats(im,jm,nSx,nSy), lons(im,jm,nSx,nSy)
62     _RL chfr(nchp,Nsx,Nsy),chlt(nchp,Nsx,Nsy),chlon(nchp,Nsx,Nsy)
63 molod 1.1 character*40 vegdata
64 molod 1.6 integer imdata,jmdata,Nxgdata,Nygdata
65 molod 1.12 integer nchplocal,biglobal,bjglobal
66 molod 1.1
67 molod 1.6 integer*4 im_32, jm_32, Nxg_32, Nyg_32
68     integer*4 iveg_32(im,jm,maxtyp,Nxg,Nyg)
69     real*4 veg_32(im,jm,maxtyp,Nxg,Nyg)
70 molod 1.1
71 molod 1.3 integer i,j,k,bi,bj,ierr1,kveg
72 molod 1.1
73     call mdsfindunit( kveg, myThid )
74 molod 1.2 close(kveg)
75     open(kveg,file=vegdata,form='unformatted',access='sequential',
76     . iostat=ierr1)
77 molod 1.1 if( ierr1.eq.0 ) then
78 molod 1.6 read(kveg)im_32,jm_32,Nxg_32,Nyg_32,IVEG_32,VEG_32
79 molod 1.1 else
80     print *
81     print *, 'Veg Dataset: ',vegdata,' not found!'
82     print *
83 molod 1.2 call exit(101)
84 molod 1.1 endif
85 molod 1.2 close(kveg)
86 molod 1.3 IF (myThid.eq.1) THEN
87 molod 1.2 imdata = im_32
88     jmdata = jm_32
89 molod 1.6 Nxgdata = Nxg_32
90     Nygdata = Nyg_32
91 molod 1.2 if( (imdata.ne.im) .or. (jmdata.ne.jm) .or.
92 molod 1.6 . (Nxgdata.ne.Nxg) .or. (Nygdata.ne.Nyg) ) then
93 molod 1.2 print *
94     print *, 'Veg Data Resolution is Incorrect! '
95     print *,' Model Res: ',im,'x',jm,' Data Res: ',imdata,'x',jmdata
96 molod 1.6 print *,' Model Nxg Nyg: ',Nxg,' ',Nyg,' Data Nxg Nyg: ',Nxgdata,
97     . ' ',Nygdata
98 molod 1.2 print *
99     call exit(102)
100 molod 1.1 ENDIF
101 molod 1.12 ENDIF
102    
103 molod 1.5 DO BJ = myByLo(myThid), myByHi(myThid)
104     DO BI = myBxLo(myThid), myBxHi(myThid)
105    
106     biglobal=bi+(myXGlobalLo-1)/im
107     bjglobal=bj+(myYGlobalLo-1)/jm
108 molod 1.13 #ifdef _BYTESWAPIO
109     call MDS_BYTESWAPR4(im*jm*maxtyp,veg_32(1,1,1,biglobal,bjglobal))
110     #endif
111 molod 1.2 do k = 1,maxtyp
112 molod 1.4 do j = 1,jm
113     do i = 1,im
114 molod 1.5 surftype(i,j,k,bi,bj) = iveg_32(i,j,k,biglobal,bjglobal)
115     tilefrac(i,j,k,bi,bj) = veg_32(i,j,k,biglobal,bjglobal)
116 molod 1.2 enddo
117 molod 1.1 enddo
118     enddo
119    
120     c create chip arrays for :
121     c igrd : grid index
122     c ityp : veg. type
123     c chfr : vegetation fraction
124 molod 1.7 c chlon: chip longitude
125     c chlt : chip latitude
126 molod 1.1
127 molod 1.12 c nchpland<=nchplocal is the actual number of land chips
128 molod 1.1
129     c land points
130     c -----------
131 molod 1.12 nchpland = 0
132 molod 1.1 do k=1,maxtyp
133     do j=1,jm
134     do i=1,im
135 molod 1.2 if(surftype(i,j,k,bi,bj).lt.100.and.
136     . tilefrac(i,j,k,bi,bj).gt.0.)then
137 molod 1.12 nchpland = nchpland + 1
138     igrd (nchpland,bi,bj) = i + (j-1)*im
139     ityp (nchpland,bi,bj) = surftype(i,j,k,bi,bj)
140     chfr (nchpland,bi,bj) = tilefrac(i,j,k,bi,bj)
141     chlon(nchpland,bi,bj) = lons(i,j,bi,bj)
142     chlt (nchpland,bi,bj) = lats(i,j,bi,bj)
143 molod 1.1 endif
144     enddo
145     enddo
146     enddo
147    
148     c ocean points
149     c ------------
150 molod 1.12 nchplocal = nchpland
151 molod 1.1
152     do k=1,maxtyp
153     do j=1,jm
154     do i=1,im
155 molod 1.2 if(surftype(i,j,k,bi,bj).ge.100 .and.
156     . tilefrac(i,j,k,bi,bj).gt.0.)then
157 molod 1.6 nchplocal = nchplocal + 1
158     igrd (nchplocal,bi,bj) = i + (j-1)*im
159     ityp (nchplocal,bi,bj) = surftype(i,j,k,bi,bj)
160     chfr (nchplocal,bi,bj) = tilefrac(i,j,k,bi,bj)
161 molod 1.7 chlon(nchplocal,bi,bj) = lons(i,j,bi,bj)
162     chlt (nchplocal,bi,bj) = lats(i,j,bi,bj)
163 molod 1.1 endif
164     enddo
165     enddo
166     enddo
167    
168 molod 1.3 print *, 'bi ',bi,' bj ',bj
169 molod 1.6 print *, 'Number of Total Tiles: ',nchplocal
170 molod 1.12 print *, 'Number of Land Tiles: ',nchpland
171 molod 1.1 print *
172 molod 1.2
173     ENDDO
174     ENDDO
175 molod 1.1
176     RETURN
177     END

  ViewVC Help
Powered by ViewVC 1.1.22