1 |
C $Header: /u/gcmpack/MITgcm/pkg/fizhi/fizhi_init_vegsurftiles.F,v 1.12 2009/05/12 19:56:35 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "FIZHI_OPTIONS.h" |
5 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
6 |
CBOP |
7 |
C !ROUTINE: FIZHI_INIT_VEGSURFTILES |
8 |
C !INTERFACE: |
9 |
subroutine fizhi_init_vegsurftiles(globalArr,xsize,ysize, |
10 |
& nymd,nhms,prec,myThid) |
11 |
|
12 |
C !DESCRIPTION: |
13 |
C Read in grid space values of the land state |
14 |
C and then convert to vegetation tile space |
15 |
|
16 |
C !USES: |
17 |
C Calls routine grd2msc to do grid to tile space for each bi bj |
18 |
implicit none |
19 |
#include "SIZE.h" |
20 |
#include "fizhi_SIZE.h" |
21 |
#include "fizhi_land_SIZE.h" |
22 |
#include "fizhi_coms.h" |
23 |
#include "fizhi_land_coms.h" |
24 |
#include "fizhi_earth_coms.h" |
25 |
#include "EEPARAMS.h" |
26 |
#include "PARAMS.h" |
27 |
#ifdef ALLOW_EXCH2 |
28 |
#include "W2_EXCH2_SIZE.h" |
29 |
#include "W2_EXCH2_TOPOLOGY.h" |
30 |
#endif /* ALLOW_EXCH2 */ |
31 |
|
32 |
C !INPUT/OUTPUT PARAMETERS: |
33 |
integer xsize, ysize |
34 |
Real*8 globalArr(xsize,ysize,8) |
35 |
CHARACTER*1 prec |
36 |
INTEGER nhms,nymd |
37 |
INTEGER myThid |
38 |
|
39 |
EXTERNAL ILNBLNK |
40 |
INTEGER ILNBLNK |
41 |
INTEGER MDS_RECLEN |
42 |
CEOP |
43 |
C !LOCAL VARIABLES: |
44 |
CHARACTER*80 fn |
45 |
integer ihour |
46 |
integer i,j,n |
47 |
integer bislot,bjslot,iunit |
48 |
integer recl |
49 |
integer bi,bj,fileprec |
50 |
_RL tempgrid(sNx,sNy) |
51 |
_RL temptile(nchp) |
52 |
_RL fracland(sNx,sNy,Nsx,Nsy) |
53 |
|
54 |
ihour = nhms/10000 |
55 |
if(xsize.eq.192) then |
56 |
WRITE(fn,'(a,I8,a,I2.2,a)') |
57 |
. 'vegtiles_cs32.d',nymd,'z',ihour,'.bin' |
58 |
elseif(xsize.eq.612) then |
59 |
WRITE(fn,'(a,I8,a,I2.2,a)') |
60 |
. 'vegtiles_cs102.d',nymd,'z',ihour,'.bin' |
61 |
else |
62 |
print *,' xsize is ',xsize |
63 |
stop 'do not seem to have correct vegtiles data ' |
64 |
endif |
65 |
fileprec = 64 |
66 |
|
67 |
call MDSFINDUNIT( iunit, mythid ) |
68 |
recl=MDS_RECLEN( fileprec, Nx*Ny*8, mythid ) |
69 |
|
70 |
C Only do I/O if I am the master thread |
71 |
_BEGIN_MASTER( myThid ) |
72 |
|
73 |
open(iUnit,file=fn,status='old',access='direct',recl=recl) |
74 |
read(iunit,rec=1) globalarr |
75 |
close( iunit ) |
76 |
_END_MASTER( myThid ) |
77 |
|
78 |
|
79 |
#ifdef _BYTESWAPIO |
80 |
call MDS_BYTESWAPR8( Nx*Ny*8, globalarr ) |
81 |
#endif |
82 |
|
83 |
DO bj = myByLo(myThid), myByHi(myThid) |
84 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
85 |
|
86 |
#if defined(ALLOW_EXCH2) |
87 |
bislot = exch2_txglobalo(W2_myTileList(bi,bj))-1 |
88 |
bjslot = exch2_tyglobalo(W2_myTileList(bi,bj))-1 |
89 |
#else |
90 |
bislot = myXGlobalLo-1+(bi-1)*sNx |
91 |
bjslot = myYGlobalLo-1+(bj-1)*sNy |
92 |
#endif /* ALLOW_EXCH2 */ |
93 |
|
94 |
call get_landfrac(sNx,sNy,Nsx,Nsy,bi,bj,maxtyp, |
95 |
. surftype,tilefrac,fracland(1,1,bi,bj)) |
96 |
|
97 |
do j = 1,sNy |
98 |
do i = 1,sNx |
99 |
tempgrid(i,j) = globalarr(i+bislot,j+bjslot,1) |
100 |
enddo |
101 |
enddo |
102 |
call grd2msc(tempgrid,sNx,sNy,igrd(1,bi,bj), |
103 |
. temptile,nchp,nchptot(bi,bj)) |
104 |
do n = 1,nchp |
105 |
tcanopy(n,bi,bj) = temptile(n) |
106 |
enddo |
107 |
|
108 |
do j = 1,sNy |
109 |
do i = 1,sNx |
110 |
tempgrid(i,j) = globalarr(i+bislot,j+bjslot,2) |
111 |
if (tempgrid(i,j).gt.1.e14 .and. fracland(i,j,bi,bj).gt.0.0001) |
112 |
. tempgrid(i,j) = globalarr(i+bislot,j+bjslot,1) - 0.5 |
113 |
enddo |
114 |
enddo |
115 |
call grd2msc(tempgrid,sNx,sNy,igrd(1,bi,bj), |
116 |
. temptile,nchp,nchptot(bi,bj)) |
117 |
do n = 1,nchp |
118 |
tdeep(n,bi,bj) = temptile(n) |
119 |
enddo |
120 |
|
121 |
do j = 1,sNy |
122 |
do i = 1,sNx |
123 |
tempgrid(i,j) = globalarr(i+bislot,j+bjslot,3) |
124 |
if (tempgrid(i,j).gt.1.e14 .and. fracland(i,j,bi,bj).gt.0.0001) |
125 |
. tempgrid(i,j) = 0.01 |
126 |
enddo |
127 |
enddo |
128 |
call grd2msc(tempgrid,sNx,sNy,igrd(1,bi,bj), |
129 |
. temptile,nchp,nchptot(bi,bj)) |
130 |
do n = 1,nchp |
131 |
ecanopy(n,bi,bj) = temptile(n) |
132 |
enddo |
133 |
|
134 |
do j = 1,sNy |
135 |
do i = 1,sNx |
136 |
tempgrid(i,j) = globalarr(i+bislot,j+bjslot,4) |
137 |
if (tempgrid(i,j).gt.1.e14 .and. fracland(i,j,bi,bj).gt.0.0001) |
138 |
. tempgrid(i,j) = 0.7 |
139 |
enddo |
140 |
enddo |
141 |
call grd2msc(tempgrid,sNx,sNy,igrd(1,bi,bj), |
142 |
. temptile,nchp,nchptot(bi,bj)) |
143 |
do n = 1,nchp |
144 |
swetshal(n,bi,bj) = temptile(n) |
145 |
enddo |
146 |
|
147 |
do j = 1,sNy |
148 |
do i = 1,sNx |
149 |
tempgrid(i,j) = globalarr(i+bislot,j+bjslot,5) |
150 |
if (tempgrid(i,j).gt.1.e14 .and. fracland(i,j,bi,bj).gt.0.0001) |
151 |
. tempgrid(i,j) = 0.5 |
152 |
enddo |
153 |
enddo |
154 |
call grd2msc(tempgrid,sNx,sNy,igrd(1,bi,bj), |
155 |
. temptile,nchp,nchptot(bi,bj)) |
156 |
do n = 1,nchp |
157 |
swetroot(n,bi,bj) = temptile(n) |
158 |
enddo |
159 |
|
160 |
do j = 1,sNy |
161 |
do i = 1,sNx |
162 |
tempgrid(i,j) = globalarr(i+bislot,j+bjslot,6) |
163 |
if (tempgrid(i,j).gt.1.e14 .and. fracland(i,j,bi,bj).gt.0.0001) |
164 |
. tempgrid(i,j) = 0.3 |
165 |
enddo |
166 |
enddo |
167 |
call grd2msc(tempgrid,sNx,sNy,igrd(1,bi,bj), |
168 |
. temptile,nchp,nchptot(bi,bj)) |
169 |
do n = 1,nchp |
170 |
swetdeep(n,bi,bj) = temptile(n) |
171 |
enddo |
172 |
|
173 |
do j = 1,sNy |
174 |
do i = 1,sNx |
175 |
tempgrid(i,j) = globalarr(i+bislot,j+bjslot,7) |
176 |
if (tempgrid(i,j).gt.1.e14 .and. fracland(i,j,bi,bj).gt.0.0001) |
177 |
. tempgrid(i,j) = 0. |
178 |
enddo |
179 |
enddo |
180 |
call grd2msc(tempgrid,sNx,sNy,igrd(1,bi,bj), |
181 |
. temptile,nchp,nchptot(bi,bj)) |
182 |
do n = 1,nchp |
183 |
snodep(n,bi,bj) = temptile(n) |
184 |
enddo |
185 |
|
186 |
do j = 1,sNy |
187 |
do i = 1,sNx |
188 |
tempgrid(i,j) = globalarr(i+bislot,j+bjslot,8) |
189 |
if (tempgrid(i,j).gt.1.e14 .and. fracland(i,j,bi,bj).gt.0.0001) |
190 |
. tempgrid(i,j) = 0. |
191 |
enddo |
192 |
enddo |
193 |
call grd2msc(tempgrid,sNx,sNy,igrd(1,bi,bj), |
194 |
. temptile,nchp,nchptot(bi,bj)) |
195 |
do n = 1,nchp |
196 |
capac(n,bi,bj) = temptile(n) |
197 |
enddo |
198 |
|
199 |
close(iunit) |
200 |
|
201 |
C End of bi bj loop |
202 |
enddo |
203 |
enddo |
204 |
|
205 |
RETURN |
206 |
END |