45 use write_data,
only : write_fv3_sfc_data_netcdf
47 use utilities,
only : error_handler
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(:,:,:)
109 use sfc_input_data,
only : cleanup_input_sfc_data, &
112 use nst_input_data,
only : cleanup_input_nst_data, &
123 use utilities,
only : error_handler
127 integer,
intent(in) :: localpet
145 call read_input_sfc_data(localpet)
151 if (
convert_nst)
call read_input_nst_data(localpet)
218 call cleanup_input_sfc_data
226 call write_fv3_sfc_data_netcdf(localpet)
248 subroutine interp(localpet)
253 use sfc_input_data,
only : canopy_mc_input_grid, &
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, &
279 use nst_input_data,
only : c_d_input_grid, &
282 dt_cool_input_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__)) &
392 call error_handler(
"IN FieldRegridStore", rc)
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__)) &
396 call error_handler(
"IN FieldBundleCreate", rc)
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__)) &
399 call error_handler(
"IN FieldBundleCreate", rc)
404 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
405 call error_handler(
"IN FieldBundleAdd", rc)
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__)) &
410 call error_handler(
"IN FieldBundleAdd", rc)
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__)) &
414 call error_handler(
"IN FieldBundleGet", rc)
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__)) &
424 call error_handler(
"IN FieldBundleDestroy", rc)
425 call esmf_fieldbundledestroy(bundle_all_input,rc=rc)
426 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
427 call error_handler(
"IN FieldBundleDestroy", rc)
429 print*,
"- CALL FieldGet FOR SRFLAG." 431 farrayptr=srflag_target_ptr, rc=rc)
432 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
433 call error_handler(
"IN FieldGet", rc)
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__)) &
445 call error_handler(
"IN FieldRegridRelease", rc)
451 print*,
"- CALL GridAddItem FOR 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__)) &
456 call error_handler(
"IN GridAddItem", rc)
458 print*,
"- CALL GridGetItem FOR 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__)) &
463 call error_handler(
"IN GridGetItem", rc)
465 print*,
"- CALL FieldGet FOR TARGET GRID SEAMASK." 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__)) &
471 call error_handler(
"IN FieldGet", rc)
473 print*,
"- CALL FieldGet FOR TARGET GRID LANDMASK." 475 farrayptr=landmask_target_ptr, rc=rc)
476 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
477 call error_handler(
"IN FieldGet", rc)
479 print*,
"- CALL GridAddItem FOR INPUT GRID SEAMASK." 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__)) &
484 call error_handler(
"IN GridAddItem", rc)
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__)) &
490 call error_handler(
"IN FieldGet", rc)
492 print*,
"- CALL GridGetItem FOR INPUT GRID LANDMASK." 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__)) &
497 call error_handler(
"IN GridGetItem", rc)
499 if (localpet == 0)
then 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." 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__)) &
529 call error_handler(
"IN FieldCreate", rc)
531 print*,
"- CALL FieldRegridStore for land fields." 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__)) &
544 call error_handler(
"IN FieldRegridStore", rc)
546 print*,
"- CALL Field_Regrid TERRAIN." 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__)) &
552 call error_handler(
"IN FieldRegrid", rc)
554 print*,
"- CALL FieldGet FOR terrain from input grid at land." 556 farrayptr=terrain_from_input_ptr, rc=rc)
557 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
558 call error_handler(
"IN FieldGet", rc)
560 l = lbound(unmapped_ptr)
561 u = ubound(unmapped_ptr)
565 terrain_from_input_ptr(i,j) = -9999.9
567 nullify(terrain_from_input_ptr)
571 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
573 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
574 call error_handler(
"IN FieldGather", rc)
576 print*,
"- CALL FieldGather FOR TERRAIN FROM INPUT GRID: ", tile
578 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
579 call error_handler(
"IN FieldGather", rc)
581 if (localpet == 0)
then 583 land_target_one_tile = 0
584 where(mask_target_one_tile == 1) land_target_one_tile = 1
586 deallocate(land_target_one_tile)
589 print*,
"- CALL FieldScatter FOR TERRAIN FROM INPUT GRID: ", tile
591 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
592 call error_handler(
"IN FieldScatter", rc)
597 print*,
"- CALL FieldRegrid VEG TYPE." 598 call esmf_fieldregrid(veg_type_input_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__)) &
603 call error_handler(
"IN FieldRegrid", rc)
605 print*,
"- CALL FieldGet FOR TARGET grid veg type." 607 farrayptr=veg_type_target_ptr, rc=rc)
608 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
609 call error_handler(
"IN FieldGet", rc)
611 l = lbound(unmapped_ptr)
612 u = ubound(unmapped_ptr)
616 veg_type_target_ptr(i,j) = -9999.9
620 print*,
"- CALL FieldGather FOR TARGET GRID VEG TYPE TILE: ", tile
622 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
623 call error_handler(
"IN FieldGather", rc)
625 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
627 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
628 call error_handler(
"IN FieldGather", rc)
630 if (localpet == 0)
then 632 land_target_one_tile = 0
633 where(mask_target_one_tile == 1) land_target_one_tile = 1
635 deallocate(land_target_one_tile)
638 print*,
"- CALL FieldScatter FOR TARGET GRID VEG TYPE: ", tile
640 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
641 call error_handler(
"IN FieldScatter", rc)
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__)) &
648 call error_handler(
"IN FieldRegridRelease", rc)
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, &
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__)) &
677 call error_handler(
"IN FieldRegridStore", rc)
679 print*,
"- CALL Field_Regrid for sea ice fraction." 680 call esmf_fieldregrid(seaice_fract_input_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__)) &
685 call error_handler(
"IN FieldRegrid", rc)
687 print*,
"- CALL FieldGet FOR TARGET grid sea ice fraction." 689 farrayptr=seaice_fract_target_ptr, rc=rc)
690 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
691 call error_handler(
"IN FieldGet", rc)
693 l = lbound(unmapped_ptr)
694 u = ubound(unmapped_ptr)
698 seaice_fract_target_ptr(i,j) = -9999.9
703 if (localpet == 0)
then 706 allocate(latitude_one_tile(0,0))
711 print*,
"- CALL FieldGather FOR TARGET GRID SEAICE FRACTION TILE: ", tile
713 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
714 call error_handler(
"IN FieldGather", rc)
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__)) &
719 call error_handler(
"IN FieldGather", rc)
721 print*,
"- CALL FieldGather FOR TARGET LATITUDE TILE: ", tile
723 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
724 call error_handler(
"IN FieldGather", rc)
726 if (localpet == 0)
then 728 latitude=latitude_one_tile)
731 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
733 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
734 call error_handler(
"IN FieldGather", rc)
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
751 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
752 call error_handler(
"IN FieldScatter", rc)
754 print*,
"- CALL FieldScatter FOR TARGET LANDMASK TILE: ", tile
756 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
757 call error_handler(
"IN FieldScatter", rc)
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__)) &
766 call error_handler(
"IN FieldRegridRelease", rc)
774 where (nint(landmask_input_ptr) == 2) mask_input_ptr = 1
776 print*,
"- CALL FieldGet FOR TARGET land sea mask." 778 farrayptr=landmask_target_ptr, rc=rc)
779 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
780 call error_handler(
"IN FieldGet", rc)
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, &
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__)) &
805 call error_handler(
"IN FieldRegridStore", rc)
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__)) &
809 call error_handler(
"IN FieldBundleCreate", rc)
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__)) &
812 call error_handler(
"IN FieldBundleCreate", rc)
816 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
817 call error_handler(
"IN FieldBundleAdd", rc)
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__)) &
822 call error_handler(
"IN FieldBundleAdd", rc)
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__)) &
825 call error_handler(
"IN FieldBundleGet", rc)
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__)) &
842 call error_handler(
"IN FieldBundleDestroy", rc)
846 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
848 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
849 call error_handler(
"IN FieldGather", rc)
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
857 call search_many(num_fields,bundle_seaice_target,data_one_tile, mask_target_one_tile,tile,search_nums,localpet, &
858 field_data_3d=data_one_tile_3d)
861 deallocate(search_nums)
862 call esmf_fieldbundledestroy(bundle_seaice_target,rc=rc)
863 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
864 call error_handler(
"IN FieldBundleDestroy", rc)
866 print*,
"- CALL FieldRegridRelease." 867 call esmf_fieldregridrelease(routehandle=regrid_seaice, rc=rc)
868 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
869 call error_handler(
"IN FieldRegridRelease", rc)
876 where (nint(landmask_input_ptr) == 0) mask_input_ptr = 1
879 where (landmask_target_ptr == 0) mask_target_ptr = 1
881 method=esmf_regridmethod_conserve
882 isrctermprocessing = 1
884 print*,
"- CALL FieldRegridStore for water fields." 885 call esmf_fieldregridstore(skin_temp_input_grid, &
887 srcmaskvalues=(/0/), &
888 dstmaskvalues=(/0/), &
889 polemethod=esmf_polemethod_none, &
890 srctermprocessing=isrctermprocessing, &
891 unmappedaction=esmf_unmappedaction_ignore, &
892 normtype=esmf_normtype_fracarea, &
893 routehandle=regrid_water, &
894 regridmethod=method, &
895 unmappeddstlist=unmapped_ptr, rc=rc)
896 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
897 call error_handler(
"IN FieldRegridStore", rc)
899 bundle_water_target = esmf_fieldbundlecreate(name=
"water target", rc=rc)
900 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
901 call error_handler(
"IN FieldBundleCreate", rc)
902 bundle_water_input = esmf_fieldbundlecreate(name=
"water input", rc=rc)
903 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
904 call error_handler(
"IN FieldBundleCreate", rc)
906 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
907 call error_handler(
"IN FieldBundleAdd", rc)
908 call esmf_fieldbundleadd(bundle_water_input, (/skin_temp_input_grid, z0_input_grid/), rc=rc)
909 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
910 call error_handler(
"IN FieldBundleAdd", rc)
919 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
920 call error_handler(
"IN FieldBundleAdd", rc)
922 call esmf_fieldbundleadd(bundle_water_input, (/c_d_input_grid,c_0_input_grid,d_conv_input_grid, &
923 dt_cool_input_grid,ifd_input_grid,qrain_input_grid,tref_input_grid, &
924 w_d_input_grid,w_0_input_grid,xs_input_grid,xt_input_grid,xu_input_grid, &
925 xv_input_grid,xz_input_grid,xtts_input_grid,xzts_input_grid, &
926 z_c_input_grid,zm_input_grid/), rc=rc)
927 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
928 call error_handler(
"IN FieldBundleAdd", rc)
929 call esmf_fieldbundleget(bundle_water_target,fieldcount=num_fields,rc=rc)
930 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
931 call error_handler(
"IN FieldBundleGet", rc)
933 allocate(search_nums(num_fields))
934 allocate(dozero(num_fields))
936 search_nums(:)=(/11,83,0,0,0,0,1,0,11,0,0,0,0,0,0,30,0,0,0,0/)
940 call esmf_fieldbundleget(bundle_water_target,fieldcount=num_fields,rc=rc)
941 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
942 call error_handler(
"IN FieldBundleGet", rc)
944 allocate(search_nums(num_fields))
945 allocate(dozero(num_fields))
946 search_nums(:)=(/11,83/)
950 call regrid_many(bundle_water_input,bundle_water_target,num_fields,regrid_water,dozero, &
951 unmapped_ptr=unmapped_ptr, resetifd=.true.)
953 call esmf_fieldbundledestroy(bundle_water_input,rc=rc)
954 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
955 call error_handler(
"IN FieldBundleDestroy", rc)
958 if (localpet == 0)
then 961 allocate(latitude_one_tile(0,0))
966 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
968 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
969 call error_handler(
"IN FieldGather", rc)
971 print*,
"- CALL FieldGather FOR TARGET LATITUDE TILE: ", tile
973 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
974 call error_handler(
"IN FieldGather", rc)
976 if (localpet == 0)
then 978 water_target_one_tile = 0
979 where(mask_target_one_tile == 0) water_target_one_tile = 1
982 call search_many(num_fields,bundle_water_target,data_one_tile, water_target_one_tile,&
983 tile,search_nums,localpet,latitude=latitude_one_tile)
985 if (localpet == 0)
deallocate(water_target_one_tile)
989 deallocate(latitude_one_tile,search_nums)
991 call esmf_fieldbundledestroy(bundle_water_target,rc=rc)
992 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
993 call error_handler(
"IN FieldBundleDestroy", rc)
995 print*,
"- CALL FieldRegridRelease." 996 call esmf_fieldregridrelease(routehandle=regrid_water, rc=rc)
997 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
998 call error_handler(
"IN FieldRegridRelease", rc)
1005 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1
1008 where (landmask_target_ptr == 1) mask_target_ptr = 1
1010 method=esmf_regridmethod_conserve
1011 isrctermprocessing = 1
1013 print*,
"- CALL FieldRegridStore for land fields." 1014 call esmf_fieldregridstore(snow_depth_input_grid, &
1016 srcmaskvalues=(/0/), &
1017 dstmaskvalues=(/0/), &
1018 polemethod=esmf_polemethod_none, &
1019 srctermprocessing=isrctermprocessing, &
1020 unmappedaction=esmf_unmappedaction_ignore, &
1021 normtype=esmf_normtype_fracarea, &
1022 routehandle=regrid_all_land, &
1023 regridmethod=method, &
1024 unmappeddstlist=unmapped_ptr, rc=rc)
1025 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1026 call error_handler(
"IN FieldRegridStore", rc)
1028 bundle_allland_target = esmf_fieldbundlecreate(name=
"all land target", rc=rc)
1029 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1030 call error_handler(
"IN FieldBundleCreate", rc)
1031 bundle_allland_input = esmf_fieldbundlecreate(name=
"all land input", rc=rc)
1032 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1033 call error_handler(
"IN FieldBundleCreate", rc)
1036 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1037 call error_handler(
"IN FieldBundleAdd", rc)
1038 call esmf_fieldbundleadd(bundle_allland_input, (/canopy_mc_input_grid, snow_depth_input_grid, &
1039 snow_liq_equiv_input_grid/), rc=rc)
1040 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1041 call error_handler(
"IN FieldBundleAdd", rc)
1042 call esmf_fieldbundleget(bundle_allland_target,fieldcount=num_fields,rc=rc)
1043 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1044 call error_handler(
"IN FieldBundleGet", rc)
1046 allocate(search_nums(num_fields))
1047 allocate(dozero(num_fields))
1049 search_nums = (/223,66,65/)
1050 dozero=(/.true.,.false.,.false./)
1052 call regrid_many(bundle_allland_input,bundle_allland_target,num_fields,regrid_all_land,dozero, &
1053 unmapped_ptr=unmapped_ptr)
1055 call esmf_fieldbundledestroy(bundle_allland_input,rc=rc)
1056 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1057 call error_handler(
"IN FieldBundleDestroy", rc)
1062 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
1064 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1065 call error_handler(
"IN FieldGather", rc)
1067 if (localpet == 0)
then 1069 land_target_one_tile = 0
1070 where(mask_target_one_tile == 1) land_target_one_tile = 1
1073 call search_many(num_fields,bundle_allland_target,data_one_tile, land_target_one_tile,&
1074 tile,search_nums,localpet)
1076 if (localpet == 0)
deallocate(land_target_one_tile)
1079 deallocate(search_nums)
1080 call esmf_fieldbundledestroy(bundle_allland_target,rc=rc)
1081 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1082 call error_handler(
"IN FieldBundleDestroy", rc)
1084 print*,
"- CALL FieldRegridRelease." 1085 call esmf_fieldregridrelease(routehandle=regrid_all_land, rc=rc)
1086 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1087 call error_handler(
"IN FieldRegridRelease", rc)
1093 print*,
"- CALL FieldGet FOR INPUT GRID VEG TYPE." 1094 call esmf_fieldget(veg_type_input_grid, &
1095 farrayptr=veg_type_input_ptr, rc=rc)
1096 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1097 call error_handler(
"IN FieldGet", rc)
1099 print*,
'land ice check ',veg_type_landice_input
1102 where (nint(veg_type_input_ptr) == veg_type_landice_input) mask_input_ptr = 1
1104 print*,
"- CALL FieldGet FOR TARGET GRID VEG TYPE." 1106 farrayptr=veg_type_target_ptr, rc=rc)
1107 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1108 call error_handler(
"IN FieldGet", rc)
1113 method=esmf_regridmethod_nearest_stod
1114 isrctermprocessing = 1
1116 print*,
"- CALL FieldRegridStore for landice fields." 1117 call esmf_fieldregridstore(soil_temp_input_grid, &
1119 srcmaskvalues=(/0/), &
1120 dstmaskvalues=(/0/), &
1121 polemethod=esmf_polemethod_none, &
1122 srctermprocessing=isrctermprocessing, &
1123 unmappedaction=esmf_unmappedaction_ignore, &
1124 normtype=esmf_normtype_fracarea, &
1125 routehandle=regrid_landice, &
1126 regridmethod=method, &
1127 unmappeddstlist=unmapped_ptr, rc=rc)
1128 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1129 call error_handler(
"IN FieldRegridStore", rc)
1131 bundle_landice_target = esmf_fieldbundlecreate(name=
"landice target", rc=rc)
1132 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1133 call error_handler(
"IN FieldBundleCreate", rc)
1134 bundle_landice_input = esmf_fieldbundlecreate(name=
"landice input", rc=rc)
1135 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1136 call error_handler(
"IN FieldBundleCreate", rc)
1139 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1140 call error_handler(
"IN FieldBundleAdd", rc)
1141 call esmf_fieldbundleadd(bundle_landice_input, (/skin_temp_input_grid,
terrain_input_grid,&
1142 soil_temp_input_grid/), rc=rc)
1143 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1144 call error_handler(
"IN FieldBundleAdd", rc)
1147 call esmf_fieldbundleadd(bundle_landice_input, (/soil_type_input_grid/),rc=rc)
1148 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1149 call error_handler(
"IN FieldBundleAdd", rc)
1151 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1152 call error_handler(
"IN FieldBundleAdd", rc)
1155 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1156 call error_handler(
"IN FieldBundleAdd", rc)
1157 call esmf_fieldbundleget(bundle_landice_target,fieldcount=num_fields,rc=rc)
1158 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1159 call error_handler(
"IN FieldBundleGet", rc)
1161 allocate(search_nums(num_fields))
1162 allocate(dozero(num_fields))
1165 search_nums = (/21,7,21/)
1168 search_nums = (/21,7,21,231/)
1169 dozero(:)=(/.false.,.false.,.false.,.true./)
1172 call regrid_many(bundle_landice_input,bundle_landice_target,num_fields,regrid_landice,dozero, &
1173 unmapped_ptr=unmapped_ptr )
1175 call esmf_fieldbundledestroy(bundle_landice_input,rc=rc)
1176 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1177 call error_handler(
"IN FieldBundleDestroy", rc)
1179 if (localpet == 0)
then 1184 allocate (veg_type_target_one_tile(0,0))
1185 allocate (land_target_one_tile(0,0))
1186 allocate (data_one_tile2(0,0))
1190 print*,
"- CALL FieldGather FOR TARGET VEG TYPE TILE: ", tile
1191 call esmf_fieldgather(
veg_type_target_grid, veg_type_target_one_tile, rootpet=0, tile=tile, rc=rc)
1192 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1193 call error_handler(
"IN FieldGather", rc)
1195 if (localpet == 0)
then 1196 land_target_one_tile = 0
1200 print*,
"- CALL FieldGather FOR TERRAIN FROM INPUT GRID LAND, TILE: ", tile
1202 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1203 call error_handler(
"IN FieldGather", rc)
1205 call search_many(num_fields,bundle_landice_target,data_one_tile, land_target_one_tile,&
1206 tile,search_nums,localpet,terrain_land=data_one_tile2,field_data_3d=data_one_tile_3d)
1209 deallocate (veg_type_target_one_tile)
1210 deallocate (land_target_one_tile)
1211 deallocate(search_nums)
1213 call esmf_fieldbundledestroy(bundle_landice_target,rc=rc)
1214 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1215 call error_handler(
"IN FieldBundleDestroy", rc)
1217 print*,
"- CALL FieldRegridRelease." 1218 call esmf_fieldregridrelease(routehandle=regrid_landice, rc=rc)
1219 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1220 call error_handler(
"IN FieldRegridRelease", rc)
1227 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1
1228 where (nint(veg_type_input_ptr) == veg_type_landice_input) mask_input_ptr = 0
1231 where (landmask_target_ptr == 1) mask_target_ptr = 1
1234 method=esmf_regridmethod_nearest_stod
1235 isrctermprocessing = 1
1237 print*,
"- CALL FieldRegridStore for 3d land (but no land ice) fields." 1238 call esmf_fieldregridstore(soilm_tot_input_grid, &
1240 srcmaskvalues=(/0/), &
1241 dstmaskvalues=(/0/), &
1242 polemethod=esmf_polemethod_none, &
1243 srctermprocessing=isrctermprocessing, &
1244 unmappedaction=esmf_unmappedaction_ignore, &
1245 normtype=esmf_normtype_fracarea, &
1246 routehandle=regrid_land, &
1247 regridmethod=method, &
1248 unmappeddstlist=unmapped_ptr, rc=rc)
1249 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1250 call error_handler(
"IN FieldRegridStore", rc)
1252 bundle_nolandice_target = esmf_fieldbundlecreate(name=
"land no landice target", rc=rc)
1253 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1254 call error_handler(
"IN FieldBundleCreate", rc)
1256 bundle_nolandice_input = esmf_fieldbundlecreate(name=
"land no landice input", rc=rc)
1257 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1258 call error_handler(
"IN FieldBundleCreate", rc)
1262 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1263 call error_handler(
"IN FieldBundleAdd", rc)
1265 call esmf_fieldbundleadd(bundle_nolandice_input, (/skin_temp_input_grid,
terrain_input_grid,&
1266 soil_type_input_grid,soilm_tot_input_grid,soil_temp_input_grid/), rc=rc)
1267 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1268 call error_handler(
"IN FieldBundleAdd", rc)
1278 print*,
"- CALL Field_Regrid ." 1279 call esmf_fieldregrid(soil_type_input_grid, &
1281 routehandle=regrid_land, &
1282 zeroregion=esmf_region_select, &
1283 termorderflag=esmf_termorder_srcseq, rc=rc)
1284 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1285 call error_handler(
"IN FieldRegrid", rc)
1288 farrayptr=soil_type_target_ptr, rc=rc)
1289 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1290 call error_handler(
"IN FieldGet", rc)
1292 l = lbound(unmapped_ptr)
1293 u = ubound(unmapped_ptr)
1297 soil_type_target_ptr(i,j) = -9999.9
1307 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1308 call error_handler(
"IN FieldBundleAdd", rc)
1309 call esmf_fieldbundleadd(bundle_nolandice_input, (/veg_greenness_input_grid/), rc=rc)
1310 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1311 call error_handler(
"IN FieldBundleAdd", rc)
1312 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1313 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1314 call error_handler(
"IN FieldBundleGet", rc)
1315 vgfrc_ind = num_fields
1319 call esmf_fieldbundleadd(bundle_nolandice_target, (/
lai_target_grid/), rc=rc)
1320 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1321 call error_handler(
"IN FieldBundleAdd", rc)
1322 call esmf_fieldbundleadd(bundle_nolandice_input, (/lai_input_grid/), rc=rc)
1323 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1324 call error_handler(
"IN FieldBundleAdd", rc)
1325 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1326 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1327 call error_handler(
"IN FieldBundleGet", rc)
1328 lai_ind = num_fields
1333 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1334 call error_handler(
"IN FieldBundleAdd", rc)
1335 call esmf_fieldbundleadd(bundle_nolandice_input, (/max_veg_greenness_input_grid/), rc=rc)
1336 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1337 call error_handler(
"IN FieldBundleAdd", rc)
1340 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1341 call error_handler(
"IN FieldBundleAdd", rc)
1342 call esmf_fieldbundleadd(bundle_nolandice_input, (/min_veg_greenness_input_grid/), rc=rc)
1343 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1344 call error_handler(
"IN FieldBundleAdd", rc)
1346 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1347 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1348 call error_handler(
"IN FieldBundleGet", rc)
1350 mmvg_ind = num_fields-1
1353 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1354 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1355 call error_handler(
"IN FieldBundleGet", rc)
1357 allocate(search_nums(num_fields))
1358 allocate(dozero(num_fields))
1360 search_nums(1:5) = (/85,7,224,85,86/)
1361 dozero(1:5) = (/.false.,.false.,.true.,.true.,.false./)
1369 search_nums(vgfrc_ind) = 224
1370 dozero(vgfrc_ind) = .true.
1374 search_nums(lai_ind) = 229
1375 dozero(lai_ind) = .true.
1379 search_nums(mmvg_ind) = 227
1380 dozero(mmvg_ind) = .true.
1382 search_nums(mmvg_ind+1) = 228
1383 dozero(mmvg_ind+1) = .true.
1386 call regrid_many(bundle_nolandice_input,bundle_nolandice_target,num_fields,regrid_land,dozero, &
1387 unmapped_ptr=unmapped_ptr)
1389 call esmf_fieldbundledestroy(bundle_nolandice_input,rc=rc)
1390 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1391 call error_handler(
"IN FieldBundleDestroy", rc)
1393 if (localpet == 0)
then 1396 allocate (veg_type_target_one_tile(0,0))
1401 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
1403 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1404 call error_handler(
"IN FieldGather", rc)
1406 print*,
"- CALL FieldGather FOR TARGET VEG TYPE TILE: ", tile
1407 call esmf_fieldgather(
veg_type_target_grid, veg_type_target_one_tile, rootpet=0, tile=tile, rc=rc)
1408 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1409 call error_handler(
"IN FieldGather", rc)
1411 if (localpet == 0)
then 1415 print*,
"- CALL FieldGather FOR SOIL TYPE TARGET GRID, TILE: ", tile
1417 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1418 call error_handler(
"IN FieldGather", rc)
1420 call search_many(num_fields,bundle_nolandice_target,data_one_tile, mask_target_one_tile,&
1421 tile,search_nums,localpet,soilt_climo=data_one_tile2, field_data_3d=data_one_tile_3d)
1423 print*,
"- CALL FieldGather FOR TARGET GRID TOTAL SOIL MOISTURE, TILE: ", tile
1425 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1426 call error_handler(
"IN FieldGather", rc)
1428 if (localpet == 0)
then 1430 data_one_tile = data_one_tile_3d(:,:,j)
1432 data_one_tile_3d(:,:,j) = data_one_tile
1436 print*,
"- CALL FieldGather FOR TARGET GRID SOIL TEMPERATURE, TILE: ", tile
1438 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1439 call error_handler(
"IN FieldGather", rc)
1442 print*,
"- CALL FieldScatter FOR TARGET GRID SUBSTRATE TEMPERATURE, TILE: ", tile
1444 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1445 call error_handler(
"IN FieldScatter", rc)
1449 print*,
"- CALL FieldGather FOR SOIL TYPE TARGET GRID LAND, TILE: ",tile
1451 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1452 call error_handler(
"IN FieldGather", rc)
1454 if (localpet == 0)
then 1458 print*,
"- CALL FieldScatter FOR SOIL TYPE TARGET GRID, TILE: ", tile
1460 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1461 call error_handler(
"IN FieldScatter", rc)
1466 deallocate(search_nums)
1467 call esmf_fieldbundledestroy(bundle_nolandice_target,rc=rc)
1468 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1469 call error_handler(
"IN FieldBundleDestroy", rc)
1471 print*,
"- CALL FieldRegridRelease." 1472 call esmf_fieldregridrelease(routehandle=regrid_land, rc=rc)
1473 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1474 call error_handler(
"IN FieldRegridRelease", rc)
1476 deallocate(veg_type_target_one_tile)
1478 deallocate(data_one_tile, data_one_tile2)
1479 deallocate(data_one_tile_3d)
1480 deallocate(mask_target_one_tile)
1504 integer :: clb(3), cub(3), rc
1505 integer :: i, j, n, soil_type
1507 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
1510 real(esmf_kind_r8),
pointer :: soilm_liq_ptr(:,:,:)
1511 real(esmf_kind_r8),
pointer :: soilm_tot_ptr(:,:,:)
1512 real(esmf_kind_r8),
pointer :: soil_temp_ptr(:,:,:)
1513 real(esmf_kind_r8),
pointer :: soil_type_ptr(:,:)
1514 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
1516 print*,
"- COMPUTE LIQUID PORTION OF TOTAL SOIL MOISTURE." 1518 print*,
"- CALL FieldGet FOR TOTAL SOIL MOISTURE." 1520 computationallbound=clb, &
1521 computationalubound=cub, &
1522 farrayptr=soilm_tot_ptr, rc=rc)
1523 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1524 call error_handler(
"IN FieldGet", rc)
1526 print*,
"- CALL FieldGet FOR LIQUID SOIL MOISTURE." 1528 farrayptr=soilm_liq_ptr, rc=rc)
1529 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1530 call error_handler(
"IN FieldGet", rc)
1532 print*,
"- CALL FieldGet FOR SOIL TEMPERATURE." 1534 farrayptr=soil_temp_ptr, rc=rc)
1535 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1536 call error_handler(
"IN FieldGet", rc)
1538 print*,
"- CALL FieldGet FOR VEGETATION TYPE." 1540 farrayptr=veg_type_ptr, rc=rc)
1541 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1542 call error_handler(
"IN FieldGet", rc)
1544 print*,
"- CALL FieldGet FOR SOIL TYPE." 1546 farrayptr=soil_type_ptr, rc=rc)
1547 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1548 call error_handler(
"IN FieldGet", rc)
1550 print*,
"- CALL FieldGet FOR LANDMASK." 1552 farrayptr=landmask_ptr, rc=rc)
1553 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1554 call error_handler(
"IN FieldGet", rc)
1556 do j = clb(2), cub(2)
1557 do i = clb(1), cub(1)
1565 soil_type = nint(soil_type_ptr(i,j))
1567 do n = clb(3), cub(3)
1569 if (soil_temp_ptr(i,j,n) < (
frz_h2o-0.0001))
then 1576 ((soil_temp_ptr(i,j,n)-
frz_h2o)/soil_temp_ptr(i,j,n)))** &
1579 if (fk .lt. 0.02) fk = 0.02
1581 soilm_liq_ptr(i,j,n) = min( fk, soilm_tot_ptr(i,j,n) )
1589 soilm_liq_ptr(i,j,n) = frh2o(soil_temp_ptr(i,j,n), &
1590 soilm_tot_ptr(i,j,n), soilm_liq_ptr(i,j,n), &
1596 soilm_liq_ptr(i,j,n) = soilm_tot_ptr(i,j,n)
1633 FUNCTION frh2o (TKELV,SMC,SH2O,SMCMAX,BEXP,PSIS)
1650 REAL(esmf_kind_r8) :: sh2o
1651 REAL(esmf_kind_r8) :: smc
1655 REAL(esmf_kind_r8) :: tkelv
1657 REAL,
PARAMETER :: ck = 8.0
1658 REAL,
PARAMETER :: error = 0.005
1676 IF (ck .NE. 0.0)
THEN 1691 IF (swl .GT. (smc-0.02)) swl = smc-0.02
1692 IF (swl .LT. 0.) swl = 0.
1698 DO WHILE ( (nlog .LT. 10) .AND. (kcount .EQ. 0) )
1701 df = log(( psis*
grav/
hlice ) * ( ( 1.+ck*swl )**2. ) * &
1702 ( smcmax/(smc-swl) )**bx) - log(-(tkelv-
frz_h2o)/tkelv)
1703 denom = 2. * ck / ( 1.+ck*swl ) + bx / ( smc - swl )
1704 swlk = swl - df/denom
1710 IF (swlk .GT. (smc-0.02)) swlk = smc - 0.02
1711 IF (swlk .LT. 0.) swlk = 0.
1717 dswl = abs(swlk-swl)
1725 IF ( dswl .LE. error )
THEN 1751 IF (kcount .EQ. 0)
THEN 1754 ((tkelv-
frz_h2o)/tkelv))**(-1/bx))*smcmax
1756 IF (fk .LT. 0.02) fk = 0.02
1758 frh2o = min(fk, smc)
1788 integer :: clb(3), cub(3), i, j, k, rc
1789 integer :: soilt_input, soilt_target
1790 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
1792 real(esmf_kind_r8),
pointer :: soilm_tot_ptr(:,:,:)
1793 real(esmf_kind_r8),
pointer :: soil_type_input_ptr(:,:)
1794 real(esmf_kind_r8),
pointer :: soil_type_target_ptr(:,:)
1795 real(esmf_kind_r8),
pointer :: veg_greenness_ptr(:,:)
1796 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
1797 real :: f1, fn, smcdir, smctra
1799 print*,
"- RESCALE SOIL MOISTURE FOR CHANGES IN SOIL TYPE." 1801 print*,
"- CALL FieldGet FOR TOTAL SOIL MOISTURE." 1803 computationallbound=clb, &
1804 computationalubound=cub, &
1805 farrayptr=soilm_tot_ptr, rc=rc)
1806 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1807 call error_handler(
"IN FieldGet", rc)
1809 print*,
"- CALL FieldGet FOR LAND MASK." 1811 farrayptr=landmask_ptr, rc=rc)
1812 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1813 call error_handler(
"IN FieldGet", rc)
1815 print*,
"- CALL FieldGet FOR VEGETATION TYPE." 1817 farrayptr=veg_type_ptr, rc=rc)
1818 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1819 call error_handler(
"IN FieldGet", rc)
1821 print*,
"- CALL FieldGet FOR VEGETATION GREENNESS." 1823 farrayptr=veg_greenness_ptr, rc=rc)
1824 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1825 call error_handler(
"IN FieldGet", rc)
1827 print*,
"- CALL FieldGet FOR TARGET GRID SOIL TYPE." 1829 farrayptr=soil_type_target_ptr, rc=rc)
1830 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1831 call error_handler(
"IN FieldGet", rc)
1833 print*,
"- CALL FieldGet FOR SOIL TYPE FROM INPUT GRID." 1835 farrayptr=soil_type_input_ptr, rc=rc)
1836 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1837 call error_handler(
"IN FieldGet", rc)
1839 do j = clb(2), cub(2)
1840 do i = clb(1), cub(1)
1848 soilt_target = nint(soil_type_target_ptr(i,j))
1849 soilt_input = nint(soil_type_input_ptr(i,j))
1857 if (soilt_target /= soilt_input)
then 1862 f1=(soilm_tot_ptr(i,j,1)-
drysmc_input(soilt_input)) / &
1872 if (soilm_tot_ptr(i,j,1) <
refsmc_input(soilt_input))
then 1873 f1=(soilm_tot_ptr(i,j,1) -
wltsmc_input(soilt_input)) / &
1878 f1=(soilm_tot_ptr(i,j,1) -
refsmc_input(soilt_input)) / &
1888 soilm_tot_ptr(i,j,1) = ((1.0 - veg_greenness_ptr(i,j)) * smcdir) + &
1889 (veg_greenness_ptr(i,j) * smctra)
1899 if (soilm_tot_ptr(i,j,k) <
refsmc_input(soilt_input))
then 1900 fn = (soilm_tot_ptr(i,j,k) -
wltsmc_input(soilt_input)) / &
1905 fn = (soilm_tot_ptr(i,j,k) -
refsmc_input(soilt_input)) / &
1918 soilm_tot_ptr(i,j,1)=min(soilm_tot_ptr(i,j,1),
maxsmc_target(soilt_target))
1919 soilm_tot_ptr(i,j,1)=max(
drysmc_target(soilt_target),soilm_tot_ptr(i,j,1))
1922 soilm_tot_ptr(i,j,k)=min(soilm_tot_ptr(i,j,k),
maxsmc_target(soilt_target))
1923 soilm_tot_ptr(i,j,k)=max(
wltsmc_target(soilt_target),soilm_tot_ptr(i,j,k))
1948 integer :: clb(3), cub(3), i, j, k, rc
1949 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
1951 real,
parameter :: lapse_rate = 6.5e-03
1952 real :: terrain_diff
1953 real(esmf_kind_r8),
pointer :: terrain_input_ptr(:,:)
1954 real(esmf_kind_r8),
pointer :: terrain_target_ptr(:,:)
1955 real(esmf_kind_r8),
pointer :: veg_type_target_ptr(:,:)
1956 real(esmf_kind_r8),
pointer :: soil_temp_target_ptr(:,:,:)
1958 print*,
"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK." 1960 farrayptr=landmask_ptr, rc=rc)
1961 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1962 call error_handler(
"IN FieldGet", rc)
1964 print*,
"- CALL FieldGet FOR TARGET GRID VEGETATION TYPE." 1966 farrayptr=veg_type_target_ptr, rc=rc)
1967 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1968 call error_handler(
"IN FieldGet", rc)
1970 print*,
"- CALL FieldGet FOR TARGET GRID TERRAIN." 1972 farrayptr=terrain_target_ptr, rc=rc)
1973 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1974 call error_handler(
"IN FieldGet", rc)
1976 print*,
"- CALL FieldGet FOR TERRAIN INTERP TO TARGET GRID." 1978 farrayptr=terrain_input_ptr, rc=rc)
1979 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1980 call error_handler(
"IN FieldGet", rc)
1982 print*,
"- CALL FieldGet FOR SOIL TEMP TARGET GRID." 1984 computationallbound=clb, &
1985 computationalubound=cub, &
1986 farrayptr=soil_temp_target_ptr, rc=rc)
1987 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1988 call error_handler(
"IN FieldGet", rc)
1990 do j = clb(2), cub(2)
1991 do i = clb(1), cub(1)
1992 if (landmask_ptr(i,j) == 1)
then 1993 terrain_diff = abs(terrain_input_ptr(i,j) - terrain_target_ptr(i,j))
1994 if (terrain_diff > 100.0)
then 1995 do k = clb(3), cub(3)
1996 soil_temp_target_ptr(i,j,k) = soil_temp_target_ptr(i,j,k) + &
1997 ((terrain_input_ptr(i,j) - terrain_target_ptr(i,j)) * lapse_rate)
1999 soil_temp_target_ptr(i,j,k) = min(soil_temp_target_ptr(i,j,k), 273.16)
2017 use sfc_input_data,
only : lsoil_input, soil_temp_input_grid, &
2018 soilm_liq_input_grid, soilm_tot_input_grid
2020 integer,
intent(in) :: localpet
2021 character(len=500) :: msg
2022 character(len=2) :: lsoil_input_ch, lsoil_target_ch
2024 real(esmf_kind_r8) :: tmp(i_input,j_input), &
2025 data_one_tile(i_input,j_input,lsoil_input), &
2026 tmp3d(i_input,j_input,lsoil_target)
2027 if (lsoil_input == 9 .and. lsoil_target == 4)
then 2028 print*,
"CONVERTING FROM 9 INPUT SOIL LEVELS TO 4 TARGET SOIL LEVELS" 2029 call esmf_fieldgather(soil_temp_input_grid, data_one_tile, rootpet=0, tile=1, rc=rc)
2030 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2031 call error_handler(
"IN FieldGather", rc)
2033 call esmf_fielddestroy(soil_temp_input_grid,rc=rc)
2034 soil_temp_input_grid = esmf_fieldcreate(
input_grid, &
2035 typekind=esmf_typekind_r8, &
2036 staggerloc=esmf_staggerloc_center, &
2037 ungriddedlbound=(/1/), &
2038 ungriddedubound=(/lsoil_target/), rc=rc)
2041 tmp3d(:,:,1)= (data_one_tile(:,:,1) + data_one_tile(:,:,2))/2.0 * 0.1 + &
2042 (data_one_tile(:,:,2) + data_one_tile(:,:,3))/2.0 * 0.3 + &
2043 (data_one_tile(:,:,3) + data_one_tile(:,:,4))/2.0 * 0.6
2044 tmp = (data_one_tile(:,:,6) - data_one_tile(:,:,5)) / 30.0 * 10.0 + data_one_tile(:,:,5)
2045 tmp3d(:,:,2)= (data_one_tile(:,:,4) + data_one_tile(:,:,5)) / 2.0 * 0.75 + &
2046 (data_one_tile(:,:,5) + tmp) / 2.0 * 0.25
2047 tmp3d(:,:,3)= (tmp + data_one_tile(:,:,6)) /2.0 * (1.0/3.0) + &
2048 (data_one_tile(:,:,6) + data_one_tile(:,:,7)) / 2.0 * (2.0/3.0)
2049 tmp = (data_one_tile(:,:,9) - data_one_tile(:,:,9)) / 140.0 * 40.0 + data_one_tile(:,:,8)
2050 tmp3d(:,:,4)= (data_one_tile(:,:,7) + data_one_tile(:,:,8)) / 2.0 * 0.6 + &
2051 (data_one_tile(:,:,8) + tmp) / 2.0 * 0.4
2054 call esmf_fieldscatter(soil_temp_input_grid, tmp3d, rootpet=0, rc=rc)
2055 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2056 call error_handler(
"IN FieldScatter", rc)
2058 call esmf_fieldgather(soilm_tot_input_grid, data_one_tile, rootpet=0, tile=1, rc=rc)
2059 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2060 call error_handler(
"IN FieldGather", rc)
2062 call esmf_fielddestroy(soilm_tot_input_grid,rc=rc)
2063 soilm_tot_input_grid = esmf_fieldcreate(
input_grid, &
2064 typekind=esmf_typekind_r8, &
2065 staggerloc=esmf_staggerloc_center, &
2066 ungriddedlbound=(/1/), &
2067 ungriddedubound=(/lsoil_target/), rc=rc)
2069 if(localpet==0)
then 2070 tmp3d(:,:,1)= (data_one_tile(:,:,1) + data_one_tile(:,:,2))/2.0 * 0.1 + &
2071 (data_one_tile(:,:,2) + data_one_tile(:,:,3))/2.0 * 0.3 + &
2072 (data_one_tile(:,:,3) + data_one_tile(:,:,4))/2.0 * 0.6
2073 tmp = (data_one_tile(:,:,6) - data_one_tile(:,:,5)) / 30.0 * 10.0 + data_one_tile(:,:,5)
2074 tmp3d(:,:,2)= (data_one_tile(:,:,4) + data_one_tile(:,:,5)) / 2.0 * 0.75 + &
2075 (data_one_tile(:,:,5) + tmp) / 2.0 * 0.25
2076 tmp3d(:,:,3)= (tmp + data_one_tile(:,:,6)) /2.0 * (1.0/3.0) + &
2077 (data_one_tile(:,:,6) + data_one_tile(:,:,7)) / 2.0 * (2.0/3.0)
2078 tmp = (data_one_tile(:,:,9) - data_one_tile(:,:,9)) / 140.0 * 40.0 + data_one_tile(:,:,8)
2079 tmp3d(:,:,4)= (data_one_tile(:,:,7) + data_one_tile(:,:,8)) / 2.0 * 0.6 + &
2080 (data_one_tile(:,:,8) + tmp) / 2.0 * 0.4
2083 call esmf_fieldscatter(soilm_tot_input_grid, tmp3d, rootpet=0, rc=rc)
2084 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2085 call error_handler(
"IN FieldScatter", rc)
2087 call esmf_fieldgather(soilm_liq_input_grid, data_one_tile, rootpet=0, tile=1, rc=rc)
2088 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2089 call error_handler(
"IN FieldGather", rc)
2091 call esmf_fielddestroy(soilm_liq_input_grid,rc=rc)
2092 soilm_liq_input_grid = esmf_fieldcreate(
input_grid, &
2093 typekind=esmf_typekind_r8, &
2094 staggerloc=esmf_staggerloc_center, &
2095 ungriddedlbound=(/1/), &
2096 ungriddedubound=(/lsoil_target/), rc=rc)
2097 if(localpet==0)
then 2098 tmp3d(:,:,1)= (data_one_tile(:,:,1) + data_one_tile(:,:,2))/2.0 * 0.1 + &
2099 (data_one_tile(:,:,2) + data_one_tile(:,:,3))/2.0 * 0.3 + &
2100 (data_one_tile(:,:,3) + data_one_tile(:,:,4))/2.0 * 0.6
2101 tmp = (data_one_tile(:,:,6) - data_one_tile(:,:,5)) / 30.0 * 10.0 + data_one_tile(:,:,5)
2102 tmp3d(:,:,2)= (data_one_tile(:,:,4) + data_one_tile(:,:,5)) / 2.0 * 0.75 + &
2103 (data_one_tile(:,:,5) + tmp) / 2.0 * 0.25
2104 tmp3d(:,:,3)= (tmp + data_one_tile(:,:,6)) /2.0 * (1.0/3.0) + &
2105 (data_one_tile(:,:,6) + data_one_tile(:,:,7)) / 2.0 * (2.0/3.0)
2106 tmp = (data_one_tile(:,:,9) - data_one_tile(:,:,9)) / 140.0 * 40.0 + data_one_tile(:,:,8)
2107 tmp3d(:,:,4)= (data_one_tile(:,:,7) + data_one_tile(:,:,8)) / 2.0 * 0.6 + &
2108 (data_one_tile(:,:,8) + tmp) / 2.0 * 0.4
2111 call esmf_fieldscatter(soilm_liq_input_grid, tmp3d, rootpet=0, rc=rc)
2112 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2113 call error_handler(
"IN FieldScatter", rc)
2115 elseif (lsoil_input /= lsoil_target)
then 2117 write(lsoil_input_ch,
'(i2)') lsoil_input
2118 write(lsoil_target_ch,
'(i2)') lsoil_target
2119 msg=
"NUMBER OF SOIL LEVELS IN INPUT " // lsoil_input_ch //
" AND OUTPUT " &
2120 // lsoil_target_ch //
" MUST EITHER BE EQUAL OR 9 AND 4 RESPECTIVELY." 2121 call error_handler(msg, rc)
2138 integer :: clb(2), cub(2), i, j, rc
2139 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
2142 real(esmf_kind_r8),
pointer :: data_ptr(:,:)
2143 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
2145 data z0_igbp /1.089, 2.653, 0.854, 0.826, 0.800, 0.050, &
2146 0.030, 0.856, 0.856, 0.150, 0.040, 0.130, &
2147 1.000, 0.250, 0.011, 0.011, 0.001, 0.076, &
2150 print*,
"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK." 2152 computationallbound=clb, &
2153 computationalubound=cub, &
2154 farrayptr=landmask_ptr, rc=rc)
2155 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2156 call error_handler(
"IN FieldGet", rc)
2158 print*,
"- CALL FieldGet FOR TARGET GRID VEGETATION TYPE." 2160 farrayptr=veg_type_ptr, rc=rc)
2161 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2162 call error_handler(
"IN FieldGet", rc)
2164 print*,
"- CALL FieldGet FOR TARGET GRID Z0." 2166 farrayptr=data_ptr, rc=rc)
2167 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2168 call error_handler(
"IN FieldGet", rc)
2170 do j = clb(2), cub(2)
2171 do i = clb(1), cub(1)
2172 if (landmask_ptr(i,j) == 2)
then 2174 elseif (landmask_ptr(i,j) == 1)
then 2175 data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0
2206 integer :: clb(2), cub(2), i, j, rc
2207 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
2209 real(esmf_kind_r8),
pointer :: data_ptr(:,:)
2210 real(esmf_kind_r8),
pointer :: data3d_ptr(:,:,:)
2211 real(esmf_kind_r8),
pointer :: soilmt_ptr(:,:,:)
2212 real(esmf_kind_r8),
pointer :: soilml_ptr(:,:,:)
2213 real(esmf_kind_r8),
pointer :: veg_greenness_ptr(:,:)
2214 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
2215 real(esmf_kind_r8),
pointer :: seaice_skint_ptr(:,:)
2216 real(esmf_kind_r8),
pointer :: skint_ptr(:,:)
2217 real(esmf_kind_r8),
pointer :: fice_ptr(:,:)
2218 real(esmf_kind_r8),
pointer :: hice_ptr(:,:)
2220 print*,
"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK." 2222 computationallbound=clb, &
2223 computationalubound=cub, &
2224 farrayptr=landmask_ptr, rc=rc)
2225 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2226 call error_handler(
"IN FieldGet", rc)
2228 print*,
"- SET NON-LAND FLAG FOR TARGET GRID SLOPE TYPE." 2230 farrayptr=data_ptr, rc=rc)
2231 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2232 call error_handler(
"IN FieldGet", rc)
2234 do j = clb(2), cub(2)
2235 do i = clb(1), cub(1)
2236 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2240 print*,
"- SET NON-LAND FLAG FOR TARGET GRID SOIL TYPE." 2242 farrayptr=data_ptr, rc=rc)
2243 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2244 call error_handler(
"IN FieldGet", rc)
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 VEGETATION TYPE." 2254 farrayptr=veg_type_ptr, rc=rc)
2255 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2256 call error_handler(
"IN FieldGet", rc)
2258 do j = clb(2), cub(2)
2259 do i = clb(1), cub(1)
2260 if (landmask_ptr(i,j) /= 1) veg_type_ptr(i,j) = 0.0
2264 print*,
"- SET TARGET GRID ALVSF AT NON-LAND." 2266 farrayptr=data_ptr, rc=rc)
2267 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2268 call error_handler(
"IN FieldGet", rc)
2270 do j = clb(2), cub(2)
2271 do i = clb(1), cub(1)
2272 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06
2276 print*,
"- SET TARGET GRID ALVWF AT NON-LAND." 2278 farrayptr=data_ptr, rc=rc)
2279 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2280 call error_handler(
"IN FieldGet", rc)
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 ALNSF AT NON-LAND." 2290 farrayptr=data_ptr, rc=rc)
2291 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2292 call error_handler(
"IN FieldGet", rc)
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 ALNWF AT NON-LAND." 2302 farrayptr=data_ptr, rc=rc)
2303 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2304 call error_handler(
"IN FieldGet", rc)
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 NON-LAND FLAG FOR TARGET GRID FACSF." 2314 farrayptr=data_ptr, rc=rc)
2315 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2316 call error_handler(
"IN FieldGet", rc)
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.0
2324 print*,
"- SET NON-LAND FLAG FOR TARGET GRID FACSF." 2326 farrayptr=data_ptr, rc=rc)
2327 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2328 call error_handler(
"IN FieldGet", rc)
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 MAXIMUM GREENNESS." 2338 farrayptr=data_ptr, rc=rc)
2339 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2340 call error_handler(
"IN FieldGet", rc)
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 MINIMUM GREENNESS." 2350 farrayptr=data_ptr, rc=rc)
2351 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2352 call error_handler(
"IN FieldGet", rc)
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 VEGETATION GREENNESS." 2362 farrayptr=veg_greenness_ptr, rc=rc)
2363 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2364 call error_handler(
"IN FieldGet", rc)
2366 do j = clb(2), cub(2)
2367 do i = clb(1), cub(1)
2368 if (landmask_ptr(i,j) /= 1) veg_greenness_ptr(i,j) = 0.0
2372 print*,
"- SET NON-LAND FLAG FOR TARGET GRID MAX SNOW ALBEDO." 2374 farrayptr=data_ptr, rc=rc)
2375 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2376 call error_handler(
"IN FieldGet", rc)
2378 do j = clb(2), cub(2)
2379 do i = clb(1), cub(1)
2380 if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2384 print*,
"- ZERO OUT TARGET GRID CANOPY MOISTURE CONTENT WHERE NO PLANTS." 2386 farrayptr=data_ptr, rc=rc)
2387 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2388 call error_handler(
"IN FieldGet", rc)
2390 do j = clb(2), cub(2)
2391 do i = clb(1), cub(1)
2392 if (veg_greenness_ptr(i,j) <= 0.01) data_ptr(i,j) = 0.0
2396 print*,
"- CALL FieldGet FOR TARGET GRID ICE SKIN TEMP." 2398 farrayptr=seaice_skint_ptr, rc=rc)
2399 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2400 call error_handler(
"IN FieldGet", rc)
2402 print*,
"- SET TARGET GRID SKIN TEMP AT ICE POINTS." 2404 farrayptr=skint_ptr, rc=rc)
2405 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2406 call error_handler(
"IN FieldGet", rc)
2408 print*,
"- CALL FieldGet FOR TARGET GRID SEA ICE FRACTION." 2410 farrayptr=fice_ptr, rc=rc)
2411 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2412 call error_handler(
"IN FieldGet", rc)
2414 print*,
"- SET TARGET GRID SEA ICE DEPTH TO ZERO AT NON-ICE POINTS." 2416 farrayptr=hice_ptr, rc=rc)
2417 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2418 call error_handler(
"IN FieldGet", rc)
2420 do j = clb(2), cub(2)
2421 do i = clb(1), cub(1)
2422 if (fice_ptr(i,j) > 0.0)
then 2423 skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + &
2424 ( (1.0 - fice_ptr(i,j)) *
frz_ice )
2426 seaice_skint_ptr(i,j) = skint_ptr(i,j)
2432 print*,
"- SET TARGET GRID SUBSTRATE TEMP AT ICE." 2434 farrayptr=data_ptr, rc=rc)
2435 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2436 call error_handler(
"IN FieldGet", rc)
2438 do j = clb(2), cub(2)
2439 do i = clb(1), cub(1)
2440 if (landmask_ptr(i,j) == 2)
then 2442 elseif (landmask_ptr(i,j) == 0)
then 2443 data_ptr(i,j) = skint_ptr(i,j)
2448 print*,
"- ZERO OUT TARGET GRID SNOW DEPTH AT OPEN WATER." 2450 farrayptr=data_ptr, rc=rc)
2451 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2452 call error_handler(
"IN FieldGet", rc)
2454 do j = clb(2), cub(2)
2455 do i = clb(1), cub(1)
2456 if (landmask_ptr(i,j) == 0)
then 2462 print*,
"- ZERO OUT TARGET GRID SNOW LIQ AT OPEN WATER." 2464 farrayptr=data_ptr, rc=rc)
2465 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2466 call error_handler(
"IN FieldGet", rc)
2468 do j = clb(2), cub(2)
2469 do i = clb(1), cub(1)
2470 if (landmask_ptr(i,j) == 0)
then 2476 print*,
"- SET NON-LAND FLAG VALUE FOR TARGET GRID TOTAL SOIL MOISTURE." 2478 farrayptr=soilmt_ptr, rc=rc)
2479 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2480 call error_handler(
"IN FieldGet", rc)
2482 print*,
"- SET NON-LAND FLAG VALUE FOR TARGET GRID LIQUID SOIL MOISTURE." 2484 farrayptr=soilml_ptr, rc=rc)
2485 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2486 call error_handler(
"IN FieldGet", rc)
2488 do j = clb(2), cub(2)
2489 do i = clb(1), cub(1)
2490 if (landmask_ptr(i,j) == 2 .or. landmask_ptr(i,j) == 0 .or. &
2492 soilmt_ptr(i,j,:) = 1.0
2493 soilml_ptr(i,j,:) = 1.0
2498 print*,
"- SET OPEN WATER FLAG FOR TARGET GRID SOIL TEMPERATURE." 2500 farrayptr=data3d_ptr, rc=rc)
2501 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2502 call error_handler(
"IN FieldGet", rc)
2504 do j = clb(2), cub(2)
2505 do i = clb(1), cub(1)
2506 if (landmask_ptr(i,j) == 0)
then 2507 data3d_ptr(i,j,:) = skint_ptr(i,j)
2526 integer(esmf_kind_i8),
pointer :: mask_ptr(:,:)
2528 integer,
PARAMETER :: num_nst_fields_minus2 = 16
2529 integer,
PARAMETER :: xz_fill = 30.0
2530 integer,
PARAMETER :: nst_fill = 0.0
2532 real(esmf_kind_r8),
pointer :: data_ptr(:,:)
2533 real(esmf_kind_r8),
pointer :: skint_ptr(:,:)
2535 type(esmf_field) :: temp_field
2536 type(esmf_fieldbundle) :: nst_bundle
2538 print*,
"- CALL FieldGet FOR TARGET GRID LANDMASK." 2540 farrayptr=mask_ptr, rc=rc)
2541 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2542 call error_handler(
"IN FieldGet", rc)
2544 nst_bundle = esmf_fieldbundlecreate(name=
"nst_bundle", rc=rc)
2545 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2546 call error_handler(
"IN FieldBundleCreate", rc)
2553 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2554 call error_handler(
"IN FieldBundleAdd", rc)
2556 print*,
"- CALL FieldGet FOR TREF." 2558 farrayptr=data_ptr, rc=rc)
2559 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2560 call error_handler(
"IN FieldGet", rc)
2562 print*,
"- CALL FieldGet FOR SKIN T." 2564 farrayptr=skint_ptr, rc=rc)
2565 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2566 call error_handler(
"IN FieldGet", rc)
2568 where(mask_ptr /= 0) data_ptr = skint_ptr
2572 print*,
"- CALL FieldGet FOR XZ." 2574 farrayptr=data_ptr, rc=rc)
2575 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2576 call error_handler(
"IN FieldGet", rc)
2578 where(mask_ptr /= 0) data_ptr = xz_fill
2580 do i = 1,num_nst_fields_minus2
2582 call esmf_fieldbundleget(nst_bundle,i,temp_field,rc=rc)
2583 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2584 call error_handler(
"IN FieldBundleGet", rc)
2586 call esmf_fieldget(temp_field,farrayptr=data_ptr,rc=rc)
2587 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2588 call error_handler(
"IN FieldGet", rc)
2590 where(mask_ptr /= 0) data_ptr = nst_fill
2594 call esmf_fieldbundledestroy(nst_bundle,rc=rc)
2595 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2596 call error_handler(
"IN FieldBundleDestroy", rc)
2611 real(esmf_kind_r8),
pointer :: target_ptr(:,:), target_ptr_3d(:,:,:)
2612 real :: init_val = -999.9
2614 print*,
"- CALL FieldCreate FOR TARGET GRID T2M." 2616 typekind=esmf_typekind_r8, &
2617 name=
"t2m_target_grid", &
2618 staggerloc=esmf_staggerloc_center, rc=rc)
2619 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2620 call error_handler(
"IN FieldCreate", rc)
2622 print*,
"- INITIALIZE TARGET grid t2m." 2624 farrayptr=target_ptr, rc=rc)
2625 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2626 call error_handler(
"IN FieldGet", rc)
2628 target_ptr = init_val
2630 print*,
"- CALL FieldCreate FOR TARGET GRID Q2M." 2632 typekind=esmf_typekind_r8, &
2633 name=
"q2m_target_grid", &
2634 staggerloc=esmf_staggerloc_center, rc=rc)
2635 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2636 call error_handler(
"IN FieldCreate", rc)
2638 print*,
"- INITIALIZE TARGET grid q2m." 2640 farrayptr=target_ptr, rc=rc)
2641 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2642 call error_handler(
"IN FieldGet", rc)
2644 target_ptr = init_val
2646 print*,
"- CALL FieldCreate FOR TARGET GRID TPRCP." 2648 typekind=esmf_typekind_r8, &
2649 name=
"tprcp_target_grid", &
2650 staggerloc=esmf_staggerloc_center, rc=rc)
2651 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2652 call error_handler(
"IN FieldCreate", rc)
2654 print*,
"- INITIALIZE TARGET grid tprcp." 2656 farrayptr=target_ptr, rc=rc)
2657 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2658 call error_handler(
"IN FieldGet", rc)
2660 target_ptr = init_val
2662 print*,
"- CALL FieldCreate FOR TARGET GRID F10M." 2664 typekind=esmf_typekind_r8, &
2665 name=
"f10m_target_grid", &
2666 staggerloc=esmf_staggerloc_center, rc=rc)
2667 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2668 call error_handler(
"IN FieldCreate", rc)
2670 print*,
"- INITIALIZE TARGET grid f10m." 2672 farrayptr=target_ptr, rc=rc)
2673 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2674 call error_handler(
"IN FieldGet", rc)
2676 target_ptr = init_val
2678 print*,
"- CALL FieldCreate FOR TARGET GRID FFMM." 2680 typekind=esmf_typekind_r8, &
2681 name=
"ffmm_target_grid", &
2682 staggerloc=esmf_staggerloc_center, rc=rc)
2683 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2684 call error_handler(
"IN FieldCreate", rc)
2686 print*,
"- INITIALIZE TARGET grid ffmm." 2688 farrayptr=target_ptr, rc=rc)
2689 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2690 call error_handler(
"IN FieldGet", rc)
2692 target_ptr = init_val
2694 print*,
"- CALL FieldCreate FOR TARGET GRID USTAR." 2696 typekind=esmf_typekind_r8, &
2697 name=
"ustar_target_grid", &
2698 staggerloc=esmf_staggerloc_center, rc=rc)
2699 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2700 call error_handler(
"IN FieldCreate", rc)
2702 print*,
"- INITIALIZE TARGET grid ustar." 2704 farrayptr=target_ptr, rc=rc)
2705 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2706 call error_handler(
"IN FieldGet", rc)
2708 target_ptr = init_val
2710 print*,
"- CALL FieldCreate FOR TARGET GRID SNOW LIQ EQUIV." 2712 typekind=esmf_typekind_r8, &
2713 name=
"snow_liq_equiv_target_grid", &
2714 staggerloc=esmf_staggerloc_center, rc=rc)
2715 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2716 call error_handler(
"IN FieldCreate", rc)
2718 print*,
"- INITIALIZE TARGET grid snow liq equiv." 2720 farrayptr=target_ptr, rc=rc)
2721 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2722 call error_handler(
"IN FieldGet", rc)
2724 target_ptr = init_val
2726 print*,
"- CALL FieldCreate FOR TARGET GRID SNOW DEPTH." 2728 typekind=esmf_typekind_r8, &
2729 name=
"snow_depth_target_grid", &
2730 staggerloc=esmf_staggerloc_center, rc=rc)
2731 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2732 call error_handler(
"IN FieldCreate", rc)
2734 print*,
"- INITIALIZE TARGET grid snow depth." 2736 farrayptr=target_ptr, rc=rc)
2737 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2738 call error_handler(
"IN FieldGet", rc)
2740 target_ptr = init_val
2742 print*,
"- CALL FieldCreate FOR TARGET GRID SEA ICE FRACTION." 2744 typekind=esmf_typekind_r8, &
2745 name=
"seaice_fract_target_grid", &
2746 staggerloc=esmf_staggerloc_center, rc=rc)
2747 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2748 call error_handler(
"IN FieldCreate", rc)
2750 print*,
"- INITIALIZE TARGET grid sea ice fraction." 2752 farrayptr=target_ptr, rc=rc)
2753 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2754 call error_handler(
"IN FieldGet", rc)
2756 target_ptr = init_val
2758 print*,
"- CALL FieldCreate FOR TARGET GRID SEA ICE DEPTH." 2760 typekind=esmf_typekind_r8, &
2761 name=
"seaice_depth_target_grid", &
2762 staggerloc=esmf_staggerloc_center, rc=rc)
2763 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2764 call error_handler(
"IN FieldCreate", rc)
2766 print*,
"- INITIALIZE TARGET sea ice depth." 2768 farrayptr=target_ptr, rc=rc)
2769 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2770 call error_handler(
"IN FieldGet", rc)
2772 target_ptr = init_val
2774 print*,
"- CALL FieldCreate FOR TARGET GRID SEA ICE SKIN TEMP." 2776 typekind=esmf_typekind_r8, &
2777 name=
"seaice_skin_temp_target_grid", &
2778 staggerloc=esmf_staggerloc_center, rc=rc)
2779 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2780 call error_handler(
"IN FieldCreate", rc)
2782 print*,
"- INITIALIZE TARGET sea ice skin temp." 2784 farrayptr=target_ptr, rc=rc)
2785 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2786 call error_handler(
"IN FieldGet", rc)
2788 target_ptr = init_val
2790 print*,
"- CALL FieldCreate FOR TARGET GRID SRFLAG." 2792 typekind=esmf_typekind_r8, &
2793 name=
"srflag_target_grid", &
2794 staggerloc=esmf_staggerloc_center, rc=rc)
2795 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2796 call error_handler(
"IN FieldCreate", rc)
2798 print*,
"- INITIALIZE TARGET srflag." 2800 farrayptr=target_ptr, rc=rc)
2801 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2802 call error_handler(
"IN FieldGet", rc)
2804 target_ptr = init_val
2806 print*,
"- CALL FieldCreate FOR TARGET GRID SKIN TEMPERATURE." 2808 typekind=esmf_typekind_r8, &
2809 name=
"skin_temp_target_grid", &
2810 staggerloc=esmf_staggerloc_center, rc=rc)
2811 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2812 call error_handler(
"IN FieldCreate", rc)
2814 print*,
"- INITIALIZE TARGET grid skin temp." 2816 farrayptr=target_ptr, rc=rc)
2817 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2818 call error_handler(
"IN FieldGet", rc)
2820 target_ptr = init_val
2822 print*,
"- CALL FieldCreate FOR TARGET GRID CANOPY MOISTURE CONTENT." 2824 typekind=esmf_typekind_r8, &
2825 name=
"canopy_mc_target_grid", &
2826 staggerloc=esmf_staggerloc_center, rc=rc)
2827 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2828 call error_handler(
"IN FieldCreate", rc)
2830 print*,
"- INITIALIZE TARGET grid canopy moisture." 2832 farrayptr=target_ptr, rc=rc)
2833 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2834 call error_handler(
"IN FieldGet", rc)
2836 target_ptr = init_val
2838 print*,
"- CALL FieldCreate FOR TARGET GRID LEAF AREA INDEX." 2840 typekind=esmf_typekind_r8, &
2841 name=
"lai_target_grid",&
2842 staggerloc=esmf_staggerloc_center, rc=rc)
2843 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2844 call error_handler(
"IN FieldCreate", rc)
2846 print*,
"- INITIALIZE TARGET leaf area index." 2848 farrayptr=target_ptr, rc=rc)
2849 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2850 call error_handler(
"IN FieldGet", rc)
2852 target_ptr = init_val
2854 print*,
"- CALL FieldCreate FOR TARGET GRID Z0." 2856 typekind=esmf_typekind_r8, &
2857 name=
"z0_target_grid", &
2858 staggerloc=esmf_staggerloc_center, rc=rc)
2859 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2860 call error_handler(
"IN FieldCreate", rc)
2862 print*,
"- INITIALIZE TARGET grid z0." 2864 farrayptr=target_ptr, rc=rc)
2865 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2866 call error_handler(
"IN FieldGet", rc)
2868 target_ptr = init_val
2870 print*,
"- CALL FieldCreate FOR INTERPOLATED TARGET GRID TERRAIN." 2872 typekind=esmf_typekind_r8, &
2873 name=
"terrain_from_input_grid", &
2874 staggerloc=esmf_staggerloc_center, rc=rc)
2875 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2876 call error_handler(
"IN FieldCreate", rc)
2878 print*,
"- INITIALIZE TARGET grid interpolated terrain." 2880 farrayptr=target_ptr, rc=rc)
2881 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2882 call error_handler(
"IN FieldGet", rc)
2884 target_ptr = init_val
2886 print*,
"- CALL FieldCreate FOR INTERPOLATED TARGET GRID SOIL TYPE." 2888 typekind=esmf_typekind_r8, &
2889 staggerloc=esmf_staggerloc_center, &
2890 name=
"soil_type_from_input_grid", rc=rc)
2891 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2892 call error_handler(
"IN FieldCreate", rc)
2894 print*,
"- INITIALIZE TARGET grid soil type" 2896 farrayptr=target_ptr, rc=rc)
2897 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2898 call error_handler(
"IN FieldGet", rc)
2900 target_ptr = init_val
2902 print*,
"- CALL FieldCreate FOR TARGET GRID SOIL TEMPERATURE." 2904 typekind=esmf_typekind_r8, &
2905 staggerloc=esmf_staggerloc_center, &
2906 name=
"soil_temp_target_grid", &
2907 ungriddedlbound=(/1/), &
2909 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2910 call error_handler(
"IN FieldCreate", rc)
2912 print*,
"- INITIALIZE TARGET grid soil temp" 2914 farrayptr=target_ptr_3d, rc=rc)
2915 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2916 call error_handler(
"IN FieldGet", rc)
2918 target_ptr_3d = init_val
2920 print*,
"- CALL FieldCreate FOR TARGET GRID TOTAL SOIL MOISTURE." 2922 typekind=esmf_typekind_r8, &
2923 staggerloc=esmf_staggerloc_center, &
2924 name=
"soilm_tot_target_grid", &
2925 ungriddedlbound=(/1/), &
2927 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2928 call error_handler(
"IN FieldCreate", rc)
2930 print*,
"- INITIALIZE TARGET grid soil moist" 2932 farrayptr=target_ptr_3d, rc=rc)
2933 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2934 call error_handler(
"IN FieldGet", rc)
2936 target_ptr_3d = init_val
2938 print*,
"- CALL FieldCreate FOR TARGET GRID LIQUID SOIL MOISTURE." 2940 typekind=esmf_typekind_r8, &
2941 staggerloc=esmf_staggerloc_center, &
2942 name=
"soilm_liq_target_grid", &
2943 ungriddedlbound=(/1/), &
2945 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2946 call error_handler(
"IN FieldCreate", rc)
2948 print*,
"- INITIALIZE TARGET grid soil liq" 2950 farrayptr=target_ptr_3d, rc=rc)
2951 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2952 call error_handler(
"IN FieldGet", rc)
2954 target_ptr_3d = init_val
2969 print*,
"- CALL FieldCreate FOR TARGET GRID C_D." 2971 typekind=esmf_typekind_r8, &
2973 staggerloc=esmf_staggerloc_center, rc=rc)
2974 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2975 call error_handler(
"IN FieldCreate", rc)
2977 print*,
"- CALL FieldCreate FOR TARGET GRID C_0." 2979 typekind=esmf_typekind_r8, &
2981 staggerloc=esmf_staggerloc_center, rc=rc)
2982 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2983 call error_handler(
"IN FieldCreate", rc)
2985 print*,
"- CALL FieldCreate FOR TARGET GRID D_CONV." 2987 typekind=esmf_typekind_r8, &
2989 staggerloc=esmf_staggerloc_center, rc=rc)
2990 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2991 call error_handler(
"IN FieldCreate", rc)
2993 print*,
"- CALL FieldCreate FOR TARGET GRID DT_COOL." 2995 typekind=esmf_typekind_r8, &
2997 staggerloc=esmf_staggerloc_center, rc=rc)
2998 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2999 call error_handler(
"IN FieldCreate", rc)
3001 print*,
"- CALL FieldCreate FOR TARGET GRID IFD." 3003 typekind=esmf_typekind_r8, &
3005 staggerloc=esmf_staggerloc_center, rc=rc)
3006 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3007 call error_handler(
"IN FieldCreate", rc)
3009 print*,
"- CALL FieldCreate FOR TARGET GRID QRAIN." 3011 typekind=esmf_typekind_r8, &
3013 staggerloc=esmf_staggerloc_center, rc=rc)
3014 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3015 call error_handler(
"IN FieldCreate", rc)
3017 print*,
"- CALL FieldCreate FOR TARGET GRID TREF." 3019 typekind=esmf_typekind_r8, &
3021 staggerloc=esmf_staggerloc_center, rc=rc)
3022 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3023 call error_handler(
"IN FieldCreate", rc)
3025 print*,
"- CALL FieldCreate FOR TARGET GRID W_D." 3027 typekind=esmf_typekind_r8, &
3029 staggerloc=esmf_staggerloc_center, rc=rc)
3030 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3031 call error_handler(
"IN FieldCreate", rc)
3033 print*,
"- CALL FieldCreate FOR TARGET GRID W_0." 3035 typekind=esmf_typekind_r8, &
3037 staggerloc=esmf_staggerloc_center, rc=rc)
3038 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3039 call error_handler(
"IN FieldCreate", rc)
3041 print*,
"- CALL FieldCreate FOR TARGET GRID XS." 3043 typekind=esmf_typekind_r8, &
3045 staggerloc=esmf_staggerloc_center, rc=rc)
3046 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3047 call error_handler(
"IN FieldCreate", rc)
3049 print*,
"- CALL FieldCreate FOR TARGET GRID XT." 3051 typekind=esmf_typekind_r8, &
3053 staggerloc=esmf_staggerloc_center, rc=rc)
3054 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3055 call error_handler(
"IN FieldCreate", rc)
3057 print*,
"- CALL FieldCreate FOR TARGET GRID XU." 3059 typekind=esmf_typekind_r8, &
3061 staggerloc=esmf_staggerloc_center, rc=rc)
3062 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3063 call error_handler(
"IN FieldCreate", rc)
3065 print*,
"- CALL FieldCreate FOR TARGET GRID XV." 3067 typekind=esmf_typekind_r8, &
3069 staggerloc=esmf_staggerloc_center, rc=rc)
3070 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3071 call error_handler(
"IN FieldCreate", rc)
3073 print*,
"- CALL FieldCreate FOR TARGET GRID XZ." 3075 typekind=esmf_typekind_r8, &
3077 staggerloc=esmf_staggerloc_center, rc=rc)
3078 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3079 call error_handler(
"IN FieldCreate", rc)
3081 print*,
"- CALL FieldCreate FOR TARGET GRID XTTS." 3083 typekind=esmf_typekind_r8, &
3085 staggerloc=esmf_staggerloc_center, rc=rc)
3086 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3087 call error_handler(
"IN FieldCreate", rc)
3089 print*,
"- CALL FieldCreate FOR TARGET GRID XZTS." 3091 typekind=esmf_typekind_r8, &
3093 staggerloc=esmf_staggerloc_center, rc=rc)
3094 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3095 call error_handler(
"IN FieldCreate", rc)
3097 print*,
"- CALL FieldCreate FOR TARGET GRID Z_C." 3099 typekind=esmf_typekind_r8, &
3101 staggerloc=esmf_staggerloc_center, rc=rc)
3102 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3103 call error_handler(
"IN FieldCreate", rc)
3105 print*,
"- CALL FieldCreate FOR TARGET GRID ZM." 3107 typekind=esmf_typekind_r8, &
3109 staggerloc=esmf_staggerloc_center, rc=rc)
3110 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3111 call error_handler(
"IN FieldCreate", rc)
3123 subroutine ij_to_i_j(ij, itile, jtile, i, j)
3127 integer(esmf_kind_i4),
intent(in) :: ij
3128 integer ,
intent(in) :: itile, jtile
3130 integer ,
intent(out) :: i, j
3133 integer :: pt_loc_this_tile
3135 tile_num = ((ij-1) / (itile*jtile))
3136 pt_loc_this_tile = ij - (tile_num * itile * jtile)
3139 j = (pt_loc_this_tile - 1) / itile + 1
3140 i = mod(pt_loc_this_tile, itile)
3158 subroutine regrid_many(bundle_pre,bundle_post, num_field,route,dozero, &
3159 unmapped_ptr,resetifd)
3167 integer,
intent(in) :: num_field
3168 type(esmf_routehandle),
intent(inout) :: route
3169 type(esmf_fieldbundle),
intent(in) :: bundle_pre, bundle_post
3170 logical,
intent(in) :: dozero(num_field)
3171 logical,
intent(in),
optional :: resetifd
3172 integer(esmf_kind_i4),
intent(inout),
optional :: unmapped_ptr(:)
3174 type(esmf_field) :: field_pre,field_post
3175 real(esmf_kind_r8),
pointer :: tmp_ptr(:,:)
3178 logical :: is2d(num_field)
3179 character(len=50) :: fname
3180 integer :: i, j, k, ij, ind_2d, ind_3d, rc, ndims,n2d, n3d,localpet, l(1), u(1)
3186 if(
present(unmapped_ptr))
then 3187 l = lbound(unmapped_ptr)
3188 u = ubound(unmapped_ptr)
3192 call esmf_fieldbundleget(bundle_pre,i,field_pre,rc=rc)
3193 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3194 call error_handler(
"IN FieldBundleGet", rc)
3196 call esmf_fieldbundleget(bundle_post,i,field_post,rc=rc)
3197 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3198 call error_handler(
"IN FieldBundleGet", rc)
3200 call esmf_fieldget(field_post,dimcount=ndims,name=fname,rc=rc)
3201 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3202 call error_handler(
"IN FieldGet", rc)
3204 call esmf_vmgetglobal(vm, rc=rc)
3205 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3206 call error_handler(
"IN VMGetGlobal", rc)
3207 call esmf_vmget(vm, localpet=localpet, rc=rc)
3208 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3209 call error_handler(
"IN VMGet", rc)
3210 if(localpet==0) print*,
"in regrid_many fname = ", fname, ndims
3211 if (ndims == 2) is2d(i) = .true.
3212 if (ndims == 3) is2d(i) = .false.
3215 call esmf_fieldregrid(field_pre, &
3217 routehandle=route, &
3218 termorderflag=esmf_termorder_srcseq, rc=rc)
3219 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3220 call error_handler(
"IN FieldRegrid", rc)
3222 call esmf_fieldregrid(field_pre, &
3224 routehandle=route, &
3225 zeroregion=esmf_region_select, &
3226 termorderflag=esmf_termorder_srcseq, rc=rc)
3227 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3228 call error_handler(
"IN FieldRegrid", rc)
3232 if (
present(resetifd))
then 3235 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3236 call error_handler(
"IN FieldGet", rc)
3237 tmp_ptr = float(nint(tmp_ptr))
3241 n2d = count(is2d(:))
3242 n3d = count(.not.is2d(:))
3243 if(localpet==0) print*, is2d(:)
3244 if (
present(unmapped_ptr))
then 3245 allocate(ptr_2d(n2d))
3246 if (n3d .ne. 0)
allocate(ptr_3d(n3d))
3250 call esmf_fieldbundleget(bundle_post,i,field_post,rc=rc)
3251 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3252 call error_handler(
"IN FieldBundleGet", rc)
3253 call esmf_fieldget(field_post, farrayptr=ptr_2d(ind_2d)%p, rc=rc)
3254 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3255 call error_handler(
"IN FieldGet", rc)
3256 call esmf_fieldget(field_post,name=fname,rc=rc)
3257 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3258 call error_handler(
"IN FieldGet", rc)
3259 if (localpet==0) print*,
"in doreplace loop, 2d field = ", trim(fname)
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__))&
3264 call error_handler(
"IN FieldBundleGet", rc)
3265 call esmf_fieldget(field_post,name=fname,rc=rc)
3266 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3267 call error_handler(
"IN FieldGet", rc)
3268 if (localpet==0) print*,
"in doreplace loop, 3d field = ", trim(fname)
3269 call esmf_fieldget(field_post, farrayptr=ptr_3d(ind_3d)%p, rc=rc)
3270 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3271 call error_handler(
"IN FieldGet", rc)
3278 ptr_2d(k)%p(i,j) = -9999.9
3281 ptr_3d(k)%p(i,j,:) = -9999.9
3285 if(n3d .ne. 0)
deallocate(ptr_3d)
3304 subroutine search_many(num_field,bundle_target,field_data_2d,mask, tile, &
3305 search_nums,localpet,latitude,terrain_land,soilt_climo,&
3314 integer,
intent(in) :: num_field
3315 type(esmf_fieldbundle),
intent(inout) :: bundle_target
3319 real(esmf_kind_r8),
intent(inout),
optional :: terrain_land(
i_target,
j_target)
3320 real(esmf_kind_r8),
intent(inout),
optional :: soilt_climo(
i_target,
j_target)
3324 integer,
intent(in) :: tile,localpet
3325 integer,
intent(inout) :: search_nums(num_field)
3327 type(esmf_field) :: temp_field
3328 character(len=50) :: fname
3329 integer,
parameter :: sotyp_land_field_num = 224
3330 integer,
parameter :: sst_field_num = 11
3331 integer,
parameter :: terrain_field_num= 7
3332 integer :: j,k, rc, ndims
3335 call esmf_fieldbundleget(bundle_target,k,temp_field, rc=rc)
3336 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3337 call error_handler(
"IN FieldGet", rc)
3338 call esmf_fieldget(temp_field, name=fname, dimcount=ndims,rc=rc)
3339 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3340 call error_handler(
"IN FieldGet", rc)
3341 if (ndims .eq. 2)
then 3342 print*,
"processing 2d field ", trim(fname)
3343 print*,
"FieldGather" 3344 call esmf_fieldgather(temp_field,field_data_2d,rootpet=0,tile=tile, rc=rc)
3345 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3346 call error_handler(
"IN FieldGather", rc)
3347 if (localpet == 0)
then 3348 if (
present(latitude) .and. search_nums(k).eq.sst_field_num)
then 3352 elseif (
present(terrain_land) .and. search_nums(k) .eq. terrain_field_num)
then 3356 elseif (search_nums(k) .eq. sotyp_land_field_num)
then 3358 if (fname .eq.
"soil_type_target_grid")
then 3363 elseif (
present(soilt_climo))
then 3374 field_data_2d = soilt_climo
3383 call esmf_fieldscatter(temp_field, field_data_2d, rootpet=0, tile=tile,rc=rc)
3384 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3385 call error_handler(
"IN FieldScatter", rc)
3388 print*,
"FieldGather" 3389 call esmf_fieldgather(temp_field,field_data_3d,rootpet=0,tile=tile,rc=rc)
3390 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3391 call error_handler(
"IN FieldGather", rc)
3392 print*,
"processing 3d field ", trim(fname)
3393 if (localpet==0)
then 3395 field_data_2d = field_data_3d(:,:,j)
3397 field_data_3d(:,:,j) = field_data_2d
3400 call esmf_fieldscatter(temp_field, field_data_3d, rootpet=0, tile=tile,rc=rc)
3401 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3402 call error_handler(
"IN FieldScatter", rc)
3420 print*,
"- DESTROY LOCAL TARGET GRID SURFACE FIELDS." type(esmf_field), public d_conv_target_grid
Thickness of free convection layer.
integer, public j_target
j dimension of each global tile, or of a nest, target grid.
type(esmf_field), public zm_target_grid
Oceanic mixed layer depth.
This module contains code to read the setup namelist file, handle the varmap file for GRIB2 data...
real, parameter, private hlice
latent heat of fusion
integer, public num_tiles_target_grid
Number of tiles, target grid.
integer, public lsoil_target
Number of soil layers, target grid.
subroutine roughness
Set roughness length at land and sea ice.
real, parameter, private frz_ice
melting pt sea ice
type(esmf_field), public canopy_mc_target_grid
Canopy moisture content.
type(esmf_field), public f10m_target_grid
log((z0+10)*1/z0) See sfc_diff.f for details.
type(esmf_field), public c_d_target_grid
Coefficient 2 to calculate d(tz)/d(ts).
type(esmf_field), public ifd_target_grid
Model mode index.
integer, public j_input
j-dimension of input grid (or of each global tile)
type(esmf_field), public w_d_target_grid
Coefficient 4 to calculate d(tz)/d(ts).
type(esmf_field), public xtts_target_grid
d(xt)/d(ts).
real, dimension(:), allocatable, public wltsmc_input
Plant wilting point soil moisture content input grid.
subroutine, public search_many(num_field, bundle_target, field_data_2d, mask, tile, search_nums, localpet, latitude, terrain_land, soilt_climo, field_data_3d)
Execute the search function for multple fields.
logical, public lai_from_climo
If false, interpolate leaf area index from the input data to the target grid instead of using data fr...
type(esmf_field), public srflag_target_grid
Snow/rain flag.
type(esmf_field), public xu_target_grid
u-current content in diurnal thermocline layer.
subroutine, public surface_driver(localpet)
Driver routine to process surface/nst data.
real, dimension(:), allocatable, public maxsmc_input
Maximum soil moisture content input grid.
real, dimension(:), allocatable, public satpsi_target
Saturated soil potential, target grid.
Module to hold ESMF fields associated with the target grid surface data.
type(esmf_field), public min_veg_greenness_target_grid
minimum annual greenness fraction
type(esmf_field), public tprcp_target_grid
Precipitation.
type(esmf_field), public max_veg_greenness_target_grid
maximum annual greenness fraction
type(esmf_field), public mxsno_albedo_target_grid
maximum snow albedo
Sets up the ESMF grid objects for the input data grid and target FV3 grid.
real, dimension(:), allocatable, public bb_target
Soil 'b' parameter, target grid.
type(esmf_field), public alvwf_target_grid
visible white sky albedo
type(esmf_field) terrain_from_input_grid_land
terrain height interpolated from input grid at all land points
subroutine cleanup_all_target_sfc_data
Free up memory once the target grid surface fields are no longer needed.
type(esmf_field), public latitude_target_grid
latitude of grid center, target grid
Replace undefined values with a valid value.
integer, public i_target
i dimension of each global tile, or of a nest, target grid.
logical, public sotyp_from_climo
If false, interpolate soil type from the input data to the target grid instead of using data from sta...
type(esmf_field), public xzts_target_grid
d(xz)/d(ts).
logical, public minmax_vgfrc_from_climo
If false, interpolate min/max vegetation fraction from the input data to the target grid instead of u...
type(esmf_field), public c_0_target_grid
Coefficient 1 to calculate d(tz)/d(ts).
subroutine, public create_surface_esmf_fields
Create ESMF fields for the target grid surface variables.
type(esmf_field), public soilm_liq_target_grid
3-d liquid soil moisture.
type(esmf_grid), public target_grid
target grid esmf grid object.
type(esmf_field), public alnsf_target_grid
near ir black sky albedo
type(esmf_field), public xz_target_grid
Diurnal thermocline layer thickness.
real, parameter, private grav
gravity
character(len=20), public external_model
The model that the input data is derived from.
type(esmf_field), public z_c_target_grid
Sub-layer cooling thickness.
subroutine, public search(field, mask, idim, jdim, tile, field_num, latitude, terrain_land, soilt_climo)
Replace undefined surface values.
type(esmf_field) soil_type_from_input_grid
soil type interpolated from input grid
type(esmf_field), public lai_target_grid
Leaf area index.
subroutine, public cleanup_static_fields
Free up memory for fields in this module.
subroutine calc_liq_soil_moisture
Compute liquid portion of the total soil moisture.
type(esmf_field), public landmask_target_grid
land mask target grid - '1' land; '0' non-land
type(esmf_field), public seaice_fract_target_grid
Sea ice fraction.
subroutine rescale_soil_moisture
Adjust soil moisture for changes in soil type between the input and target grids. ...
subroutine adjust_soilt_for_terrain
Adjust soil temperature for changes in terrain height between the input and target grids...
logical, public convert_nst
Convert nst data when true.
type(esmf_field), public snow_liq_equiv_target_grid
Liquid equivalent snow depth.
type(esmf_field), public qrain_target_grid
Sensible heat flux due to rainfall.
type(esmf_field), public soilm_tot_target_grid
3-d total soil moisture.
subroutine adjust_soil_levels(localpet)
Adjust soil levels of the input grid if there is a mismatch between input and target grids...
logical, public tg3_from_soil
If false, use lowest level soil temperature for the base soil temperature instead of using data from ...
integer, parameter veg_type_landice_target
Vegetation type category that defines permanent land ice points.
type(esmf_field), public seaice_depth_target_grid
Sea ice depth.
type(esmf_field), public ffmm_target_grid
log((z0+z1)*1/z0) See sfc_diff.f for details.
type(esmf_field), public seaice_skin_temp_target_grid
Sea ice skin temperature.
subroutine, public interp(localpet)
Horizontally interpolate surface fields from input to target FV3 grid using esmf routines.
type(esmf_field), public alvsf_target_grid
visible black sky albedo
real, dimension(:), allocatable, public drysmc_input
Air dry soil moisture content input grid.
real, dimension(:), allocatable, public wltsmc_target
Plant wilting point soil moisture content target grid.
type(esmf_field), public slope_type_target_grid
slope type
Reads static surface climatological data for the target FV3 grid (such as soil type and vegetation ty...
type(esmf_field), public xs_target_grid
Salinity content in diurnal thermocline layer.
logical, public vgfrc_from_climo
If false, interpolate vegetation fraction from the input data to the target grid instead of using dat...
subroutine, public calc_soil_params_driver(localpet)
Driver routine to compute soil parameters for each soil type.
subroutine, public create_nst_esmf_fields
Create ESMF fields for the target grid nst variables.
type(esmf_grid), public input_grid
input grid esmf grid object
type(esmf_field), public ustar_target_grid
Friction velocity.
type(esmf_field), public tref_target_grid
Reference temperature.
type(esmf_field), public q2m_target_grid
2-m specific humidity.
subroutine, public regrid_many(bundle_pre, bundle_post, num_field, route, dozero, unmapped_ptr, resetifd)
Regrid multiple ESMF fields from input to target grid.
subroutine, public nst_land_fill
nst is not active at land or sea ice points.
character(len=25), public input_type
Input data type:
real, parameter, private frz_h2o
melting pt water
Process surface and nst fields.
type(esmf_field), public terrain_target_grid
terrain height target grid
real, dimension(:), allocatable, public refsmc_target
Reference soil moisture content target grid (onset of soil moisture stress).
type(esmf_field), public substrate_temp_target_grid
soil subtrate temperature
type(esmf_field), public veg_greenness_target_grid
vegetation greenness fraction
type(esmf_field), public skin_temp_target_grid
Skin temperature/sst.
type(esmf_field), public xv_target_grid
v-current content in diurnal thermocline layer.
type(esmf_field), public xt_target_grid
Heat content in diurnal thermocline layer.
type(esmf_field), public seamask_target_grid
sea mask target grid - '1' non-land; '0' land
type(esmf_field), public veg_type_target_grid
vegetation type
subroutine qc_check
Perform some quality control checks before output.
type(esmf_field), public z0_target_grid
Roughness length.
logical, public vgtyp_from_climo
If false, interpolate vegetation type from the input data to the target grid instead of using data fr...
type(esmf_field), public facwf_target_grid
fractional coverage for weak zenith angle dependent albedo
type(esmf_field) terrain_from_input_grid
terrain height interpolated from input grid
subroutine, public get_static_fields(localpet)
Driver routine to read/time interpolate static/climo fields on the fv3 target grid.
subroutine ij_to_i_j(ij, itile, jtile, i, j)
Convert 1d index to 2d indices.
type(esmf_field), public t2m_target_grid
2-m temperatrure.
subroutine, public cleanup_target_nst_data
Free up memory once the target grid nst fields are no longer needed.
type(esmf_field), public soil_temp_target_grid
3-d soil temperature.
real, dimension(:), allocatable, public refsmc_input
Reference soil moisture content input grid (onset of soil moisture stress).
subroutine, public cleanup_target_sfc_data
Free up memory once the target grid surface fields are no longer needed.
type(esmf_field), public alnwf_target_grid
near ir white sky albedo
real, dimension(:), allocatable, public maxsmc_target
Maximum soil moisture content target grid.
real, dimension(:), allocatable, public drysmc_target
Air dry soil moisture content target grid.
type(esmf_field), public dt_cool_target_grid
Sub-layer cooling amount.
integer, public i_input
i-dimension of input grid (or of each global tile)
type(esmf_field), public w_0_target_grid
Coefficient 3 to calculate d(tz)/d(ts).
type(esmf_field), public facsf_target_grid
fractional coverage for strong zenith angle dependent albedo
real, parameter, private blim
soil 'b' parameter limit
type(esmf_field), public snow_depth_target_grid
Physical snow depth.
type(esmf_field), public soil_type_target_grid
soil type