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, &
53 integer,
parameter :: veg_type_landice_target = 15
59 type(esmf_field
) :: soil_type_from_input_grid
62 type(esmf_field
) :: terrain_from_input_grid
65 type(esmf_field
) :: terrain_from_input_grid_land
69 real,
parameter,
private :: blim = 5.5
71 real,
parameter,
private :: frz_h2o = 273.15
73 real,
parameter,
private :: frz_ice = 271.21
75 real,
parameter,
private :: grav = 9.81
77 real,
parameter,
private :: hlice = 3.335E5
82 real(esmf_kind_r8),
pointer :: p(:,:)
87 real(esmf_kind_r8),
pointer :: p(:,:,:)
127 integer,
intent(in) :: localpet
256 landsea_mask_input_grid, &
258 seaice_depth_input_grid, &
259 seaice_fract_input_grid, &
260 seaice_skin_temp_input_grid, &
261 skin_temp_input_grid, &
262 snow_depth_input_grid, &
263 snow_liq_equiv_input_grid, &
264 soil_temp_input_grid, &
265 soil_type_input_grid, &
266 soilm_tot_input_grid, &
271 veg_type_input_grid, &
273 veg_type_landice_input, &
274 veg_greenness_input_grid, &
275 max_veg_greenness_input_grid, &
276 min_veg_greenness_input_grid, &
282 dt_cool_input_grid, &
300 use model_grid, only : input_grid, target_grid, &
301 i_target, j_target, &
303 num_tiles_target_grid, &
304 landmask_target_grid, &
305 seamask_target_grid, &
312 minmax_vgfrc_from_climo, &
317 soil_type_target_grid, &
318 veg_greenness_target_grid, &
319 substrate_temp_target_grid,&
320 min_veg_greenness_target_grid,&
321 max_veg_greenness_target_grid
327 integer,
intent(in) :: localpet
329 integer :: l(1), u(1)
330 integer :: i, j, ij, rc, tile
331 integer :: clb_target(2), cub_target(2)
332 integer :: isrctermprocessing
333 integer :: num_fields
334 integer :: vgfrc_ind, mmvg_ind, lai_ind
335 integer,
allocatable :: search_nums(:)
336 integer(esmf_kind_i4),
pointer :: unmapped_ptr(:)
337 integer(esmf_kind_i4),
pointer :: mask_input_ptr(:,:)
338 integer(esmf_kind_i4),
pointer :: mask_target_ptr(:,:)
339 integer(esmf_kind_i8),
pointer :: landmask_target_ptr(:,:)
340 integer(esmf_kind_i8),
allocatable :: mask_target_one_tile(:,:)
341 integer(esmf_kind_i8),
allocatable :: water_target_one_tile(:,:)
342 integer(esmf_kind_i8),
allocatable :: land_target_one_tile(:,:)
343 integer(esmf_kind_i8),
pointer :: seamask_target_ptr(:,:)
345 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
346 real(esmf_kind_r8),
allocatable :: data_one_tile2(:,:)
347 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
348 real(esmf_kind_r8),
allocatable :: latitude_one_tile(:,:)
349 real(esmf_kind_r8),
pointer :: seaice_fract_target_ptr(:,:)
350 real(esmf_kind_r8),
pointer :: srflag_target_ptr(:,:)
351 real(esmf_kind_r8),
pointer :: terrain_from_input_ptr(:,:)
352 real(esmf_kind_r8),
pointer :: veg_type_target_ptr(:,:)
353 real(esmf_kind_r8),
pointer :: soil_type_target_ptr(:,:)
354 real(esmf_kind_r8),
pointer :: landmask_input_ptr(:,:)
355 real(esmf_kind_r8),
pointer :: veg_type_input_ptr(:,:)
356 real(esmf_kind_r8),
allocatable :: veg_type_target_one_tile(:,:)
358 type(esmf_regridmethod_flag
) :: method
359 type(esmf_routehandle
) :: regrid_bl_no_mask
360 type(esmf_routehandle
) :: regrid_all_land
361 type(esmf_routehandle
) :: regrid_land
362 type(esmf_routehandle
) :: regrid_landice
363 type(esmf_routehandle
) :: regrid_nonland
364 type(esmf_routehandle
) :: regrid_seaice
365 type(esmf_routehandle
) :: regrid_water
367 type(esmf_fieldbundle
) :: bundle_all_target, bundle_all_input
368 type(esmf_fieldbundle
) :: bundle_seaice_target, bundle_seaice_input
369 type(esmf_fieldbundle
) :: bundle_water_target, bundle_water_input
370 type(esmf_fieldbundle
) :: bundle_allland_target, bundle_allland_input
371 type(esmf_fieldbundle
) :: bundle_landice_target, bundle_landice_input
372 type(esmf_fieldbundle
) :: bundle_nolandice_target, bundle_nolandice_input
374 logical,
allocatable :: dozero(:)
380 method=esmf_regridmethod_bilinear
382 isrctermprocessing = 1
384 print*,
"- CALL FieldRegridStore FOR NON-MASKED BILINEAR INTERPOLATION."
385 call esmf_fieldregridstore(t2m_input_grid, &
387 polemethod=esmf_polemethod_allavg, &
388 srctermprocessing=isrctermprocessing, &
389 routehandle=regrid_bl_no_mask, &
390 regridmethod=method, rc=rc)
391 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
394 bundle_all_target = esmf_fieldbundlecreate(name=
"all points target", rc=rc)
395 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
397 bundle_all_input = esmf_fieldbundlecreate(name=
"all points input", rc=rc)
398 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
401 call esmf_fieldbundleadd(bundle_all_target, (/t2m_target_grid,q2m_target_grid,tprcp_target_grid, &
402 f10m_target_grid,ffmm_target_grid,ustar_target_grid,srflag_target_grid/), &
404 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
406 call esmf_fieldbundleadd(bundle_all_input, (/t2m_input_grid,q2m_input_grid,tprcp_input_grid, &
407 f10m_input_grid,ffmm_input_grid,ustar_input_grid,srflag_input_grid/), &
409 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
412 call esmf_fieldbundleget(bundle_all_target,fieldcount=num_fields,rc=rc)
413 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
416 allocate(dozero(num_fields))
419 call
regrid_many(bundle_all_input,bundle_all_target,num_fields,regrid_bl_no_mask,dozero)
422 call esmf_fieldbundledestroy(bundle_all_target,rc=rc)
423 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
425 call esmf_fieldbundledestroy(bundle_all_input,rc=rc)
426 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
429 print*,
"- CALL FieldGet FOR SRFLAG."
430 call esmf_fieldget(srflag_target_grid, &
431 farrayptr=srflag_target_ptr, rc=rc)
432 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
440 srflag_target_ptr = nint(srflag_target_ptr)
442 print*,
"- CALL FieldRegridRelease."
443 call esmf_fieldregridrelease(routehandle=regrid_bl_no_mask, rc=rc)
444 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
451 print*,
"- CALL GridAddItem FOR TARGET GRID."
452 call esmf_gridadditem(target_grid, &
453 itemflag=esmf_griditem_mask, &
454 staggerloc=esmf_staggerloc_center, rc=rc)
455 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
458 print*,
"- CALL GridGetItem FOR TARGET GRID."
459 call esmf_gridgetitem(target_grid, &
460 itemflag=esmf_griditem_mask, &
461 farrayptr=mask_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 SEAMASK."
466 call esmf_fieldget(seamask_target_grid, &
467 computationallbound=clb_target, &
468 computationalubound=cub_target, &
469 farrayptr=seamask_target_ptr, rc=rc)
470 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
473 print*,
"- CALL FieldGet FOR TARGET GRID LANDMASK."
474 call esmf_fieldget(landmask_target_grid, &
475 farrayptr=landmask_target_ptr, rc=rc)
476 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
479 print*,
"- CALL GridAddItem FOR INPUT GRID SEAMASK."
480 call esmf_gridadditem(input_grid, &
481 itemflag=esmf_griditem_mask, &
482 staggerloc=esmf_staggerloc_center, rc=rc)
483 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
486 print*,
"- CALL FieldGet FOR INPUT GRID LANDMASK."
487 call esmf_fieldget(landsea_mask_input_grid, &
488 farrayptr=landmask_input_ptr, rc=rc)
489 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
492 print*,
"- CALL GridGetItem FOR INPUT GRID LANDMASK."
493 call esmf_gridgetitem(input_grid, &
494 itemflag=esmf_griditem_mask, &
495 farrayptr=mask_input_ptr, rc=rc)
496 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
499 if (localpet == 0)
then
500 allocate(data_one_tile(i_target,j_target))
501 allocate(data_one_tile_3d(i_target,j_target,lsoil_target))
502 allocate(mask_target_one_tile(i_target,j_target))
504 allocate(data_one_tile(0,0))
505 allocate(data_one_tile_3d(0,0,0))
506 allocate(mask_target_one_tile(0,0))
514 method=esmf_regridmethod_nearest_stod
516 isrctermprocessing = 1
519 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1
522 where (landmask_target_ptr == 1) mask_target_ptr = 1
524 print*,
"- CALL FieldCreate FOR TERRAIN FROM INPUT GRID LAND."
525 terrain_from_input_grid_land = esmf_fieldcreate(target_grid, &
526 typekind=esmf_typekind_r8, &
527 staggerloc=esmf_staggerloc_center, rc=rc)
528 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
531 print*,
"- CALL FieldRegridStore for land fields."
532 call esmf_fieldregridstore(terrain_input_grid, &
533 terrain_from_input_grid_land, &
534 srcmaskvalues=(/0/), &
535 dstmaskvalues=(/0/), &
536 polemethod=esmf_polemethod_none, &
537 srctermprocessing=isrctermprocessing, &
538 unmappedaction=esmf_unmappedaction_ignore, &
539 normtype=esmf_normtype_fracarea, &
540 routehandle=regrid_all_land, &
541 regridmethod=method, &
542 unmappeddstlist=unmapped_ptr, rc=rc)
543 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
546 print*,
"- CALL Field_Regrid TERRAIN."
547 call esmf_fieldregrid(terrain_input_grid, &
548 terrain_from_input_grid_land, &
549 routehandle=regrid_all_land, &
550 termorderflag=esmf_termorder_srcseq, rc=rc)
551 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
554 print*,
"- CALL FieldGet FOR terrain from input grid at land."
555 call esmf_fieldget(terrain_from_input_grid_land, &
556 farrayptr=terrain_from_input_ptr, rc=rc)
557 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
560 l = lbound(unmapped_ptr)
561 u = ubound(unmapped_ptr)
564 call
ij_to_i_j(unmapped_ptr(ij), i_target, j_target, i, j)
565 terrain_from_input_ptr(i,j) = -9999.9
567 nullify(terrain_from_input_ptr)
569 do tile = 1, num_tiles_target_grid
571 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
572 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
573 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
576 print*,
"- CALL FieldGather FOR TERRAIN FROM INPUT GRID: ", tile
577 call esmf_fieldgather(terrain_from_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
578 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
581 if (localpet == 0)
then
582 allocate(land_target_one_tile(i_target,j_target))
583 land_target_one_tile = 0
584 where(mask_target_one_tile == 1) land_target_one_tile = 1
585 call
search(data_one_tile, land_target_one_tile, i_target, j_target, tile, 7)
586 deallocate(land_target_one_tile)
589 print*,
"- CALL FieldScatter FOR TERRAIN FROM INPUT GRID: ", tile
590 call esmf_fieldscatter(terrain_from_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
591 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
595 if(.not. vgtyp_from_climo)
then
597 print*,
"- CALL FieldRegrid VEG TYPE."
598 call esmf_fieldregrid(veg_type_input_grid, &
599 veg_type_target_grid, &
600 routehandle=regrid_all_land, &
601 termorderflag=esmf_termorder_srcseq, rc=rc)
602 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
605 print*,
"- CALL FieldGet FOR TARGET grid veg type."
606 call esmf_fieldget(veg_type_target_grid, &
607 farrayptr=veg_type_target_ptr, rc=rc)
608 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
611 l = lbound(unmapped_ptr)
612 u = ubound(unmapped_ptr)
615 call
ij_to_i_j(unmapped_ptr(ij), i_target, j_target, i, j)
616 veg_type_target_ptr(i,j) = -9999.9
619 do tile = 1, num_tiles_target_grid
620 print*,
"- CALL FieldGather FOR TARGET GRID VEG TYPE TILE: ", tile
621 call esmf_fieldgather(veg_type_target_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
622 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
625 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
626 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
627 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
630 if (localpet == 0)
then
631 allocate(land_target_one_tile(i_target,j_target))
632 land_target_one_tile = 0
633 where(mask_target_one_tile == 1) land_target_one_tile = 1
634 call
search(data_one_tile, land_target_one_tile, i_target, j_target, tile, 225)
635 deallocate(land_target_one_tile)
638 print*,
"- CALL FieldScatter FOR TARGET GRID VEG TYPE: ", tile
639 call esmf_fieldscatter(veg_type_target_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
640 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
643 nullify(veg_type_target_ptr)
645 print*,
"- CALL FieldRegridRelease."
646 call esmf_fieldregridrelease(routehandle=regrid_all_land, rc=rc)
647 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
656 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 0
658 mask_target_ptr = int(seamask_target_ptr,kind=esmf_kind_i4)
660 method=esmf_regridmethod_conserve
662 isrctermprocessing = 1
664 print*,
"- CALL FieldRegridStore for sea ice fraction."
665 call esmf_fieldregridstore(seaice_fract_input_grid, &
666 seaice_fract_target_grid, &
667 srcmaskvalues=(/0/), &
668 dstmaskvalues=(/0/), &
669 polemethod=esmf_polemethod_none, &
670 srctermprocessing=isrctermprocessing, &
671 unmappedaction=esmf_unmappedaction_ignore, &
672 normtype=esmf_normtype_fracarea, &
673 routehandle=regrid_nonland, &
674 regridmethod=method, &
675 unmappeddstlist=unmapped_ptr, rc=rc)
676 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
679 print*,
"- CALL Field_Regrid for sea ice fraction."
680 call esmf_fieldregrid(seaice_fract_input_grid, &
681 seaice_fract_target_grid, &
682 routehandle=regrid_nonland, &
683 termorderflag=esmf_termorder_srcseq, rc=rc)
684 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
687 print*,
"- CALL FieldGet FOR TARGET grid sea ice fraction."
688 call esmf_fieldget(seaice_fract_target_grid, &
689 farrayptr=seaice_fract_target_ptr, rc=rc)
690 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
693 l = lbound(unmapped_ptr)
694 u = ubound(unmapped_ptr)
697 call
ij_to_i_j(unmapped_ptr(ij), i_target, j_target, i, j)
698 seaice_fract_target_ptr(i,j) = -9999.9
703 if (localpet == 0)
then
704 allocate(latitude_one_tile(i_target,j_target))
706 allocate(latitude_one_tile(0,0))
709 do tile = 1, num_tiles_target_grid
711 print*,
"- CALL FieldGather FOR TARGET GRID SEAICE FRACTION TILE: ", tile
712 call esmf_fieldgather(seaice_fract_target_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
713 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
716 print*,
"- CALL FieldGather FOR TARGET GRID MASK TILE: ", tile
717 call esmf_fieldgather(seamask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
718 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
721 print*,
"- CALL FieldGather FOR TARGET LATITUDE TILE: ", tile
722 call esmf_fieldgather(latitude_target_grid, latitude_one_tile, rootpet=0, tile=tile, rc=rc)
723 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
726 if (localpet == 0)
then
727 call
search(data_one_tile, mask_target_one_tile, i_target, j_target, tile, 91, &
728 latitude=latitude_one_tile)
731 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
732 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
733 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
737 if (localpet == 0)
then
740 if (data_one_tile(i,j) > 1.0_esmf_kind_r8)
then
741 data_one_tile(i,j) = 1.0_esmf_kind_r8
743 if (data_one_tile(i,j) < 0.15_esmf_kind_r8) data_one_tile(i,j) = 0.0_esmf_kind_r8
744 if (data_one_tile(i,j) >= 0.15_esmf_kind_r8) mask_target_one_tile(i,j) = 2
749 print*,
"- CALL FieldScatter FOR TARGET GRID SEAICE FRACTION TILE: ", tile
750 call esmf_fieldscatter(seaice_fract_target_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
751 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
754 print*,
"- CALL FieldScatter FOR TARGET LANDMASK TILE: ", tile
755 call esmf_fieldscatter(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
756 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
761 deallocate(latitude_one_tile)
763 print*,
"- CALL FieldRegridRelease."
764 call esmf_fieldregridrelease(routehandle=regrid_nonland, rc=rc)
765 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
774 where (nint(landmask_input_ptr) == 2) mask_input_ptr = 1
776 print*,
"- CALL FieldGet FOR TARGET land sea mask."
777 call esmf_fieldget(landmask_target_grid, &
778 farrayptr=landmask_target_ptr, rc=rc)
779 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
783 do j = clb_target(2), cub_target(2)
784 do i = clb_target(1), cub_target(1)
785 if (landmask_target_ptr(i,j) == 2) mask_target_ptr(i,j) = 1
789 method=esmf_regridmethod_nearest_stod
790 isrctermprocessing = 1
792 print*,
"- CALL FieldRegridStore for 3d seaice fields."
793 call esmf_fieldregridstore(soil_temp_input_grid, &
794 soil_temp_target_grid, &
795 srcmaskvalues=(/0/), &
796 dstmaskvalues=(/0/), &
797 polemethod=esmf_polemethod_none, &
798 srctermprocessing=isrctermprocessing, &
799 unmappedaction=esmf_unmappedaction_ignore, &
800 normtype=esmf_normtype_fracarea, &
801 routehandle=regrid_seaice, &
802 regridmethod=method, &
803 unmappeddstlist=unmapped_ptr, rc=rc)
804 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
807 bundle_seaice_target = esmf_fieldbundlecreate(name=
"sea ice target", rc=rc)
808 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
810 bundle_seaice_input = esmf_fieldbundlecreate(name=
"sea ice input", rc=rc)
811 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
813 call esmf_fieldbundleadd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_target_grid, &
814 snow_liq_equiv_target_grid, seaice_skin_temp_target_grid, &
815 soil_temp_target_grid/), rc=rc)
816 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
818 call esmf_fieldbundleadd(bundle_seaice_input, (/seaice_depth_input_grid, snow_depth_input_grid, &
819 snow_liq_equiv_input_grid, seaice_skin_temp_input_grid, &
820 soil_temp_input_grid/), rc=rc)
821 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
823 call esmf_fieldbundleget(bundle_seaice_target,fieldcount=num_fields,rc=rc)
824 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
828 allocate(search_nums(num_fields))
829 allocate(dozero(num_fields))
831 search_nums = (/92,66,65,21,21/)
834 l = lbound(unmapped_ptr)
835 u = ubound(unmapped_ptr)
837 call
regrid_many(bundle_seaice_input,bundle_seaice_target,num_fields,regrid_seaice,dozero, &
838 unmapped_ptr=unmapped_ptr )
840 call esmf_fieldbundledestroy(bundle_seaice_input,rc=rc)
841 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
844 do tile = 1, num_tiles_target_grid
846 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
847 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
848 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
851 if (localpet == 0)
then
852 where(mask_target_one_tile == 1) mask_target_one_tile = 0
853 where(mask_target_one_tile == 2) mask_target_one_tile = 1
854 call
search_many(num_fields,bundle_seaice_target,tile, search_nums,localpet, &
855 mask=mask_target_one_tile)
857 call
search_many(num_fields,bundle_seaice_target, tile,search_nums,localpet)
862 deallocate(search_nums)
863 call esmf_fieldbundledestroy(bundle_seaice_target,rc=rc)
864 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
867 print*,
"- CALL FieldRegridRelease."
868 call esmf_fieldregridrelease(routehandle=regrid_seaice, rc=rc)
869 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
877 where (nint(landmask_input_ptr) == 0) mask_input_ptr = 1
880 where (landmask_target_ptr == 0) mask_target_ptr = 1
882 method=esmf_regridmethod_conserve
883 isrctermprocessing = 1
885 print*,
"- CALL FieldRegridStore for water fields."
886 call esmf_fieldregridstore(skin_temp_input_grid, &
887 skin_temp_target_grid, &
888 srcmaskvalues=(/0/), &
889 dstmaskvalues=(/0/), &
890 polemethod=esmf_polemethod_none, &
891 srctermprocessing=isrctermprocessing, &
892 unmappedaction=esmf_unmappedaction_ignore, &
893 normtype=esmf_normtype_fracarea, &
894 routehandle=regrid_water, &
895 regridmethod=method, &
896 unmappeddstlist=unmapped_ptr, rc=rc)
897 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
900 bundle_water_target = esmf_fieldbundlecreate(name=
"water target", rc=rc)
901 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
903 bundle_water_input = esmf_fieldbundlecreate(name=
"water input", rc=rc)
904 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
906 call esmf_fieldbundleadd(bundle_water_target, (/skin_temp_target_grid, z0_target_grid/), rc=rc)
907 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
909 call esmf_fieldbundleadd(bundle_water_input, (/skin_temp_input_grid, z0_input_grid/), rc=rc)
910 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
913 if (convert_nst)
then
915 call esmf_fieldbundleadd(bundle_water_target, (/c_d_target_grid,c_0_target_grid,d_conv_target_grid, &
916 dt_cool_target_grid,ifd_target_grid,qrain_target_grid,tref_target_grid, &
917 w_d_target_grid,w_0_target_grid,xs_target_grid,xt_target_grid,xu_target_grid, &
918 xv_target_grid,xz_target_grid,xtts_target_grid,xzts_target_grid, &
919 z_c_target_grid,zm_target_grid/), rc=rc)
920 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
923 call esmf_fieldbundleadd(bundle_water_input, (/c_d_input_grid,c_0_input_grid,d_conv_input_grid, &
924 dt_cool_input_grid,ifd_input_grid,qrain_input_grid,tref_input_grid, &
925 w_d_input_grid,w_0_input_grid,xs_input_grid,xt_input_grid,xu_input_grid, &
926 xv_input_grid,xz_input_grid,xtts_input_grid,xzts_input_grid, &
927 z_c_input_grid,zm_input_grid/), rc=rc)
928 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
930 call esmf_fieldbundleget(bundle_water_target,fieldcount=num_fields,rc=rc)
931 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
934 allocate(search_nums(num_fields))
935 allocate(dozero(num_fields))
937 search_nums(:)=(/11,83,0,0,0,0,1,0,11,0,0,0,0,0,0,30,0,0,0,0/)
941 call esmf_fieldbundleget(bundle_water_target,fieldcount=num_fields,rc=rc)
942 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
945 allocate(search_nums(num_fields))
946 allocate(dozero(num_fields))
947 search_nums(:)=(/11,83/)
951 call
regrid_many(bundle_water_input,bundle_water_target,num_fields,regrid_water,dozero, &
952 unmapped_ptr=unmapped_ptr, resetifd=.true.)
954 call esmf_fieldbundledestroy(bundle_water_input,rc=rc)
955 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
959 if (localpet == 0)
then
960 allocate(latitude_one_tile(i_target,j_target))
962 allocate(latitude_one_tile(0,0))
965 do tile = 1, num_tiles_target_grid
967 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
968 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
969 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
972 print*,
"- CALL FieldGather FOR TARGET LATITUDE TILE: ", tile
973 call esmf_fieldgather(latitude_target_grid, latitude_one_tile, rootpet=0, tile=tile, rc=rc)
974 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
977 if (localpet == 0)
then
978 allocate(water_target_one_tile(i_target,j_target))
979 water_target_one_tile = 0
980 where(mask_target_one_tile == 0) water_target_one_tile = 1
982 call
search_many(num_fields,bundle_water_target, tile,search_nums,localpet, &
983 latitude=latitude_one_tile,mask=water_target_one_tile)
985 call
search_many(num_fields,bundle_water_target, tile,search_nums,localpet)
988 if (localpet == 0)
deallocate(water_target_one_tile)
992 deallocate(latitude_one_tile,search_nums)
994 call esmf_fieldbundledestroy(bundle_water_target,rc=rc)
995 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
998 print*,
"- CALL FieldRegridRelease."
999 call esmf_fieldregridrelease(routehandle=regrid_water, rc=rc)
1000 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1008 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1
1011 where (landmask_target_ptr == 1) mask_target_ptr = 1
1013 method=esmf_regridmethod_conserve
1014 isrctermprocessing = 1
1016 print*,
"- CALL FieldRegridStore for land fields."
1017 call esmf_fieldregridstore(snow_depth_input_grid, &
1018 snow_depth_target_grid, &
1019 srcmaskvalues=(/0/), &
1020 dstmaskvalues=(/0/), &
1021 polemethod=esmf_polemethod_none, &
1022 srctermprocessing=isrctermprocessing, &
1023 unmappedaction=esmf_unmappedaction_ignore, &
1024 normtype=esmf_normtype_fracarea, &
1025 routehandle=regrid_all_land, &
1026 regridmethod=method, &
1027 unmappeddstlist=unmapped_ptr, rc=rc)
1028 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1031 bundle_allland_target = esmf_fieldbundlecreate(name=
"all land target", rc=rc)
1032 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1034 bundle_allland_input = esmf_fieldbundlecreate(name=
"all land input", rc=rc)
1035 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1037 call esmf_fieldbundleadd(bundle_allland_target, (/canopy_mc_target_grid, snow_depth_target_grid, &
1038 snow_liq_equiv_target_grid/), rc=rc)
1039 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1041 call esmf_fieldbundleadd(bundle_allland_input, (/canopy_mc_input_grid, snow_depth_input_grid, &
1042 snow_liq_equiv_input_grid/), rc=rc)
1043 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1045 call esmf_fieldbundleget(bundle_allland_target,fieldcount=num_fields,rc=rc)
1046 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1049 allocate(search_nums(num_fields))
1050 allocate(dozero(num_fields))
1052 search_nums = (/223,66,65/)
1053 dozero=(/.true.,.false.,.false./)
1055 call
regrid_many(bundle_allland_input,bundle_allland_target,num_fields,regrid_all_land,dozero, &
1056 unmapped_ptr=unmapped_ptr)
1058 call esmf_fieldbundledestroy(bundle_allland_input,rc=rc)
1059 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1063 do tile = 1, num_tiles_target_grid
1065 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
1066 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
1067 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1070 if (localpet == 0)
then
1071 allocate(land_target_one_tile(i_target,j_target))
1072 land_target_one_tile = 0
1073 where(mask_target_one_tile == 1) land_target_one_tile = 1
1075 call
search_many(num_fields,bundle_allland_target, &
1076 tile,search_nums,localpet, mask=land_target_one_tile)
1078 call
search_many(num_fields,bundle_allland_target, tile,search_nums,localpet)
1081 if (localpet == 0)
deallocate(land_target_one_tile)
1084 deallocate(search_nums)
1085 call esmf_fieldbundledestroy(bundle_allland_target,rc=rc)
1086 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1089 print*,
"- CALL FieldRegridRelease."
1090 call esmf_fieldregridrelease(routehandle=regrid_all_land, rc=rc)
1091 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1098 print*,
"- CALL FieldGet FOR INPUT GRID VEG TYPE."
1099 call esmf_fieldget(veg_type_input_grid, &
1100 farrayptr=veg_type_input_ptr, rc=rc)
1101 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1104 print*,
'land ice check ',veg_type_landice_input
1107 where (nint(veg_type_input_ptr) == veg_type_landice_input) mask_input_ptr = 1
1109 print*,
"- CALL FieldGet FOR TARGET GRID VEG TYPE."
1110 call esmf_fieldget(veg_type_target_grid, &
1111 farrayptr=veg_type_target_ptr, rc=rc)
1112 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1116 where (nint(veg_type_target_ptr) == veg_type_landice_target) mask_target_ptr = 1
1118 method=esmf_regridmethod_nearest_stod
1119 isrctermprocessing = 1
1121 print*,
"- CALL FieldRegridStore for landice fields."
1122 call esmf_fieldregridstore(soil_temp_input_grid, &
1123 soil_temp_target_grid, &
1124 srcmaskvalues=(/0/), &
1125 dstmaskvalues=(/0/), &
1126 polemethod=esmf_polemethod_none, &
1127 srctermprocessing=isrctermprocessing, &
1128 unmappedaction=esmf_unmappedaction_ignore, &
1129 normtype=esmf_normtype_fracarea, &
1130 routehandle=regrid_landice, &
1131 regridmethod=method, &
1132 unmappeddstlist=unmapped_ptr, rc=rc)
1133 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1136 bundle_landice_target = esmf_fieldbundlecreate(name=
"landice target", rc=rc)
1137 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1139 bundle_landice_input = esmf_fieldbundlecreate(name=
"landice input", rc=rc)
1140 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1142 call esmf_fieldbundleadd(bundle_landice_target, (/skin_temp_target_grid, terrain_from_input_grid,&
1143 soil_temp_target_grid/), rc=rc)
1144 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1146 call esmf_fieldbundleadd(bundle_landice_input, (/skin_temp_input_grid, terrain_input_grid,&
1147 soil_temp_input_grid/), rc=rc)
1148 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1151 if (.not. sotyp_from_climo)
then
1152 call esmf_fieldbundleadd(bundle_landice_input, (/soil_type_input_grid/),rc=rc)
1153 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1155 call esmf_fieldbundleadd(bundle_landice_target,(/soil_type_target_grid/),rc=rc)
1156 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1160 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1162 call esmf_fieldbundleget(bundle_landice_target,fieldcount=num_fields,rc=rc)
1163 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1166 allocate(search_nums(num_fields))
1167 allocate(dozero(num_fields))
1169 if (sotyp_from_climo)
then
1170 search_nums = (/21,7,21/)
1173 search_nums = (/21,7,21,231/)
1174 dozero(:)=(/.false.,.false.,.false.,.true./)
1177 call
regrid_many(bundle_landice_input,bundle_landice_target,num_fields,regrid_landice,dozero, &
1178 unmapped_ptr=unmapped_ptr )
1180 call esmf_fieldbundledestroy(bundle_landice_input,rc=rc)
1181 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1184 if (localpet == 0)
then
1185 allocate (veg_type_target_one_tile(i_target,j_target))
1186 allocate (land_target_one_tile(i_target,j_target))
1187 allocate (data_one_tile2(i_target,j_target))
1189 allocate (veg_type_target_one_tile(0,0))
1190 allocate (land_target_one_tile(0,0))
1191 allocate (data_one_tile2(0,0))
1194 do tile = 1, num_tiles_target_grid
1195 print*,
"- CALL FieldGather FOR TARGET VEG TYPE TILE: ", tile
1196 call esmf_fieldgather(veg_type_target_grid, veg_type_target_one_tile, rootpet=0, tile=tile, rc=rc)
1197 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1200 if (localpet == 0)
then
1201 land_target_one_tile = 0
1202 where(nint(veg_type_target_one_tile) == veg_type_landice_target) land_target_one_tile = 1
1205 print*,
"- CALL FieldGather FOR TERRAIN FROM INPUT GRID LAND, TILE: ", tile
1206 call esmf_fieldgather(terrain_from_input_grid_land, data_one_tile2, rootpet=0, tile=tile, rc=rc)
1207 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1210 if (localpet==0)
then
1211 call
search_many(num_fields,bundle_landice_target,tile,search_nums,localpet,&
1212 terrain_land=data_one_tile2,mask=land_target_one_tile)
1214 call
search_many(num_fields,bundle_landice_target,tile,search_nums,localpet)
1218 deallocate (veg_type_target_one_tile)
1219 deallocate (land_target_one_tile)
1220 deallocate(search_nums)
1222 call esmf_fieldbundledestroy(bundle_landice_target,rc=rc)
1223 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1226 print*,
"- CALL FieldRegridRelease."
1227 call esmf_fieldregridrelease(routehandle=regrid_landice, rc=rc)
1228 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1236 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1
1237 where (nint(veg_type_input_ptr) == veg_type_landice_input) mask_input_ptr = 0
1240 where (landmask_target_ptr == 1) mask_target_ptr = 1
1241 where (nint(veg_type_target_ptr) == veg_type_landice_target) mask_target_ptr = 0
1243 method=esmf_regridmethod_nearest_stod
1244 isrctermprocessing = 1
1246 print*,
"- CALL FieldRegridStore for 3d land (but no land ice) fields."
1247 call esmf_fieldregridstore(soilm_tot_input_grid, &
1248 soilm_tot_target_grid, &
1249 srcmaskvalues=(/0/), &
1250 dstmaskvalues=(/0/), &
1251 polemethod=esmf_polemethod_none, &
1252 srctermprocessing=isrctermprocessing, &
1253 unmappedaction=esmf_unmappedaction_ignore, &
1254 normtype=esmf_normtype_fracarea, &
1255 routehandle=regrid_land, &
1256 regridmethod=method, &
1257 unmappeddstlist=unmapped_ptr, rc=rc)
1258 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1261 bundle_nolandice_target = esmf_fieldbundlecreate(name=
"land no landice target", rc=rc)
1262 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1265 bundle_nolandice_input = esmf_fieldbundlecreate(name=
"land no landice input", rc=rc)
1266 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1269 call esmf_fieldbundleadd(bundle_nolandice_target, (/skin_temp_target_grid, terrain_from_input_grid,&
1270 soil_type_from_input_grid,soilm_tot_target_grid,soil_temp_target_grid/), rc=rc)
1271 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1274 call esmf_fieldbundleadd(bundle_nolandice_input, (/skin_temp_input_grid, terrain_input_grid,&
1275 soil_type_input_grid,soilm_tot_input_grid,soil_temp_input_grid/), rc=rc)
1276 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1280 if (.not. sotyp_from_climo)
then
1287 print*,
"- CALL Field_Regrid ."
1288 call esmf_fieldregrid(soil_type_input_grid, &
1289 soil_type_target_grid, &
1290 routehandle=regrid_land, &
1291 zeroregion=esmf_region_select, &
1292 termorderflag=esmf_termorder_srcseq, rc=rc)
1293 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1296 call esmf_fieldget(soil_type_target_grid, &
1297 farrayptr=soil_type_target_ptr, rc=rc)
1298 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1301 l = lbound(unmapped_ptr)
1302 u = ubound(unmapped_ptr)
1305 call
ij_to_i_j(unmapped_ptr(ij), i_target, j_target, i, j)
1306 soil_type_target_ptr(i,j) = -9999.9
1314 if (.not. vgfrc_from_climo)
then
1315 call esmf_fieldbundleadd(bundle_nolandice_target, (/veg_greenness_target_grid/), rc=rc)
1316 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1318 call esmf_fieldbundleadd(bundle_nolandice_input, (/veg_greenness_input_grid/), rc=rc)
1319 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1321 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1322 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1324 vgfrc_ind = num_fields
1327 if (.not. lai_from_climo)
then
1328 call esmf_fieldbundleadd(bundle_nolandice_target, (/lai_target_grid/), rc=rc)
1329 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1331 call esmf_fieldbundleadd(bundle_nolandice_input, (/lai_input_grid/), rc=rc)
1332 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1334 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1335 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1337 lai_ind = num_fields
1340 if (.not. minmax_vgfrc_from_climo)
then
1341 call esmf_fieldbundleadd(bundle_nolandice_target, (/max_veg_greenness_target_grid/), rc=rc)
1342 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1344 call esmf_fieldbundleadd(bundle_nolandice_input, (/max_veg_greenness_input_grid/), rc=rc)
1345 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1348 call esmf_fieldbundleadd(bundle_nolandice_target, (/min_veg_greenness_target_grid/), rc=rc)
1349 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1351 call esmf_fieldbundleadd(bundle_nolandice_input, (/min_veg_greenness_input_grid/), rc=rc)
1352 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1355 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1356 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1359 mmvg_ind = num_fields-1
1362 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1363 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1366 allocate(search_nums(num_fields))
1367 allocate(dozero(num_fields))
1369 search_nums(1:5) = (/85,7,224,85,86/)
1370 dozero(1:5) = (/.false.,.false.,.true.,.true.,.false./)
1377 if (.not. vgfrc_from_climo)
then
1378 search_nums(vgfrc_ind) = 224
1379 dozero(vgfrc_ind) = .true.
1382 if (.not. lai_from_climo)
then
1383 search_nums(lai_ind) = 229
1384 dozero(lai_ind) = .true.
1387 if (.not. minmax_vgfrc_from_climo)
then
1388 search_nums(mmvg_ind) = 227
1389 dozero(mmvg_ind) = .true.
1391 search_nums(mmvg_ind+1) = 228
1392 dozero(mmvg_ind+1) = .true.
1395 call
regrid_many(bundle_nolandice_input,bundle_nolandice_target,num_fields,regrid_land,dozero, &
1396 unmapped_ptr=unmapped_ptr)
1398 call esmf_fieldbundledestroy(bundle_nolandice_input,rc=rc)
1399 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1402 if (localpet == 0)
then
1403 allocate (veg_type_target_one_tile(i_target,j_target))
1405 allocate (veg_type_target_one_tile(0,0))
1408 do tile = 1, num_tiles_target_grid
1410 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
1411 call esmf_fieldgather(landmask_target_grid, mask_target_one_tile, rootpet=0, tile=tile, rc=rc)
1412 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1415 print*,
"- CALL FieldGather FOR TARGET VEG TYPE TILE: ", tile
1416 call esmf_fieldgather(veg_type_target_grid, veg_type_target_one_tile, 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 where(nint(veg_type_target_one_tile) == veg_type_landice_target) mask_target_one_tile = 0
1424 print*,
"- CALL FieldGather FOR SOIL TYPE TARGET GRID, TILE: ", tile
1425 call esmf_fieldgather(soil_type_target_grid, data_one_tile2, rootpet=0,tile=tile, rc=rc)
1426 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1428 if (localpet==0)
then
1429 call
search_many(num_fields,bundle_nolandice_target,tile,search_nums,localpet, &
1430 soilt_climo=data_one_tile2, mask=mask_target_one_tile)
1432 call
search_many(num_fields,bundle_nolandice_target, tile,search_nums,localpet)
1435 print*,
"- CALL FieldGather FOR TARGET GRID TOTAL SOIL MOISTURE, TILE: ", tile
1436 call esmf_fieldgather(soilm_tot_target_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1437 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1440 if (localpet == 0)
then
1441 do j = 1, lsoil_target
1442 data_one_tile = data_one_tile_3d(:,:,j)
1443 call
search(data_one_tile, mask_target_one_tile, i_target, j_target, tile, 86)
1444 data_one_tile_3d(:,:,j) = data_one_tile
1448 print*,
"- CALL FieldGather FOR TARGET GRID SOIL TEMPERATURE, TILE: ", tile
1449 call esmf_fieldgather(soil_temp_target_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1450 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1453 if (tg3_from_soil)
then
1454 print*,
"- CALL FieldScatter FOR TARGET GRID SUBSTRATE TEMPERATURE, TILE: ", tile
1455 call esmf_fieldscatter(substrate_temp_target_grid, data_one_tile_3d(:,:,lsoil_target), rootpet=0, tile=tile, rc=rc)
1456 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1460 if (.not. sotyp_from_climo)
then
1461 print*,
"- CALL FieldGather FOR SOIL TYPE TARGET GRID LAND, TILE: ",tile
1462 call esmf_fieldgather(soil_type_target_grid, data_one_tile,rootpet=0,tile=tile, rc=rc)
1463 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1466 if (localpet == 0)
then
1467 call
search(data_one_tile, mask_target_one_tile, i_target, j_target,tile,226)
1470 print*,
"- CALL FieldScatter FOR SOIL TYPE TARGET GRID, TILE: ", tile
1471 call esmf_fieldscatter(soil_type_target_grid,data_one_tile,rootpet=0,tile=tile,rc=rc)
1472 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1478 deallocate(search_nums)
1479 call esmf_fieldbundledestroy(bundle_nolandice_target,rc=rc)
1480 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1483 print*,
"- CALL FieldRegridRelease."
1484 call esmf_fieldregridrelease(routehandle=regrid_land, rc=rc)
1485 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1488 deallocate(veg_type_target_one_tile)
1490 deallocate(data_one_tile, data_one_tile2)
1491 deallocate(data_one_tile_3d)
1492 deallocate(mask_target_one_tile)
1512 veg_type_target_grid
1516 integer :: clb(3), cub(3), rc
1517 integer :: i, j, n, soil_type
1519 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
1522 real(esmf_kind_r8),
pointer :: soilm_liq_ptr(:,:,:)
1523 real(esmf_kind_r8),
pointer :: soilm_tot_ptr(:,:,:)
1524 real(esmf_kind_r8),
pointer :: soil_temp_ptr(:,:,:)
1525 real(esmf_kind_r8),
pointer :: soil_type_ptr(:,:)
1526 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
1528 print*,
"- COMPUTE LIQUID PORTION OF TOTAL SOIL MOISTURE."
1530 print*,
"- CALL FieldGet FOR TOTAL SOIL MOISTURE."
1531 call esmf_fieldget(soilm_tot_target_grid, &
1532 computationallbound=clb, &
1533 computationalubound=cub, &
1534 farrayptr=soilm_tot_ptr, rc=rc)
1535 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1538 print*,
"- CALL FieldGet FOR LIQUID SOIL MOISTURE."
1539 call esmf_fieldget(soilm_liq_target_grid, &
1540 farrayptr=soilm_liq_ptr, rc=rc)
1541 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1544 print*,
"- CALL FieldGet FOR SOIL TEMPERATURE."
1545 call esmf_fieldget(soil_temp_target_grid, &
1546 farrayptr=soil_temp_ptr, rc=rc)
1547 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1550 print*,
"- CALL FieldGet FOR VEGETATION TYPE."
1551 call esmf_fieldget(veg_type_target_grid, &
1552 farrayptr=veg_type_ptr, rc=rc)
1553 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1556 print*,
"- CALL FieldGet FOR SOIL TYPE."
1557 call esmf_fieldget(soil_type_target_grid, &
1558 farrayptr=soil_type_ptr, rc=rc)
1559 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1562 print*,
"- CALL FieldGet FOR LANDMASK."
1563 call esmf_fieldget(landmask_target_grid, &
1564 farrayptr=landmask_ptr, rc=rc)
1565 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1568 do j = clb(2), cub(2)
1569 do i = clb(1), cub(1)
1575 if (landmask_ptr(i,j) == 1 .and. nint(veg_type_ptr(i,j)) /= veg_type_landice_target)
then
1577 soil_type = nint(soil_type_ptr(i,j))
1579 do n = clb(3), cub(3)
1581 if (soil_temp_ptr(i,j,n) < (frz_h2o-0.0001))
then
1583 bx = bb_target(soil_type)
1585 if (bx .gt. blim) bx = blim
1587 fk=(((hlice/(grav*(-satpsi_target(soil_type))))* &
1588 ((soil_temp_ptr(i,j,n)-frz_h2o)/soil_temp_ptr(i,j,n)))** &
1589 (-1/bx))*maxsmc_target(soil_type)
1591 if (fk .lt. 0.02) fk = 0.02
1593 soilm_liq_ptr(i,j,n) = min( fk, soilm_tot_ptr(i,j,n) )
1601 soilm_liq_ptr(i,j,n) =
frh2o(soil_temp_ptr(i,j,n), &
1602 soilm_tot_ptr(i,j,n), soilm_liq_ptr(i,j,n), &
1603 maxsmc_target(soil_type),bb_target(soil_type), &
1604 satpsi_target(soil_type))
1608 soilm_liq_ptr(i,j,n) = soilm_tot_ptr(i,j,n)
1645 FUNCTION frh2o (TKELV,SMC,SH2O,SMCMAX,BEXP,PSIS)
1662 REAL(esmf_kind_r8) :: sh2o
1663 REAL(esmf_kind_r8) :: smc
1667 REAL(esmf_kind_r8) :: tkelv
1669 REAL,
PARAMETER :: ck = 8.0
1670 REAL,
PARAMETER :: error = 0.005
1679 IF (bexp .GT. blim) bx = blim
1688 IF (ck .NE. 0.0)
THEN
1703 IF (swl .GT. (smc-0.02)) swl = smc-0.02
1704 IF (swl .LT. 0.) swl = 0.
1710 DO WHILE ( (nlog .LT. 10) .AND. (kcount .EQ. 0) )
1713 df = log(( psis*grav/hlice ) * ( ( 1.+ck*swl )**2. ) * &
1714 ( smcmax/(smc-swl) )**bx) - log(-(tkelv-frz_h2o)/tkelv)
1715 denom = 2. * ck / ( 1.+ck*swl ) + bx / ( smc - swl )
1716 swlk = swl - df/denom
1722 IF (swlk .GT. (smc-0.02)) swlk = smc - 0.02
1723 IF (swlk .LT. 0.) swlk = 0.
1729 dswl = abs(swlk-swl)
1737 IF ( dswl .LE. error )
THEN
1763 IF (kcount .EQ. 0)
THEN
1765 fk = (((hlice/(grav*(-psis)))* &
1766 ((tkelv-frz_h2o)/tkelv))**(-1/bx))*smcmax
1768 IF (fk .LT. 0.02) fk = 0.02
1770 frh2o = min(fk, smc)
1790 maxsmc_input, maxsmc_target, &
1791 refsmc_input, refsmc_target, &
1792 wltsmc_input, wltsmc_target
1795 veg_greenness_target_grid, &
1796 veg_type_target_grid
1800 integer :: clb(3), cub(3), i, j, k, rc
1801 integer :: soilt_input, soilt_target
1802 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
1804 real(esmf_kind_r8),
pointer :: soilm_tot_ptr(:,:,:)
1805 real(esmf_kind_r8),
pointer :: soil_type_input_ptr(:,:)
1806 real(esmf_kind_r8),
pointer :: soil_type_target_ptr(:,:)
1807 real(esmf_kind_r8),
pointer :: veg_greenness_ptr(:,:)
1808 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
1809 real :: f1, fn, smcdir, smctra
1811 print*,
"- RESCALE SOIL MOISTURE FOR CHANGES IN SOIL TYPE."
1813 print*,
"- CALL FieldGet FOR TOTAL SOIL MOISTURE."
1814 call esmf_fieldget(soilm_tot_target_grid, &
1815 computationallbound=clb, &
1816 computationalubound=cub, &
1817 farrayptr=soilm_tot_ptr, rc=rc)
1818 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1821 print*,
"- CALL FieldGet FOR LAND MASK."
1822 call esmf_fieldget(landmask_target_grid, &
1823 farrayptr=landmask_ptr, rc=rc)
1824 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1827 print*,
"- CALL FieldGet FOR VEGETATION TYPE."
1828 call esmf_fieldget(veg_type_target_grid, &
1829 farrayptr=veg_type_ptr, rc=rc)
1830 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1833 print*,
"- CALL FieldGet FOR VEGETATION GREENNESS."
1834 call esmf_fieldget(veg_greenness_target_grid, &
1835 farrayptr=veg_greenness_ptr, rc=rc)
1836 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1839 print*,
"- CALL FieldGet FOR TARGET GRID SOIL TYPE."
1840 call esmf_fieldget(soil_type_target_grid, &
1841 farrayptr=soil_type_target_ptr, rc=rc)
1842 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1845 print*,
"- CALL FieldGet FOR SOIL TYPE FROM INPUT GRID."
1846 call esmf_fieldget(soil_type_from_input_grid, &
1847 farrayptr=soil_type_input_ptr, rc=rc)
1848 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1851 do j = clb(2), cub(2)
1852 do i = clb(1), cub(1)
1858 if (landmask_ptr(i,j) == 1 .and. nint(veg_type_ptr(i,j)) /= veg_type_landice_target)
then
1860 soilt_target = nint(soil_type_target_ptr(i,j))
1861 soilt_input = nint(soil_type_input_ptr(i,j))
1869 if (soilt_target /= soilt_input)
then
1874 f1=(soilm_tot_ptr(i,j,1)-drysmc_input(soilt_input)) / &
1875 (maxsmc_input(soilt_input)-drysmc_input(soilt_input))
1877 smcdir=drysmc_target(soilt_target) + f1 * &
1878 (maxsmc_target(soilt_target) - drysmc_target(soilt_target))
1884 if (soilm_tot_ptr(i,j,1) < refsmc_input(soilt_input))
then
1885 f1=(soilm_tot_ptr(i,j,1) - wltsmc_input(soilt_input)) / &
1886 (refsmc_input(soilt_input) - wltsmc_input(soilt_input))
1887 smctra=wltsmc_target(soilt_target) + f1 * &
1888 (refsmc_target(soilt_target) - wltsmc_target(soilt_target))
1890 f1=(soilm_tot_ptr(i,j,1) - refsmc_input(soilt_input)) / &
1891 (maxsmc_input(soilt_input) - refsmc_input(soilt_input))
1892 smctra=refsmc_target(soilt_target) + f1 * &
1893 (maxsmc_target(soilt_target) - refsmc_target(soilt_target))
1900 soilm_tot_ptr(i,j,1) = ((1.0 - veg_greenness_ptr(i,j)) * smcdir) + &
1901 (veg_greenness_ptr(i,j) * smctra)
1911 if (soilm_tot_ptr(i,j,k) < refsmc_input(soilt_input))
then
1912 fn = (soilm_tot_ptr(i,j,k) - wltsmc_input(soilt_input)) / &
1913 (refsmc_input(soilt_input) - wltsmc_input(soilt_input))
1914 soilm_tot_ptr(i,j,k) = wltsmc_target(soilt_target) + fn * &
1915 (refsmc_target(soilt_target) - wltsmc_target(soilt_target))
1917 fn = (soilm_tot_ptr(i,j,k) - refsmc_input(soilt_input)) / &
1918 (maxsmc_input(soilt_input) - refsmc_input(soilt_input))
1919 soilm_tot_ptr(i,j,k) = refsmc_target(soilt_target) + fn * &
1920 (maxsmc_target(soilt_target) - refsmc_target(soilt_target))
1930 soilm_tot_ptr(i,j,1)=min(soilm_tot_ptr(i,j,1),maxsmc_target(soilt_target))
1931 soilm_tot_ptr(i,j,1)=max(drysmc_target(soilt_target),soilm_tot_ptr(i,j,1))
1934 soilm_tot_ptr(i,j,k)=min(soilm_tot_ptr(i,j,k),maxsmc_target(soilt_target))
1935 soilm_tot_ptr(i,j,k)=max(wltsmc_target(soilt_target),soilm_tot_ptr(i,j,k))
1953 use model_grid, only : landmask_target_grid, &
1960 integer :: clb(3), cub(3), i, j, k, rc
1961 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
1963 real,
parameter :: lapse_rate = 6.5e-03
1964 real :: terrain_diff
1965 real(esmf_kind_r8),
pointer :: terrain_input_ptr(:,:)
1966 real(esmf_kind_r8),
pointer :: terrain_target_ptr(:,:)
1967 real(esmf_kind_r8),
pointer :: veg_type_target_ptr(:,:)
1968 real(esmf_kind_r8),
pointer :: soil_temp_target_ptr(:,:,:)
1970 print*,
"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK."
1971 call esmf_fieldget(landmask_target_grid, &
1972 farrayptr=landmask_ptr, rc=rc)
1973 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1976 print*,
"- CALL FieldGet FOR TARGET GRID VEGETATION TYPE."
1977 call esmf_fieldget(veg_type_target_grid, &
1978 farrayptr=veg_type_target_ptr, rc=rc)
1979 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1982 print*,
"- CALL FieldGet FOR TARGET GRID TERRAIN."
1983 call esmf_fieldget(terrain_target_grid, &
1984 farrayptr=terrain_target_ptr, rc=rc)
1985 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1988 print*,
"- CALL FieldGet FOR TERRAIN INTERP TO TARGET GRID."
1989 call esmf_fieldget(terrain_from_input_grid, &
1990 farrayptr=terrain_input_ptr, rc=rc)
1991 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1994 print*,
"- CALL FieldGet FOR SOIL TEMP TARGET GRID."
1995 call esmf_fieldget(soil_temp_target_grid, &
1996 computationallbound=clb, &
1997 computationalubound=cub, &
1998 farrayptr=soil_temp_target_ptr, rc=rc)
1999 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2002 do j = clb(2), cub(2)
2003 do i = clb(1), cub(1)
2004 if (landmask_ptr(i,j) == 1)
then
2005 terrain_diff = abs(terrain_input_ptr(i,j) - terrain_target_ptr(i,j))
2006 if (terrain_diff > 100.0)
then
2007 do k = clb(3), cub(3)
2008 soil_temp_target_ptr(i,j,k) = soil_temp_target_ptr(i,j,k) + &
2009 ((terrain_input_ptr(i,j) - terrain_target_ptr(i,j)) * lapse_rate)
2010 if (nint(veg_type_target_ptr(i,j)) == veg_type_landice_target)
then
2011 soil_temp_target_ptr(i,j,k) = min(soil_temp_target_ptr(i,j,k), 273.16)
2028 use model_grid, only : lsoil_target, i_input, j_input, input_grid
2030 soilm_liq_input_grid, soilm_tot_input_grid
2032 integer,
intent(in) :: localpet
2033 character(len=500) :: msg
2034 character(len=2) :: lsoil_input_ch, lsoil_target_ch
2036 real(esmf_kind_r8) :: tmp(i_input,j_input), &
2037 data_one_tile(i_input,j_input,lsoil_input), &
2038 tmp3d(i_input,j_input,lsoil_target)
2039 if (lsoil_input == 9 .and. lsoil_target == 4)
then
2040 print*,
"CONVERTING FROM 9 INPUT SOIL LEVELS TO 4 TARGET SOIL LEVELS"
2041 call esmf_fieldgather(soil_temp_input_grid, data_one_tile, rootpet=0, tile=1, rc=rc)
2042 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2045 call esmf_fielddestroy(soil_temp_input_grid,rc=rc)
2046 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
2047 typekind=esmf_typekind_r8, &
2048 staggerloc=esmf_staggerloc_center, &
2049 ungriddedlbound=(/1/), &
2050 ungriddedubound=(/lsoil_target/), rc=rc)
2053 tmp3d(:,:,1)= (data_one_tile(:,:,1) + data_one_tile(:,:,2))/2.0 * 0.1 + &
2054 (data_one_tile(:,:,2) + data_one_tile(:,:,3))/2.0 * 0.3 + &
2055 (data_one_tile(:,:,3) + data_one_tile(:,:,4))/2.0 * 0.6
2056 tmp = (data_one_tile(:,:,6) - data_one_tile(:,:,5)) / 30.0 * 10.0 + data_one_tile(:,:,5)
2057 tmp3d(:,:,2)= (data_one_tile(:,:,4) + data_one_tile(:,:,5)) / 2.0 * 0.75 + &
2058 (data_one_tile(:,:,5) + tmp) / 2.0 * 0.25
2059 tmp3d(:,:,3)= (tmp + data_one_tile(:,:,6)) /2.0 * (1.0/3.0) + &
2060 (data_one_tile(:,:,6) + data_one_tile(:,:,7)) / 2.0 * (2.0/3.0)
2061 tmp = (data_one_tile(:,:,9) - data_one_tile(:,:,9)) / 140.0 * 40.0 + data_one_tile(:,:,8)
2062 tmp3d(:,:,4)= (data_one_tile(:,:,7) + data_one_tile(:,:,8)) / 2.0 * 0.6 + &
2063 (data_one_tile(:,:,8) + tmp) / 2.0 * 0.4
2066 call esmf_fieldscatter(soil_temp_input_grid, tmp3d, rootpet=0, rc=rc)
2067 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2070 call esmf_fieldgather(soilm_tot_input_grid, data_one_tile, rootpet=0, tile=1, rc=rc)
2071 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2074 call esmf_fielddestroy(soilm_tot_input_grid,rc=rc)
2075 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
2076 typekind=esmf_typekind_r8, &
2077 staggerloc=esmf_staggerloc_center, &
2078 ungriddedlbound=(/1/), &
2079 ungriddedubound=(/lsoil_target/), rc=rc)
2081 if(localpet==0)
then
2082 tmp3d(:,:,1)= (data_one_tile(:,:,1) + data_one_tile(:,:,2))/2.0 * 0.1 + &
2083 (data_one_tile(:,:,2) + data_one_tile(:,:,3))/2.0 * 0.3 + &
2084 (data_one_tile(:,:,3) + data_one_tile(:,:,4))/2.0 * 0.6
2085 tmp = (data_one_tile(:,:,6) - data_one_tile(:,:,5)) / 30.0 * 10.0 + data_one_tile(:,:,5)
2086 tmp3d(:,:,2)= (data_one_tile(:,:,4) + data_one_tile(:,:,5)) / 2.0 * 0.75 + &
2087 (data_one_tile(:,:,5) + tmp) / 2.0 * 0.25
2088 tmp3d(:,:,3)= (tmp + data_one_tile(:,:,6)) /2.0 * (1.0/3.0) + &
2089 (data_one_tile(:,:,6) + data_one_tile(:,:,7)) / 2.0 * (2.0/3.0)
2090 tmp = (data_one_tile(:,:,9) - data_one_tile(:,:,9)) / 140.0 * 40.0 + data_one_tile(:,:,8)
2091 tmp3d(:,:,4)= (data_one_tile(:,:,7) + data_one_tile(:,:,8)) / 2.0 * 0.6 + &
2092 (data_one_tile(:,:,8) + tmp) / 2.0 * 0.4
2095 call esmf_fieldscatter(soilm_tot_input_grid, tmp3d, rootpet=0, rc=rc)
2096 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2099 call esmf_fieldgather(soilm_liq_input_grid, data_one_tile, rootpet=0, tile=1, rc=rc)
2100 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2103 call esmf_fielddestroy(soilm_liq_input_grid,rc=rc)
2104 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
2105 typekind=esmf_typekind_r8, &
2106 staggerloc=esmf_staggerloc_center, &
2107 ungriddedlbound=(/1/), &
2108 ungriddedubound=(/lsoil_target/), rc=rc)
2109 if(localpet==0)
then
2110 tmp3d(:,:,1)= (data_one_tile(:,:,1) + data_one_tile(:,:,2))/2.0 * 0.1 + &
2111 (data_one_tile(:,:,2) + data_one_tile(:,:,3))/2.0 * 0.3 + &
2112 (data_one_tile(:,:,3) + data_one_tile(:,:,4))/2.0 * 0.6
2113 tmp = (data_one_tile(:,:,6) - data_one_tile(:,:,5)) / 30.0 * 10.0 + data_one_tile(:,:,5)
2114 tmp3d(:,:,2)= (data_one_tile(:,:,4) + data_one_tile(:,:,5)) / 2.0 * 0.75 + &
2115 (data_one_tile(:,:,5) + tmp) / 2.0 * 0.25
2116 tmp3d(:,:,3)= (tmp + data_one_tile(:,:,6)) /2.0 * (1.0/3.0) + &
2117 (data_one_tile(:,:,6) + data_one_tile(:,:,7)) / 2.0 * (2.0/3.0)
2118 tmp = (data_one_tile(:,:,9) - data_one_tile(:,:,9)) / 140.0 * 40.0 + data_one_tile(:,:,8)
2119 tmp3d(:,:,4)= (data_one_tile(:,:,7) + data_one_tile(:,:,8)) / 2.0 * 0.6 + &
2120 (data_one_tile(:,:,8) + tmp) / 2.0 * 0.4
2123 call esmf_fieldscatter(soilm_liq_input_grid, tmp3d, rootpet=0, rc=rc)
2124 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2127 elseif (lsoil_input /= lsoil_target)
then
2129 write(lsoil_input_ch,
'(i2)') lsoil_input
2130 write(lsoil_target_ch,
'(i2)') lsoil_target
2131 msg=
"NUMBER OF SOIL LEVELS IN INPUT " // lsoil_input_ch //
" AND OUTPUT " &
2132 // lsoil_target_ch //
" MUST EITHER BE EQUAL OR 9 AND 4 RESPECTIVELY."
2150 integer :: clb(2), cub(2), i, j, rc
2151 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
2154 real(esmf_kind_r8),
pointer :: data_ptr(:,:)
2155 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
2157 data z0_igbp /1.089, 2.653, 0.854, 0.826, 0.800, 0.050, &
2158 0.030, 0.856, 0.856, 0.150, 0.040, 0.130, &
2159 1.000, 0.250, 0.011, 0.011, 0.001, 0.076, &
2162 print*,
"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK."
2163 call esmf_fieldget(landmask_target_grid, &
2164 computationallbound=clb, &
2165 computationalubound=cub, &
2166 farrayptr=landmask_ptr, rc=rc)
2167 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2170 print*,
"- CALL FieldGet FOR TARGET GRID VEGETATION TYPE."
2171 call esmf_fieldget(veg_type_target_grid, &
2172 farrayptr=veg_type_ptr, rc=rc)
2173 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2176 print*,
"- CALL FieldGet FOR TARGET GRID Z0."
2177 call esmf_fieldget(z0_target_grid, &
2178 farrayptr=data_ptr, rc=rc)
2179 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2182 do j = clb(2), cub(2)
2183 do i = clb(1), cub(1)
2184 if (landmask_ptr(i,j) == 2)
then
2186 elseif (landmask_ptr(i,j) == 1)
then
2187 data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0
2202 alvwf_target_grid, &
2203 alnsf_target_grid, &
2204 alnwf_target_grid, &
2205 facsf_target_grid, &
2206 facwf_target_grid, &
2207 mxsno_albedo_target_grid, &
2208 max_veg_greenness_target_grid, &
2209 min_veg_greenness_target_grid, &
2210 slope_type_target_grid, &
2211 soil_type_target_grid, &
2212 substrate_temp_target_grid, &
2213 veg_greenness_target_grid, &
2214 veg_type_target_grid
2218 integer :: clb(2), cub(2), i, j, rc
2219 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
2221 real(esmf_kind_r8),
pointer :: data_ptr(:,:)
2222 real(esmf_kind_r8),
pointer :: data3d_ptr(:,:,:)
2223 real(esmf_kind_r8),
pointer :: soilmt_ptr(:,:,:)
2224 real(esmf_kind_r8),
pointer :: soilml_ptr(:,:,:)
2225 real(esmf_kind_r8),
pointer :: veg_greenness_ptr(:,:)
2226 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
2227 real(esmf_kind_r8),
pointer :: seaice_skint_ptr(:,:)
2228 real(esmf_kind_r8),
pointer :: skint_ptr(:,:)
2229 real(esmf_kind_r8),
pointer :: fice_ptr(:,:)
2230 real(esmf_kind_r8),
pointer :: hice_ptr(:,:)
2232 print*,
"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK."
2233 call esmf_fieldget(landmask_target_grid, &
2234 computationallbound=clb, &
2235 computationalubound=cub, &
2236 farrayptr=landmask_ptr, rc=rc)
2237 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2240 print*,
"- SET NON-LAND FLAG FOR TARGET GRID SLOPE TYPE."
2241 call esmf_fieldget(slope_type_target_grid, &
2242 farrayptr=data_ptr, rc=rc)
2243 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2246 do j = clb(2), cub(2)
2247 do i = clb(1), cub(1)
2248 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2252 print*,
"- SET NON-LAND FLAG FOR TARGET GRID SOIL TYPE."
2253 call esmf_fieldget(soil_type_target_grid, &
2254 farrayptr=data_ptr, rc=rc)
2255 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2258 do j = clb(2), cub(2)
2259 do i = clb(1), cub(1)
2260 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2264 print*,
"- SET NON-LAND FLAG FOR TARGET GRID VEGETATION TYPE."
2265 call esmf_fieldget(veg_type_target_grid, &
2266 farrayptr=veg_type_ptr, rc=rc)
2267 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2270 do j = clb(2), cub(2)
2271 do i = clb(1), cub(1)
2272 if (landmask_ptr(i,j) /= 1) veg_type_ptr(i,j) = 0.0
2276 print*,
"- SET TARGET GRID ALVSF AT NON-LAND."
2277 call esmf_fieldget(alvsf_target_grid, &
2278 farrayptr=data_ptr, rc=rc)
2279 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2282 do j = clb(2), cub(2)
2283 do i = clb(1), cub(1)
2284 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06
2288 print*,
"- SET TARGET GRID ALVWF AT NON-LAND."
2289 call esmf_fieldget(alvwf_target_grid, &
2290 farrayptr=data_ptr, rc=rc)
2291 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2294 do j = clb(2), cub(2)
2295 do i = clb(1), cub(1)
2296 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06
2300 print*,
"- SET TARGET GRID ALNSF AT NON-LAND."
2301 call esmf_fieldget(alnsf_target_grid, &
2302 farrayptr=data_ptr, rc=rc)
2303 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2306 do j = clb(2), cub(2)
2307 do i = clb(1), cub(1)
2308 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06
2312 print*,
"- SET TARGET GRID ALNWF AT NON-LAND."
2313 call esmf_fieldget(alnwf_target_grid, &
2314 farrayptr=data_ptr, rc=rc)
2315 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2318 do j = clb(2), cub(2)
2319 do i = clb(1), cub(1)
2320 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06
2324 print*,
"- SET NON-LAND FLAG FOR TARGET GRID FACSF."
2325 call esmf_fieldget(facsf_target_grid, &
2326 farrayptr=data_ptr, rc=rc)
2327 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2330 do j = clb(2), cub(2)
2331 do i = clb(1), cub(1)
2332 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2336 print*,
"- SET NON-LAND FLAG FOR TARGET GRID FACSF."
2337 call esmf_fieldget(facwf_target_grid, &
2338 farrayptr=data_ptr, rc=rc)
2339 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2342 do j = clb(2), cub(2)
2343 do i = clb(1), cub(1)
2344 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2348 print*,
"- SET NON-LAND FLAG FOR TARGET GRID MAXIMUM GREENNESS."
2349 call esmf_fieldget(max_veg_greenness_target_grid, &
2350 farrayptr=data_ptr, rc=rc)
2351 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2354 do j = clb(2), cub(2)
2355 do i = clb(1), cub(1)
2356 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2360 print*,
"- SET NON-LAND FLAG FOR TARGET GRID MINIMUM GREENNESS."
2361 call esmf_fieldget(min_veg_greenness_target_grid, &
2362 farrayptr=data_ptr, rc=rc)
2363 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2366 do j = clb(2), cub(2)
2367 do i = clb(1), cub(1)
2368 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2372 print*,
"- SET NON-LAND FLAG FOR TARGET GRID VEGETATION GREENNESS."
2373 call esmf_fieldget(veg_greenness_target_grid, &
2374 farrayptr=veg_greenness_ptr, rc=rc)
2375 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2378 do j = clb(2), cub(2)
2379 do i = clb(1), cub(1)
2380 if (landmask_ptr(i,j) /= 1) veg_greenness_ptr(i,j) = 0.0
2384 print*,
"- SET NON-LAND FLAG FOR TARGET GRID MAX SNOW ALBEDO."
2385 call esmf_fieldget(mxsno_albedo_target_grid, &
2386 farrayptr=data_ptr, rc=rc)
2387 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2390 do j = clb(2), cub(2)
2391 do i = clb(1), cub(1)
2392 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2396 print*,
"- ZERO OUT TARGET GRID CANOPY MOISTURE CONTENT WHERE NO PLANTS."
2397 call esmf_fieldget(canopy_mc_target_grid, &
2398 farrayptr=data_ptr, rc=rc)
2399 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2402 do j = clb(2), cub(2)
2403 do i = clb(1), cub(1)
2404 if (veg_greenness_ptr(i,j) <= 0.01) data_ptr(i,j) = 0.0
2408 print*,
"- CALL FieldGet FOR TARGET GRID ICE SKIN TEMP."
2409 call esmf_fieldget(seaice_skin_temp_target_grid, &
2410 farrayptr=seaice_skint_ptr, rc=rc)
2411 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2414 print*,
"- SET TARGET GRID SKIN TEMP AT ICE POINTS."
2415 call esmf_fieldget(skin_temp_target_grid, &
2416 farrayptr=skint_ptr, rc=rc)
2417 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2420 print*,
"- CALL FieldGet FOR TARGET GRID SEA ICE FRACTION."
2421 call esmf_fieldget(seaice_fract_target_grid, &
2422 farrayptr=fice_ptr, rc=rc)
2423 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2426 print*,
"- SET TARGET GRID SEA ICE DEPTH TO ZERO AT NON-ICE POINTS."
2427 call esmf_fieldget(seaice_depth_target_grid, &
2428 farrayptr=hice_ptr, rc=rc)
2429 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2432 do j = clb(2), cub(2)
2433 do i = clb(1), cub(1)
2434 if (fice_ptr(i,j) > 0.0)
then
2435 skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + &
2436 ( (1.0 - fice_ptr(i,j)) * frz_ice )
2438 seaice_skint_ptr(i,j) = skint_ptr(i,j)
2444 print*,
"- SET TARGET GRID SUBSTRATE TEMP AT ICE."
2445 call esmf_fieldget(substrate_temp_target_grid, &
2446 farrayptr=data_ptr, rc=rc)
2447 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2450 do j = clb(2), cub(2)
2451 do i = clb(1), cub(1)
2452 if (landmask_ptr(i,j) == 2)
then
2453 data_ptr(i,j) = frz_ice
2454 elseif (landmask_ptr(i,j) == 0)
then
2455 data_ptr(i,j) = skint_ptr(i,j)
2460 print*,
"- ZERO OUT TARGET GRID SNOW DEPTH AT OPEN WATER."
2461 call esmf_fieldget(snow_depth_target_grid, &
2462 farrayptr=data_ptr, rc=rc)
2463 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2466 do j = clb(2), cub(2)
2467 do i = clb(1), cub(1)
2468 if (landmask_ptr(i,j) == 0)
then
2474 print*,
"- ZERO OUT TARGET GRID SNOW LIQ AT OPEN WATER."
2475 call esmf_fieldget(snow_liq_equiv_target_grid, &
2476 farrayptr=data_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) == 0)
then
2488 print*,
"- SET NON-LAND FLAG VALUE FOR TARGET GRID TOTAL SOIL MOISTURE."
2489 call esmf_fieldget(soilm_tot_target_grid, &
2490 farrayptr=soilmt_ptr, rc=rc)
2491 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2494 print*,
"- SET NON-LAND FLAG VALUE FOR TARGET GRID LIQUID SOIL MOISTURE."
2495 call esmf_fieldget(soilm_liq_target_grid, &
2496 farrayptr=soilml_ptr, rc=rc)
2497 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2500 do j = clb(2), cub(2)
2501 do i = clb(1), cub(1)
2502 if (landmask_ptr(i,j) == 2 .or. landmask_ptr(i,j) == 0 .or. &
2503 nint(veg_type_ptr(i,j)) == veg_type_landice_target)
then
2504 soilmt_ptr(i,j,:) = 1.0
2505 soilml_ptr(i,j,:) = 1.0
2510 print*,
"- SET OPEN WATER FLAG FOR TARGET GRID SOIL TEMPERATURE."
2511 call esmf_fieldget(soil_temp_target_grid, &
2512 farrayptr=data3d_ptr, rc=rc)
2513 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2516 do j = clb(2), cub(2)
2517 do i = clb(1), cub(1)
2518 if (landmask_ptr(i,j) == 0)
then
2519 data3d_ptr(i,j,:) = skint_ptr(i,j)
2538 integer(esmf_kind_i8),
pointer :: mask_ptr(:,:)
2540 integer,
PARAMETER :: num_nst_fields_minus2 = 16
2541 integer,
PARAMETER :: xz_fill = 30.0
2542 integer,
PARAMETER :: nst_fill = 0.0
2544 real(esmf_kind_r8),
pointer :: data_ptr(:,:)
2545 real(esmf_kind_r8),
pointer :: skint_ptr(:,:)
2547 type(esmf_field
) :: temp_field
2548 type(esmf_fieldbundle
) :: nst_bundle
2550 print*,
"- CALL FieldGet FOR TARGET GRID LANDMASK."
2551 call esmf_fieldget(landmask_target_grid, &
2552 farrayptr=mask_ptr, rc=rc)
2553 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2556 nst_bundle = esmf_fieldbundlecreate(name=
"nst_bundle", rc=rc)
2557 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2560 call esmf_fieldbundleadd(nst_bundle, (/c_d_target_grid,c_0_target_grid,d_conv_target_grid, &
2561 dt_cool_target_grid,ifd_target_grid,qrain_target_grid,&
2562 w_d_target_grid,w_0_target_grid,xs_target_grid,xt_target_grid,&
2563 xu_target_grid,xv_target_grid,xtts_target_grid,xzts_target_grid, &
2564 z_c_target_grid, zm_target_grid/), rc=rc)
2565 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2568 print*,
"- CALL FieldGet FOR TREF."
2569 call esmf_fieldget(tref_target_grid, &
2570 farrayptr=data_ptr, rc=rc)
2571 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2574 print*,
"- CALL FieldGet FOR SKIN T."
2575 call esmf_fieldget(skin_temp_target_grid, &
2576 farrayptr=skint_ptr, rc=rc)
2577 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2580 where(mask_ptr /= 0) data_ptr = skint_ptr
2584 print*,
"- CALL FieldGet FOR XZ."
2585 call esmf_fieldget(xz_target_grid, &
2586 farrayptr=data_ptr, rc=rc)
2587 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2590 where(mask_ptr /= 0) data_ptr = xz_fill
2592 do i = 1,num_nst_fields_minus2
2594 call esmf_fieldbundleget(nst_bundle,i,temp_field,rc=rc)
2595 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2598 call esmf_fieldget(temp_field,farrayptr=data_ptr,rc=rc)
2599 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2602 where(mask_ptr /= 0) data_ptr = nst_fill
2606 call esmf_fieldbundledestroy(nst_bundle,rc=rc)
2607 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2617 use model_grid, only : target_grid, lsoil_target
2623 real(esmf_kind_r8),
pointer :: target_ptr(:,:), target_ptr_3d(:,:,:)
2624 real :: init_val = -999.9
2626 print*,
"- CALL FieldCreate FOR TARGET GRID T2M."
2627 t2m_target_grid = esmf_fieldcreate(target_grid, &
2628 typekind=esmf_typekind_r8, &
2629 name=
"t2m_target_grid", &
2630 staggerloc=esmf_staggerloc_center, rc=rc)
2631 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2634 print*,
"- INITIALIZE TARGET grid t2m."
2635 call esmf_fieldget(t2m_target_grid, &
2636 farrayptr=target_ptr, rc=rc)
2637 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2640 target_ptr = init_val
2642 print*,
"- CALL FieldCreate FOR TARGET GRID Q2M."
2643 q2m_target_grid = esmf_fieldcreate(target_grid, &
2644 typekind=esmf_typekind_r8, &
2645 name=
"q2m_target_grid", &
2646 staggerloc=esmf_staggerloc_center, rc=rc)
2647 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2650 print*,
"- INITIALIZE TARGET grid q2m."
2651 call esmf_fieldget(q2m_target_grid, &
2652 farrayptr=target_ptr, rc=rc)
2653 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2656 target_ptr = init_val
2658 print*,
"- CALL FieldCreate FOR TARGET GRID TPRCP."
2659 tprcp_target_grid = esmf_fieldcreate(target_grid, &
2660 typekind=esmf_typekind_r8, &
2661 name=
"tprcp_target_grid", &
2662 staggerloc=esmf_staggerloc_center, rc=rc)
2663 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2666 print*,
"- INITIALIZE TARGET grid tprcp."
2667 call esmf_fieldget(tprcp_target_grid, &
2668 farrayptr=target_ptr, rc=rc)
2669 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2672 target_ptr = init_val
2674 print*,
"- CALL FieldCreate FOR TARGET GRID F10M."
2675 f10m_target_grid = esmf_fieldcreate(target_grid, &
2676 typekind=esmf_typekind_r8, &
2677 name=
"f10m_target_grid", &
2678 staggerloc=esmf_staggerloc_center, rc=rc)
2679 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2682 print*,
"- INITIALIZE TARGET grid f10m."
2683 call esmf_fieldget(f10m_target_grid, &
2684 farrayptr=target_ptr, rc=rc)
2685 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2688 target_ptr = init_val
2690 print*,
"- CALL FieldCreate FOR TARGET GRID FFMM."
2691 ffmm_target_grid = esmf_fieldcreate(target_grid, &
2692 typekind=esmf_typekind_r8, &
2693 name=
"ffmm_target_grid", &
2694 staggerloc=esmf_staggerloc_center, rc=rc)
2695 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2698 print*,
"- INITIALIZE TARGET grid ffmm."
2699 call esmf_fieldget(ffmm_target_grid, &
2700 farrayptr=target_ptr, rc=rc)
2701 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2704 target_ptr = init_val
2706 print*,
"- CALL FieldCreate FOR TARGET GRID USTAR."
2707 ustar_target_grid = esmf_fieldcreate(target_grid, &
2708 typekind=esmf_typekind_r8, &
2709 name=
"ustar_target_grid", &
2710 staggerloc=esmf_staggerloc_center, rc=rc)
2711 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2714 print*,
"- INITIALIZE TARGET grid ustar."
2715 call esmf_fieldget(ustar_target_grid, &
2716 farrayptr=target_ptr, rc=rc)
2717 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2720 target_ptr = init_val
2722 print*,
"- CALL FieldCreate FOR TARGET GRID SNOW LIQ EQUIV."
2723 snow_liq_equiv_target_grid = esmf_fieldcreate(target_grid, &
2724 typekind=esmf_typekind_r8, &
2725 name=
"snow_liq_equiv_target_grid", &
2726 staggerloc=esmf_staggerloc_center, rc=rc)
2727 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2730 print*,
"- INITIALIZE TARGET grid snow liq equiv."
2731 call esmf_fieldget(snow_liq_equiv_target_grid, &
2732 farrayptr=target_ptr, rc=rc)
2733 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2736 target_ptr = init_val
2738 print*,
"- CALL FieldCreate FOR TARGET GRID SNOW DEPTH."
2739 snow_depth_target_grid = esmf_fieldcreate(target_grid, &
2740 typekind=esmf_typekind_r8, &
2741 name=
"snow_depth_target_grid", &
2742 staggerloc=esmf_staggerloc_center, rc=rc)
2743 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2746 print*,
"- INITIALIZE TARGET grid snow depth."
2747 call esmf_fieldget(snow_depth_target_grid, &
2748 farrayptr=target_ptr, rc=rc)
2749 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2752 target_ptr = init_val
2754 print*,
"- CALL FieldCreate FOR TARGET GRID SEA ICE FRACTION."
2755 seaice_fract_target_grid = esmf_fieldcreate(target_grid, &
2756 typekind=esmf_typekind_r8, &
2757 name=
"seaice_fract_target_grid", &
2758 staggerloc=esmf_staggerloc_center, rc=rc)
2759 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2762 print*,
"- INITIALIZE TARGET grid sea ice fraction."
2763 call esmf_fieldget(seaice_fract_target_grid, &
2764 farrayptr=target_ptr, rc=rc)
2765 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2768 target_ptr = init_val
2770 print*,
"- CALL FieldCreate FOR TARGET GRID SEA ICE DEPTH."
2771 seaice_depth_target_grid = esmf_fieldcreate(target_grid, &
2772 typekind=esmf_typekind_r8, &
2773 name=
"seaice_depth_target_grid", &
2774 staggerloc=esmf_staggerloc_center, rc=rc)
2775 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2778 print*,
"- INITIALIZE TARGET sea ice depth."
2779 call esmf_fieldget(seaice_depth_target_grid, &
2780 farrayptr=target_ptr, rc=rc)
2781 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2784 target_ptr = init_val
2786 print*,
"- CALL FieldCreate FOR TARGET GRID SEA ICE SKIN TEMP."
2787 seaice_skin_temp_target_grid = esmf_fieldcreate(target_grid, &
2788 typekind=esmf_typekind_r8, &
2789 name=
"seaice_skin_temp_target_grid", &
2790 staggerloc=esmf_staggerloc_center, rc=rc)
2791 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2794 print*,
"- INITIALIZE TARGET sea ice skin temp."
2795 call esmf_fieldget(seaice_skin_temp_target_grid, &
2796 farrayptr=target_ptr, rc=rc)
2797 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2800 target_ptr = init_val
2802 print*,
"- CALL FieldCreate FOR TARGET GRID SRFLAG."
2803 srflag_target_grid = esmf_fieldcreate(target_grid, &
2804 typekind=esmf_typekind_r8, &
2805 name=
"srflag_target_grid", &
2806 staggerloc=esmf_staggerloc_center, rc=rc)
2807 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2810 print*,
"- INITIALIZE TARGET srflag."
2811 call esmf_fieldget(srflag_target_grid, &
2812 farrayptr=target_ptr, rc=rc)
2813 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2816 target_ptr = init_val
2818 print*,
"- CALL FieldCreate FOR TARGET GRID SKIN TEMPERATURE."
2819 skin_temp_target_grid = esmf_fieldcreate(target_grid, &
2820 typekind=esmf_typekind_r8, &
2821 name=
"skin_temp_target_grid", &
2822 staggerloc=esmf_staggerloc_center, rc=rc)
2823 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2826 print*,
"- INITIALIZE TARGET grid skin temp."
2827 call esmf_fieldget(skin_temp_target_grid, &
2828 farrayptr=target_ptr, rc=rc)
2829 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2832 target_ptr = init_val
2834 print*,
"- CALL FieldCreate FOR TARGET GRID CANOPY MOISTURE CONTENT."
2835 canopy_mc_target_grid = esmf_fieldcreate(target_grid, &
2836 typekind=esmf_typekind_r8, &
2837 name=
"canopy_mc_target_grid", &
2838 staggerloc=esmf_staggerloc_center, rc=rc)
2839 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2842 print*,
"- INITIALIZE TARGET grid canopy moisture."
2843 call esmf_fieldget(canopy_mc_target_grid, &
2844 farrayptr=target_ptr, rc=rc)
2845 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2848 target_ptr = init_val
2850 print*,
"- CALL FieldCreate FOR TARGET GRID LEAF AREA INDEX."
2851 lai_target_grid = esmf_fieldcreate(target_grid, &
2852 typekind=esmf_typekind_r8, &
2853 name=
"lai_target_grid",&
2854 staggerloc=esmf_staggerloc_center, rc=rc)
2855 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2858 print*,
"- INITIALIZE TARGET leaf area index."
2859 call esmf_fieldget(lai_target_grid, &
2860 farrayptr=target_ptr, rc=rc)
2861 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2864 target_ptr = init_val
2866 print*,
"- CALL FieldCreate FOR TARGET GRID Z0."
2867 z0_target_grid = esmf_fieldcreate(target_grid, &
2868 typekind=esmf_typekind_r8, &
2869 name=
"z0_target_grid", &
2870 staggerloc=esmf_staggerloc_center, rc=rc)
2871 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2874 print*,
"- INITIALIZE TARGET grid z0."
2875 call esmf_fieldget(z0_target_grid, &
2876 farrayptr=target_ptr, rc=rc)
2877 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2880 target_ptr = init_val
2882 print*,
"- CALL FieldCreate FOR INTERPOLATED TARGET GRID TERRAIN."
2883 terrain_from_input_grid = esmf_fieldcreate(target_grid, &
2884 typekind=esmf_typekind_r8, &
2885 name=
"terrain_from_input_grid", &
2886 staggerloc=esmf_staggerloc_center, rc=rc)
2887 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2890 print*,
"- INITIALIZE TARGET grid interpolated terrain."
2891 call esmf_fieldget(terrain_from_input_grid, &
2892 farrayptr=target_ptr, rc=rc)
2893 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2896 target_ptr = init_val
2898 print*,
"- CALL FieldCreate FOR INTERPOLATED TARGET GRID SOIL TYPE."
2899 soil_type_from_input_grid = esmf_fieldcreate(target_grid, &
2900 typekind=esmf_typekind_r8, &
2901 staggerloc=esmf_staggerloc_center, &
2902 name=
"soil_type_from_input_grid", rc=rc)
2903 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2906 print*,
"- INITIALIZE TARGET grid soil type"
2907 call esmf_fieldget(soil_type_from_input_grid, &
2908 farrayptr=target_ptr, rc=rc)
2909 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2912 target_ptr = init_val
2914 print*,
"- CALL FieldCreate FOR TARGET GRID SOIL TEMPERATURE."
2915 soil_temp_target_grid = esmf_fieldcreate(target_grid, &
2916 typekind=esmf_typekind_r8, &
2917 staggerloc=esmf_staggerloc_center, &
2918 name=
"soil_temp_target_grid", &
2919 ungriddedlbound=(/1/), &
2920 ungriddedubound=(/lsoil_target/), rc=rc)
2921 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2924 print*,
"- INITIALIZE TARGET grid soil temp"
2925 call esmf_fieldget(soil_temp_target_grid, &
2926 farrayptr=target_ptr_3d, rc=rc)
2927 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2930 target_ptr_3d = init_val
2932 print*,
"- CALL FieldCreate FOR TARGET GRID TOTAL SOIL MOISTURE."
2933 soilm_tot_target_grid = esmf_fieldcreate(target_grid, &
2934 typekind=esmf_typekind_r8, &
2935 staggerloc=esmf_staggerloc_center, &
2936 name=
"soilm_tot_target_grid", &
2937 ungriddedlbound=(/1/), &
2938 ungriddedubound=(/lsoil_target/), rc=rc)
2939 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2942 print*,
"- INITIALIZE TARGET grid soil moist"
2943 call esmf_fieldget(soilm_tot_target_grid, &
2944 farrayptr=target_ptr_3d, rc=rc)
2945 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2948 target_ptr_3d = init_val
2950 print*,
"- CALL FieldCreate FOR TARGET GRID LIQUID SOIL MOISTURE."
2951 soilm_liq_target_grid = esmf_fieldcreate(target_grid, &
2952 typekind=esmf_typekind_r8, &
2953 staggerloc=esmf_staggerloc_center, &
2954 name=
"soilm_liq_target_grid", &
2955 ungriddedlbound=(/1/), &
2956 ungriddedubound=(/lsoil_target/), rc=rc)
2957 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2960 print*,
"- INITIALIZE TARGET grid soil liq"
2961 call esmf_fieldget(soilm_liq_target_grid, &
2962 farrayptr=target_ptr_3d, rc=rc)
2963 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2966 target_ptr_3d = init_val
2981 print*,
"- CALL FieldCreate FOR TARGET GRID C_D."
2982 c_d_target_grid = esmf_fieldcreate(target_grid, &
2983 typekind=esmf_typekind_r8, &
2985 staggerloc=esmf_staggerloc_center, rc=rc)
2986 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2989 print*,
"- CALL FieldCreate FOR TARGET GRID C_0."
2990 c_0_target_grid = esmf_fieldcreate(target_grid, &
2991 typekind=esmf_typekind_r8, &
2993 staggerloc=esmf_staggerloc_center, rc=rc)
2994 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2997 print*,
"- CALL FieldCreate FOR TARGET GRID D_CONV."
2998 d_conv_target_grid = esmf_fieldcreate(target_grid, &
2999 typekind=esmf_typekind_r8, &
3001 staggerloc=esmf_staggerloc_center, rc=rc)
3002 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3005 print*,
"- CALL FieldCreate FOR TARGET GRID DT_COOL."
3006 dt_cool_target_grid = esmf_fieldcreate(target_grid, &
3007 typekind=esmf_typekind_r8, &
3009 staggerloc=esmf_staggerloc_center, rc=rc)
3010 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3013 print*,
"- CALL FieldCreate FOR TARGET GRID IFD."
3014 ifd_target_grid = esmf_fieldcreate(target_grid, &
3015 typekind=esmf_typekind_r8, &
3017 staggerloc=esmf_staggerloc_center, rc=rc)
3018 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3021 print*,
"- CALL FieldCreate FOR TARGET GRID QRAIN."
3022 qrain_target_grid = esmf_fieldcreate(target_grid, &
3023 typekind=esmf_typekind_r8, &
3025 staggerloc=esmf_staggerloc_center, rc=rc)
3026 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3029 print*,
"- CALL FieldCreate FOR TARGET GRID TREF."
3030 tref_target_grid = esmf_fieldcreate(target_grid, &
3031 typekind=esmf_typekind_r8, &
3033 staggerloc=esmf_staggerloc_center, rc=rc)
3034 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3037 print*,
"- CALL FieldCreate FOR TARGET GRID W_D."
3038 w_d_target_grid = esmf_fieldcreate(target_grid, &
3039 typekind=esmf_typekind_r8, &
3041 staggerloc=esmf_staggerloc_center, rc=rc)
3042 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3045 print*,
"- CALL FieldCreate FOR TARGET GRID W_0."
3046 w_0_target_grid = esmf_fieldcreate(target_grid, &
3047 typekind=esmf_typekind_r8, &
3049 staggerloc=esmf_staggerloc_center, rc=rc)
3050 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3053 print*,
"- CALL FieldCreate FOR TARGET GRID XS."
3054 xs_target_grid = esmf_fieldcreate(target_grid, &
3055 typekind=esmf_typekind_r8, &
3057 staggerloc=esmf_staggerloc_center, rc=rc)
3058 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3061 print*,
"- CALL FieldCreate FOR TARGET GRID XT."
3062 xt_target_grid = esmf_fieldcreate(target_grid, &
3063 typekind=esmf_typekind_r8, &
3065 staggerloc=esmf_staggerloc_center, rc=rc)
3066 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3069 print*,
"- CALL FieldCreate FOR TARGET GRID XU."
3070 xu_target_grid = esmf_fieldcreate(target_grid, &
3071 typekind=esmf_typekind_r8, &
3073 staggerloc=esmf_staggerloc_center, rc=rc)
3074 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3077 print*,
"- CALL FieldCreate FOR TARGET GRID XV."
3078 xv_target_grid = esmf_fieldcreate(target_grid, &
3079 typekind=esmf_typekind_r8, &
3081 staggerloc=esmf_staggerloc_center, rc=rc)
3082 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3085 print*,
"- CALL FieldCreate FOR TARGET GRID XZ."
3086 xz_target_grid = esmf_fieldcreate(target_grid, &
3087 typekind=esmf_typekind_r8, &
3089 staggerloc=esmf_staggerloc_center, rc=rc)
3090 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3093 print*,
"- CALL FieldCreate FOR TARGET GRID XTTS."
3094 xtts_target_grid = esmf_fieldcreate(target_grid, &
3095 typekind=esmf_typekind_r8, &
3097 staggerloc=esmf_staggerloc_center, rc=rc)
3098 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3101 print*,
"- CALL FieldCreate FOR TARGET GRID XZTS."
3102 xzts_target_grid = esmf_fieldcreate(target_grid, &
3103 typekind=esmf_typekind_r8, &
3105 staggerloc=esmf_staggerloc_center, rc=rc)
3106 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3109 print*,
"- CALL FieldCreate FOR TARGET GRID Z_C."
3110 z_c_target_grid = esmf_fieldcreate(target_grid, &
3111 typekind=esmf_typekind_r8, &
3113 staggerloc=esmf_staggerloc_center, rc=rc)
3114 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3117 print*,
"- CALL FieldCreate FOR TARGET GRID ZM."
3118 zm_target_grid = esmf_fieldcreate(target_grid, &
3119 typekind=esmf_typekind_r8, &
3121 staggerloc=esmf_staggerloc_center, rc=rc)
3122 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3139 integer(esmf_kind_i4),
intent(in) :: ij
3140 integer ,
intent(in) :: itile, jtile
3142 integer ,
intent(out) :: i, j
3145 integer :: pt_loc_this_tile
3147 tile_num = ((ij-1) / (itile*jtile))
3148 pt_loc_this_tile = ij - (tile_num * itile * jtile)
3151 j = (pt_loc_this_tile - 1) / itile + 1
3152 i = mod(pt_loc_this_tile, itile)
3170 subroutine regrid_many(bundle_pre,bundle_post, num_field,route,dozero, &
3171 unmapped_ptr,resetifd)
3179 integer,
intent(in) :: num_field
3180 type(esmf_routehandle
),
intent(inout) :: route
3181 type(esmf_fieldbundle
),
intent(in) :: bundle_pre, bundle_post
3182 logical,
intent(in) :: dozero(num_field)
3183 logical,
intent(in),
optional :: resetifd
3184 integer(esmf_kind_i4),
intent(inout),
optional :: unmapped_ptr(:)
3186 type(esmf_field
) :: field_pre,field_post
3187 real(esmf_kind_r8),
pointer :: tmp_ptr(:,:)
3190 logical :: is2d(num_field)
3191 character(len=50) :: fname
3192 integer :: i, j, k, ij, ind_2d, ind_3d, rc, ndims,n2d, n3d,localpet, l(1), u(1)
3198 if(present(unmapped_ptr))
then
3199 l = lbound(unmapped_ptr)
3200 u = ubound(unmapped_ptr)
3204 call esmf_fieldbundleget(bundle_pre,i,field_pre,rc=rc)
3205 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3208 call esmf_fieldbundleget(bundle_post,i,field_post,rc=rc)
3209 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3212 call esmf_fieldget(field_post,dimcount=ndims,name=fname,rc=rc)
3213 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3216 call esmf_vmgetglobal(vm, rc=rc)
3217 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3219 call esmf_vmget(vm, localpet=localpet, rc=rc)
3220 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3222 if(localpet==0) print*,
"in regrid_many fname = ", fname, ndims
3223 if (ndims == 2) is2d(i) = .true.
3224 if (ndims == 3) is2d(i) = .false.
3227 call esmf_fieldregrid(field_pre, &
3229 routehandle=route, &
3230 termorderflag=esmf_termorder_srcseq, rc=rc)
3231 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3234 call esmf_fieldregrid(field_pre, &
3236 routehandle=route, &
3237 zeroregion=esmf_region_select, &
3238 termorderflag=esmf_termorder_srcseq, rc=rc)
3239 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3244 if (present(resetifd))
then
3245 if( resetifd .and. convert_nst)
then
3246 call esmf_fieldget(ifd_target_grid,farrayptr=tmp_ptr,rc=rc)
3247 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3249 tmp_ptr = float(nint(tmp_ptr))
3253 n2d = count(is2d(:))
3254 n3d = count(.not.is2d(:))
3255 if(localpet==0) print*, is2d(:)
3256 if (present(unmapped_ptr))
then
3257 allocate(ptr_2d(n2d))
3258 if (n3d .ne. 0)
allocate(ptr_3d(n3d))
3262 call esmf_fieldbundleget(bundle_post,i,field_post,rc=rc)
3263 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3265 call esmf_fieldget(field_post, farrayptr=ptr_2d(ind_2d)%p, rc=rc)
3266 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3268 call esmf_fieldget(field_post,name=fname,rc=rc)
3269 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3271 if (localpet==0) print*,
"in doreplace loop, 2d field = ", trim(fname)
3274 call esmf_fieldbundleget(bundle_post,i,field_post,rc=rc)
3275 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3277 call esmf_fieldget(field_post,name=fname,rc=rc)
3278 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3280 if (localpet==0) print*,
"in doreplace loop, 3d field = ", trim(fname)
3281 call esmf_fieldget(field_post, farrayptr=ptr_3d(ind_3d)%p, rc=rc)
3282 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3288 call
ij_to_i_j(unmapped_ptr(ij), i_target, j_target, i, j)
3290 ptr_2d(k)%p(i,j) = -9999.9
3293 ptr_3d(k)%p(i,j,:) = -9999.9
3297 if(n3d .ne. 0)
deallocate(ptr_3d)
3315 subroutine search_many(num_field,bundle_target,tile,search_nums,localpet,latitude, &
3316 terrain_land,soilt_climo, mask)
3318 use model_grid, only : i_target,j_target, lsoil_target
3324 integer,
intent(in) :: num_field
3325 type(esmf_fieldbundle
),
intent(inout) :: bundle_target
3327 real(esmf_kind_r8),
intent(inout),
optional :: latitude(i_target,j_target)
3328 real(esmf_kind_r8),
intent(inout),
optional :: terrain_land(i_target,j_target)
3329 real(esmf_kind_r8),
intent(inout),
optional :: soilt_climo(i_target,j_target)
3330 integer(esmf_kind_i8),
intent(inout),
optional :: mask(i_target,j_target)
3332 real(esmf_kind_r8),
allocatable :: field_data_2d(:,:)
3333 real(esmf_kind_r8),
allocatable :: field_data_3d(:,:,:)
3334 integer,
intent(in) :: tile,localpet
3335 integer,
intent(inout) :: search_nums(num_field)
3337 type(esmf_field
) :: temp_field
3338 character(len=50) :: fname
3339 integer,
parameter :: sotyp_land_field_num = 224
3340 integer,
parameter :: sst_field_num = 11
3341 integer,
parameter :: terrain_field_num= 7
3342 integer :: j,k, rc, ndims
3346 call esmf_fieldbundleget(bundle_target,k,temp_field, rc=rc)
3347 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3349 call esmf_fieldget(temp_field, name=fname, dimcount=ndims,rc=rc)
3350 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3352 if (localpet==0)
then
3353 allocate(field_data_2d(i_target,j_target))
3355 allocate(field_data_2d(0,0))
3357 if (ndims .eq. 2)
then
3358 call esmf_fieldgather(temp_field,field_data_2d,rootpet=0,tile=tile, rc=rc)
3359 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3361 if (localpet == 0)
then
3362 if (present(latitude) .and. search_nums(k).eq.sst_field_num)
then
3364 call
search(field_data_2d, mask, i_target, j_target, tile,search_nums(k),latitude=latitude)
3365 elseif (present(terrain_land) .and. search_nums(k) .eq. terrain_field_num)
then
3367 call
search(field_data_2d, mask, i_target, j_target, tile,search_nums(k),terrain_land=terrain_land)
3368 elseif (search_nums(k) .eq. sotyp_land_field_num)
then
3370 if (fname .eq.
"soil_type_target_grid")
then
3373 call
search(field_data_2d, mask, i_target, j_target, tile,search_nums(k),soilt_climo=soilt_climo)
3374 elseif (present(soilt_climo))
then
3375 if (maxval(field_data_2d) > 0 .and. (trim(external_model) .ne.
"GFS" .or. trim(input_type) .ne.
"grib2"))
then
3378 call
search(field_data_2d, mask, i_target, j_target, tile, search_nums(k))
3383 field_data_2d = soilt_climo
3389 call
search(field_data_2d, mask, i_target, j_target, tile,search_nums(k))
3392 call esmf_fieldscatter(temp_field, field_data_2d, rootpet=0, tile=tile,rc=rc)
3393 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3396 if (localpet==0)
then
3397 allocate(field_data_3d(i_target,j_target,lsoil_target))
3399 allocate(field_data_3d(0,0,0))
3403 call esmf_fieldgather(temp_field,field_data_3d,rootpet=0,tile=tile,rc=rc)
3404 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3407 if (localpet==0)
then
3408 do j = 1, lsoil_target
3409 field_data_2d = field_data_3d(:,:,j)
3410 call
search(field_data_2d, mask, i_target, j_target, tile, 21)
3411 field_data_3d(:,:,j) = field_data_2d
3414 call esmf_fieldscatter(temp_field, field_data_3d, rootpet=0, tile=tile,rc=rc)
3415 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3417 deallocate(field_data_3d)
3419 deallocate(field_data_2d)
3436 print*,
"- DESTROY LOCAL TARGET GRID SURFACE FIELDS."
3438 call esmf_fielddestroy(terrain_from_input_grid, rc=rc)
3439 call esmf_fielddestroy(terrain_from_input_grid_land, rc=rc)
3440 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.
subroutine, public search_many(num_field, bundle_target, tile, search_nums, localpet, latitude, terrain_land, soilt_climo, mask)
Execute the search function for multple fields.
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 error_handler(string, rc)
General error handler.
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, 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.
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.