00001
00002
00003
00004 subroutine open_single_td( sib, time, filename)
00005
00006
00007
00008
00009
00010
00011
00012
00013 use kinds
00014 use sibtype
00015 use timetype
00016 use sib_io_module
00017 use sib_const_module
00018 use sib_bc_module
00019
00020 implicit none
00021
00022
00023 type(sib_t), dimension(subcount), intent(inout) :: sib
00024 type(time_struct) :: time
00025
00026
00027 integer(kind=int_kind) :: ntest1
00028 integer(kind=int_kind) :: i,j,k,l,m,n
00029 character*100 filename
00030
00031
00032 close(32)
00033
00034
00035 open(32, file=trim(filename), form='formatted', status='old')
00036
00037
00038 read(32,*) ntest1
00039 if(ntest1/=nsib) stop ' param file nsib no match with model nsib'
00040
00041
00042 read(32,*) nper
00043 if(nper>npermax) stop ' too many composite periods in param file'
00044
00045
00046 read(32,*)
00047 do i = 1,nper
00048
00049
00050
00051 read(32,*) time%modis_start(i), time%modis_stop(i), j
00052 enddo
00053
00054
00055 read(32,*)
00056
00057 end subroutine open_single_td
00058
00059
00060 subroutine read_single_td_param(sib, time)
00061
00062
00063
00064
00065
00066
00067
00068 use kinds
00069 use sibtype
00070 use timetype
00071 use sib_io_module
00072 use sib_const_module
00073 use sib_bc_module
00074
00075 implicit none
00076
00077
00078 type(sib_t), dimension(subcount), intent(inout) :: sib
00079 type(time_struct), intent(in) :: time
00080
00081
00082 read(32,*)
00083
00084
00085
00086 read(32,*) sib%param%mlai3
00087 read(32,*) sib%param%mfpar3
00088 read(32,*) sib%param%modis_time3
00089
00090 read(32,*) sib%param%d13cresp3
00091 read(32,*) sib%param%physfrac3(1)
00092 read(32,*) sib%param%physfrac3(2)
00093 read(32,*) sib%param%physfrac3(3)
00094 read(32,*) sib%param%physfrac3(4)
00095 read(32,*) sib%param%physfrac3(5)
00096
00097
00098
00099 sib%param%modis_period3 = time%bc_recnum
00100
00101
00102
00103 end subroutine read_single_td_param
00104
00105
00106 subroutine open_global_td( sib, time, filename )
00107
00108
00109
00110
00111
00112
00113
00114
00115 use sibtype
00116 use timetype
00117 use sib_io_module
00118 use sib_const_module
00119 use sib_bc_module
00120
00121 #ifdef PGF
00122 use netcdf
00123 use typeSizes
00124 #endif
00125
00126 implicit none
00127
00128
00129 type(sib_t), dimension(subcount), intent(inout) :: sib
00130 type(time_struct) :: time
00131 character*100 filename
00132
00133
00134 integer(kind=int_kind) :: ntest1
00135 integer(kind=int_kind) :: dimid
00136 integer(kind=int_kind) :: var_id
00137 integer(kind=int_kind) :: status
00138 character(len=10) :: name
00139
00140
00141 if(param_id/=0) then
00142 status = nf90_close ( param_id )
00143 if (status /= nf90_noerr) call handle_err (status)
00144 endif
00145
00146
00147
00148 print*,'open_global_td: filename=',trim(filename)
00149
00150 status = nf90_open ( trim(filename), nf90_nowrite, param_id )
00151 if (status /= nf90_noerr) call handle_err(status)
00152
00153
00154 status = nf90_inq_dimid ( param_id, 'nsib', dimid )
00155 if (status /= nf90_noerr) call handle_err(status)
00156 status = nf90_inquire_dimension ( param_id, dimid, name, ntest1 )
00157 if (status /= nf90_noerr) call handle_err(status)
00158 if(ntest1 /= nsib) stop ' open: file sib_bc no match with model for nsib'
00159
00160
00161
00162 status = nf90_get_att( param_id, nf90_global, 'ndvi_source', ndvi_source )
00163 status = nf90_get_att( param_id, nf90_global, 'c4_source', c4_source )
00164 status = nf90_get_att( param_id, nf90_global, 'd13cresp_source', d13cresp_source )
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 status = nf90_inq_varid ( param_id, 'lai', mlai_id )
00185 if (status /= nf90_noerr) call handle_err(status)
00186 status = nf90_inq_varid ( param_id, 'fpar', mfpar_id )
00187 if (status /= nf90_noerr) call handle_err(status)
00188
00189
00190 status = nf90_inq_varid ( param_id, 'modis_time', modis_time_id )
00191 if (status /= nf90_noerr) call handle_err(status)
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 status = nf90_inq_varid ( param_id, 'd13cresp', d13_id )
00204 if (status /= nf90_noerr) call handle_err(status)
00205
00206
00207 status = nf90_inq_varid ( param_id, 'physfrac', phys_id )
00208 if (status /= nf90_noerr) call handle_err(status)
00209
00210
00211 status = nf90_inq_varid ( param_id, 'mapsyear', var_id )
00212 if (status /= nf90_noerr) call handle_err(status)
00213 status = nf90_get_var ( param_id, var_id, nper )
00214 if (status /= nf90_noerr) call handle_err (status)
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 status = nf90_inq_varid ( param_id, 'modis_start', var_id )
00233 if (status /= nf90_noerr) call handle_err(status)
00234 status = nf90_get_var ( param_id, var_id, time%modis_start(1:nper) )
00235 if (status /= nf90_noerr) call handle_err (status)
00236
00237
00238 status = nf90_inq_varid ( param_id, 'modis_stop', var_id )
00239 if (status /= nf90_noerr) call handle_err(status)
00240 status = nf90_get_var ( param_id, var_id, time%modis_stop(1:nper) )
00241 if (status /= nf90_noerr) call handle_err (status)
00242
00243
00244
00245
00246 end subroutine open_global_td
00247
00248
00249 subroutine read_global_td_param(sib, time)
00250
00251
00252
00253
00254
00255
00256
00257 use sibtype
00258 use timetype
00259 use sib_io_module
00260 use sib_const_module
00261 use sib_bc_module
00262
00263 #ifdef PGF
00264 use netcdf
00265 use typeSizes
00266 #endif
00267
00268 Implicit none
00269
00270
00271 type(sib_t), dimension(subcount), intent(inout) :: sib
00272 type(time_struct), intent(in) :: time
00273
00274
00275 integer(kind=int_kind) :: i,j
00276 integer(kind=int_kind) :: ntest1
00277 integer(kind=int_kind) :: status
00278 integer(kind=int_kind) :: begin (2)
00279 integer(kind=int_kind) :: finish (2)
00280
00281
00282
00283
00284
00285 real(kind=real_kind), dimension(nsib) :: mlai
00286 real(kind=real_kind), dimension(nsib) :: mfpar
00287 real(kind=real_kind), dimension(nsib) :: modis_time
00288
00289
00290
00291 real(kind=real_kind), dimension(nsib,physmax) :: frac
00292 real(kind=real_kind), dimension(nsib) :: d13
00293 character(len=10) :: name
00294
00295
00296 begin (1) = time%bc_recnum
00297 begin (2) = 1
00298 finish (1) = 1
00299 finish (2) = nsib
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314 status = nf90_get_var ( param_id, mlai_id, mlai, begin, finish )
00315 if (status /= nf90_noerr) call handle_err (status,'read_modis',1)
00316
00317 status = nf90_get_var ( param_id, mfpar_id, mfpar, begin, finish )
00318 if (status /= nf90_noerr) call handle_err (status,'read_modis',2)
00319
00320
00321 status = nf90_get_var ( param_id, modis_time_id, modis_time, begin, finish )
00322 if (status /= nf90_noerr) call handle_err (status,'read_modis',3)
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332 status = nf90_get_var ( param_id, d13_id, d13 )
00333 if (status /= nf90_noerr) call handle_err (status,'read_ndvi',3)
00334
00335
00336 status = nf90_get_var ( param_id, phys_id, frac )
00337 if (status /= nf90_noerr) call handle_err (status,'read_ndvi',4)
00338
00339
00340 do i = 1, subcount
00341
00342
00343
00344
00345
00346
00347 sib(i)%param%mlai3 = mlai(subset(i))
00348 sib(i)%param%mfpar3 = mfpar(subset(i))
00349
00350 sib(i)%param%modis_time3 = modis_time(subset(i))
00351 sib(i)%param%modis_period3 = time%bc_recnum
00352
00353
00354
00355 sib(i)%param%d13cresp = d13(subset(i))
00356 do j = 1, physmax
00357 sib(i)%param%physfrac3(j) = frac(subset(i),j)
00358 enddo
00359 enddo
00360
00361 end subroutine read_global_td_param
00362
00363
00364 subroutine calculate_td_param (sib, lat)
00365
00366
00367
00368
00369
00370
00371
00372
00373 use sibtype
00374 use sib_const_module
00375 use sib_bc_module
00376 use kinds
00377
00378 implicit none
00379
00380
00381 type(sib_t), intent(inout) :: sib
00382 real(kind=real_kind) lat
00383
00384
00385 integer(kind=int_kind) :: i,j,k,l,m,n
00386 type time_dep_var
00387 real(kind=real_kind) :: fpar
00388 real(kind=real_kind) :: lai
00389 real(kind=real_kind) :: green
00390 real(kind=real_kind) :: zo
00391 real(kind=real_kind) :: zp_disp
00392 real(kind=real_kind) :: rbc
00393 real(kind=real_kind) :: rdc
00394 real(kind=real_kind) :: gmudmu
00395 end type time_dep_var
00396 type(time_dep_var) :: timevar
00397 real(kind=real_kind) :: temptran (2,2)
00398 real(kind=real_kind) :: tempref (2,2)
00399 type(aero_var) :: tempaerovar(50,50)
00400
00401
00402 i = int(sib%param%biome)
00403
00404
00405 temptran = sib%param%tran(:,:)
00406 tempref = sib%param%ref(:,:)
00407 tempaerovar = aerovar(:,:,i)
00408
00409
00410 call mapper( &
00411 lat,&
00412 sib%param%modis_time1, &
00413 sib%param%modis_time2, &
00414 sib%param%mlai1, &
00415 sib%param%mlai2, &
00416 sib%param%mfpar1, &
00417 sib%param%mfpar2, &
00418 sib%param%vcover, &
00419 sib%param%chil, &
00420 temptran, &
00421 tempref, &
00422 morphtab(i), &
00423 tempaerovar, &
00424 laigrid, &
00425 fvcovergrid, &
00426 timevar)
00427
00428
00429 sib%param%aparc2 = timevar%fpar
00430 sib%param%zlt2 = timevar%lai
00431 sib%param%green2 = timevar%green
00432 sib%param%z0d2 = timevar%zo
00433 sib%param%zp_disp2 = timevar%zp_disp
00434 sib%param%rbc2 = timevar%rbc
00435 sib%param%rdc2 = timevar%rdc
00436 sib%param%gmudmu2 = timevar%gmudmu
00437
00438 end subroutine calculate_td_param
00439
00440
00441 subroutine need_to_switch (sib,time)
00442
00443
00444
00445
00446
00447
00448
00449 use sibtype
00450 use timetype
00451 use sib_const_module
00452 use sib_bc_module
00453 use kinds
00454
00455 implicit none
00456
00457
00458 type(sib_t), dimension(subcount), intent(inout) :: sib
00459 type(time_struct), intent(in) :: time
00460
00461
00462 integer i
00463 real(kind=real_kind) :: ndtime
00464 integer(kind=int_kind) :: ndp
00465 real(kind=real_kind) :: conv
00466
00467 conv = real(time%sec_per_day)
00468 do i=1,subcount
00469
00470
00471
00472
00473 ndtime = sib(i)%param%modis_time2
00474
00475
00476 ndp = sib(i)%param%modis_period2
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517 if ( ndtime >= time%modis_stop(ndp) - 0.1*time%dtsib/conv .and. &
00518 ndtime <= time%modis_stop(ndp) + 0.1*time%dtsib/conv ) then
00519 if ( time%real_doy >= ndtime - 1.1*time%dtsib/conv .and. &
00520 time%real_doy <= ndtime - 0.9*time%dtsib/conv .and. &
00521 ndp<nper ) then
00522 call switch_td_param (sib(i))
00523 call calculate_td_param (sib(i), latsib(subset(i)))
00524
00525 else if ( time%real_doy >= 365. - 1.1*time%dtsib/conv .and. &
00526 time%real_doy <= 365. - 0.9*time%dtsib/conv .and. &
00527 ndp==nper ) then
00528 call switch_td_param (sib(i))
00529 call calculate_td_param (sib(i), latsib(subset(i)))
00530
00531 end if
00532
00533
00534
00535 else if (time%new_day) then
00536 if (time%real_doy>=ndtime .and. &
00537 (ndp>1.or.time%real_doy<time%modis_start(nper))) then
00538 call switch_td_param (sib(i))
00539 call calculate_td_param (sib(i), latsib(subset(i)))
00540
00541 end if
00542 end if
00543
00544 end do
00545
00546 end subroutine need_to_switch
00547
00548
00549 subroutine switch_td_param (sib)
00550
00551
00552
00553
00554
00555
00556
00557 use sibtype
00558 use sib_const_module
00559 use sib_bc_module
00560 use kinds
00561
00562 implicit none
00563
00564
00565 type(sib_t), intent(inout) :: sib
00566
00567
00568 integer(kind=int_kind) :: i,j,k,l,m,n
00569
00570
00571
00572
00573
00574
00575
00576 sib%param%mlai1 = sib%param%mlai2
00577 sib%param%mfpar1 = sib%param%mfpar2
00578 sib%param%modis_time1 = sib%param%modis_time2
00579
00580
00581 sib%param%modis_period1 = sib%param%modis_period2
00582
00583
00584 sib%param%aparc1 = sib%param%aparc2
00585 sib%param%zlt1 = sib%param%zlt2
00586 sib%param%green1 = sib%param%green2
00587 sib%param%z0d1 = sib%param%z0d2
00588 sib%param%zp_disp1 = sib%param%zp_disp2
00589 sib%param%rbc1 = sib%param%rbc2
00590 sib%param%rdc1 = sib%param%rdc2
00591 sib%param%gmudmu1 = sib%param%gmudmu2
00592 sib%param%d13cresp1 = sib%param%d13cresp2
00593 do i = 1, physmax
00594 sib%param%physfrac1(i) = sib%param%physfrac2(i)
00595 enddo
00596
00597
00598
00599
00600
00601
00602 sib%param%mlai2 = sib%param%mlai3
00603 sib%param%mfpar2 = sib%param%mfpar3
00604 sib%param%modis_time2 = sib%param%modis_time3
00605 sib%param%modis_period2 = sib%param%modis_period3
00606
00607
00608
00609 sib%param%d13cresp2 = sib%param%d13cresp3
00610 do i = 1, physmax
00611 sib%param%physfrac2(i) = sib%param%physfrac3(i)
00612 enddo
00613
00614
00615
00616 end subroutine switch_td_param
00617