/[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.16 - (hide annotations) (download)
Thu Sep 23 03:28:42 2004 UTC (19 years, 9 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint55c_post, checkpoint55d_pre, checkpoint55e_post, checkpoint55d_post
Changes since 1.15: +19 -14 lines
 o finish MNC_CW_ADD_VATTR_* cleanup and add 'IF (useMNC) THEN' around
   all current sections of MNC code
   - the following tests compiled & ran with these fixes:
       exp0 global_ocean.90x40x15 aim.5l_cs dic_example hs94.cs-32x32x5

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

  ViewVC Help
Powered by ViewVC 1.1.22