00001 subroutine sibdrv_read_ncep2_single( sib, time )
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 use sib_const_module, only: &
00030 nsib, &
00031 latsib, &
00032 lonsib, &
00033 subset, &
00034 subcount
00035
00036 use sib_io_module, only: &
00037 dr_format, &
00038 driver_id
00039
00040 use physical_parameters, only: &
00041 kapa => kappa, &
00042 pi
00043
00044 use kinds
00045 #ifdef PGF
00046 use netcdf
00047 use typeSizes
00048 #endif
00049 use sibtype
00050 use timetype
00051
00052 implicit none
00053
00054
00055 type(sib_t), dimension(subcount), intent(inout) :: sib
00056 type(time_struct), intent(in) :: time
00057
00058
00059
00060
00061 integer(kind=int_kind) :: i, iyear, imon, iday, idoy, ihour, imin
00062
00063 integer(kind=int_kind) :: n
00064
00065 character*80 filename
00066 character*7 gchar
00067 integer(kind=int_kind) :: nctimeid,ncyid,ncmid,nctdid,ncdoyid,nchid
00068 integer(kind=int_kind), dimension(2) :: mstart,mcount
00069
00070 integer(kind=int_kind) :: nct2mid
00071 integer(kind=int_kind) :: nctccid
00072 integer(kind=int_kind) :: ncswdid
00073 integer(kind=int_kind) :: ncldwid
00074 integer(kind=int_kind) :: ncuwdid
00075 integer(kind=int_kind) :: ncvwdid
00076 integer(kind=int_kind) :: ncshid
00077 integer(kind=int_kind) :: ncsfpid
00078 integer(kind=int_kind) :: nclspid
00079 integer(kind=int_kind) :: nccvpid
00080 integer(kind=int_kind) :: ncsflid
00081
00082
00083 integer(kind=int_kind),parameter :: nsib_global=14637
00084 integer(kind=int_kind) :: ipoint
00085
00086
00087 real(kind=real_kind), dimension(nsib_global) :: t2m
00088 real(kind=real_kind), dimension(nsib_global) :: tcc
00089 real(kind=real_kind), dimension(nsib_global) :: swd
00090 real(kind=real_kind), dimension(nsib_global) :: ldw
00091 real(kind=real_kind), dimension(nsib_global) :: sh
00092 real(kind=real_kind), dimension(nsib_global) :: sfp
00093 real(kind=real_kind), dimension(nsib_global) :: lsp
00094 real(kind=real_kind), dimension(nsib_global) :: cvp
00095 real(kind=real_kind), dimension(nsib_global) :: sfl
00096
00097 integer(kind=int_kind) :: status
00098 real(kind=real_kind) :: xtime,xyear,xmonth,xdoy,xday,xhour
00099 real(kind=real_kind), dimension(nsib_global) :: xx,uwd,vwd
00100
00101
00102
00103 character(len=23) :: subname
00104 data subname/'sibdrv_read_single_ncep '/
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 do i=1,subcount
00116 sib(i)%prog%ps1 = sib(i)%prog%ps2
00117 sib(i)%prog%tm1 = sib(i)%prog%tm2
00118 sib(i)%prog%tcc1 = sib(i)%prog%tcc2
00119 sib(i)%prog%sh1 = sib(i)%prog%sh2
00120 sib(i)%prog%spdm1 = sib(i)%prog%spdm2
00121 sib(i)%prog%lspr1 = sib(i)%prog%lspr2
00122 sib(i)%prog%cupr1 = sib(i)%prog%cupr2
00123 sib(i)%prog%dlwbot1 = sib(i)%prog%dlwbot2
00124 sib(i)%prog%sw_dwn1 = sib(i)%prog%sw_dwn2
00125
00126
00127 ipoint = sib(i)%param%pt_1x1
00128
00129
00130 enddo
00131
00132
00133 if ( time%switch_driver ) then
00134 status = nf90_close( driver_id )
00135
00136 write( filename, dr_format ) time%driver_year, time%driver_month
00137
00138
00139 status = nf90_open( trim(filename), nf90_nowrite, driver_id )
00140 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',1)
00141 endif
00142
00143
00144
00145
00146
00147
00148
00149 status = nf90_inq_varid( driver_id, 'year', ncyid )
00150 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',2)
00151 status = nf90_inq_varid( driver_id, 'month',ncmid )
00152 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',3)
00153 status = nf90_inq_varid( driver_id, 'doy', ncdoyid )
00154 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',4)
00155 status = nf90_inq_varid( driver_id, 'day', nctdid )
00156 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',5)
00157 status = nf90_inq_varid( driver_id, 'hour', nchid )
00158 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',6)
00159
00160
00161 mstart(1) = time%driver_recnum
00162
00163
00164 status = nf90_get_var( driver_id, ncyid, xyear, mstart(1:1) )
00165 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',7)
00166 status = nf90_get_var( driver_id, ncmid, xmonth, mstart(1:1) )
00167 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',8)
00168 status = nf90_get_var( driver_id, ncdoyid, xdoy, mstart(1:1) )
00169 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',9)
00170 status = nf90_get_var( driver_id, nctdid, xday, mstart(1:1) )
00171 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',10)
00172 status = nf90_get_var( driver_id, nchid, xhour, mstart(1:1) )
00173 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',11)
00174
00175 ihour=xhour
00176 iday =xday
00177 idoy =xdoy
00178 imon =xmonth
00179 iyear=xyear
00180 imin=0
00181
00182
00183
00184
00185
00186
00187 status = nf90_inq_varid( driver_id, 't2m', nct2mid )
00188 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',12)
00189 status = nf90_inq_varid( driver_id, 'tcc', nctccid )
00190 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',13)
00191 status = nf90_inq_varid( driver_id, 'swd', ncswdid )
00192 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',14)
00193 status = nf90_inq_varid( driver_id, 'lwd', ncldwid )
00194 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',15)
00195 status = nf90_inq_varid( driver_id, 'uwd', ncuwdid )
00196 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',16)
00197 status = nf90_inq_varid( driver_id, 'vwd', ncvwdid )
00198 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',17)
00199 status = nf90_inq_varid( driver_id, 'shum', ncshid )
00200 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',18)
00201 status = nf90_inq_varid( driver_id, 'sfp', ncsfpid )
00202 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',19)
00203 status = nf90_inq_varid( driver_id, 'lsp', nclspid )
00204 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',20)
00205 status = nf90_inq_varid( driver_id, 'cvp', nccvpid )
00206 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',21)
00207 status = nf90_inq_varid( driver_id, 'sfl', ncsflid )
00208 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',22)
00209
00210
00211
00212 mstart=(/1,time%driver_recnum/); mcount=(/nsib_global,1/)
00213 status = nf90_get_var( driver_id, nct2mid, t2m, &
00214 mstart, mcount )
00215 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',23)
00216 status = nf90_get_var( driver_id, nctccid, tcc, &
00217 mstart, mcount )
00218 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',24)
00219 status = nf90_get_var( driver_id, ncswdid, swd, &
00220 mstart, mcount )
00221 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',25)
00222 status = nf90_get_var( driver_id, ncldwid, ldw, &
00223 mstart, mcount )
00224 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',26)
00225 status = nf90_get_var( driver_id, ncuwdid, uwd, &
00226 mstart, mcount )
00227 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',27)
00228 status = nf90_get_var( driver_id, ncvwdid, vwd, &
00229 mstart, mcount )
00230 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',28)
00231 status = nf90_get_var( driver_id, ncshid, sh, &
00232 mstart, mcount )
00233 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',29)
00234 status = nf90_get_var( driver_id, ncsfpid, sfp, &
00235 mstart, mcount )
00236 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',30)
00237 status = nf90_get_var( driver_id, nclspid, lsp, &
00238 mstart, mcount )
00239 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',31)
00240 status = nf90_get_var( driver_id, nccvpid, cvp, &
00241 mstart, mcount )
00242 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',32)
00243 status = nf90_get_var(driver_id, ncsflid, xx, &
00244 mstart, mcount )
00245 if(status/=nf90_noerr) call handle_err(status,'read_ncep2',33)
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 sib(1)%prog%tm2 = t2m(ipoint)
00256 sib(1)%prog%tcc2 = tcc(ipoint)
00257 sib(1)%prog%sw_dwn2 = swd(ipoint)
00258 sib(1)%prog%dlwbot2 = ldw(ipoint)
00259 sib(1)%prog%sh2 = sh(ipoint)
00260 sib(1)%prog%ps2 = sfp(ipoint)
00261 sib(1)%prog%lspr2 = lsp(ipoint)
00262 sib(1)%prog%cupr2 = cvp(ipoint)
00263
00264
00265
00266
00267 if ( sib(1)%prog%sw_dwn2 < 0 ) sib(1)%prog%sw_dwn2 = 0.0
00268 if ( sib(1)%prog%dlwbot2 < 0 ) sib(1)%prog%dlwbot2 = 0.0
00269
00270
00271 sib(1)%prog%tcc2 = sib(1)%prog%tcc2 * 0.01
00272
00273
00274 sib(1)%prog%spdm2=SQRT(uwd(ipoint)*uwd(ipoint)+vwd(ipoint)*vwd(ipoint))
00275
00276
00277 sib(1)%prog%lspr2 = sib(1)%prog%lspr2+xx(ipoint)
00278
00279 sib(1)%prog%lspr2 = (sib(1)%prog%lspr2-sib(1)%prog%cupr2)*time%driver_step
00280 sib(1)%prog%cupr2 = sib(1)%prog%cupr2*time%driver_step
00281
00282 if ( sib(1)%prog%lspr2 < 0.0 ) sib(1)%prog%lspr2 = 0.0
00283 if ( sib(1)%prog%cupr2 < 0.0 ) sib(1)%prog%cupr2 = 0.0
00284
00285
00286 sib(1)%prog%ps2 = sib(1)%prog%ps2 * 0.01
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305 end subroutine sibdrv_read_ncep2_single
00306