39 function load(this, file, fileID)
result (err_message)
41 integer,
intent(in) :: fileid
42 character(len=*),
intent(in) :: file
43 character(len=128) :: err_message
44 integer :: i1, i2, i3, ierr
45 real(kind=4), dimension(:),
allocatable :: lat4, pres4, time4, tempin
51 open(unit=fileid,file=trim(file), form=
'unformatted', convert=
'big_endian', iostat=ierr, iomsg=err_message)
52 if (ierr /= 0 )
return
53 read (fileid, iostat=ierr, iomsg=err_message) this%ncf, this%nlat, this%nlev, this%ntime
54 if (ierr /= 0 )
return
57 allocate (this%lat(this%nlat))
58 allocate (this%pres(this%nlev))
59 allocate (this%ph2o(this%nlev))
60 allocate (this%time(this%ntime+1))
61 allocate (this%data(this%nlat,this%nlev,this%ncf,this%ntime))
63 allocate(lat4(this%nlat), pres4(this%nlev), time4(this%ntime+1))
64 read (fileid, iostat=ierr, iomsg=err_message) this%ncf, this%nlat, this%nlev, this%ntime, lat4, pres4, time4
65 if (ierr /= 0 )
return
68 this%pres(:) = pres4(:)
69 this%ph2o(:) = log(100.0*this%pres(:))
71 this%time(:) = time4(:)
72 deallocate(lat4, pres4, time4)
74 allocate(tempin(this%nlat))
78 read(fileid, iostat=ierr, iomsg=err_message) tempin
79 if (ierr /= 0 )
return
80 this%data(:,i3,i2,i1) = tempin(:)
93 subroutine setup(this, lat, idx1, idx2, idxh)
95 real(kind_phys),
intent(in) :: lat(:)
96 integer,
intent(out) :: idx1(:), idx2(:)
97 real(kind_phys),
intent(out) :: idxh(:)
101 idx2(j) = this%nlat + 1
103 if (lat(j) < this%lat(i))
then
108 idx1(j) = max(idx2(j)-1,1)
109 idx2(j) = min(idx2(j),this%nlat)
110 if (idx2(j) .ne. idx1(j))
then
111 idxh(j) = (lat(j) - this%lat(idx1(j))) / (this%lat(idx2(j)) - this%lat(idx1(j)))
122 subroutine update(this, idx1, idx2, idxh, rjday, idxt1, idxt2, h2opl)
124 integer,
intent(in) :: idx1(:), idx2(:)
125 real(kind_phys),
intent(in) :: idxh(:)
126 real(kind_phys),
intent(in) :: rjday
127 integer,
intent(in) :: idxt1, idxt2
128 real(kind_phys),
intent(out) :: h2opl(:,:,:)
129 integer :: nc, l, j, j1, j2
130 real(kind_phys) :: tem, tx1, tx2
132 tx1 = (this%time(idxt2) - rjday) / (this%time(idxt2) - this%time(idxt1))
137 do j=1,
size(h2opl(:,1,1))
141 h2opl(j,l,nc) = tx1*(tem*this%data(j1,l,nc,idxt1)+idxh(j)*this%data(j2,l,nc,idxt1)) &
142 + tx2*(tem*this%data(j1,l,nc,idxt2)+idxh(j)*this%data(j2,l,nc,idxt2))
152 subroutine run(this, dt, p, h2opltc, h2o, dqv_dt_prd, dqv_dt_qv)
154 real(kind_phys),
intent(in) :: &
156 real(kind_phys),
intent(in),
dimension(:,:) :: &
158 real(kind_phys),
intent(in),
dimension(:,:,:) :: &
160 real(kind_phys),
intent(inout),
dimension(:,:) :: &
162 real(kind_phys),
intent(inout),
dimension(:, :),
optional :: &
166 integer :: nCol, nLev, iCol, iLev, iCf, kmax, kmin, k
167 logical,
dimension(size(p,1)) :: flg
168 real(kind_phys) :: pmax, pmin, temp
169 real(kind_phys),
dimension(size(p,1)) :: wk1, wk2, wk3, h2oib
170 real(kind_phys),
dimension(size(p,1),this%ncf) :: pltc
171 real(kind_phys),
parameter :: prsmax=10000.0, pmaxl=log(prsmax)
181 wk1(icol) = log(p(icol,ilev))
182 pmin = min(wk1(icol), pmin)
183 pmax = max(wk1(icol), pmax)
184 pltc(icol,:) = 0._kind_phys
186 if (pmin < pmaxl)
then
190 if (pmin < this%ph2o(k)) kmax = k
191 if (pmax < this%ph2o(k)) kmin = k
195 temp = 1.0 / (this%ph2o(k) - this%ph2o(k+1))
198 if (wk1(icol) < this%ph2o(k) .and. wk1(icol) >= this%ph2o(k+1))
then
200 wk2(icol) = (wk1(icol) - this%ph2o(k+1)) * temp
201 wk3(icol) = 1.0 - wk2(icol)
207 pltc(icol,icf) = wk2(icol) * h2opltc(icol,k,icf) + wk3(icol) * h2opltc(icol,k+1,icf)
215 if (wk1(icol) < this%ph2o(this%nlev))
then
216 pltc(icol,icf) = h2opltc(icol,this%nlev,icf)
218 if (wk1(icol) >= this%ph2o(1))
then
219 pltc(icol,icf) = h2opltc(icol,1,icf)
226 if (p(icol,ilev) < prsmax .and. pltc(icol,2) /= 0.0)
then
227 h2oib(icol) = h2o(icol,ilev)
228 temp = 1.0 / pltc(icol,2)
229 h2o(icol,ilev) = (h2oib(icol) + (pltc(icol,1)+pltc(icol,3)*temp)*dt) / (1.0 + temp*dt)
233 if (
present(dqv_dt_prd)) dqv_dt_prd(:, ilev) = pltc(:, 1) * dt
234 if (
present(dqv_dt_qv))
then
235 where (pltc(:, 2) .ne. 0)
236 dqv_dt_qv(:, ilev) = (h2o(:, ilev) - pltc(:, 3)) * dt / pltc(:, 2)
238 dqv_dt_qv(:, ilev) = 0