26 q2m_target_grid, tprcp_target_grid, &
27 f10m_target_grid, seaice_fract_target_grid, &
28 ffmm_target_grid, ustar_target_grid, &
29 srflag_target_grid, soil_temp_target_grid, &
30 seaice_depth_target_grid, snow_liq_equiv_target_grid, &
31 seaice_skin_temp_target_grid, skin_temp_target_grid, &
32 snow_depth_target_grid, z0_target_grid, &
33 c_d_target_grid, c_0_target_grid, &
34 d_conv_target_grid, dt_cool_target_grid, &
35 ifd_target_grid, qrain_target_grid, &
36 tref_target_grid, w_d_target_grid, &
37 w_0_target_grid, xs_target_grid, &
38 xt_target_grid, xu_target_grid, &
39 xv_target_grid, xz_target_grid, &
40 xtts_target_grid, xzts_target_grid, &
41 z_c_target_grid, zm_target_grid, &
42 soilm_tot_target_grid, lai_target_grid, &
51 integer,
parameter :: veg_type_landice_target = 15
57 type(esmf_field
) :: soil_type_from_input_grid
60 type(esmf_field
) :: terrain_from_input_grid
63 type(esmf_field
) :: terrain_from_input_grid_land
67 real,
parameter,
private :: blim = 5.5
69 real,
parameter,
private :: frz_h2o = 273.15
71 real,
parameter,
private :: frz_ice = 271.21
73 real,
parameter,
private :: grav = 9.81
75 real,
parameter,
private :: hlice = 3.335E5
80 real(esmf_kind_r8),
pointer :: p(:,:)
85 real(esmf_kind_r8),
pointer :: p(:,:,:)
122 integer,
intent(in) :: localpet
248 use input_data, only : canopy_mc_input_grid, &
251 landsea_mask_input_grid, &
253 seaice_depth_input_grid, &
254 seaice_fract_input_grid, &
255 seaice_skin_temp_input_grid, &
256 skin_temp_input_grid, &
257 snow_depth_input_grid, &
258 snow_liq_equiv_input_grid, &
259 soil_temp_input_grid, &
260 soil_type_input_grid, &
261 soilm_tot_input_grid, &
266 veg_type_input_grid, &
271 dt_cool_input_grid, &
285 zm_input_grid, terrain_input_grid, &
286 veg_type_landice_input, &
287 veg_greenness_input_grid, &
288 max_veg_greenness_input_grid, &
289 min_veg_greenness_input_grid, &
292 use model_grid, only : input_grid, target_grid, &
293 i_target, j_target, &
295 num_tiles_target_grid, &
296 landmask_target_grid, &
297 seamask_target_grid, &
304 minmax_vgfrc_from_climo, &
309 soil_type_target_grid, &
310 veg_greenness_target_grid, &
311 substrate_temp_target_grid,&
312 min_veg_greenness_target_grid,&
313 max_veg_greenness_target_grid
319 integer,
intent(in) :: localpet
321 integer :: l(1), u(1)
322 integer :: i, j, ij, rc, tile
323 integer :: clb_target(2), cub_target(2)
324 integer :: isrctermprocessing
325 integer :: num_fields
326 integer :: vgfrc_ind, mmvg_ind, lai_ind
327 integer,
allocatable :: search_nums(:)
328 integer(esmf_kind_i4),
pointer :: unmapped_ptr(:)
329 integer(esmf_kind_i4),
pointer :: mask_input_ptr(:,:)
330 integer(esmf_kind_i4),
pointer :: mask_target_ptr(:,:)
331 integer(esmf_kind_i8),
pointer :: landmask_target_ptr(:,:)
332 integer(esmf_kind_i8),
allocatable :: mask_target_one_tile(:,:)
333 integer(esmf_kind_i8),
allocatable :: water_target_one_tile(:,:)
334 integer(esmf_kind_i8),
allocatable :: land_target_one_tile(:,:)
335 integer(esmf_kind_i8),
pointer :: seamask_target_ptr(:,:)
337 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
338 real(esmf_kind_r8),
allocatable :: data_one_tile2(:,:)
339 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
340 real(esmf_kind_r8),
allocatable :: latitude_one_tile(:,:)
341 real(esmf_kind_r8),
pointer :: seaice_fract_target_ptr(:,:)
342 real(esmf_kind_r8),
pointer :: srflag_target_ptr(:,:)
343 real(esmf_kind_r8),
pointer :: terrain_from_input_ptr(:,:)
344 real(esmf_kind_r8),
pointer :: veg_type_target_ptr(:,:)
345 real(esmf_kind_r8),
pointer :: soil_type_target_ptr(:,:)
346 real(esmf_kind_r8),
pointer :: landmask_input_ptr(:,:)
347 real(esmf_kind_r8),
pointer :: veg_type_input_ptr(:,:)
348 real(esmf_kind_r8),
allocatable :: veg_type_target_one_tile(:,:)
350 type(esmf_regridmethod_flag
) :: method
351 type(esmf_routehandle
) :: regrid_bl_no_mask
352 type(esmf_routehandle
) :: regrid_all_land
353 type(esmf_routehandle
) :: regrid_land
354 type(esmf_routehandle
) :: regrid_landice
355 type(esmf_routehandle
) :: regrid_nonland
356 type(esmf_routehandle
) :: regrid_seaice
357 type(esmf_routehandle
) :: regrid_water
359 type(esmf_fieldbundle
) :: bundle_all_target, bundle_all_input
360 type(esmf_fieldbundle
) :: bundle_seaice_target, bundle_seaice_input
361 type(esmf_fieldbundle
) :: bundle_water_target, bundle_water_input
362 type(esmf_fieldbundle
) :: bundle_allland_target, bundle_allland_input
363 type(esmf_fieldbundle
) :: bundle_landice_target, bundle_landice_input
364 type(esmf_fieldbundle
) :: bundle_nolandice_target, bundle_nolandice_input
366 logical,
allocatable :: dozero(:)
372 method=esmf_regridmethod_bilinear
374 isrctermprocessing = 1
376 print*,
"- CALL FieldRegridStore FOR NON-MASKED BILINEAR INTERPOLATION."
377 call esmf_fieldregridstore(t2m_input_grid, &
379 polemethod=esmf_polemethod_allavg, &
380 srctermprocessing=isrctermprocessing, &
381 routehandle=regrid_bl_no_mask, &
382 regridmethod=method, rc=rc)
383 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
386 bundle_all_target = esmf_fieldbundlecreate(name=
"all points target", rc=rc)
387 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
389 bundle_all_input = esmf_fieldbundlecreate(name=
"all points input", rc=rc)
390 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
393 call esmf_fieldbundleadd(bundle_all_target, (/t2m_target_grid,q2m_target_grid,tprcp_target_grid, &
394 f10m_target_grid,ffmm_target_grid,ustar_target_grid,srflag_target_grid/), &
396 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
398 call esmf_fieldbundleadd(bundle_all_input, (/t2m_input_grid,q2m_input_grid,tprcp_input_grid, &
399 f10m_input_grid,ffmm_input_grid,ustar_input_grid,srflag_input_grid/), &
401 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
404 call esmf_fieldbundleget(bundle_all_target,fieldcount=num_fields,rc=rc)
405 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
408 allocate(dozero(num_fields))
411 call
regrid_many(bundle_all_input,bundle_all_target,num_fields,regrid_bl_no_mask,dozero)
414 call esmf_fieldbundledestroy(bundle_all_target,rc=rc)
415 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
417 call esmf_fieldbundledestroy(bundle_all_input,rc=rc)
418 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
421 print*,
"- CALL FieldGet FOR SRFLAG."
422 call esmf_fieldget(srflag_target_grid, &
423 farrayptr=srflag_target_ptr, rc=rc)
424 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
432 srflag_target_ptr = nint(srflag_target_ptr)
434 print*,
"- CALL FieldRegridRelease."
435 call esmf_fieldregridrelease(routehandle=regrid_bl_no_mask, rc=rc)
436 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
443 print*,
"- CALL GridAddItem FOR TARGET GRID."
444 call esmf_gridadditem(target_grid, &
445 itemflag=esmf_griditem_mask, &
446 staggerloc=esmf_staggerloc_center, rc=rc)
447 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
450 print*,
"- CALL GridGetItem FOR TARGET GRID."
451 call esmf_gridgetitem(target_grid, &
452 itemflag=esmf_griditem_mask, &
453 farrayptr=mask_target_ptr, rc=rc)
454 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
457 print*,
"- CALL FieldGet FOR TARGET GRID SEAMASK."
458 call esmf_fieldget(seamask_target_grid, &
459 computationallbound=clb_target, &
460 computationalubound=cub_target, &
461 farrayptr=seamask_target_ptr, rc=rc)
462 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
465 print*,
"- CALL FieldGet FOR TARGET GRID LANDMASK."
466 call esmf_fieldget(landmask_target_grid, &
467 farrayptr=landmask_target_ptr, rc=rc)
468 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
471 print*,
"- CALL GridAddItem FOR INPUT GRID SEAMASK."
472 call esmf_gridadditem(input_grid, &
473 itemflag=esmf_griditem_mask, &
474 staggerloc=esmf_staggerloc_center, rc=rc)
475 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
478 print*,
"- CALL FieldGet FOR INPUT GRID LANDMASK."
479 call esmf_fieldget(landsea_mask_input_grid, &
480 farrayptr=landmask_input_ptr, rc=rc)
481 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
484 print*,
"- CALL GridGetItem FOR INPUT GRID LANDMASK."
485 call esmf_gridgetitem(input_grid, &
486 itemflag=esmf_griditem_mask, &
487 farrayptr=mask_input_ptr, rc=rc)
488 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
491 if (localpet == 0)
then
492 allocate(data_one_tile(i_target,j_target))
493 allocate(data_one_tile_3d(i_target,j_target,lsoil_target))
494 allocate(mask_target_one_tile(i_target,j_target))
496 allocate(data_one_tile(0,0))
497 allocate(data_one_tile_3d(0,0,0))
498 allocate(mask_target_one_tile(0,0))
506 method=esmf_regridmethod_nearest_stod
508 isrctermprocessing = 1
511 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1
514 where (landmask_target_ptr == 1) mask_target_ptr = 1
516 print*,
"- CALL FieldCreate FOR TERRAIN FROM INPUT GRID LAND."
517 terrain_from_input_grid_land = esmf_fieldcreate(target_grid, &
518 typekind=esmf_typekind_r8, &
519 staggerloc=esmf_staggerloc_center, rc=rc)
520 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
523 print*,
"- CALL FieldRegridStore for land fields."
524 call esmf_fieldregridstore(terrain_input_grid, &
525 terrain_from_input_grid_land, &
526 srcmaskvalues=(/0/), &
527 dstmaskvalues=(/0/), &
528 polemethod=esmf_polemethod_none, &
529 srctermprocessing=isrctermprocessing, &
530 unmappedaction=esmf_unmappedaction_ignore, &
531 normtype=esmf_normtype_fracarea, &
532 routehandle=regrid_all_land, &
533 regridmethod=method, &
534 unmappeddstlist=unmapped_ptr, rc=rc)
535 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
538 print*,
"- CALL Field_Regrid TERRAIN."
539 call esmf_fieldregrid(terrain_input_grid, &
540 terrain_from_input_grid_land, &
541 routehandle=regrid_all_land, &
542 termorderflag=esmf_termorder_srcseq, rc=rc)
543 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
546 print*,
"- CALL FieldGet FOR terrain from input grid at land."
547 call esmf_fieldget(terrain_from_input_grid_land, &
548 farrayptr=terrain_from_input_ptr, rc=rc)
549 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
552 l = lbound(unmapped_ptr)
553 u = ubound(unmapped_ptr)
556 call
ij_to_i_j(unmapped_ptr(ij), i_target, j_target, i, j)
557 terrain_from_input_ptr(i,j) = -9999.9
559 nullify(terrain_from_input_ptr)
561 do tile = 1, num_tiles_target_grid
563 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
564 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
565 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
568 print*,
"- CALL FieldGather FOR TERRAIN FROM INPUT GRID: ", tile
569 call esmf_fieldgather(terrain_from_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
570 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
573 if (localpet == 0)
then
574 allocate(land_target_one_tile(i_target,j_target))
575 land_target_one_tile = 0
576 where(mask_target_one_tile == 1) land_target_one_tile = 1
577 call
search(data_one_tile, land_target_one_tile, i_target, j_target, tile, 7)
578 deallocate(land_target_one_tile)
581 print*,
"- CALL FieldScatter FOR TERRAIN FROM INPUT GRID: ", tile
582 call esmf_fieldscatter(terrain_from_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
583 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
587 if(.not. vgtyp_from_climo)
then
589 print*,
"- CALL FieldRegrid VEG TYPE."
590 call esmf_fieldregrid(veg_type_input_grid, &
591 veg_type_target_grid, &
592 routehandle=regrid_all_land, &
593 termorderflag=esmf_termorder_srcseq, rc=rc)
594 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
597 print*,
"- CALL FieldGet FOR TARGET grid veg type."
598 call esmf_fieldget(veg_type_target_grid, &
599 farrayptr=veg_type_target_ptr, rc=rc)
600 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
603 l = lbound(unmapped_ptr)
604 u = ubound(unmapped_ptr)
607 call
ij_to_i_j(unmapped_ptr(ij), i_target, j_target, i, j)
608 veg_type_target_ptr(i,j) = -9999.9
611 do tile = 1, num_tiles_target_grid
612 print*,
"- CALL FieldGather FOR TARGET GRID VEG TYPE TILE: ", tile
613 call esmf_fieldgather(veg_type_target_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
614 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
617 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
618 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
619 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
622 if (localpet == 0)
then
623 allocate(land_target_one_tile(i_target,j_target))
624 land_target_one_tile = 0
625 where(mask_target_one_tile == 1) land_target_one_tile = 1
626 call
search(data_one_tile, land_target_one_tile, i_target, j_target, tile, 225)
627 deallocate(land_target_one_tile)
630 print*,
"- CALL FieldScatter FOR TARGET GRID VEG TYPE: ", tile
631 call esmf_fieldscatter(veg_type_target_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
632 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
635 nullify(veg_type_target_ptr)
637 print*,
"- CALL FieldRegridRelease."
638 call esmf_fieldregridrelease(routehandle=regrid_all_land, rc=rc)
639 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
648 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 0
650 mask_target_ptr = seamask_target_ptr
652 method=esmf_regridmethod_conserve
654 isrctermprocessing = 1
656 print*,
"- CALL FieldRegridStore for sea ice fraction."
657 call esmf_fieldregridstore(seaice_fract_input_grid, &
658 seaice_fract_target_grid, &
659 srcmaskvalues=(/0/), &
660 dstmaskvalues=(/0/), &
661 polemethod=esmf_polemethod_none, &
662 srctermprocessing=isrctermprocessing, &
663 unmappedaction=esmf_unmappedaction_ignore, &
664 normtype=esmf_normtype_fracarea, &
665 routehandle=regrid_nonland, &
666 regridmethod=method, &
667 unmappeddstlist=unmapped_ptr, rc=rc)
668 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
671 print*,
"- CALL Field_Regrid for sea ice fraction."
672 call esmf_fieldregrid(seaice_fract_input_grid, &
673 seaice_fract_target_grid, &
674 routehandle=regrid_nonland, &
675 termorderflag=esmf_termorder_srcseq, rc=rc)
676 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
679 print*,
"- CALL FieldGet FOR TARGET grid sea ice fraction."
680 call esmf_fieldget(seaice_fract_target_grid, &
681 farrayptr=seaice_fract_target_ptr, rc=rc)
682 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
685 l = lbound(unmapped_ptr)
686 u = ubound(unmapped_ptr)
689 call
ij_to_i_j(unmapped_ptr(ij), i_target, j_target, i, j)
690 seaice_fract_target_ptr(i,j) = -9999.9
695 if (localpet == 0)
then
696 allocate(latitude_one_tile(i_target,j_target))
698 allocate(latitude_one_tile(0,0))
701 do tile = 1, num_tiles_target_grid
703 print*,
"- CALL FieldGather FOR TARGET GRID SEAICE FRACTION TILE: ", tile
704 call esmf_fieldgather(seaice_fract_target_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
705 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
708 print*,
"- CALL FieldGather FOR TARGET GRID MASK TILE: ", tile
709 call esmf_fieldgather(seamask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
710 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
713 print*,
"- CALL FieldGather FOR TARGET LATITUDE TILE: ", tile
714 call esmf_fieldgather(latitude_target_grid, latitude_one_tile, rootpet=0, tile=tile, rc=rc)
715 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
718 if (localpet == 0)
then
719 call
search(data_one_tile, mask_target_one_tile, i_target, j_target, tile, 91, &
720 latitude=latitude_one_tile)
723 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
724 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
725 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
729 if (localpet == 0)
then
732 if (data_one_tile(i,j) > 1.0_esmf_kind_r8)
then
733 data_one_tile(i,j) = 1.0_esmf_kind_r8
735 if (data_one_tile(i,j) < 0.15_esmf_kind_r8) data_one_tile(i,j) = 0.0_esmf_kind_r8
736 if (data_one_tile(i,j) >= 0.15_esmf_kind_r8) mask_target_one_tile(i,j) = 2
741 print*,
"- CALL FieldScatter FOR TARGET GRID SEAICE FRACTION TILE: ", tile
742 call esmf_fieldscatter(seaice_fract_target_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
743 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
746 print*,
"- CALL FieldScatter FOR TARGET LANDMASK TILE: ", tile
747 call esmf_fieldscatter(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
748 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
753 deallocate(latitude_one_tile)
755 print*,
"- CALL FieldRegridRelease."
756 call esmf_fieldregridrelease(routehandle=regrid_nonland, rc=rc)
757 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
766 where (nint(landmask_input_ptr) == 2) mask_input_ptr = 1
768 print*,
"- CALL FieldGet FOR TARGET land sea mask."
769 call esmf_fieldget(landmask_target_grid, &
770 farrayptr=landmask_target_ptr, rc=rc)
771 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
775 do j = clb_target(2), cub_target(2)
776 do i = clb_target(1), cub_target(1)
777 if (landmask_target_ptr(i,j) == 2) mask_target_ptr(i,j) = 1
781 method=esmf_regridmethod_nearest_stod
782 isrctermprocessing = 1
784 print*,
"- CALL FieldRegridStore for 3d seaice fields."
785 call esmf_fieldregridstore(soil_temp_input_grid, &
786 soil_temp_target_grid, &
787 srcmaskvalues=(/0/), &
788 dstmaskvalues=(/0/), &
789 polemethod=esmf_polemethod_none, &
790 srctermprocessing=isrctermprocessing, &
791 unmappedaction=esmf_unmappedaction_ignore, &
792 normtype=esmf_normtype_fracarea, &
793 routehandle=regrid_seaice, &
794 regridmethod=method, &
795 unmappeddstlist=unmapped_ptr, rc=rc)
796 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
799 bundle_seaice_target = esmf_fieldbundlecreate(name=
"sea ice target", rc=rc)
800 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
802 bundle_seaice_input = esmf_fieldbundlecreate(name=
"sea ice input", rc=rc)
803 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
805 call esmf_fieldbundleadd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_target_grid, &
806 snow_liq_equiv_target_grid, seaice_skin_temp_target_grid, &
807 soil_temp_target_grid/), rc=rc)
808 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
810 call esmf_fieldbundleadd(bundle_seaice_input, (/seaice_depth_input_grid, snow_depth_input_grid, &
811 snow_liq_equiv_input_grid, seaice_skin_temp_input_grid, &
812 soil_temp_input_grid/), rc=rc)
813 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
815 call esmf_fieldbundleget(bundle_seaice_target,fieldcount=num_fields,rc=rc)
816 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
820 allocate(search_nums(num_fields))
821 allocate(dozero(num_fields))
823 search_nums = (/92,66,65,21,21/)
826 l = lbound(unmapped_ptr)
827 u = ubound(unmapped_ptr)
829 call
regrid_many(bundle_seaice_input,bundle_seaice_target,num_fields,regrid_seaice,dozero, &
830 unmapped_ptr=unmapped_ptr )
832 call esmf_fieldbundledestroy(bundle_seaice_input,rc=rc)
833 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
836 do tile = 1, num_tiles_target_grid
838 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
839 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
840 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
843 if (localpet == 0)
then
844 where(mask_target_one_tile == 1) mask_target_one_tile = 0
845 where(mask_target_one_tile == 2) mask_target_one_tile = 1
849 call
search_many(num_fields,bundle_seaice_target,data_one_tile, mask_target_one_tile,tile,search_nums,localpet, &
850 field_data_3d=data_one_tile_3d)
853 deallocate(search_nums)
854 call esmf_fieldbundledestroy(bundle_seaice_target,rc=rc)
855 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
858 print*,
"- CALL FieldRegridRelease."
859 call esmf_fieldregridrelease(routehandle=regrid_seaice, rc=rc)
860 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
868 where (nint(landmask_input_ptr) == 0) mask_input_ptr = 1
871 where (landmask_target_ptr == 0) mask_target_ptr = 1
873 method=esmf_regridmethod_conserve
874 isrctermprocessing = 1
876 print*,
"- CALL FieldRegridStore for water fields."
877 call esmf_fieldregridstore(skin_temp_input_grid, &
878 skin_temp_target_grid, &
879 srcmaskvalues=(/0/), &
880 dstmaskvalues=(/0/), &
881 polemethod=esmf_polemethod_none, &
882 srctermprocessing=isrctermprocessing, &
883 unmappedaction=esmf_unmappedaction_ignore, &
884 normtype=esmf_normtype_fracarea, &
885 routehandle=regrid_water, &
886 regridmethod=method, &
887 unmappeddstlist=unmapped_ptr, rc=rc)
888 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
891 bundle_water_target = esmf_fieldbundlecreate(name=
"water target", rc=rc)
892 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
894 bundle_water_input = esmf_fieldbundlecreate(name=
"water input", rc=rc)
895 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
897 call esmf_fieldbundleadd(bundle_water_target, (/skin_temp_target_grid, z0_target_grid/), rc=rc)
898 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
900 call esmf_fieldbundleadd(bundle_water_input, (/skin_temp_input_grid, z0_input_grid/), rc=rc)
901 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
904 if (convert_nst)
then
906 call esmf_fieldbundleadd(bundle_water_target, (/c_d_target_grid,c_0_target_grid,d_conv_target_grid, &
907 dt_cool_target_grid,ifd_target_grid,qrain_target_grid,tref_target_grid, &
908 w_d_target_grid,w_0_target_grid,xs_target_grid,xt_target_grid,xu_target_grid, &
909 xv_target_grid,xz_target_grid,xtts_target_grid,xzts_target_grid, &
910 z_c_target_grid,zm_target_grid/), rc=rc)
911 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
914 call esmf_fieldbundleadd(bundle_water_input, (/c_d_input_grid,c_0_input_grid,d_conv_input_grid, &
915 dt_cool_input_grid,ifd_input_grid,qrain_input_grid,tref_input_grid, &
916 w_d_input_grid,w_0_input_grid,xs_input_grid,xt_input_grid,xu_input_grid, &
917 xv_input_grid,xz_input_grid,xtts_input_grid,xzts_input_grid, &
918 z_c_input_grid,zm_input_grid/), rc=rc)
919 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
921 call esmf_fieldbundleget(bundle_water_target,fieldcount=num_fields,rc=rc)
922 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
925 allocate(search_nums(num_fields))
926 allocate(dozero(num_fields))
928 search_nums(:)=(/11,83,0,0,0,0,1,0,11,0,0,0,0,0,0,30,0,0,0,0/)
932 call esmf_fieldbundleget(bundle_water_target,fieldcount=num_fields,rc=rc)
933 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
936 allocate(search_nums(num_fields))
937 allocate(dozero(num_fields))
938 search_nums(:)=(/11,83/)
942 call
regrid_many(bundle_water_input,bundle_water_target,num_fields,regrid_water,dozero, &
943 unmapped_ptr=unmapped_ptr, resetifd=.true.)
945 call esmf_fieldbundledestroy(bundle_water_input,rc=rc)
946 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
950 if (localpet == 0)
then
951 allocate(latitude_one_tile(i_target,j_target))
953 allocate(latitude_one_tile(0,0))
956 do tile = 1, num_tiles_target_grid
958 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
959 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
960 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
963 print*,
"- CALL FieldGather FOR TARGET LATITUDE TILE: ", tile
964 call esmf_fieldgather(latitude_target_grid, latitude_one_tile, rootpet=0, tile=tile, rc=rc)
965 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
968 if (localpet == 0)
then
969 allocate(water_target_one_tile(i_target,j_target))
970 water_target_one_tile = 0
971 where(mask_target_one_tile == 0) water_target_one_tile = 1
974 call
search_many(num_fields,bundle_water_target,data_one_tile, water_target_one_tile,&
975 tile,search_nums,localpet,latitude=latitude_one_tile)
977 if (localpet == 0)
deallocate(water_target_one_tile)
981 deallocate(latitude_one_tile,search_nums)
983 call esmf_fieldbundledestroy(bundle_water_target,rc=rc)
984 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
987 print*,
"- CALL FieldRegridRelease."
988 call esmf_fieldregridrelease(routehandle=regrid_water, rc=rc)
989 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
997 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1
1000 where (landmask_target_ptr == 1) mask_target_ptr = 1
1002 method=esmf_regridmethod_conserve
1003 isrctermprocessing = 1
1005 print*,
"- CALL FieldRegridStore for land fields."
1006 call esmf_fieldregridstore(snow_depth_input_grid, &
1007 snow_depth_target_grid, &
1008 srcmaskvalues=(/0/), &
1009 dstmaskvalues=(/0/), &
1010 polemethod=esmf_polemethod_none, &
1011 srctermprocessing=isrctermprocessing, &
1012 unmappedaction=esmf_unmappedaction_ignore, &
1013 normtype=esmf_normtype_fracarea, &
1014 routehandle=regrid_all_land, &
1015 regridmethod=method, &
1016 unmappeddstlist=unmapped_ptr, rc=rc)
1017 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1020 bundle_allland_target = esmf_fieldbundlecreate(name=
"all land target", rc=rc)
1021 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1023 bundle_allland_input = esmf_fieldbundlecreate(name=
"all land input", rc=rc)
1024 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1026 call esmf_fieldbundleadd(bundle_allland_target, (/canopy_mc_target_grid, snow_depth_target_grid, &
1027 snow_liq_equiv_target_grid/), rc=rc)
1028 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1030 call esmf_fieldbundleadd(bundle_allland_input, (/canopy_mc_input_grid, snow_depth_input_grid, &
1031 snow_liq_equiv_input_grid/), rc=rc)
1032 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1034 call esmf_fieldbundleget(bundle_allland_target,fieldcount=num_fields,rc=rc)
1035 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1038 allocate(search_nums(num_fields))
1039 allocate(dozero(num_fields))
1041 search_nums = (/223,66,65/)
1042 dozero=(/.true.,.false.,.false./)
1044 call
regrid_many(bundle_allland_input,bundle_allland_target,num_fields,regrid_all_land,dozero, &
1045 unmapped_ptr=unmapped_ptr)
1047 call esmf_fieldbundledestroy(bundle_allland_input,rc=rc)
1048 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1052 do tile = 1, num_tiles_target_grid
1054 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
1055 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
1056 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1059 if (localpet == 0)
then
1060 allocate(land_target_one_tile(i_target,j_target))
1061 land_target_one_tile = 0
1062 where(mask_target_one_tile == 1) land_target_one_tile = 1
1065 call
search_many(num_fields,bundle_allland_target,data_one_tile, land_target_one_tile,&
1066 tile,search_nums,localpet)
1068 if (localpet == 0)
deallocate(land_target_one_tile)
1071 deallocate(search_nums)
1072 call esmf_fieldbundledestroy(bundle_allland_target,rc=rc)
1073 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1076 print*,
"- CALL FieldRegridRelease."
1077 call esmf_fieldregridrelease(routehandle=regrid_all_land, rc=rc)
1078 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1085 print*,
"- CALL FieldGet FOR INPUT GRID VEG TYPE."
1086 call esmf_fieldget(veg_type_input_grid, &
1087 farrayptr=veg_type_input_ptr, rc=rc)
1088 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1091 print*,
'land ice check ',veg_type_landice_input
1094 where (nint(veg_type_input_ptr) == veg_type_landice_input) mask_input_ptr = 1
1096 print*,
"- CALL FieldGet FOR TARGET GRID VEG TYPE."
1097 call esmf_fieldget(veg_type_target_grid, &
1098 farrayptr=veg_type_target_ptr, rc=rc)
1099 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1103 where (nint(veg_type_target_ptr) == veg_type_landice_target) mask_target_ptr = 1
1105 method=esmf_regridmethod_nearest_stod
1106 isrctermprocessing = 1
1108 print*,
"- CALL FieldRegridStore for landice fields."
1109 call esmf_fieldregridstore(soil_temp_input_grid, &
1110 soil_temp_target_grid, &
1111 srcmaskvalues=(/0/), &
1112 dstmaskvalues=(/0/), &
1113 polemethod=esmf_polemethod_none, &
1114 srctermprocessing=isrctermprocessing, &
1115 unmappedaction=esmf_unmappedaction_ignore, &
1116 normtype=esmf_normtype_fracarea, &
1117 routehandle=regrid_landice, &
1118 regridmethod=method, &
1119 unmappeddstlist=unmapped_ptr, rc=rc)
1120 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1123 bundle_landice_target = esmf_fieldbundlecreate(name=
"landice target", rc=rc)
1124 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1126 bundle_landice_input = esmf_fieldbundlecreate(name=
"landice input", rc=rc)
1127 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1129 call esmf_fieldbundleadd(bundle_landice_target, (/skin_temp_target_grid, terrain_from_input_grid,&
1130 soil_temp_target_grid/), rc=rc)
1131 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1133 call esmf_fieldbundleadd(bundle_landice_input, (/skin_temp_input_grid, terrain_input_grid,&
1134 soil_temp_input_grid/), rc=rc)
1135 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1138 if (.not. sotyp_from_climo)
then
1139 call esmf_fieldbundleadd(bundle_landice_input, (/soil_type_input_grid/),rc=rc)
1140 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1142 call esmf_fieldbundleadd(bundle_landice_target,(/soil_type_target_grid/),rc=rc)
1143 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1147 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1149 call esmf_fieldbundleget(bundle_landice_target,fieldcount=num_fields,rc=rc)
1150 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1153 allocate(search_nums(num_fields))
1154 allocate(dozero(num_fields))
1156 if (sotyp_from_climo)
then
1157 search_nums = (/21,7,21/)
1160 search_nums = (/21,7,21,231/)
1161 dozero(:)=(/.false.,.false.,.false.,.true./)
1164 call
regrid_many(bundle_landice_input,bundle_landice_target,num_fields,regrid_landice,dozero, &
1165 unmapped_ptr=unmapped_ptr )
1167 call esmf_fieldbundledestroy(bundle_landice_input,rc=rc)
1168 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1171 if (localpet == 0)
then
1172 allocate (veg_type_target_one_tile(i_target,j_target))
1173 allocate (land_target_one_tile(i_target,j_target))
1174 allocate (data_one_tile2(i_target,j_target))
1176 allocate (veg_type_target_one_tile(0,0))
1177 allocate (land_target_one_tile(0,0))
1178 allocate (data_one_tile2(0,0))
1181 do tile = 1, num_tiles_target_grid
1182 print*,
"- CALL FieldGather FOR TARGET VEG TYPE TILE: ", tile
1183 call esmf_fieldgather(veg_type_target_grid, veg_type_target_one_tile, rootpet=0, tile=tile, rc=rc)
1184 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1187 if (localpet == 0)
then
1188 land_target_one_tile = 0
1189 where(nint(veg_type_target_one_tile) == veg_type_landice_target) land_target_one_tile = 1
1192 print*,
"- CALL FieldGather FOR TERRAIN FROM INPUT GRID LAND, TILE: ", tile
1193 call esmf_fieldgather(terrain_from_input_grid_land, data_one_tile2, rootpet=0, tile=tile, rc=rc)
1194 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1197 call
search_many(num_fields,bundle_landice_target,data_one_tile, land_target_one_tile,&
1198 tile,search_nums,localpet,terrain_land=data_one_tile2,field_data_3d=data_one_tile_3d)
1201 deallocate (veg_type_target_one_tile)
1202 deallocate (land_target_one_tile)
1203 deallocate(search_nums)
1205 call esmf_fieldbundledestroy(bundle_landice_target,rc=rc)
1206 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1209 print*,
"- CALL FieldRegridRelease."
1210 call esmf_fieldregridrelease(routehandle=regrid_landice, rc=rc)
1211 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1219 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1
1220 where (nint(veg_type_input_ptr) == veg_type_landice_input) mask_input_ptr = 0
1223 where (landmask_target_ptr == 1) mask_target_ptr = 1
1224 where (nint(veg_type_target_ptr) == veg_type_landice_target) mask_target_ptr = 0
1226 method=esmf_regridmethod_nearest_stod
1227 isrctermprocessing = 1
1229 print*,
"- CALL FieldRegridStore for 3d land (but no land ice) fields."
1230 call esmf_fieldregridstore(soilm_tot_input_grid, &
1231 soilm_tot_target_grid, &
1232 srcmaskvalues=(/0/), &
1233 dstmaskvalues=(/0/), &
1234 polemethod=esmf_polemethod_none, &
1235 srctermprocessing=isrctermprocessing, &
1236 unmappedaction=esmf_unmappedaction_ignore, &
1237 normtype=esmf_normtype_fracarea, &
1238 routehandle=regrid_land, &
1239 regridmethod=method, &
1240 unmappeddstlist=unmapped_ptr, rc=rc)
1241 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1244 bundle_nolandice_target = esmf_fieldbundlecreate(name=
"land no landice target", rc=rc)
1245 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1248 bundle_nolandice_input = esmf_fieldbundlecreate(name=
"land no landice input", rc=rc)
1249 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1252 call esmf_fieldbundleadd(bundle_nolandice_target, (/skin_temp_target_grid, terrain_from_input_grid,&
1253 soil_type_from_input_grid,soilm_tot_target_grid,soil_temp_target_grid/), rc=rc)
1254 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1257 call esmf_fieldbundleadd(bundle_nolandice_input, (/skin_temp_input_grid, terrain_input_grid,&
1258 soil_type_input_grid,soilm_tot_input_grid,soil_temp_input_grid/), rc=rc)
1259 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1263 if (.not. sotyp_from_climo)
then
1270 print*,
"- CALL Field_Regrid ."
1271 call esmf_fieldregrid(soil_type_input_grid, &
1272 soil_type_target_grid, &
1273 routehandle=regrid_land, &
1274 zeroregion=esmf_region_select, &
1275 termorderflag=esmf_termorder_srcseq, rc=rc)
1276 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1279 call esmf_fieldget(soil_type_target_grid, &
1280 farrayptr=soil_type_target_ptr, rc=rc)
1281 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1284 l = lbound(unmapped_ptr)
1285 u = ubound(unmapped_ptr)
1288 call
ij_to_i_j(unmapped_ptr(ij), i_target, j_target, i, j)
1289 soil_type_target_ptr(i,j) = -9999.9
1297 if (.not. vgfrc_from_climo)
then
1298 call esmf_fieldbundleadd(bundle_nolandice_target, (/veg_greenness_target_grid/), rc=rc)
1299 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1301 call esmf_fieldbundleadd(bundle_nolandice_input, (/veg_greenness_input_grid/), rc=rc)
1302 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1304 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1305 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1307 vgfrc_ind = num_fields
1310 if (.not. lai_from_climo)
then
1311 call esmf_fieldbundleadd(bundle_nolandice_target, (/lai_target_grid/), rc=rc)
1312 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1314 call esmf_fieldbundleadd(bundle_nolandice_input, (/lai_input_grid/), rc=rc)
1315 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1317 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1318 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1320 lai_ind = num_fields
1323 if (.not. minmax_vgfrc_from_climo)
then
1324 call esmf_fieldbundleadd(bundle_nolandice_target, (/max_veg_greenness_target_grid/), rc=rc)
1325 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1327 call esmf_fieldbundleadd(bundle_nolandice_input, (/max_veg_greenness_input_grid/), rc=rc)
1328 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1331 call esmf_fieldbundleadd(bundle_nolandice_target, (/min_veg_greenness_target_grid/), rc=rc)
1332 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1334 call esmf_fieldbundleadd(bundle_nolandice_input, (/min_veg_greenness_input_grid/), rc=rc)
1335 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1338 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1339 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1342 mmvg_ind = num_fields-1
1345 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1346 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1349 allocate(search_nums(num_fields))
1350 allocate(dozero(num_fields))
1352 search_nums(1:5) = (/85,7,224,85,86/)
1353 dozero(1:5) = (/.false.,.false.,.true.,.true.,.false./)
1360 if (.not. vgfrc_from_climo)
then
1361 search_nums(vgfrc_ind) = 224
1362 dozero(vgfrc_ind) = .true.
1365 if (.not. lai_from_climo)
then
1366 search_nums(lai_ind) = 229
1367 dozero(lai_ind) = .true.
1370 if (.not. minmax_vgfrc_from_climo)
then
1371 search_nums(mmvg_ind) = 227
1372 dozero(mmvg_ind) = .true.
1374 search_nums(mmvg_ind+1) = 228
1375 dozero(mmvg_ind+1) = .true.
1378 call
regrid_many(bundle_nolandice_input,bundle_nolandice_target,num_fields,regrid_land,dozero, &
1379 unmapped_ptr=unmapped_ptr)
1381 call esmf_fieldbundledestroy(bundle_nolandice_input,rc=rc)
1382 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1385 if (localpet == 0)
then
1386 allocate (veg_type_target_one_tile(i_target,j_target))
1388 allocate (veg_type_target_one_tile(0,0))
1391 do tile = 1, num_tiles_target_grid
1393 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
1394 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
1395 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1398 print*,
"- CALL FieldGather FOR TARGET VEG TYPE TILE: ", tile
1399 call esmf_fieldgather(veg_type_target_grid, veg_type_target_one_tile, rootpet=0, tile=tile, rc=rc)
1400 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1403 if (localpet == 0)
then
1404 where(nint(veg_type_target_one_tile) == veg_type_landice_target) mask_target_one_tile = 0
1407 print*,
"- CALL FieldGather FOR SOIL TYPE TARGET GRID, TILE: ", tile
1408 call esmf_fieldgather(soil_type_target_grid, data_one_tile2, rootpet=0,tile=tile, rc=rc)
1409 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1412 call
search_many(num_fields,bundle_nolandice_target,data_one_tile, mask_target_one_tile,&
1413 tile,search_nums,localpet,soilt_climo=data_one_tile2, field_data_3d=data_one_tile_3d)
1415 print*,
"- CALL FieldGather FOR TARGET GRID TOTAL SOIL MOISTURE, TILE: ", tile
1416 call esmf_fieldgather(soilm_tot_target_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1417 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1420 if (localpet == 0)
then
1421 do j = 1, lsoil_target
1422 data_one_tile = data_one_tile_3d(:,:,j)
1423 call
search(data_one_tile, mask_target_one_tile, i_target, j_target, tile, 86)
1424 data_one_tile_3d(:,:,j) = data_one_tile
1428 print*,
"- CALL FieldGather FOR TARGET GRID SOIL TEMPERATURE, TILE: ", tile
1429 call esmf_fieldgather(soil_temp_target_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1430 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1433 if (tg3_from_soil)
then
1434 print*,
"- CALL FieldScatter FOR TARGET GRID SUBSTRATE TEMPERATURE, TILE: ", tile
1435 call esmf_fieldscatter(substrate_temp_target_grid, data_one_tile_3d(:,:,lsoil_target), rootpet=0, tile=tile, rc=rc)
1436 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1440 if (.not. sotyp_from_climo)
then
1441 print*,
"- CALL FieldGather FOR SOIL TYPE TARGET GRID LAND, TILE: ",tile
1442 call esmf_fieldgather(soil_type_target_grid, data_one_tile,rootpet=0,tile=tile, rc=rc)
1443 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1446 if (localpet == 0)
then
1447 call
search(data_one_tile, mask_target_one_tile, i_target, j_target,tile,226)
1450 print*,
"- CALL FieldScatter FOR SOIL TYPE TARGET GRID, TILE: ", tile
1451 call esmf_fieldscatter(soil_type_target_grid,data_one_tile,rootpet=0,tile=tile,rc=rc)
1452 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1458 deallocate(search_nums)
1459 call esmf_fieldbundledestroy(bundle_nolandice_target,rc=rc)
1460 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1463 print*,
"- CALL FieldRegridRelease."
1464 call esmf_fieldregridrelease(routehandle=regrid_land, rc=rc)
1465 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1468 deallocate(veg_type_target_one_tile)
1470 deallocate(data_one_tile, data_one_tile2)
1471 deallocate(data_one_tile_3d)
1472 deallocate(mask_target_one_tile)
1492 veg_type_target_grid
1496 integer :: clb(3), cub(3), rc
1497 integer :: i, j, n, soil_type
1499 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
1502 real(esmf_kind_r8),
pointer :: soilm_liq_ptr(:,:,:)
1503 real(esmf_kind_r8),
pointer :: soilm_tot_ptr(:,:,:)
1504 real(esmf_kind_r8),
pointer :: soil_temp_ptr(:,:,:)
1505 real(esmf_kind_r8),
pointer :: soil_type_ptr(:,:)
1506 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
1508 print*,
"- COMPUTE LIQUID PORTION OF TOTAL SOIL MOISTURE."
1510 print*,
"- CALL FieldGet FOR TOTAL SOIL MOISTURE."
1511 call esmf_fieldget(soilm_tot_target_grid, &
1512 computationallbound=clb, &
1513 computationalubound=cub, &
1514 farrayptr=soilm_tot_ptr, rc=rc)
1515 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1518 print*,
"- CALL FieldGet FOR LIQUID SOIL MOISTURE."
1519 call esmf_fieldget(soilm_liq_target_grid, &
1520 farrayptr=soilm_liq_ptr, rc=rc)
1521 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1524 print*,
"- CALL FieldGet FOR SOIL TEMPERATURE."
1525 call esmf_fieldget(soil_temp_target_grid, &
1526 farrayptr=soil_temp_ptr, rc=rc)
1527 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1530 print*,
"- CALL FieldGet FOR VEGETATION TYPE."
1531 call esmf_fieldget(veg_type_target_grid, &
1532 farrayptr=veg_type_ptr, rc=rc)
1533 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1536 print*,
"- CALL FieldGet FOR SOIL TYPE."
1537 call esmf_fieldget(soil_type_target_grid, &
1538 farrayptr=soil_type_ptr, rc=rc)
1539 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1542 print*,
"- CALL FieldGet FOR LANDMASK."
1543 call esmf_fieldget(landmask_target_grid, &
1544 farrayptr=landmask_ptr, rc=rc)
1545 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1548 do j = clb(2), cub(2)
1549 do i = clb(1), cub(1)
1555 if (landmask_ptr(i,j) == 1 .and. nint(veg_type_ptr(i,j)) /= veg_type_landice_target)
then
1557 soil_type = nint(soil_type_ptr(i,j))
1559 do n = clb(3), cub(3)
1561 if (soil_temp_ptr(i,j,n) < (frz_h2o-0.0001))
then
1563 bx = bb_target(soil_type)
1565 if (bx .gt. blim) bx = blim
1567 fk=(((hlice/(grav*(-satpsi_target(soil_type))))* &
1568 ((soil_temp_ptr(i,j,n)-frz_h2o)/soil_temp_ptr(i,j,n)))** &
1569 (-1/bx))*maxsmc_target(soil_type)
1571 if (fk .lt. 0.02) fk = 0.02
1573 soilm_liq_ptr(i,j,n) = min( fk, soilm_tot_ptr(i,j,n) )
1581 soilm_liq_ptr(i,j,n) =
frh2o(soil_temp_ptr(i,j,n), &
1582 soilm_tot_ptr(i,j,n), soilm_liq_ptr(i,j,n), &
1583 maxsmc_target(soil_type),bb_target(soil_type), &
1584 satpsi_target(soil_type))
1588 soilm_liq_ptr(i,j,n) = soilm_tot_ptr(i,j,n)
1625 FUNCTION frh2o (TKELV,SMC,SH2O,SMCMAX,BEXP,PSIS)
1642 REAL(esmf_kind_r8) :: sh2o
1643 REAL(esmf_kind_r8) :: smc
1647 REAL(esmf_kind_r8) :: tkelv
1649 REAL,
PARAMETER :: ck = 8.0
1650 REAL,
PARAMETER :: error = 0.005
1659 IF (bexp .GT. blim) bx = blim
1668 IF (ck .NE. 0.0)
THEN
1683 IF (swl .GT. (smc-0.02)) swl = smc-0.02
1684 IF (swl .LT. 0.) swl = 0.
1690 DO WHILE ( (nlog .LT. 10) .AND. (kcount .EQ. 0) )
1693 df = log(( psis*grav/hlice ) * ( ( 1.+ck*swl )**2. ) * &
1694 ( smcmax/(smc-swl) )**bx) - log(-(tkelv-frz_h2o)/tkelv)
1695 denom = 2. * ck / ( 1.+ck*swl ) + bx / ( smc - swl )
1696 swlk = swl - df/denom
1702 IF (swlk .GT. (smc-0.02)) swlk = smc - 0.02
1703 IF (swlk .LT. 0.) swlk = 0.
1709 dswl = abs(swlk-swl)
1717 IF ( dswl .LE. error )
THEN
1743 IF (kcount .EQ. 0)
THEN
1745 fk = (((hlice/(grav*(-psis)))* &
1746 ((tkelv-frz_h2o)/tkelv))**(-1/bx))*smcmax
1748 IF (fk .LT. 0.02) fk = 0.02
1750 frh2o = min(fk, smc)
1770 maxsmc_input, maxsmc_target, &
1771 refsmc_input, refsmc_target, &
1772 wltsmc_input, wltsmc_target
1775 veg_greenness_target_grid, &
1776 veg_type_target_grid
1780 integer :: clb(3), cub(3), i, j, k, rc
1781 integer :: soilt_input, soilt_target
1782 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
1784 real(esmf_kind_r8),
pointer :: soilm_tot_ptr(:,:,:)
1785 real(esmf_kind_r8),
pointer :: soil_type_input_ptr(:,:)
1786 real(esmf_kind_r8),
pointer :: soil_type_target_ptr(:,:)
1787 real(esmf_kind_r8),
pointer :: veg_greenness_ptr(:,:)
1788 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
1789 real :: f1, fn, smcdir, smctra
1791 print*,
"- RESCALE SOIL MOISTURE FOR CHANGES IN SOIL TYPE."
1793 print*,
"- CALL FieldGet FOR TOTAL SOIL MOISTURE."
1794 call esmf_fieldget(soilm_tot_target_grid, &
1795 computationallbound=clb, &
1796 computationalubound=cub, &
1797 farrayptr=soilm_tot_ptr, rc=rc)
1798 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1801 print*,
"- CALL FieldGet FOR LAND MASK."
1802 call esmf_fieldget(landmask_target_grid, &
1803 farrayptr=landmask_ptr, rc=rc)
1804 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1807 print*,
"- CALL FieldGet FOR VEGETATION TYPE."
1808 call esmf_fieldget(veg_type_target_grid, &
1809 farrayptr=veg_type_ptr, rc=rc)
1810 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1813 print*,
"- CALL FieldGet FOR VEGETATION GREENNESS."
1814 call esmf_fieldget(veg_greenness_target_grid, &
1815 farrayptr=veg_greenness_ptr, rc=rc)
1816 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1819 print*,
"- CALL FieldGet FOR TARGET GRID SOIL TYPE."
1820 call esmf_fieldget(soil_type_target_grid, &
1821 farrayptr=soil_type_target_ptr, rc=rc)
1822 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1825 print*,
"- CALL FieldGet FOR SOIL TYPE FROM INPUT GRID."
1826 call esmf_fieldget(soil_type_from_input_grid, &
1827 farrayptr=soil_type_input_ptr, rc=rc)
1828 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1831 do j = clb(2), cub(2)
1832 do i = clb(1), cub(1)
1838 if (landmask_ptr(i,j) == 1 .and. nint(veg_type_ptr(i,j)) /= veg_type_landice_target)
then
1840 soilt_target = nint(soil_type_target_ptr(i,j))
1841 soilt_input = nint(soil_type_input_ptr(i,j))
1849 if (soilt_target /= soilt_input)
then
1854 f1=(soilm_tot_ptr(i,j,1)-drysmc_input(soilt_input)) / &
1855 (maxsmc_input(soilt_input)-drysmc_input(soilt_input))
1857 smcdir=drysmc_target(soilt_target) + f1 * &
1858 (maxsmc_target(soilt_target) - drysmc_target(soilt_target))
1864 if (soilm_tot_ptr(i,j,1) < refsmc_input(soilt_input))
then
1865 f1=(soilm_tot_ptr(i,j,1) - wltsmc_input(soilt_input)) / &
1866 (refsmc_input(soilt_input) - wltsmc_input(soilt_input))
1867 smctra=wltsmc_target(soilt_target) + f1 * &
1868 (refsmc_target(soilt_target) - wltsmc_target(soilt_target))
1870 f1=(soilm_tot_ptr(i,j,1) - refsmc_input(soilt_input)) / &
1871 (maxsmc_input(soilt_input) - refsmc_input(soilt_input))
1872 smctra=refsmc_target(soilt_target) + f1 * &
1873 (maxsmc_target(soilt_target) - refsmc_target(soilt_target))
1880 soilm_tot_ptr(i,j,1) = ((1.0 - veg_greenness_ptr(i,j)) * smcdir) + &
1881 (veg_greenness_ptr(i,j) * smctra)
1891 if (soilm_tot_ptr(i,j,k) < refsmc_input(soilt_input))
then
1892 fn = (soilm_tot_ptr(i,j,k) - wltsmc_input(soilt_input)) / &
1893 (refsmc_input(soilt_input) - wltsmc_input(soilt_input))
1894 soilm_tot_ptr(i,j,k) = wltsmc_target(soilt_target) + fn * &
1895 (refsmc_target(soilt_target) - wltsmc_target(soilt_target))
1897 fn = (soilm_tot_ptr(i,j,k) - refsmc_input(soilt_input)) / &
1898 (maxsmc_input(soilt_input) - refsmc_input(soilt_input))
1899 soilm_tot_ptr(i,j,k) = refsmc_target(soilt_target) + fn * &
1900 (maxsmc_target(soilt_target) - refsmc_target(soilt_target))
1910 soilm_tot_ptr(i,j,1)=min(soilm_tot_ptr(i,j,1),maxsmc_target(soilt_target))
1911 soilm_tot_ptr(i,j,1)=max(drysmc_target(soilt_target),soilm_tot_ptr(i,j,1))
1914 soilm_tot_ptr(i,j,k)=min(soilm_tot_ptr(i,j,k),maxsmc_target(soilt_target))
1915 soilm_tot_ptr(i,j,k)=max(wltsmc_target(soilt_target),soilm_tot_ptr(i,j,k))
1933 use model_grid, only : landmask_target_grid, &
1940 integer :: clb(3), cub(3), i, j, k, rc
1941 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
1943 real,
parameter :: lapse_rate = 6.5e-03
1944 real :: terrain_diff
1945 real(esmf_kind_r8),
pointer :: terrain_input_ptr(:,:)
1946 real(esmf_kind_r8),
pointer :: terrain_target_ptr(:,:)
1947 real(esmf_kind_r8),
pointer :: veg_type_target_ptr(:,:)
1948 real(esmf_kind_r8),
pointer :: soil_temp_target_ptr(:,:,:)
1950 print*,
"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK."
1951 call esmf_fieldget(landmask_target_grid, &
1952 farrayptr=landmask_ptr, rc=rc)
1953 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1956 print*,
"- CALL FieldGet FOR TARGET GRID VEGETATION TYPE."
1957 call esmf_fieldget(veg_type_target_grid, &
1958 farrayptr=veg_type_target_ptr, rc=rc)
1959 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1962 print*,
"- CALL FieldGet FOR TARGET GRID TERRAIN."
1963 call esmf_fieldget(terrain_target_grid, &
1964 farrayptr=terrain_target_ptr, rc=rc)
1965 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1968 print*,
"- CALL FieldGet FOR TERRAIN INTERP TO TARGET GRID."
1969 call esmf_fieldget(terrain_from_input_grid, &
1970 farrayptr=terrain_input_ptr, rc=rc)
1971 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1974 print*,
"- CALL FieldGet FOR SOIL TEMP TARGET GRID."
1975 call esmf_fieldget(soil_temp_target_grid, &
1976 computationallbound=clb, &
1977 computationalubound=cub, &
1978 farrayptr=soil_temp_target_ptr, rc=rc)
1979 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1982 do j = clb(2), cub(2)
1983 do i = clb(1), cub(1)
1984 if (landmask_ptr(i,j) == 1)
then
1985 terrain_diff = abs(terrain_input_ptr(i,j) - terrain_target_ptr(i,j))
1986 if (terrain_diff > 100.0)
then
1987 do k = clb(3), cub(3)
1988 soil_temp_target_ptr(i,j,k) = soil_temp_target_ptr(i,j,k) + &
1989 ((terrain_input_ptr(i,j) - terrain_target_ptr(i,j)) * lapse_rate)
1990 if (nint(veg_type_target_ptr(i,j)) == veg_type_landice_target)
then
1991 soil_temp_target_ptr(i,j,k) = min(soil_temp_target_ptr(i,j,k), 273.16)
2008 use model_grid, only : lsoil_target, i_input, j_input, input_grid
2009 use input_data, only : lsoil_input, soil_temp_input_grid, &
2010 soilm_liq_input_grid, soilm_tot_input_grid
2012 integer,
intent(in) :: localpet
2013 character(len=1000) :: msg
2015 real(esmf_kind_r8) :: tmp(i_input,j_input), &
2016 data_one_tile(i_input,j_input,lsoil_input), &
2017 tmp3d(i_input,j_input,lsoil_target)
2018 if (lsoil_input == 9 .and. lsoil_target == 4)
then
2019 print*,
"CONVERTING FROM 9 INPUT SOIL LEVELS TO 4 TARGET SOIL LEVELS"
2020 call esmf_fieldgather(soil_temp_input_grid, data_one_tile, rootpet=0, tile=1, rc=rc)
2021 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2024 call esmf_fielddestroy(soil_temp_input_grid,rc=rc)
2025 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
2026 typekind=esmf_typekind_r8, &
2027 staggerloc=esmf_staggerloc_center, &
2028 ungriddedlbound=(/1/), &
2029 ungriddedubound=(/lsoil_target/), rc=rc)
2032 tmp3d(:,:,1)= (data_one_tile(:,:,1) + data_one_tile(:,:,2))/2.0 * 0.1 + &
2033 (data_one_tile(:,:,2) + data_one_tile(:,:,3))/2.0 * 0.3 + &
2034 (data_one_tile(:,:,3) + data_one_tile(:,:,4))/2.0 * 0.6
2035 tmp = (data_one_tile(:,:,6) - data_one_tile(:,:,5)) / 30.0 * 10.0 + data_one_tile(:,:,5)
2036 tmp3d(:,:,2)= (data_one_tile(:,:,4) + data_one_tile(:,:,5)) / 2.0 * 0.75 + &
2037 (data_one_tile(:,:,5) + tmp) / 2.0 * 0.25
2038 tmp3d(:,:,3)= (tmp + data_one_tile(:,:,6)) /2.0 * (1.0/3.0) + &
2039 (data_one_tile(:,:,6) + data_one_tile(:,:,7)) / 2.0 * (2.0/3.0)
2040 tmp = (data_one_tile(:,:,9) - data_one_tile(:,:,9)) / 140.0 * 40.0 + data_one_tile(:,:,8)
2041 tmp3d(:,:,4)= (data_one_tile(:,:,7) + data_one_tile(:,:,8)) / 2.0 * 0.6 + &
2042 (data_one_tile(:,:,8) + tmp) / 2.0 * 0.4
2045 call esmf_fieldscatter(soil_temp_input_grid, tmp3d, rootpet=0, rc=rc)
2046 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2049 call esmf_fieldgather(soilm_tot_input_grid, data_one_tile, rootpet=0, tile=1, rc=rc)
2050 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2053 call esmf_fielddestroy(soilm_tot_input_grid,rc=rc)
2054 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
2055 typekind=esmf_typekind_r8, &
2056 staggerloc=esmf_staggerloc_center, &
2057 ungriddedlbound=(/1/), &
2058 ungriddedubound=(/lsoil_target/), rc=rc)
2060 if(localpet==0)
then
2061 tmp3d(:,:,1)= (data_one_tile(:,:,1) + data_one_tile(:,:,2))/2.0 * 0.1 + &
2062 (data_one_tile(:,:,2) + data_one_tile(:,:,3))/2.0 * 0.3 + &
2063 (data_one_tile(:,:,3) + data_one_tile(:,:,4))/2.0 * 0.6
2064 tmp = (data_one_tile(:,:,6) - data_one_tile(:,:,5)) / 30.0 * 10.0 + data_one_tile(:,:,5)
2065 tmp3d(:,:,2)= (data_one_tile(:,:,4) + data_one_tile(:,:,5)) / 2.0 * 0.75 + &
2066 (data_one_tile(:,:,5) + tmp) / 2.0 * 0.25
2067 tmp3d(:,:,3)= (tmp + data_one_tile(:,:,6)) /2.0 * (1.0/3.0) + &
2068 (data_one_tile(:,:,6) + data_one_tile(:,:,7)) / 2.0 * (2.0/3.0)
2069 tmp = (data_one_tile(:,:,9) - data_one_tile(:,:,9)) / 140.0 * 40.0 + data_one_tile(:,:,8)
2070 tmp3d(:,:,4)= (data_one_tile(:,:,7) + data_one_tile(:,:,8)) / 2.0 * 0.6 + &
2071 (data_one_tile(:,:,8) + tmp) / 2.0 * 0.4
2074 call esmf_fieldscatter(soilm_tot_input_grid, tmp3d, rootpet=0, rc=rc)
2075 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2078 call esmf_fieldgather(soilm_liq_input_grid, data_one_tile, rootpet=0, tile=1, rc=rc)
2079 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2082 call esmf_fielddestroy(soilm_liq_input_grid,rc=rc)
2083 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
2084 typekind=esmf_typekind_r8, &
2085 staggerloc=esmf_staggerloc_center, &
2086 ungriddedlbound=(/1/), &
2087 ungriddedubound=(/lsoil_target/), rc=rc)
2088 if(localpet==0)
then
2089 tmp3d(:,:,1)= (data_one_tile(:,:,1) + data_one_tile(:,:,2))/2.0 * 0.1 + &
2090 (data_one_tile(:,:,2) + data_one_tile(:,:,3))/2.0 * 0.3 + &
2091 (data_one_tile(:,:,3) + data_one_tile(:,:,4))/2.0 * 0.6
2092 tmp = (data_one_tile(:,:,6) - data_one_tile(:,:,5)) / 30.0 * 10.0 + data_one_tile(:,:,5)
2093 tmp3d(:,:,2)= (data_one_tile(:,:,4) + data_one_tile(:,:,5)) / 2.0 * 0.75 + &
2094 (data_one_tile(:,:,5) + tmp) / 2.0 * 0.25
2095 tmp3d(:,:,3)= (tmp + data_one_tile(:,:,6)) /2.0 * (1.0/3.0) + &
2096 (data_one_tile(:,:,6) + data_one_tile(:,:,7)) / 2.0 * (2.0/3.0)
2097 tmp = (data_one_tile(:,:,9) - data_one_tile(:,:,9)) / 140.0 * 40.0 + data_one_tile(:,:,8)
2098 tmp3d(:,:,4)= (data_one_tile(:,:,7) + data_one_tile(:,:,8)) / 2.0 * 0.6 + &
2099 (data_one_tile(:,:,8) + tmp) / 2.0 * 0.4
2102 call esmf_fieldscatter(soilm_liq_input_grid, tmp3d, rootpet=0, rc=rc)
2103 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2106 elseif (lsoil_input /= lsoil_target)
then
2109 write(msg,
'("NUMBER OF SOIL LEVELS IN INPUT (",I2,") and OUPUT &
2110 (",I2,") MUST EITHER BE EQUAL OR 9 AND 4, RESPECTIVELY")') &
2111 lsoil_input, lsoil_target
2130 integer :: clb(2), cub(2), i, j, rc
2131 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
2134 real(esmf_kind_r8),
pointer :: data_ptr(:,:)
2135 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
2137 data z0_igbp /1.089, 2.653, 0.854, 0.826, 0.800, 0.050, &
2138 0.030, 0.856, 0.856, 0.150, 0.040, 0.130, &
2139 1.000, 0.250, 0.011, 0.011, 0.001, 0.076, &
2142 print*,
"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK."
2143 call esmf_fieldget(landmask_target_grid, &
2144 computationallbound=clb, &
2145 computationalubound=cub, &
2146 farrayptr=landmask_ptr, rc=rc)
2147 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2150 print*,
"- CALL FieldGet FOR TARGET GRID VEGETATION TYPE."
2151 call esmf_fieldget(veg_type_target_grid, &
2152 farrayptr=veg_type_ptr, rc=rc)
2153 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2156 print*,
"- CALL FieldGet FOR TARGET GRID Z0."
2157 call esmf_fieldget(z0_target_grid, &
2158 farrayptr=data_ptr, rc=rc)
2159 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2162 do j = clb(2), cub(2)
2163 do i = clb(1), cub(1)
2164 if (landmask_ptr(i,j) == 2)
then
2166 elseif (landmask_ptr(i,j) == 1)
then
2167 data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0
2182 alvwf_target_grid, &
2183 alnsf_target_grid, &
2184 alnwf_target_grid, &
2185 facsf_target_grid, &
2186 facwf_target_grid, &
2187 mxsno_albedo_target_grid, &
2188 max_veg_greenness_target_grid, &
2189 min_veg_greenness_target_grid, &
2190 slope_type_target_grid, &
2191 soil_type_target_grid, &
2192 substrate_temp_target_grid, &
2193 veg_greenness_target_grid, &
2194 veg_type_target_grid
2198 integer :: clb(2), cub(2), i, j, rc
2199 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
2201 real(esmf_kind_r8),
pointer :: data_ptr(:,:)
2202 real(esmf_kind_r8),
pointer :: data3d_ptr(:,:,:)
2203 real(esmf_kind_r8),
pointer :: soilmt_ptr(:,:,:)
2204 real(esmf_kind_r8),
pointer :: soilml_ptr(:,:,:)
2205 real(esmf_kind_r8),
pointer :: veg_greenness_ptr(:,:)
2206 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
2207 real(esmf_kind_r8),
pointer :: seaice_skint_ptr(:,:)
2208 real(esmf_kind_r8),
pointer :: skint_ptr(:,:)
2209 real(esmf_kind_r8),
pointer :: fice_ptr(:,:)
2210 real(esmf_kind_r8),
pointer :: hice_ptr(:,:)
2212 print*,
"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK."
2213 call esmf_fieldget(landmask_target_grid, &
2214 computationallbound=clb, &
2215 computationalubound=cub, &
2216 farrayptr=landmask_ptr, rc=rc)
2217 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2220 print*,
"- SET NON-LAND FLAG FOR TARGET GRID SLOPE TYPE."
2221 call esmf_fieldget(slope_type_target_grid, &
2222 farrayptr=data_ptr, rc=rc)
2223 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2226 do j = clb(2), cub(2)
2227 do i = clb(1), cub(1)
2228 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2232 print*,
"- SET NON-LAND FLAG FOR TARGET GRID SOIL TYPE."
2233 call esmf_fieldget(soil_type_target_grid, &
2234 farrayptr=data_ptr, rc=rc)
2235 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2238 do j = clb(2), cub(2)
2239 do i = clb(1), cub(1)
2240 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2244 print*,
"- SET NON-LAND FLAG FOR TARGET GRID VEGETATION TYPE."
2245 call esmf_fieldget(veg_type_target_grid, &
2246 farrayptr=veg_type_ptr, rc=rc)
2247 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2250 do j = clb(2), cub(2)
2251 do i = clb(1), cub(1)
2252 if (landmask_ptr(i,j) /= 1) veg_type_ptr(i,j) = 0.0
2256 print*,
"- SET TARGET GRID ALVSF AT NON-LAND."
2257 call esmf_fieldget(alvsf_target_grid, &
2258 farrayptr=data_ptr, rc=rc)
2259 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2262 do j = clb(2), cub(2)
2263 do i = clb(1), cub(1)
2264 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06
2268 print*,
"- SET TARGET GRID ALVWF AT NON-LAND."
2269 call esmf_fieldget(alvwf_target_grid, &
2270 farrayptr=data_ptr, rc=rc)
2271 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2274 do j = clb(2), cub(2)
2275 do i = clb(1), cub(1)
2276 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06
2280 print*,
"- SET TARGET GRID ALNSF AT NON-LAND."
2281 call esmf_fieldget(alnsf_target_grid, &
2282 farrayptr=data_ptr, rc=rc)
2283 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2286 do j = clb(2), cub(2)
2287 do i = clb(1), cub(1)
2288 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06
2292 print*,
"- SET TARGET GRID ALNWF AT NON-LAND."
2293 call esmf_fieldget(alnwf_target_grid, &
2294 farrayptr=data_ptr, rc=rc)
2295 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2298 do j = clb(2), cub(2)
2299 do i = clb(1), cub(1)
2300 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06
2304 print*,
"- SET NON-LAND FLAG FOR TARGET GRID FACSF."
2305 call esmf_fieldget(facsf_target_grid, &
2306 farrayptr=data_ptr, rc=rc)
2307 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2310 do j = clb(2), cub(2)
2311 do i = clb(1), cub(1)
2312 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2316 print*,
"- SET NON-LAND FLAG FOR TARGET GRID FACSF."
2317 call esmf_fieldget(facwf_target_grid, &
2318 farrayptr=data_ptr, rc=rc)
2319 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2322 do j = clb(2), cub(2)
2323 do i = clb(1), cub(1)
2324 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2328 print*,
"- SET NON-LAND FLAG FOR TARGET GRID MAXIMUM GREENNESS."
2329 call esmf_fieldget(max_veg_greenness_target_grid, &
2330 farrayptr=data_ptr, rc=rc)
2331 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2334 do j = clb(2), cub(2)
2335 do i = clb(1), cub(1)
2336 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2340 print*,
"- SET NON-LAND FLAG FOR TARGET GRID MINIMUM GREENNESS."
2341 call esmf_fieldget(min_veg_greenness_target_grid, &
2342 farrayptr=data_ptr, rc=rc)
2343 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2346 do j = clb(2), cub(2)
2347 do i = clb(1), cub(1)
2348 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2352 print*,
"- SET NON-LAND FLAG FOR TARGET GRID VEGETATION GREENNESS."
2353 call esmf_fieldget(veg_greenness_target_grid, &
2354 farrayptr=veg_greenness_ptr, rc=rc)
2355 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2358 do j = clb(2), cub(2)
2359 do i = clb(1), cub(1)
2360 if (landmask_ptr(i,j) /= 1) veg_greenness_ptr(i,j) = 0.0
2364 print*,
"- SET NON-LAND FLAG FOR TARGET GRID MAX SNOW ALBEDO."
2365 call esmf_fieldget(mxsno_albedo_target_grid, &
2366 farrayptr=data_ptr, rc=rc)
2367 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2370 do j = clb(2), cub(2)
2371 do i = clb(1), cub(1)
2372 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2376 print*,
"- ZERO OUT TARGET GRID CANOPY MOISTURE CONTENT WHERE NO PLANTS."
2377 call esmf_fieldget(canopy_mc_target_grid, &
2378 farrayptr=data_ptr, rc=rc)
2379 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2382 do j = clb(2), cub(2)
2383 do i = clb(1), cub(1)
2384 if (veg_greenness_ptr(i,j) <= 0.01) data_ptr(i,j) = 0.0
2388 print*,
"- CALL FieldGet FOR TARGET GRID ICE SKIN TEMP."
2389 call esmf_fieldget(seaice_skin_temp_target_grid, &
2390 farrayptr=seaice_skint_ptr, rc=rc)
2391 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2394 print*,
"- SET TARGET GRID SKIN TEMP AT ICE POINTS."
2395 call esmf_fieldget(skin_temp_target_grid, &
2396 farrayptr=skint_ptr, rc=rc)
2397 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2400 print*,
"- CALL FieldGet FOR TARGET GRID SEA ICE FRACTION."
2401 call esmf_fieldget(seaice_fract_target_grid, &
2402 farrayptr=fice_ptr, rc=rc)
2403 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2406 print*,
"- SET TARGET GRID SEA ICE DEPTH TO ZERO AT NON-ICE POINTS."
2407 call esmf_fieldget(seaice_depth_target_grid, &
2408 farrayptr=hice_ptr, rc=rc)
2409 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2412 do j = clb(2), cub(2)
2413 do i = clb(1), cub(1)
2414 if (fice_ptr(i,j) > 0.0)
then
2415 skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + &
2416 ( (1.0 - fice_ptr(i,j)) * frz_ice )
2418 seaice_skint_ptr(i,j) = skint_ptr(i,j)
2424 print*,
"- SET TARGET GRID SUBSTRATE TEMP AT ICE."
2425 call esmf_fieldget(substrate_temp_target_grid, &
2426 farrayptr=data_ptr, rc=rc)
2427 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2430 do j = clb(2), cub(2)
2431 do i = clb(1), cub(1)
2432 if (landmask_ptr(i,j) == 2)
then
2433 data_ptr(i,j) = frz_ice
2434 elseif (landmask_ptr(i,j) == 0)
then
2435 data_ptr(i,j) = skint_ptr(i,j)
2440 print*,
"- ZERO OUT TARGET GRID SNOW DEPTH AT OPEN WATER."
2441 call esmf_fieldget(snow_depth_target_grid, &
2442 farrayptr=data_ptr, rc=rc)
2443 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2446 do j = clb(2), cub(2)
2447 do i = clb(1), cub(1)
2448 if (landmask_ptr(i,j) == 0)
then
2454 print*,
"- ZERO OUT TARGET GRID SNOW LIQ AT OPEN WATER."
2455 call esmf_fieldget(snow_liq_equiv_target_grid, &
2456 farrayptr=data_ptr, rc=rc)
2457 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2460 do j = clb(2), cub(2)
2461 do i = clb(1), cub(1)
2462 if (landmask_ptr(i,j) == 0)
then
2468 print*,
"- SET NON-LAND FLAG VALUE FOR TARGET GRID TOTAL SOIL MOISTURE."
2469 call esmf_fieldget(soilm_tot_target_grid, &
2470 farrayptr=soilmt_ptr, rc=rc)
2471 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2474 print*,
"- SET NON-LAND FLAG VALUE FOR TARGET GRID LIQUID SOIL MOISTURE."
2475 call esmf_fieldget(soilm_liq_target_grid, &
2476 farrayptr=soilml_ptr, rc=rc)
2477 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2480 do j = clb(2), cub(2)
2481 do i = clb(1), cub(1)
2482 if (landmask_ptr(i,j) == 2 .or. landmask_ptr(i,j) == 0 .or. &
2483 nint(veg_type_ptr(i,j)) == veg_type_landice_target)
then
2484 soilmt_ptr(i,j,:) = 1.0
2485 soilml_ptr(i,j,:) = 1.0
2490 print*,
"- SET OPEN WATER FLAG FOR TARGET GRID SOIL TEMPERATURE."
2491 call esmf_fieldget(soil_temp_target_grid, &
2492 farrayptr=data3d_ptr, rc=rc)
2493 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2496 do j = clb(2), cub(2)
2497 do i = clb(1), cub(1)
2498 if (landmask_ptr(i,j) == 0)
then
2499 data3d_ptr(i,j,:) = skint_ptr(i,j)
2518 integer(esmf_kind_i8),
pointer :: mask_ptr(:,:)
2520 integer,
PARAMETER :: num_nst_fields_minus2 = 16
2521 integer,
PARAMETER :: xz_fill = 30.0
2522 integer,
PARAMETER :: nst_fill = 0.0
2524 real(esmf_kind_r8),
pointer :: data_ptr(:,:)
2525 real(esmf_kind_r8),
pointer :: skint_ptr(:,:)
2527 type(esmf_field
) :: temp_field
2528 type(esmf_fieldbundle
) :: nst_bundle
2530 print*,
"- CALL FieldGet FOR TARGET GRID LANDMASK."
2531 call esmf_fieldget(landmask_target_grid, &
2532 farrayptr=mask_ptr, rc=rc)
2533 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2536 nst_bundle = esmf_fieldbundlecreate(name=
"nst_bundle", rc=rc)
2537 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2540 call esmf_fieldbundleadd(nst_bundle, (/c_d_target_grid,c_0_target_grid,d_conv_target_grid, &
2541 dt_cool_target_grid,ifd_target_grid,qrain_target_grid,&
2542 w_d_target_grid,w_0_target_grid,xs_target_grid,xt_target_grid,&
2543 xu_target_grid,xv_target_grid,xtts_target_grid,xzts_target_grid, &
2544 z_c_target_grid, zm_target_grid/), rc=rc)
2545 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2548 print*,
"- CALL FieldGet FOR TREF."
2549 call esmf_fieldget(tref_target_grid, &
2550 farrayptr=data_ptr, rc=rc)
2551 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2554 print*,
"- CALL FieldGet FOR SKIN T."
2555 call esmf_fieldget(skin_temp_target_grid, &
2556 farrayptr=skint_ptr, rc=rc)
2557 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2560 where(mask_ptr /= 0) data_ptr = skint_ptr
2564 print*,
"- CALL FieldGet FOR XZ."
2565 call esmf_fieldget(xz_target_grid, &
2566 farrayptr=data_ptr, rc=rc)
2567 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2570 where(mask_ptr /= 0) data_ptr = xz_fill
2572 do i = 1,num_nst_fields_minus2
2574 call esmf_fieldbundleget(nst_bundle,i,temp_field,rc=rc)
2575 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2578 call esmf_fieldget(temp_field,farrayptr=data_ptr,rc=rc)
2579 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2582 where(mask_ptr /= 0) data_ptr = nst_fill
2586 call esmf_fieldbundledestroy(nst_bundle,rc=rc)
2587 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2597 use model_grid, only : target_grid, lsoil_target
2603 real(esmf_kind_r8),
pointer :: target_ptr(:,:), target_ptr_3d(:,:,:)
2604 real :: init_val = -999.9
2606 print*,
"- CALL FieldCreate FOR TARGET GRID T2M."
2607 t2m_target_grid = esmf_fieldcreate(target_grid, &
2608 typekind=esmf_typekind_r8, &
2609 name=
"t2m_target_grid", &
2610 staggerloc=esmf_staggerloc_center, rc=rc)
2611 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2614 print*,
"- INITIALIZE TARGET grid t2m."
2615 call esmf_fieldget(t2m_target_grid, &
2616 farrayptr=target_ptr, rc=rc)
2617 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2620 target_ptr = init_val
2622 print*,
"- CALL FieldCreate FOR TARGET GRID Q2M."
2623 q2m_target_grid = esmf_fieldcreate(target_grid, &
2624 typekind=esmf_typekind_r8, &
2625 name=
"q2m_target_grid", &
2626 staggerloc=esmf_staggerloc_center, rc=rc)
2627 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2630 print*,
"- INITIALIZE TARGET grid q2m."
2631 call esmf_fieldget(q2m_target_grid, &
2632 farrayptr=target_ptr, rc=rc)
2633 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2636 target_ptr = init_val
2638 print*,
"- CALL FieldCreate FOR TARGET GRID TPRCP."
2639 tprcp_target_grid = esmf_fieldcreate(target_grid, &
2640 typekind=esmf_typekind_r8, &
2641 name=
"tprcp_target_grid", &
2642 staggerloc=esmf_staggerloc_center, rc=rc)
2643 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2646 print*,
"- INITIALIZE TARGET grid tprcp."
2647 call esmf_fieldget(tprcp_target_grid, &
2648 farrayptr=target_ptr, rc=rc)
2649 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2652 target_ptr = init_val
2654 print*,
"- CALL FieldCreate FOR TARGET GRID F10M."
2655 f10m_target_grid = esmf_fieldcreate(target_grid, &
2656 typekind=esmf_typekind_r8, &
2657 name=
"f10m_target_grid", &
2658 staggerloc=esmf_staggerloc_center, rc=rc)
2659 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2662 print*,
"- INITIALIZE TARGET grid f10m."
2663 call esmf_fieldget(f10m_target_grid, &
2664 farrayptr=target_ptr, rc=rc)
2665 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2668 target_ptr = init_val
2670 print*,
"- CALL FieldCreate FOR TARGET GRID FFMM."
2671 ffmm_target_grid = esmf_fieldcreate(target_grid, &
2672 typekind=esmf_typekind_r8, &
2673 name=
"ffmm_target_grid", &
2674 staggerloc=esmf_staggerloc_center, rc=rc)
2675 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2678 print*,
"- INITIALIZE TARGET grid ffmm."
2679 call esmf_fieldget(ffmm_target_grid, &
2680 farrayptr=target_ptr, rc=rc)
2681 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2684 target_ptr = init_val
2686 print*,
"- CALL FieldCreate FOR TARGET GRID USTAR."
2687 ustar_target_grid = esmf_fieldcreate(target_grid, &
2688 typekind=esmf_typekind_r8, &
2689 name=
"ustar_target_grid", &
2690 staggerloc=esmf_staggerloc_center, rc=rc)
2691 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2694 print*,
"- INITIALIZE TARGET grid ustar."
2695 call esmf_fieldget(ustar_target_grid, &
2696 farrayptr=target_ptr, rc=rc)
2697 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2700 target_ptr = init_val
2702 print*,
"- CALL FieldCreate FOR TARGET GRID SNOW LIQ EQUIV."
2703 snow_liq_equiv_target_grid = esmf_fieldcreate(target_grid, &
2704 typekind=esmf_typekind_r8, &
2705 name=
"snow_liq_equiv_target_grid", &
2706 staggerloc=esmf_staggerloc_center, rc=rc)
2707 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2710 print*,
"- INITIALIZE TARGET grid snow liq equiv."
2711 call esmf_fieldget(snow_liq_equiv_target_grid, &
2712 farrayptr=target_ptr, rc=rc)
2713 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2716 target_ptr = init_val
2718 print*,
"- CALL FieldCreate FOR TARGET GRID SNOW DEPTH."
2719 snow_depth_target_grid = esmf_fieldcreate(target_grid, &
2720 typekind=esmf_typekind_r8, &
2721 name=
"snow_depth_target_grid", &
2722 staggerloc=esmf_staggerloc_center, rc=rc)
2723 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2726 print*,
"- INITIALIZE TARGET grid snow depth."
2727 call esmf_fieldget(snow_depth_target_grid, &
2728 farrayptr=target_ptr, rc=rc)
2729 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2732 target_ptr = init_val
2734 print*,
"- CALL FieldCreate FOR TARGET GRID SEA ICE FRACTION."
2735 seaice_fract_target_grid = esmf_fieldcreate(target_grid, &
2736 typekind=esmf_typekind_r8, &
2737 name=
"seaice_fract_target_grid", &
2738 staggerloc=esmf_staggerloc_center, rc=rc)
2739 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2742 print*,
"- INITIALIZE TARGET grid sea ice fraction."
2743 call esmf_fieldget(seaice_fract_target_grid, &
2744 farrayptr=target_ptr, rc=rc)
2745 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2748 target_ptr = init_val
2750 print*,
"- CALL FieldCreate FOR TARGET GRID SEA ICE DEPTH."
2751 seaice_depth_target_grid = esmf_fieldcreate(target_grid, &
2752 typekind=esmf_typekind_r8, &
2753 name=
"seaice_depth_target_grid", &
2754 staggerloc=esmf_staggerloc_center, rc=rc)
2755 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2758 print*,
"- INITIALIZE TARGET sea ice depth."
2759 call esmf_fieldget(seaice_depth_target_grid, &
2760 farrayptr=target_ptr, rc=rc)
2761 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2764 target_ptr = init_val
2766 print*,
"- CALL FieldCreate FOR TARGET GRID SEA ICE SKIN TEMP."
2767 seaice_skin_temp_target_grid = esmf_fieldcreate(target_grid, &
2768 typekind=esmf_typekind_r8, &
2769 name=
"seaice_skin_temp_target_grid", &
2770 staggerloc=esmf_staggerloc_center, rc=rc)
2771 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2774 print*,
"- INITIALIZE TARGET sea ice skin temp."
2775 call esmf_fieldget(seaice_skin_temp_target_grid, &
2776 farrayptr=target_ptr, rc=rc)
2777 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2780 target_ptr = init_val
2782 print*,
"- CALL FieldCreate FOR TARGET GRID SRFLAG."
2783 srflag_target_grid = esmf_fieldcreate(target_grid, &
2784 typekind=esmf_typekind_r8, &
2785 name=
"srflag_target_grid", &
2786 staggerloc=esmf_staggerloc_center, rc=rc)
2787 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2790 print*,
"- INITIALIZE TARGET srflag."
2791 call esmf_fieldget(srflag_target_grid, &
2792 farrayptr=target_ptr, rc=rc)
2793 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2796 target_ptr = init_val
2798 print*,
"- CALL FieldCreate FOR TARGET GRID SKIN TEMPERATURE."
2799 skin_temp_target_grid = esmf_fieldcreate(target_grid, &
2800 typekind=esmf_typekind_r8, &
2801 name=
"skin_temp_target_grid", &
2802 staggerloc=esmf_staggerloc_center, rc=rc)
2803 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2806 print*,
"- INITIALIZE TARGET grid skin temp."
2807 call esmf_fieldget(skin_temp_target_grid, &
2808 farrayptr=target_ptr, rc=rc)
2809 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2812 target_ptr = init_val
2814 print*,
"- CALL FieldCreate FOR TARGET GRID CANOPY MOISTURE CONTENT."
2815 canopy_mc_target_grid = esmf_fieldcreate(target_grid, &
2816 typekind=esmf_typekind_r8, &
2817 name=
"canopy_mc_target_grid", &
2818 staggerloc=esmf_staggerloc_center, rc=rc)
2819 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2822 print*,
"- INITIALIZE TARGET grid canopy moisture."
2823 call esmf_fieldget(canopy_mc_target_grid, &
2824 farrayptr=target_ptr, rc=rc)
2825 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2828 target_ptr = init_val
2830 print*,
"- CALL FieldCreate FOR TARGET GRID LEAF AREA INDEX."
2831 lai_target_grid = esmf_fieldcreate(target_grid, &
2832 typekind=esmf_typekind_r8, &
2833 name=
"lai_target_grid",&
2834 staggerloc=esmf_staggerloc_center, rc=rc)
2835 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2838 print*,
"- INITIALIZE TARGET leaf area index."
2839 call esmf_fieldget(lai_target_grid, &
2840 farrayptr=target_ptr, rc=rc)
2841 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2844 target_ptr = init_val
2846 print*,
"- CALL FieldCreate FOR TARGET GRID Z0."
2847 z0_target_grid = esmf_fieldcreate(target_grid, &
2848 typekind=esmf_typekind_r8, &
2849 name=
"z0_target_grid", &
2850 staggerloc=esmf_staggerloc_center, rc=rc)
2851 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2854 print*,
"- INITIALIZE TARGET grid z0."
2855 call esmf_fieldget(z0_target_grid, &
2856 farrayptr=target_ptr, rc=rc)
2857 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2860 target_ptr = init_val
2862 print*,
"- CALL FieldCreate FOR INTERPOLATED TARGET GRID TERRAIN."
2863 terrain_from_input_grid = esmf_fieldcreate(target_grid, &
2864 typekind=esmf_typekind_r8, &
2865 name=
"terrain_from_input_grid", &
2866 staggerloc=esmf_staggerloc_center, rc=rc)
2867 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2870 print*,
"- INITIALIZE TARGET grid interpolated terrain."
2871 call esmf_fieldget(terrain_from_input_grid, &
2872 farrayptr=target_ptr, rc=rc)
2873 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2876 target_ptr = init_val
2878 print*,
"- CALL FieldCreate FOR INTERPOLATED TARGET GRID SOIL TYPE."
2879 soil_type_from_input_grid = esmf_fieldcreate(target_grid, &
2880 typekind=esmf_typekind_r8, &
2881 staggerloc=esmf_staggerloc_center, &
2882 name=
"soil_type_from_input_grid", rc=rc)
2883 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2886 print*,
"- INITIALIZE TARGET grid soil type"
2887 call esmf_fieldget(soil_type_from_input_grid, &
2888 farrayptr=target_ptr, rc=rc)
2889 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2892 target_ptr = init_val
2894 print*,
"- CALL FieldCreate FOR TARGET GRID SOIL TEMPERATURE."
2895 soil_temp_target_grid = esmf_fieldcreate(target_grid, &
2896 typekind=esmf_typekind_r8, &
2897 staggerloc=esmf_staggerloc_center, &
2898 name=
"soil_temp_target_grid", &
2899 ungriddedlbound=(/1/), &
2900 ungriddedubound=(/lsoil_target/), rc=rc)
2901 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2904 print*,
"- INITIALIZE TARGET grid soil temp"
2905 call esmf_fieldget(soil_temp_target_grid, &
2906 farrayptr=target_ptr_3d, rc=rc)
2907 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2910 target_ptr_3d = init_val
2912 print*,
"- CALL FieldCreate FOR TARGET GRID TOTAL SOIL MOISTURE."
2913 soilm_tot_target_grid = esmf_fieldcreate(target_grid, &
2914 typekind=esmf_typekind_r8, &
2915 staggerloc=esmf_staggerloc_center, &
2916 name=
"soilm_tot_target_grid", &
2917 ungriddedlbound=(/1/), &
2918 ungriddedubound=(/lsoil_target/), rc=rc)
2919 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2922 print*,
"- INITIALIZE TARGET grid soil moist"
2923 call esmf_fieldget(soilm_tot_target_grid, &
2924 farrayptr=target_ptr_3d, rc=rc)
2925 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2928 target_ptr_3d = init_val
2930 print*,
"- CALL FieldCreate FOR TARGET GRID LIQUID SOIL MOISTURE."
2931 soilm_liq_target_grid = esmf_fieldcreate(target_grid, &
2932 typekind=esmf_typekind_r8, &
2933 staggerloc=esmf_staggerloc_center, &
2934 name=
"soilm_liq_target_grid", &
2935 ungriddedlbound=(/1/), &
2936 ungriddedubound=(/lsoil_target/), rc=rc)
2937 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2940 print*,
"- INITIALIZE TARGET grid soil liq"
2941 call esmf_fieldget(soilm_liq_target_grid, &
2942 farrayptr=target_ptr_3d, rc=rc)
2943 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2946 target_ptr_3d = init_val
2961 print*,
"- CALL FieldCreate FOR TARGET GRID C_D."
2962 c_d_target_grid = esmf_fieldcreate(target_grid, &
2963 typekind=esmf_typekind_r8, &
2965 staggerloc=esmf_staggerloc_center, rc=rc)
2966 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2969 print*,
"- CALL FieldCreate FOR TARGET GRID C_0."
2970 c_0_target_grid = esmf_fieldcreate(target_grid, &
2971 typekind=esmf_typekind_r8, &
2973 staggerloc=esmf_staggerloc_center, rc=rc)
2974 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2977 print*,
"- CALL FieldCreate FOR TARGET GRID D_CONV."
2978 d_conv_target_grid = esmf_fieldcreate(target_grid, &
2979 typekind=esmf_typekind_r8, &
2981 staggerloc=esmf_staggerloc_center, rc=rc)
2982 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2985 print*,
"- CALL FieldCreate FOR TARGET GRID DT_COOL."
2986 dt_cool_target_grid = esmf_fieldcreate(target_grid, &
2987 typekind=esmf_typekind_r8, &
2989 staggerloc=esmf_staggerloc_center, rc=rc)
2990 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2993 print*,
"- CALL FieldCreate FOR TARGET GRID IFD."
2994 ifd_target_grid = esmf_fieldcreate(target_grid, &
2995 typekind=esmf_typekind_r8, &
2997 staggerloc=esmf_staggerloc_center, rc=rc)
2998 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3001 print*,
"- CALL FieldCreate FOR TARGET GRID QRAIN."
3002 qrain_target_grid = esmf_fieldcreate(target_grid, &
3003 typekind=esmf_typekind_r8, &
3005 staggerloc=esmf_staggerloc_center, rc=rc)
3006 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3009 print*,
"- CALL FieldCreate FOR TARGET GRID TREF."
3010 tref_target_grid = esmf_fieldcreate(target_grid, &
3011 typekind=esmf_typekind_r8, &
3013 staggerloc=esmf_staggerloc_center, rc=rc)
3014 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3017 print*,
"- CALL FieldCreate FOR TARGET GRID W_D."
3018 w_d_target_grid = esmf_fieldcreate(target_grid, &
3019 typekind=esmf_typekind_r8, &
3021 staggerloc=esmf_staggerloc_center, rc=rc)
3022 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3025 print*,
"- CALL FieldCreate FOR TARGET GRID W_0."
3026 w_0_target_grid = esmf_fieldcreate(target_grid, &
3027 typekind=esmf_typekind_r8, &
3029 staggerloc=esmf_staggerloc_center, rc=rc)
3030 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3033 print*,
"- CALL FieldCreate FOR TARGET GRID XS."
3034 xs_target_grid = esmf_fieldcreate(target_grid, &
3035 typekind=esmf_typekind_r8, &
3037 staggerloc=esmf_staggerloc_center, rc=rc)
3038 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3041 print*,
"- CALL FieldCreate FOR TARGET GRID XT."
3042 xt_target_grid = esmf_fieldcreate(target_grid, &
3043 typekind=esmf_typekind_r8, &
3045 staggerloc=esmf_staggerloc_center, rc=rc)
3046 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3049 print*,
"- CALL FieldCreate FOR TARGET GRID XU."
3050 xu_target_grid = esmf_fieldcreate(target_grid, &
3051 typekind=esmf_typekind_r8, &
3053 staggerloc=esmf_staggerloc_center, rc=rc)
3054 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3057 print*,
"- CALL FieldCreate FOR TARGET GRID XV."
3058 xv_target_grid = esmf_fieldcreate(target_grid, &
3059 typekind=esmf_typekind_r8, &
3061 staggerloc=esmf_staggerloc_center, rc=rc)
3062 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3065 print*,
"- CALL FieldCreate FOR TARGET GRID XZ."
3066 xz_target_grid = esmf_fieldcreate(target_grid, &
3067 typekind=esmf_typekind_r8, &
3069 staggerloc=esmf_staggerloc_center, rc=rc)
3070 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3073 print*,
"- CALL FieldCreate FOR TARGET GRID XTTS."
3074 xtts_target_grid = esmf_fieldcreate(target_grid, &
3075 typekind=esmf_typekind_r8, &
3077 staggerloc=esmf_staggerloc_center, rc=rc)
3078 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3081 print*,
"- CALL FieldCreate FOR TARGET GRID XZTS."
3082 xzts_target_grid = esmf_fieldcreate(target_grid, &
3083 typekind=esmf_typekind_r8, &
3085 staggerloc=esmf_staggerloc_center, rc=rc)
3086 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3089 print*,
"- CALL FieldCreate FOR TARGET GRID Z_C."
3090 z_c_target_grid = esmf_fieldcreate(target_grid, &
3091 typekind=esmf_typekind_r8, &
3093 staggerloc=esmf_staggerloc_center, rc=rc)
3094 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3097 print*,
"- CALL FieldCreate FOR TARGET GRID ZM."
3098 zm_target_grid = esmf_fieldcreate(target_grid, &
3099 typekind=esmf_typekind_r8, &
3101 staggerloc=esmf_staggerloc_center, rc=rc)
3102 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3119 integer(esmf_kind_i4),
intent(in) :: ij
3120 integer ,
intent(in) :: itile, jtile
3122 integer ,
intent(out) :: i, j
3125 integer :: pt_loc_this_tile
3127 tile_num = ((ij-1) / (itile*jtile))
3128 pt_loc_this_tile = ij - (tile_num * itile * jtile)
3131 j = (pt_loc_this_tile - 1) / itile + 1
3132 i = mod(pt_loc_this_tile, itile)
3150 subroutine regrid_many(bundle_pre,bundle_post, num_field,route,dozero, &
3151 unmapped_ptr,resetifd)
3159 integer,
intent(in) :: num_field
3160 type(esmf_routehandle
),
intent(inout) :: route
3161 type(esmf_fieldbundle
),
intent(in) :: bundle_pre, bundle_post
3162 logical,
intent(in) :: dozero(num_field)
3163 logical,
intent(in),
optional :: resetifd
3164 integer(esmf_kind_i4),
intent(inout),
optional :: unmapped_ptr(:)
3166 type(esmf_field
) :: field_pre,field_post
3167 real(esmf_kind_r8),
pointer :: tmp_ptr(:,:)
3170 logical :: is2d(num_field)
3171 character(len=50) :: fname
3172 integer :: i, j, k, ij, ind_2d, ind_3d, rc, ndims,n2d, n3d,localpet, l(1), u(1)
3178 if(present(unmapped_ptr))
then
3179 l = lbound(unmapped_ptr)
3180 u = ubound(unmapped_ptr)
3184 call esmf_fieldbundleget(bundle_pre,i,field_pre,rc=rc)
3185 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3188 call esmf_fieldbundleget(bundle_post,i,field_post,rc=rc)
3189 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3192 call esmf_fieldget(field_post,dimcount=ndims,name=fname,rc=rc)
3193 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3196 call esmf_vmgetglobal(vm, rc=rc)
3197 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3199 call esmf_vmget(vm, localpet=localpet, rc=rc)
3200 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3202 if(localpet==0) print*,
"in regrid_many fname = ", fname, ndims
3203 if (ndims == 2) is2d(i) = .true.
3204 if (ndims == 3) is2d(i) = .false.
3207 call esmf_fieldregrid(field_pre, &
3209 routehandle=route, &
3210 termorderflag=esmf_termorder_srcseq, rc=rc)
3211 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3214 call esmf_fieldregrid(field_pre, &
3216 routehandle=route, &
3217 zeroregion=esmf_region_select, &
3218 termorderflag=esmf_termorder_srcseq, rc=rc)
3219 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3224 if (present(resetifd))
then
3225 if( resetifd .and. convert_nst)
then
3226 call esmf_fieldget(ifd_target_grid,farrayptr=tmp_ptr,rc=rc)
3227 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3229 tmp_ptr = float(nint(tmp_ptr))
3233 n2d = count(is2d(:))
3234 n3d = count(.not.is2d(:))
3235 if(localpet==0) print*, is2d(:)
3236 if (present(unmapped_ptr))
then
3237 allocate(ptr_2d(n2d))
3238 if (n3d .ne. 0)
allocate(ptr_3d(n3d))
3242 call esmf_fieldbundleget(bundle_post,i,field_post,rc=rc)
3243 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3245 call esmf_fieldget(field_post, farrayptr=ptr_2d(ind_2d)%p, rc=rc)
3246 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3248 call esmf_fieldget(field_post,name=fname,rc=rc)
3249 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3251 if (localpet==0) print*,
"in doreplace loop, 2d field = ", trim(fname)
3254 call esmf_fieldbundleget(bundle_post,i,field_post,rc=rc)
3255 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3257 call esmf_fieldget(field_post,name=fname,rc=rc)
3258 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3260 if (localpet==0) print*,
"in doreplace loop, 3d field = ", trim(fname)
3261 call esmf_fieldget(field_post, farrayptr=ptr_3d(ind_3d)%p, rc=rc)
3262 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3268 call
ij_to_i_j(unmapped_ptr(ij), i_target, j_target, i, j)
3270 ptr_2d(k)%p(i,j) = -9999.9
3273 ptr_3d(k)%p(i,j,:) = -9999.9
3277 if(n3d .ne. 0)
deallocate(ptr_3d)
3296 subroutine search_many(num_field,bundle_target,field_data_2d,mask, tile, &
3297 search_nums,localpet,latitude,terrain_land,soilt_climo,&
3300 use model_grid, only : i_target,j_target, lsoil_target
3306 integer,
intent(in) :: num_field
3307 type(esmf_fieldbundle
),
intent(inout) :: bundle_target
3308 real(esmf_kind_r8),
intent(inout) :: field_data_2d(i_target,j_target)
3309 real(esmf_kind_r8),
intent(inout),
optional :: field_data_3d(i_target,j_target,lsoil_target)
3310 real(esmf_kind_r8),
intent(inout),
optional :: latitude(i_target,j_target)
3311 real(esmf_kind_r8),
intent(inout),
optional :: terrain_land(i_target,j_target)
3312 real(esmf_kind_r8),
intent(inout),
optional :: soilt_climo(i_target,j_target)
3313 integer(esmf_kind_i8),
intent(inout) :: mask(i_target,j_target)
3316 integer,
intent(in) :: tile,localpet
3317 integer,
intent(inout) :: search_nums(num_field)
3319 type(esmf_field
) :: temp_field
3320 character(len=50) :: fname
3321 integer,
parameter :: sotyp_land_field_num = 224
3322 integer,
parameter :: sst_field_num = 11
3323 integer,
parameter :: terrain_field_num= 7
3324 integer :: j,k, rc, ndims
3327 call esmf_fieldbundleget(bundle_target,k,temp_field, rc=rc)
3328 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3330 call esmf_fieldget(temp_field, name=fname, dimcount=ndims,rc=rc)
3331 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3333 if (ndims .eq. 2)
then
3334 print*,
"processing 2d field ", trim(fname)
3335 print*,
"FieldGather"
3336 call esmf_fieldgather(temp_field,field_data_2d,rootpet=0,tile=tile, rc=rc)
3337 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3339 if (localpet == 0)
then
3340 if (present(latitude) .and. search_nums(k).eq.sst_field_num)
then
3343 call
search(field_data_2d, mask, i_target, j_target, tile,search_nums(k),latitude=latitude)
3344 elseif (present(terrain_land) .and. search_nums(k) .eq. terrain_field_num)
then
3347 call
search(field_data_2d, mask, i_target, j_target, tile,search_nums(k),terrain_land=terrain_land)
3348 elseif (search_nums(k) .eq. sotyp_land_field_num)
then
3350 if (fname .eq.
"soil_type_target_grid")
then
3354 call
search(field_data_2d, mask, i_target, j_target, tile,search_nums(k),soilt_climo=soilt_climo)
3355 elseif (present(soilt_climo))
then
3356 if (maxval(field_data_2d) > 0 .and. (trim(external_model) .ne.
"GFS" .or. trim(input_type) .ne.
"grib2"))
then
3360 call
search(field_data_2d, mask, i_target, j_target, tile, search_nums(k))
3366 field_data_2d = soilt_climo
3372 call
search(field_data_2d, mask, i_target, j_target, tile,search_nums(k))
3375 call esmf_fieldscatter(temp_field, field_data_2d, rootpet=0, tile=tile,rc=rc)
3376 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3380 print*,
"FieldGather"
3381 call esmf_fieldgather(temp_field,field_data_3d,rootpet=0,tile=tile,rc=rc)
3382 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3384 print*,
"processing 3d field ", trim(fname)
3385 if (localpet==0)
then
3386 do j = 1, lsoil_target
3387 field_data_2d = field_data_3d(:,:,j)
3388 call
search(field_data_2d, mask, i_target, j_target, tile, 21)
3389 field_data_3d(:,:,j) = field_data_2d
3392 call esmf_fieldscatter(temp_field, field_data_3d, rootpet=0, tile=tile,rc=rc)
3393 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3412 print*,
"- DESTROY LOCAL TARGET GRID SURFACE FIELDS."
3414 call esmf_fielddestroy(terrain_from_input_grid, rc=rc)
3415 call esmf_fielddestroy(terrain_from_input_grid_land, rc=rc)
3416 call esmf_fielddestroy(soil_type_from_input_grid, rc=rc)
subroutine, public calc_soil_params_driver(localpet)
Driver routine to compute soil parameters for each soil type.
subroutine qc_check
Perform some quality control checks before output.
subroutine, public write_fv3_sfc_data_netcdf(localpet)
Writes surface and nst data into a 'coldstart' file (netcdf).
subroutine, public get_static_fields(localpet)
Driver routine to read/time interpolate static/climo fields on the fv3 target grid.
subroutine, public interp(localpet)
Horizontally interpolate surface fields from input to target FV3 grid using esmf routines.
subroutine cleanup_all_target_sfc_data
Free up memory once the target grid surface fields are no longer needed.
Process surface and nst fields.
subroutine, public cleanup_target_sfc_data
Free up memory once the target grid surface fields are no longer needed.
Sets up the ESMF grid objects for the input data grid and target FV3 grid.
subroutine, public cleanup_target_nst_data
Free up memory once the target grid nst fields are no longer needed.
subroutine, public cleanup_static_fields
Free up memory for fields in this module.
Replace undefined values with a valid value.
subroutine, public regrid_many(bundle_pre, bundle_post, num_field, route, dozero, unmapped_ptr, resetifd)
Regrid multiple ESMF fields from input to target grid.
Module to hold ESMF fields associated with the target grid surface data.
subroutine rescale_soil_moisture
Adjust soil moisture for changes in soil type between the input and target grids. ...
subroutine adjust_soil_levels(localpet)
Adjust soil levels of the input grid if there is a mismatch between input and target grids...
subroutine error_handler(string, rc)
General error handler.
subroutine, public create_nst_esmf_fields
Create ESMF fields for the target grid nst variables.
This module contains code to read the setup namelist file, handle the varmap file for GRIB2 data...
real function frh2o(TKELV, SMC, SH2O, SMCMAX, BEXP, PSIS)
Calculate supercooled soil moisture.
subroutine ij_to_i_j(ij, itile, jtile, i, j)
Convert 1d index to 2d indices.
subroutine adjust_soilt_for_terrain
Adjust soil temperature for changes in terrain height between the input and target grids...
subroutine roughness
Set roughness length at land and sea ice.
subroutine, public search_many(num_field, bundle_target, field_data_2d, mask, tile, search_nums, localpet, latitude, terrain_land, soilt_climo, field_data_3d)
Execute the search function for multple fields.
Reads static surface climatological data for the target FV3 grid (such as soil type and vegetation ty...
subroutine, public search(field, mask, idim, jdim, tile, field_num, latitude, terrain_land, soilt_climo)
Replace undefined surface values.
subroutine calc_liq_soil_moisture
Compute liquid portion of the total soil moisture.
subroutine, public create_surface_esmf_fields
Create ESMF fields for the target grid surface variables.
subroutine, public nst_land_fill
nst is not active at land or sea ice points.
subroutine, public surface_driver(localpet)
Driver routine to process surface/nst data.