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
854 call search_many(num_fields,bundle_seaice_target,tile, search_nums,localpet, &
855 mask=mask_target_one_tile)
857 call search_many(num_fields,bundle_seaice_target, tile,search_nums,localpet)
862 deallocate(search_nums)
863 call esmf_fieldbundledestroy(bundle_seaice_target,rc=rc)
864 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
865 call error_handler(
"IN FieldBundleDestroy", rc)
867 print*,
"- CALL FieldRegridRelease." 868 call esmf_fieldregridrelease(routehandle=regrid_seaice, rc=rc)
869 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
870 call error_handler(
"IN FieldRegridRelease", rc)
877 where (nint(landmask_input_ptr) == 0) mask_input_ptr = 1
880 where (landmask_target_ptr == 0) mask_target_ptr = 1
882 method=esmf_regridmethod_conserve
883 isrctermprocessing = 1
885 print*,
"- CALL FieldRegridStore for water fields." 886 call esmf_fieldregridstore(skin_temp_input_grid, &
888 srcmaskvalues=(/0/), &
889 dstmaskvalues=(/0/), &
890 polemethod=esmf_polemethod_none, &
891 srctermprocessing=isrctermprocessing, &
892 unmappedaction=esmf_unmappedaction_ignore, &
893 normtype=esmf_normtype_fracarea, &
894 routehandle=regrid_water, &
895 regridmethod=method, &
896 unmappeddstlist=unmapped_ptr, rc=rc)
897 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
898 call error_handler(
"IN FieldRegridStore", rc)
900 bundle_water_target = esmf_fieldbundlecreate(name=
"water target", rc=rc)
901 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
902 call error_handler(
"IN FieldBundleCreate", rc)
903 bundle_water_input = esmf_fieldbundlecreate(name=
"water input", rc=rc)
904 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
905 call error_handler(
"IN FieldBundleCreate", rc)
907 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
908 call error_handler(
"IN FieldBundleAdd", rc)
909 call esmf_fieldbundleadd(bundle_water_input, (/skin_temp_input_grid, z0_input_grid/), rc=rc)
910 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
911 call error_handler(
"IN FieldBundleAdd", rc)
920 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
921 call error_handler(
"IN FieldBundleAdd", rc)
923 call esmf_fieldbundleadd(bundle_water_input, (/c_d_input_grid,c_0_input_grid,d_conv_input_grid, &
924 dt_cool_input_grid,ifd_input_grid,qrain_input_grid,tref_input_grid, &
925 w_d_input_grid,w_0_input_grid,xs_input_grid,xt_input_grid,xu_input_grid, &
926 xv_input_grid,xz_input_grid,xtts_input_grid,xzts_input_grid, &
927 z_c_input_grid,zm_input_grid/), rc=rc)
928 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
929 call error_handler(
"IN FieldBundleAdd", rc)
930 call esmf_fieldbundleget(bundle_water_target,fieldcount=num_fields,rc=rc)
931 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
932 call error_handler(
"IN FieldBundleGet", rc)
934 allocate(search_nums(num_fields))
935 allocate(dozero(num_fields))
937 search_nums(:)=(/11,83,0,0,0,0,1,0,11,0,0,0,0,0,0,30,0,0,0,0/)
941 call esmf_fieldbundleget(bundle_water_target,fieldcount=num_fields,rc=rc)
942 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
943 call error_handler(
"IN FieldBundleGet", rc)
945 allocate(search_nums(num_fields))
946 allocate(dozero(num_fields))
947 search_nums(:)=(/11,83/)
951 call regrid_many(bundle_water_input,bundle_water_target,num_fields,regrid_water,dozero, &
952 unmapped_ptr=unmapped_ptr, resetifd=.true.)
954 call esmf_fieldbundledestroy(bundle_water_input,rc=rc)
955 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
956 call error_handler(
"IN FieldBundleDestroy", rc)
959 if (localpet == 0)
then 962 allocate(latitude_one_tile(0,0))
967 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
969 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
970 call error_handler(
"IN FieldGather", rc)
972 print*,
"- CALL FieldGather FOR TARGET LATITUDE TILE: ", tile
974 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
975 call error_handler(
"IN FieldGather", rc)
977 if (localpet == 0)
then 979 water_target_one_tile = 0
980 where(mask_target_one_tile == 0) water_target_one_tile = 1
982 call search_many(num_fields,bundle_water_target, tile,search_nums,localpet, &
983 latitude=latitude_one_tile,mask=water_target_one_tile)
985 call search_many(num_fields,bundle_water_target, tile,search_nums,localpet)
988 if (localpet == 0)
deallocate(water_target_one_tile)
992 deallocate(latitude_one_tile,search_nums)
994 call esmf_fieldbundledestroy(bundle_water_target,rc=rc)
995 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
996 call error_handler(
"IN FieldBundleDestroy", rc)
998 print*,
"- CALL FieldRegridRelease." 999 call esmf_fieldregridrelease(routehandle=regrid_water, rc=rc)
1000 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1001 call error_handler(
"IN FieldRegridRelease", rc)
1008 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1
1011 where (landmask_target_ptr == 1) mask_target_ptr = 1
1013 method=esmf_regridmethod_conserve
1014 isrctermprocessing = 1
1016 print*,
"- CALL FieldRegridStore for land fields." 1017 call esmf_fieldregridstore(snow_depth_input_grid, &
1019 srcmaskvalues=(/0/), &
1020 dstmaskvalues=(/0/), &
1021 polemethod=esmf_polemethod_none, &
1022 srctermprocessing=isrctermprocessing, &
1023 unmappedaction=esmf_unmappedaction_ignore, &
1024 normtype=esmf_normtype_fracarea, &
1025 routehandle=regrid_all_land, &
1026 regridmethod=method, &
1027 unmappeddstlist=unmapped_ptr, rc=rc)
1028 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1029 call error_handler(
"IN FieldRegridStore", rc)
1031 bundle_allland_target = esmf_fieldbundlecreate(name=
"all land target", rc=rc)
1032 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1033 call error_handler(
"IN FieldBundleCreate", rc)
1034 bundle_allland_input = esmf_fieldbundlecreate(name=
"all land input", rc=rc)
1035 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1036 call error_handler(
"IN FieldBundleCreate", rc)
1039 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1040 call error_handler(
"IN FieldBundleAdd", rc)
1041 call esmf_fieldbundleadd(bundle_allland_input, (/canopy_mc_input_grid, snow_depth_input_grid, &
1042 snow_liq_equiv_input_grid/), rc=rc)
1043 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1044 call error_handler(
"IN FieldBundleAdd", rc)
1045 call esmf_fieldbundleget(bundle_allland_target,fieldcount=num_fields,rc=rc)
1046 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1047 call error_handler(
"IN FieldBundleGet", rc)
1049 allocate(search_nums(num_fields))
1050 allocate(dozero(num_fields))
1052 search_nums = (/223,66,65/)
1053 dozero=(/.true.,.false.,.false./)
1055 call regrid_many(bundle_allland_input,bundle_allland_target,num_fields,regrid_all_land,dozero, &
1056 unmapped_ptr=unmapped_ptr)
1058 call esmf_fieldbundledestroy(bundle_allland_input,rc=rc)
1059 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1060 call error_handler(
"IN FieldBundleDestroy", rc)
1065 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
1067 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1068 call error_handler(
"IN FieldGather", rc)
1070 if (localpet == 0)
then 1072 land_target_one_tile = 0
1073 where(mask_target_one_tile == 1) land_target_one_tile = 1
1075 call search_many(num_fields,bundle_allland_target, &
1076 tile,search_nums,localpet, mask=land_target_one_tile)
1078 call search_many(num_fields,bundle_allland_target, tile,search_nums,localpet)
1081 if (localpet == 0)
deallocate(land_target_one_tile)
1084 deallocate(search_nums)
1085 call esmf_fieldbundledestroy(bundle_allland_target,rc=rc)
1086 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1087 call error_handler(
"IN FieldBundleDestroy", rc)
1089 print*,
"- CALL FieldRegridRelease." 1090 call esmf_fieldregridrelease(routehandle=regrid_all_land, rc=rc)
1091 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1092 call error_handler(
"IN FieldRegridRelease", rc)
1098 print*,
"- CALL FieldGet FOR INPUT GRID VEG TYPE." 1099 call esmf_fieldget(veg_type_input_grid, &
1100 farrayptr=veg_type_input_ptr, rc=rc)
1101 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1102 call error_handler(
"IN FieldGet", rc)
1104 print*,
'land ice check ',veg_type_landice_input
1107 where (nint(veg_type_input_ptr) == veg_type_landice_input) mask_input_ptr = 1
1109 print*,
"- CALL FieldGet FOR TARGET GRID VEG TYPE." 1111 farrayptr=veg_type_target_ptr, rc=rc)
1112 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1113 call error_handler(
"IN FieldGet", rc)
1118 method=esmf_regridmethod_nearest_stod
1119 isrctermprocessing = 1
1121 print*,
"- CALL FieldRegridStore for landice fields." 1122 call esmf_fieldregridstore(soil_temp_input_grid, &
1124 srcmaskvalues=(/0/), &
1125 dstmaskvalues=(/0/), &
1126 polemethod=esmf_polemethod_none, &
1127 srctermprocessing=isrctermprocessing, &
1128 unmappedaction=esmf_unmappedaction_ignore, &
1129 normtype=esmf_normtype_fracarea, &
1130 routehandle=regrid_landice, &
1131 regridmethod=method, &
1132 unmappeddstlist=unmapped_ptr, rc=rc)
1133 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1134 call error_handler(
"IN FieldRegridStore", rc)
1136 bundle_landice_target = esmf_fieldbundlecreate(name=
"landice target", rc=rc)
1137 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1138 call error_handler(
"IN FieldBundleCreate", rc)
1139 bundle_landice_input = esmf_fieldbundlecreate(name=
"landice input", rc=rc)
1140 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1141 call error_handler(
"IN FieldBundleCreate", rc)
1144 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1145 call error_handler(
"IN FieldBundleAdd", rc)
1146 call esmf_fieldbundleadd(bundle_landice_input, (/skin_temp_input_grid,
terrain_input_grid,&
1147 soil_temp_input_grid/), rc=rc)
1148 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1149 call error_handler(
"IN FieldBundleAdd", rc)
1152 call esmf_fieldbundleadd(bundle_landice_input, (/soil_type_input_grid/),rc=rc)
1153 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1154 call error_handler(
"IN FieldBundleAdd", rc)
1156 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1157 call error_handler(
"IN FieldBundleAdd", rc)
1160 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1161 call error_handler(
"IN FieldBundleAdd", rc)
1162 call esmf_fieldbundleget(bundle_landice_target,fieldcount=num_fields,rc=rc)
1163 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1164 call error_handler(
"IN FieldBundleGet", rc)
1166 allocate(search_nums(num_fields))
1167 allocate(dozero(num_fields))
1170 search_nums = (/21,7,21/)
1173 search_nums = (/21,7,21,231/)
1174 dozero(:)=(/.false.,.false.,.false.,.true./)
1177 call regrid_many(bundle_landice_input,bundle_landice_target,num_fields,regrid_landice,dozero, &
1178 unmapped_ptr=unmapped_ptr )
1180 call esmf_fieldbundledestroy(bundle_landice_input,rc=rc)
1181 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1182 call error_handler(
"IN FieldBundleDestroy", rc)
1184 if (localpet == 0)
then 1189 allocate (veg_type_target_one_tile(0,0))
1190 allocate (land_target_one_tile(0,0))
1191 allocate (data_one_tile2(0,0))
1195 print*,
"- CALL FieldGather FOR TARGET VEG TYPE TILE: ", tile
1196 call esmf_fieldgather(
veg_type_target_grid, veg_type_target_one_tile, rootpet=0, tile=tile, rc=rc)
1197 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1198 call error_handler(
"IN FieldGather", rc)
1200 if (localpet == 0)
then 1201 land_target_one_tile = 0
1205 print*,
"- CALL FieldGather FOR TERRAIN FROM INPUT GRID LAND, TILE: ", tile
1207 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1208 call error_handler(
"IN FieldGather", rc)
1210 if (localpet==0)
then 1211 call search_many(num_fields,bundle_landice_target,tile,search_nums,localpet,&
1212 terrain_land=data_one_tile2,mask=land_target_one_tile)
1214 call search_many(num_fields,bundle_landice_target,tile,search_nums,localpet)
1218 deallocate (veg_type_target_one_tile)
1219 deallocate (land_target_one_tile)
1220 deallocate(search_nums)
1222 call esmf_fieldbundledestroy(bundle_landice_target,rc=rc)
1223 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1224 call error_handler(
"IN FieldBundleDestroy", rc)
1226 print*,
"- CALL FieldRegridRelease." 1227 call esmf_fieldregridrelease(routehandle=regrid_landice, rc=rc)
1228 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1229 call error_handler(
"IN FieldRegridRelease", rc)
1236 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1
1237 where (nint(veg_type_input_ptr) == veg_type_landice_input) mask_input_ptr = 0
1240 where (landmask_target_ptr == 1) mask_target_ptr = 1
1243 method=esmf_regridmethod_nearest_stod
1244 isrctermprocessing = 1
1246 print*,
"- CALL FieldRegridStore for 3d land (but no land ice) fields." 1247 call esmf_fieldregridstore(soilm_tot_input_grid, &
1249 srcmaskvalues=(/0/), &
1250 dstmaskvalues=(/0/), &
1251 polemethod=esmf_polemethod_none, &
1252 srctermprocessing=isrctermprocessing, &
1253 unmappedaction=esmf_unmappedaction_ignore, &
1254 normtype=esmf_normtype_fracarea, &
1255 routehandle=regrid_land, &
1256 regridmethod=method, &
1257 unmappeddstlist=unmapped_ptr, rc=rc)
1258 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1259 call error_handler(
"IN FieldRegridStore", rc)
1261 bundle_nolandice_target = esmf_fieldbundlecreate(name=
"land no landice target", rc=rc)
1262 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1263 call error_handler(
"IN FieldBundleCreate", rc)
1265 bundle_nolandice_input = esmf_fieldbundlecreate(name=
"land no landice input", rc=rc)
1266 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1267 call error_handler(
"IN FieldBundleCreate", rc)
1271 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1272 call error_handler(
"IN FieldBundleAdd", rc)
1274 call esmf_fieldbundleadd(bundle_nolandice_input, (/skin_temp_input_grid,
terrain_input_grid,&
1275 soil_type_input_grid,soilm_tot_input_grid,soil_temp_input_grid/), rc=rc)
1276 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1277 call error_handler(
"IN FieldBundleAdd", rc)
1287 print*,
"- CALL Field_Regrid ." 1288 call esmf_fieldregrid(soil_type_input_grid, &
1290 routehandle=regrid_land, &
1291 zeroregion=esmf_region_select, &
1292 termorderflag=esmf_termorder_srcseq, rc=rc)
1293 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1294 call error_handler(
"IN FieldRegrid", rc)
1297 farrayptr=soil_type_target_ptr, rc=rc)
1298 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1299 call error_handler(
"IN FieldGet", rc)
1301 l = lbound(unmapped_ptr)
1302 u = ubound(unmapped_ptr)
1306 soil_type_target_ptr(i,j) = -9999.9
1316 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1317 call error_handler(
"IN FieldBundleAdd", rc)
1318 call esmf_fieldbundleadd(bundle_nolandice_input, (/veg_greenness_input_grid/), rc=rc)
1319 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1320 call error_handler(
"IN FieldBundleAdd", rc)
1321 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1322 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1323 call error_handler(
"IN FieldBundleGet", rc)
1324 vgfrc_ind = num_fields
1328 call esmf_fieldbundleadd(bundle_nolandice_target, (/
lai_target_grid/), rc=rc)
1329 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1330 call error_handler(
"IN FieldBundleAdd", rc)
1331 call esmf_fieldbundleadd(bundle_nolandice_input, (/lai_input_grid/), rc=rc)
1332 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1333 call error_handler(
"IN FieldBundleAdd", rc)
1334 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1335 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1336 call error_handler(
"IN FieldBundleGet", rc)
1337 lai_ind = num_fields
1342 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1343 call error_handler(
"IN FieldBundleAdd", rc)
1344 call esmf_fieldbundleadd(bundle_nolandice_input, (/max_veg_greenness_input_grid/), rc=rc)
1345 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1346 call error_handler(
"IN FieldBundleAdd", rc)
1349 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1350 call error_handler(
"IN FieldBundleAdd", rc)
1351 call esmf_fieldbundleadd(bundle_nolandice_input, (/min_veg_greenness_input_grid/), rc=rc)
1352 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1353 call error_handler(
"IN FieldBundleAdd", rc)
1355 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1356 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1357 call error_handler(
"IN FieldBundleGet", rc)
1359 mmvg_ind = num_fields-1
1362 call esmf_fieldbundleget(bundle_nolandice_target,fieldcount=num_fields,rc=rc)
1363 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1364 call error_handler(
"IN FieldBundleGet", rc)
1366 allocate(search_nums(num_fields))
1367 allocate(dozero(num_fields))
1369 search_nums(1:5) = (/85,7,224,85,86/)
1370 dozero(1:5) = (/.false.,.false.,.true.,.true.,.false./)
1378 search_nums(vgfrc_ind) = 224
1379 dozero(vgfrc_ind) = .true.
1383 search_nums(lai_ind) = 229
1384 dozero(lai_ind) = .true.
1388 search_nums(mmvg_ind) = 227
1389 dozero(mmvg_ind) = .true.
1391 search_nums(mmvg_ind+1) = 228
1392 dozero(mmvg_ind+1) = .true.
1395 call regrid_many(bundle_nolandice_input,bundle_nolandice_target,num_fields,regrid_land,dozero, &
1396 unmapped_ptr=unmapped_ptr)
1398 call esmf_fieldbundledestroy(bundle_nolandice_input,rc=rc)
1399 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1400 call error_handler(
"IN FieldBundleDestroy", rc)
1402 if (localpet == 0)
then 1405 allocate (veg_type_target_one_tile(0,0))
1410 print*,
"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile
1412 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1413 call error_handler(
"IN FieldGather", rc)
1415 print*,
"- CALL FieldGather FOR TARGET VEG TYPE TILE: ", tile
1416 call esmf_fieldgather(
veg_type_target_grid, veg_type_target_one_tile, rootpet=0, tile=tile, rc=rc)
1417 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1418 call error_handler(
"IN FieldGather", rc)
1420 if (localpet == 0)
then 1424 print*,
"- CALL FieldGather FOR SOIL TYPE TARGET GRID, TILE: ", tile
1426 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1427 call error_handler(
"IN FieldGather", rc)
1428 if (localpet==0)
then 1429 call search_many(num_fields,bundle_nolandice_target,tile,search_nums,localpet, &
1430 soilt_climo=data_one_tile2, mask=mask_target_one_tile)
1432 call search_many(num_fields,bundle_nolandice_target, tile,search_nums,localpet)
1435 print*,
"- CALL FieldGather FOR TARGET GRID TOTAL SOIL MOISTURE, TILE: ", tile
1437 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1438 call error_handler(
"IN FieldGather", rc)
1440 if (localpet == 0)
then 1442 data_one_tile = data_one_tile_3d(:,:,j)
1444 data_one_tile_3d(:,:,j) = data_one_tile
1448 print*,
"- CALL FieldGather FOR TARGET GRID SOIL TEMPERATURE, TILE: ", tile
1450 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1451 call error_handler(
"IN FieldGather", rc)
1454 print*,
"- CALL FieldScatter FOR TARGET GRID SUBSTRATE TEMPERATURE, TILE: ", tile
1456 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1457 call error_handler(
"IN FieldScatter", rc)
1461 print*,
"- CALL FieldGather FOR SOIL TYPE TARGET GRID LAND, TILE: ",tile
1463 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1464 call error_handler(
"IN FieldGather", rc)
1466 if (localpet == 0)
then 1470 print*,
"- CALL FieldScatter FOR SOIL TYPE TARGET GRID, TILE: ", tile
1472 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1473 call error_handler(
"IN FieldScatter", rc)
1478 deallocate(search_nums)
1479 call esmf_fieldbundledestroy(bundle_nolandice_target,rc=rc)
1480 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1481 call error_handler(
"IN FieldBundleDestroy", rc)
1483 print*,
"- CALL FieldRegridRelease." 1484 call esmf_fieldregridrelease(routehandle=regrid_land, rc=rc)
1485 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1486 call error_handler(
"IN FieldRegridRelease", rc)
1488 deallocate(veg_type_target_one_tile)
1490 deallocate(data_one_tile, data_one_tile2)
1491 deallocate(data_one_tile_3d)
1492 deallocate(mask_target_one_tile)
1516 integer :: clb(3), cub(3), rc
1517 integer :: i, j, n, soil_type
1519 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
1522 real(esmf_kind_r8),
pointer :: soilm_liq_ptr(:,:,:)
1523 real(esmf_kind_r8),
pointer :: soilm_tot_ptr(:,:,:)
1524 real(esmf_kind_r8),
pointer :: soil_temp_ptr(:,:,:)
1525 real(esmf_kind_r8),
pointer :: soil_type_ptr(:,:)
1526 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
1528 print*,
"- COMPUTE LIQUID PORTION OF TOTAL SOIL MOISTURE." 1530 print*,
"- CALL FieldGet FOR TOTAL SOIL MOISTURE." 1532 computationallbound=clb, &
1533 computationalubound=cub, &
1534 farrayptr=soilm_tot_ptr, rc=rc)
1535 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1536 call error_handler(
"IN FieldGet", rc)
1538 print*,
"- CALL FieldGet FOR LIQUID SOIL MOISTURE." 1540 farrayptr=soilm_liq_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 TEMPERATURE." 1546 farrayptr=soil_temp_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 VEGETATION TYPE." 1552 farrayptr=veg_type_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 print*,
"- CALL FieldGet FOR SOIL TYPE." 1558 farrayptr=soil_type_ptr, rc=rc)
1559 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1560 call error_handler(
"IN FieldGet", rc)
1562 print*,
"- CALL FieldGet FOR LANDMASK." 1564 farrayptr=landmask_ptr, rc=rc)
1565 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1566 call error_handler(
"IN FieldGet", rc)
1568 do j = clb(2), cub(2)
1569 do i = clb(1), cub(1)
1577 soil_type = nint(soil_type_ptr(i,j))
1579 do n = clb(3), cub(3)
1581 if (soil_temp_ptr(i,j,n) < (
frz_h2o-0.0001))
then 1588 ((soil_temp_ptr(i,j,n)-
frz_h2o)/soil_temp_ptr(i,j,n)))** &
1591 if (fk .lt. 0.02) fk = 0.02
1593 soilm_liq_ptr(i,j,n) = min( fk, soilm_tot_ptr(i,j,n) )
1601 soilm_liq_ptr(i,j,n) = frh2o(soil_temp_ptr(i,j,n), &
1602 soilm_tot_ptr(i,j,n), soilm_liq_ptr(i,j,n), &
1608 soilm_liq_ptr(i,j,n) = soilm_tot_ptr(i,j,n)
1645 FUNCTION frh2o (TKELV,SMC,SH2O,SMCMAX,BEXP,PSIS)
1662 REAL(esmf_kind_r8) :: sh2o
1663 REAL(esmf_kind_r8) :: smc
1667 REAL(esmf_kind_r8) :: tkelv
1669 REAL,
PARAMETER :: ck = 8.0
1670 REAL,
PARAMETER :: error = 0.005
1688 IF (ck .NE. 0.0)
THEN 1703 IF (swl .GT. (smc-0.02)) swl = smc-0.02
1704 IF (swl .LT. 0.) swl = 0.
1710 DO WHILE ( (nlog .LT. 10) .AND. (kcount .EQ. 0) )
1713 df = log(( psis*
grav/
hlice ) * ( ( 1.+ck*swl )**2. ) * &
1714 ( smcmax/(smc-swl) )**bx) - log(-(tkelv-
frz_h2o)/tkelv)
1715 denom = 2. * ck / ( 1.+ck*swl ) + bx / ( smc - swl )
1716 swlk = swl - df/denom
1722 IF (swlk .GT. (smc-0.02)) swlk = smc - 0.02
1723 IF (swlk .LT. 0.) swlk = 0.
1729 dswl = abs(swlk-swl)
1737 IF ( dswl .LE. error )
THEN 1763 IF (kcount .EQ. 0)
THEN 1766 ((tkelv-
frz_h2o)/tkelv))**(-1/bx))*smcmax
1768 IF (fk .LT. 0.02) fk = 0.02
1770 frh2o = min(fk, smc)
1800 integer :: clb(3), cub(3), i, j, k, rc
1801 integer :: soilt_input, soilt_target
1802 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
1804 real(esmf_kind_r8),
pointer :: soilm_tot_ptr(:,:,:)
1805 real(esmf_kind_r8),
pointer :: soil_type_input_ptr(:,:)
1806 real(esmf_kind_r8),
pointer :: soil_type_target_ptr(:,:)
1807 real(esmf_kind_r8),
pointer :: veg_greenness_ptr(:,:)
1808 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
1809 real :: f1, fn, smcdir, smctra
1811 print*,
"- RESCALE SOIL MOISTURE FOR CHANGES IN SOIL TYPE." 1813 print*,
"- CALL FieldGet FOR TOTAL SOIL MOISTURE." 1815 computationallbound=clb, &
1816 computationalubound=cub, &
1817 farrayptr=soilm_tot_ptr, rc=rc)
1818 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1819 call error_handler(
"IN FieldGet", rc)
1821 print*,
"- CALL FieldGet FOR LAND MASK." 1823 farrayptr=landmask_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 VEGETATION TYPE." 1829 farrayptr=veg_type_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 VEGETATION GREENNESS." 1835 farrayptr=veg_greenness_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 print*,
"- CALL FieldGet FOR TARGET GRID SOIL TYPE." 1841 farrayptr=soil_type_target_ptr, rc=rc)
1842 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1843 call error_handler(
"IN FieldGet", rc)
1845 print*,
"- CALL FieldGet FOR SOIL TYPE FROM INPUT GRID." 1847 farrayptr=soil_type_input_ptr, rc=rc)
1848 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1849 call error_handler(
"IN FieldGet", rc)
1851 do j = clb(2), cub(2)
1852 do i = clb(1), cub(1)
1860 soilt_target = nint(soil_type_target_ptr(i,j))
1861 soilt_input = nint(soil_type_input_ptr(i,j))
1869 if (soilt_target /= soilt_input)
then 1874 f1=(soilm_tot_ptr(i,j,1)-
drysmc_input(soilt_input)) / &
1884 if (soilm_tot_ptr(i,j,1) <
refsmc_input(soilt_input))
then 1885 f1=(soilm_tot_ptr(i,j,1) -
wltsmc_input(soilt_input)) / &
1890 f1=(soilm_tot_ptr(i,j,1) -
refsmc_input(soilt_input)) / &
1900 soilm_tot_ptr(i,j,1) = ((1.0 - veg_greenness_ptr(i,j)) * smcdir) + &
1901 (veg_greenness_ptr(i,j) * smctra)
1911 if (soilm_tot_ptr(i,j,k) <
refsmc_input(soilt_input))
then 1912 fn = (soilm_tot_ptr(i,j,k) -
wltsmc_input(soilt_input)) / &
1917 fn = (soilm_tot_ptr(i,j,k) -
refsmc_input(soilt_input)) / &
1930 soilm_tot_ptr(i,j,1)=min(soilm_tot_ptr(i,j,1),
maxsmc_target(soilt_target))
1931 soilm_tot_ptr(i,j,1)=max(
drysmc_target(soilt_target),soilm_tot_ptr(i,j,1))
1934 soilm_tot_ptr(i,j,k)=min(soilm_tot_ptr(i,j,k),
maxsmc_target(soilt_target))
1935 soilm_tot_ptr(i,j,k)=max(
wltsmc_target(soilt_target),soilm_tot_ptr(i,j,k))
1960 integer :: clb(3), cub(3), i, j, k, rc
1961 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
1963 real,
parameter :: lapse_rate = 6.5e-03
1964 real :: terrain_diff
1965 real(esmf_kind_r8),
pointer :: terrain_input_ptr(:,:)
1966 real(esmf_kind_r8),
pointer :: terrain_target_ptr(:,:)
1967 real(esmf_kind_r8),
pointer :: veg_type_target_ptr(:,:)
1968 real(esmf_kind_r8),
pointer :: soil_temp_target_ptr(:,:,:)
1970 print*,
"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK." 1972 farrayptr=landmask_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 TARGET GRID VEGETATION TYPE." 1978 farrayptr=veg_type_target_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 TARGET GRID TERRAIN." 1984 farrayptr=terrain_target_ptr, rc=rc)
1985 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1986 call error_handler(
"IN FieldGet", rc)
1988 print*,
"- CALL FieldGet FOR TERRAIN INTERP TO TARGET GRID." 1990 farrayptr=terrain_input_ptr, rc=rc)
1991 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1992 call error_handler(
"IN FieldGet", rc)
1994 print*,
"- CALL FieldGet FOR SOIL TEMP TARGET GRID." 1996 computationallbound=clb, &
1997 computationalubound=cub, &
1998 farrayptr=soil_temp_target_ptr, rc=rc)
1999 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2000 call error_handler(
"IN FieldGet", rc)
2002 do j = clb(2), cub(2)
2003 do i = clb(1), cub(1)
2004 if (landmask_ptr(i,j) == 1)
then 2005 terrain_diff = abs(terrain_input_ptr(i,j) - terrain_target_ptr(i,j))
2006 if (terrain_diff > 100.0)
then 2007 do k = clb(3), cub(3)
2008 soil_temp_target_ptr(i,j,k) = soil_temp_target_ptr(i,j,k) + &
2009 ((terrain_input_ptr(i,j) - terrain_target_ptr(i,j)) * lapse_rate)
2011 soil_temp_target_ptr(i,j,k) = min(soil_temp_target_ptr(i,j,k), 273.16)
2029 use sfc_input_data,
only : lsoil_input, soil_temp_input_grid, &
2030 soilm_liq_input_grid, soilm_tot_input_grid
2032 integer,
intent(in) :: localpet
2033 character(len=500) :: msg
2034 character(len=2) :: lsoil_input_ch, lsoil_target_ch
2036 real(esmf_kind_r8) :: tmp(i_input,j_input), &
2037 data_one_tile(i_input,j_input,lsoil_input), &
2038 tmp3d(i_input,j_input,lsoil_target)
2039 if (lsoil_input == 9 .and. lsoil_target == 4)
then 2040 print*,
"CONVERTING FROM 9 INPUT SOIL LEVELS TO 4 TARGET SOIL LEVELS" 2041 call esmf_fieldgather(soil_temp_input_grid, data_one_tile, rootpet=0, tile=1, rc=rc)
2042 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2043 call error_handler(
"IN FieldGather", rc)
2045 call esmf_fielddestroy(soil_temp_input_grid,rc=rc)
2046 soil_temp_input_grid = esmf_fieldcreate(
input_grid, &
2047 typekind=esmf_typekind_r8, &
2048 staggerloc=esmf_staggerloc_center, &
2049 ungriddedlbound=(/1/), &
2050 ungriddedubound=(/lsoil_target/), rc=rc)
2053 tmp3d(:,:,1)= (data_one_tile(:,:,1) + data_one_tile(:,:,2))/2.0 * 0.1 + &
2054 (data_one_tile(:,:,2) + data_one_tile(:,:,3))/2.0 * 0.3 + &
2055 (data_one_tile(:,:,3) + data_one_tile(:,:,4))/2.0 * 0.6
2056 tmp = (data_one_tile(:,:,6) - data_one_tile(:,:,5)) / 30.0 * 10.0 + data_one_tile(:,:,5)
2057 tmp3d(:,:,2)= (data_one_tile(:,:,4) + data_one_tile(:,:,5)) / 2.0 * 0.75 + &
2058 (data_one_tile(:,:,5) + tmp) / 2.0 * 0.25
2059 tmp3d(:,:,3)= (tmp + data_one_tile(:,:,6)) /2.0 * (1.0/3.0) + &
2060 (data_one_tile(:,:,6) + data_one_tile(:,:,7)) / 2.0 * (2.0/3.0)
2061 tmp = (data_one_tile(:,:,9) - data_one_tile(:,:,9)) / 140.0 * 40.0 + data_one_tile(:,:,8)
2062 tmp3d(:,:,4)= (data_one_tile(:,:,7) + data_one_tile(:,:,8)) / 2.0 * 0.6 + &
2063 (data_one_tile(:,:,8) + tmp) / 2.0 * 0.4
2066 call esmf_fieldscatter(soil_temp_input_grid, tmp3d, rootpet=0, rc=rc)
2067 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2068 call error_handler(
"IN FieldScatter", rc)
2070 call esmf_fieldgather(soilm_tot_input_grid, data_one_tile, rootpet=0, tile=1, rc=rc)
2071 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2072 call error_handler(
"IN FieldGather", rc)
2074 call esmf_fielddestroy(soilm_tot_input_grid,rc=rc)
2075 soilm_tot_input_grid = esmf_fieldcreate(
input_grid, &
2076 typekind=esmf_typekind_r8, &
2077 staggerloc=esmf_staggerloc_center, &
2078 ungriddedlbound=(/1/), &
2079 ungriddedubound=(/lsoil_target/), rc=rc)
2081 if(localpet==0)
then 2082 tmp3d(:,:,1)= (data_one_tile(:,:,1) + data_one_tile(:,:,2))/2.0 * 0.1 + &
2083 (data_one_tile(:,:,2) + data_one_tile(:,:,3))/2.0 * 0.3 + &
2084 (data_one_tile(:,:,3) + data_one_tile(:,:,4))/2.0 * 0.6
2085 tmp = (data_one_tile(:,:,6) - data_one_tile(:,:,5)) / 30.0 * 10.0 + data_one_tile(:,:,5)
2086 tmp3d(:,:,2)= (data_one_tile(:,:,4) + data_one_tile(:,:,5)) / 2.0 * 0.75 + &
2087 (data_one_tile(:,:,5) + tmp) / 2.0 * 0.25
2088 tmp3d(:,:,3)= (tmp + data_one_tile(:,:,6)) /2.0 * (1.0/3.0) + &
2089 (data_one_tile(:,:,6) + data_one_tile(:,:,7)) / 2.0 * (2.0/3.0)
2090 tmp = (data_one_tile(:,:,9) - data_one_tile(:,:,9)) / 140.0 * 40.0 + data_one_tile(:,:,8)
2091 tmp3d(:,:,4)= (data_one_tile(:,:,7) + data_one_tile(:,:,8)) / 2.0 * 0.6 + &
2092 (data_one_tile(:,:,8) + tmp) / 2.0 * 0.4
2095 call esmf_fieldscatter(soilm_tot_input_grid, tmp3d, rootpet=0, rc=rc)
2096 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2097 call error_handler(
"IN FieldScatter", rc)
2099 call esmf_fieldgather(soilm_liq_input_grid, data_one_tile, rootpet=0, tile=1, rc=rc)
2100 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2101 call error_handler(
"IN FieldGather", rc)
2103 call esmf_fielddestroy(soilm_liq_input_grid,rc=rc)
2104 soilm_liq_input_grid = esmf_fieldcreate(
input_grid, &
2105 typekind=esmf_typekind_r8, &
2106 staggerloc=esmf_staggerloc_center, &
2107 ungriddedlbound=(/1/), &
2108 ungriddedubound=(/lsoil_target/), rc=rc)
2109 if(localpet==0)
then 2110 tmp3d(:,:,1)= (data_one_tile(:,:,1) + data_one_tile(:,:,2))/2.0 * 0.1 + &
2111 (data_one_tile(:,:,2) + data_one_tile(:,:,3))/2.0 * 0.3 + &
2112 (data_one_tile(:,:,3) + data_one_tile(:,:,4))/2.0 * 0.6
2113 tmp = (data_one_tile(:,:,6) - data_one_tile(:,:,5)) / 30.0 * 10.0 + data_one_tile(:,:,5)
2114 tmp3d(:,:,2)= (data_one_tile(:,:,4) + data_one_tile(:,:,5)) / 2.0 * 0.75 + &
2115 (data_one_tile(:,:,5) + tmp) / 2.0 * 0.25
2116 tmp3d(:,:,3)= (tmp + data_one_tile(:,:,6)) /2.0 * (1.0/3.0) + &
2117 (data_one_tile(:,:,6) + data_one_tile(:,:,7)) / 2.0 * (2.0/3.0)
2118 tmp = (data_one_tile(:,:,9) - data_one_tile(:,:,9)) / 140.0 * 40.0 + data_one_tile(:,:,8)
2119 tmp3d(:,:,4)= (data_one_tile(:,:,7) + data_one_tile(:,:,8)) / 2.0 * 0.6 + &
2120 (data_one_tile(:,:,8) + tmp) / 2.0 * 0.4
2123 call esmf_fieldscatter(soilm_liq_input_grid, tmp3d, rootpet=0, rc=rc)
2124 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2125 call error_handler(
"IN FieldScatter", rc)
2127 elseif (lsoil_input /= lsoil_target)
then 2129 write(lsoil_input_ch,
'(i2)') lsoil_input
2130 write(lsoil_target_ch,
'(i2)') lsoil_target
2131 msg=
"NUMBER OF SOIL LEVELS IN INPUT " // lsoil_input_ch //
" AND OUTPUT " &
2132 // lsoil_target_ch //
" MUST EITHER BE EQUAL OR 9 AND 4 RESPECTIVELY." 2133 call error_handler(msg, rc)
2150 integer :: clb(2), cub(2), i, j, rc
2151 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
2154 real(esmf_kind_r8),
pointer :: data_ptr(:,:)
2155 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
2157 data z0_igbp /1.089, 2.653, 0.854, 0.826, 0.800, 0.050, &
2158 0.030, 0.856, 0.856, 0.150, 0.040, 0.130, &
2159 1.000, 0.250, 0.011, 0.011, 0.001, 0.076, &
2162 print*,
"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK." 2164 computationallbound=clb, &
2165 computationalubound=cub, &
2166 farrayptr=landmask_ptr, rc=rc)
2167 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2168 call error_handler(
"IN FieldGet", rc)
2170 print*,
"- CALL FieldGet FOR TARGET GRID VEGETATION TYPE." 2172 farrayptr=veg_type_ptr, rc=rc)
2173 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2174 call error_handler(
"IN FieldGet", rc)
2176 print*,
"- CALL FieldGet FOR TARGET GRID Z0." 2178 farrayptr=data_ptr, rc=rc)
2179 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2180 call error_handler(
"IN FieldGet", rc)
2182 do j = clb(2), cub(2)
2183 do i = clb(1), cub(1)
2184 if (landmask_ptr(i,j) == 2)
then 2186 elseif (landmask_ptr(i,j) == 1)
then 2187 data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0
2218 integer :: clb(2), cub(2), i, j, rc
2219 integer(esmf_kind_i8),
pointer :: landmask_ptr(:,:)
2221 real(esmf_kind_r8),
pointer :: data_ptr(:,:)
2222 real(esmf_kind_r8),
pointer :: data3d_ptr(:,:,:)
2223 real(esmf_kind_r8),
pointer :: soilmt_ptr(:,:,:)
2224 real(esmf_kind_r8),
pointer :: soilml_ptr(:,:,:)
2225 real(esmf_kind_r8),
pointer :: veg_greenness_ptr(:,:)
2226 real(esmf_kind_r8),
pointer :: veg_type_ptr(:,:)
2227 real(esmf_kind_r8),
pointer :: seaice_skint_ptr(:,:)
2228 real(esmf_kind_r8),
pointer :: skint_ptr(:,:)
2229 real(esmf_kind_r8),
pointer :: fice_ptr(:,:)
2230 real(esmf_kind_r8),
pointer :: hice_ptr(:,:)
2232 print*,
"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK." 2234 computationallbound=clb, &
2235 computationalubound=cub, &
2236 farrayptr=landmask_ptr, rc=rc)
2237 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2238 call error_handler(
"IN FieldGet", rc)
2240 print*,
"- SET NON-LAND FLAG FOR TARGET GRID SLOPE 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 SOIL TYPE." 2254 farrayptr=data_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) data_ptr(i,j) = 0.0
2264 print*,
"- SET NON-LAND FLAG FOR TARGET GRID VEGETATION TYPE." 2266 farrayptr=veg_type_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) veg_type_ptr(i,j) = 0.0
2276 print*,
"- SET TARGET GRID ALVSF 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 ALVWF 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 ALNSF 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 TARGET GRID ALNWF AT NON-LAND." 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.06
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 FACSF." 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 MAXIMUM 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 MINIMUM GREENNESS." 2362 farrayptr=data_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) data_ptr(i,j) = 0.0
2372 print*,
"- SET NON-LAND FLAG FOR TARGET GRID VEGETATION GREENNESS." 2374 farrayptr=veg_greenness_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) veg_greenness_ptr(i,j) = 0.0
2384 print*,
"- SET NON-LAND FLAG FOR TARGET GRID MAX SNOW ALBEDO." 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 (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0
2396 print*,
"- ZERO OUT TARGET GRID CANOPY MOISTURE CONTENT WHERE NO PLANTS." 2398 farrayptr=data_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 do j = clb(2), cub(2)
2403 do i = clb(1), cub(1)
2404 if (veg_greenness_ptr(i,j) <= 0.01) data_ptr(i,j) = 0.0
2408 print*,
"- CALL FieldGet FOR TARGET GRID ICE SKIN TEMP." 2410 farrayptr=seaice_skint_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 SKIN TEMP AT ICE POINTS." 2416 farrayptr=skint_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 print*,
"- CALL FieldGet FOR TARGET GRID SEA ICE FRACTION." 2422 farrayptr=fice_ptr, rc=rc)
2423 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2424 call error_handler(
"IN FieldGet", rc)
2426 print*,
"- SET TARGET GRID SEA ICE DEPTH TO ZERO AT NON-ICE POINTS." 2428 farrayptr=hice_ptr, rc=rc)
2429 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2430 call error_handler(
"IN FieldGet", rc)
2432 do j = clb(2), cub(2)
2433 do i = clb(1), cub(1)
2434 if (fice_ptr(i,j) > 0.0)
then 2435 skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + &
2436 ( (1.0 - fice_ptr(i,j)) *
frz_ice )
2438 seaice_skint_ptr(i,j) = skint_ptr(i,j)
2444 print*,
"- SET TARGET GRID SUBSTRATE TEMP AT ICE." 2446 farrayptr=data_ptr, rc=rc)
2447 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2448 call error_handler(
"IN FieldGet", rc)
2450 do j = clb(2), cub(2)
2451 do i = clb(1), cub(1)
2452 if (landmask_ptr(i,j) == 2)
then 2454 elseif (landmask_ptr(i,j) == 0)
then 2455 data_ptr(i,j) = skint_ptr(i,j)
2460 print*,
"- ZERO OUT TARGET GRID SNOW DEPTH AT OPEN WATER." 2462 farrayptr=data_ptr, rc=rc)
2463 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2464 call error_handler(
"IN FieldGet", rc)
2466 do j = clb(2), cub(2)
2467 do i = clb(1), cub(1)
2468 if (landmask_ptr(i,j) == 0)
then 2474 print*,
"- ZERO OUT TARGET GRID SNOW LIQ AT OPEN WATER." 2476 farrayptr=data_ptr, rc=rc)
2477 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2478 call error_handler(
"IN FieldGet", rc)
2480 do j = clb(2), cub(2)
2481 do i = clb(1), cub(1)
2482 if (landmask_ptr(i,j) == 0)
then 2488 print*,
"- SET NON-LAND FLAG VALUE FOR TARGET GRID TOTAL SOIL MOISTURE." 2490 farrayptr=soilmt_ptr, rc=rc)
2491 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2492 call error_handler(
"IN FieldGet", rc)
2494 print*,
"- SET NON-LAND FLAG VALUE FOR TARGET GRID LIQUID SOIL MOISTURE." 2496 farrayptr=soilml_ptr, rc=rc)
2497 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2498 call error_handler(
"IN FieldGet", rc)
2500 do j = clb(2), cub(2)
2501 do i = clb(1), cub(1)
2502 if (landmask_ptr(i,j) == 2 .or. landmask_ptr(i,j) == 0 .or. &
2504 soilmt_ptr(i,j,:) = 1.0
2505 soilml_ptr(i,j,:) = 1.0
2510 print*,
"- SET OPEN WATER FLAG FOR TARGET GRID SOIL TEMPERATURE." 2512 farrayptr=data3d_ptr, rc=rc)
2513 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2514 call error_handler(
"IN FieldGet", rc)
2516 do j = clb(2), cub(2)
2517 do i = clb(1), cub(1)
2518 if (landmask_ptr(i,j) == 0)
then 2519 data3d_ptr(i,j,:) = skint_ptr(i,j)
2538 integer(esmf_kind_i8),
pointer :: mask_ptr(:,:)
2540 integer,
PARAMETER :: num_nst_fields_minus2 = 16
2541 integer,
PARAMETER :: xz_fill = 30.0
2542 integer,
PARAMETER :: nst_fill = 0.0
2544 real(esmf_kind_r8),
pointer :: data_ptr(:,:)
2545 real(esmf_kind_r8),
pointer :: skint_ptr(:,:)
2547 type(esmf_field) :: temp_field
2548 type(esmf_fieldbundle) :: nst_bundle
2550 print*,
"- CALL FieldGet FOR TARGET GRID LANDMASK." 2552 farrayptr=mask_ptr, rc=rc)
2553 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2554 call error_handler(
"IN FieldGet", rc)
2556 nst_bundle = esmf_fieldbundlecreate(name=
"nst_bundle", rc=rc)
2557 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2558 call error_handler(
"IN FieldBundleCreate", rc)
2565 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2566 call error_handler(
"IN FieldBundleAdd", rc)
2568 print*,
"- CALL FieldGet FOR TREF." 2570 farrayptr=data_ptr, rc=rc)
2571 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2572 call error_handler(
"IN FieldGet", rc)
2574 print*,
"- CALL FieldGet FOR SKIN T." 2576 farrayptr=skint_ptr, rc=rc)
2577 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2578 call error_handler(
"IN FieldGet", rc)
2580 where(mask_ptr /= 0) data_ptr = skint_ptr
2584 print*,
"- CALL FieldGet FOR XZ." 2586 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 = xz_fill
2592 do i = 1,num_nst_fields_minus2
2594 call esmf_fieldbundleget(nst_bundle,i,temp_field,rc=rc)
2595 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2596 call error_handler(
"IN FieldBundleGet", rc)
2598 call esmf_fieldget(temp_field,farrayptr=data_ptr,rc=rc)
2599 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2600 call error_handler(
"IN FieldGet", rc)
2602 where(mask_ptr /= 0) data_ptr = nst_fill
2606 call esmf_fieldbundledestroy(nst_bundle,rc=rc)
2607 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2608 call error_handler(
"IN FieldBundleDestroy", rc)
2623 real(esmf_kind_r8),
pointer :: target_ptr(:,:), target_ptr_3d(:,:,:)
2624 real :: init_val = -999.9
2626 print*,
"- CALL FieldCreate FOR TARGET GRID T2M." 2628 typekind=esmf_typekind_r8, &
2629 name=
"t2m_target_grid", &
2630 staggerloc=esmf_staggerloc_center, rc=rc)
2631 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2632 call error_handler(
"IN FieldCreate", rc)
2634 print*,
"- INITIALIZE TARGET grid t2m." 2636 farrayptr=target_ptr, rc=rc)
2637 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2638 call error_handler(
"IN FieldGet", rc)
2640 target_ptr = init_val
2642 print*,
"- CALL FieldCreate FOR TARGET GRID Q2M." 2644 typekind=esmf_typekind_r8, &
2645 name=
"q2m_target_grid", &
2646 staggerloc=esmf_staggerloc_center, rc=rc)
2647 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2648 call error_handler(
"IN FieldCreate", rc)
2650 print*,
"- INITIALIZE TARGET grid q2m." 2652 farrayptr=target_ptr, rc=rc)
2653 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2654 call error_handler(
"IN FieldGet", rc)
2656 target_ptr = init_val
2658 print*,
"- CALL FieldCreate FOR TARGET GRID TPRCP." 2660 typekind=esmf_typekind_r8, &
2661 name=
"tprcp_target_grid", &
2662 staggerloc=esmf_staggerloc_center, rc=rc)
2663 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2664 call error_handler(
"IN FieldCreate", rc)
2666 print*,
"- INITIALIZE TARGET grid tprcp." 2668 farrayptr=target_ptr, rc=rc)
2669 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2670 call error_handler(
"IN FieldGet", rc)
2672 target_ptr = init_val
2674 print*,
"- CALL FieldCreate FOR TARGET GRID F10M." 2676 typekind=esmf_typekind_r8, &
2677 name=
"f10m_target_grid", &
2678 staggerloc=esmf_staggerloc_center, rc=rc)
2679 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2680 call error_handler(
"IN FieldCreate", rc)
2682 print*,
"- INITIALIZE TARGET grid f10m." 2684 farrayptr=target_ptr, rc=rc)
2685 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2686 call error_handler(
"IN FieldGet", rc)
2688 target_ptr = init_val
2690 print*,
"- CALL FieldCreate FOR TARGET GRID FFMM." 2692 typekind=esmf_typekind_r8, &
2693 name=
"ffmm_target_grid", &
2694 staggerloc=esmf_staggerloc_center, rc=rc)
2695 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2696 call error_handler(
"IN FieldCreate", rc)
2698 print*,
"- INITIALIZE TARGET grid ffmm." 2700 farrayptr=target_ptr, rc=rc)
2701 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2702 call error_handler(
"IN FieldGet", rc)
2704 target_ptr = init_val
2706 print*,
"- CALL FieldCreate FOR TARGET GRID USTAR." 2708 typekind=esmf_typekind_r8, &
2709 name=
"ustar_target_grid", &
2710 staggerloc=esmf_staggerloc_center, rc=rc)
2711 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2712 call error_handler(
"IN FieldCreate", rc)
2714 print*,
"- INITIALIZE TARGET grid ustar." 2716 farrayptr=target_ptr, rc=rc)
2717 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2718 call error_handler(
"IN FieldGet", rc)
2720 target_ptr = init_val
2722 print*,
"- CALL FieldCreate FOR TARGET GRID SNOW LIQ EQUIV." 2724 typekind=esmf_typekind_r8, &
2725 name=
"snow_liq_equiv_target_grid", &
2726 staggerloc=esmf_staggerloc_center, rc=rc)
2727 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2728 call error_handler(
"IN FieldCreate", rc)
2730 print*,
"- INITIALIZE TARGET grid snow liq equiv." 2732 farrayptr=target_ptr, rc=rc)
2733 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2734 call error_handler(
"IN FieldGet", rc)
2736 target_ptr = init_val
2738 print*,
"- CALL FieldCreate FOR TARGET GRID SNOW DEPTH." 2740 typekind=esmf_typekind_r8, &
2741 name=
"snow_depth_target_grid", &
2742 staggerloc=esmf_staggerloc_center, rc=rc)
2743 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2744 call error_handler(
"IN FieldCreate", rc)
2746 print*,
"- INITIALIZE TARGET grid snow depth." 2748 farrayptr=target_ptr, rc=rc)
2749 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2750 call error_handler(
"IN FieldGet", rc)
2752 target_ptr = init_val
2754 print*,
"- CALL FieldCreate FOR TARGET GRID SEA ICE FRACTION." 2756 typekind=esmf_typekind_r8, &
2757 name=
"seaice_fract_target_grid", &
2758 staggerloc=esmf_staggerloc_center, rc=rc)
2759 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2760 call error_handler(
"IN FieldCreate", rc)
2762 print*,
"- INITIALIZE TARGET grid sea ice fraction." 2764 farrayptr=target_ptr, rc=rc)
2765 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2766 call error_handler(
"IN FieldGet", rc)
2768 target_ptr = init_val
2770 print*,
"- CALL FieldCreate FOR TARGET GRID SEA ICE DEPTH." 2772 typekind=esmf_typekind_r8, &
2773 name=
"seaice_depth_target_grid", &
2774 staggerloc=esmf_staggerloc_center, rc=rc)
2775 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2776 call error_handler(
"IN FieldCreate", rc)
2778 print*,
"- INITIALIZE TARGET sea ice depth." 2780 farrayptr=target_ptr, rc=rc)
2781 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2782 call error_handler(
"IN FieldGet", rc)
2784 target_ptr = init_val
2786 print*,
"- CALL FieldCreate FOR TARGET GRID SEA ICE SKIN TEMP." 2788 typekind=esmf_typekind_r8, &
2789 name=
"seaice_skin_temp_target_grid", &
2790 staggerloc=esmf_staggerloc_center, rc=rc)
2791 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2792 call error_handler(
"IN FieldCreate", rc)
2794 print*,
"- INITIALIZE TARGET sea ice skin temp." 2796 farrayptr=target_ptr, rc=rc)
2797 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2798 call error_handler(
"IN FieldGet", rc)
2800 target_ptr = init_val
2802 print*,
"- CALL FieldCreate FOR TARGET GRID SRFLAG." 2804 typekind=esmf_typekind_r8, &
2805 name=
"srflag_target_grid", &
2806 staggerloc=esmf_staggerloc_center, rc=rc)
2807 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2808 call error_handler(
"IN FieldCreate", rc)
2810 print*,
"- INITIALIZE TARGET srflag." 2812 farrayptr=target_ptr, rc=rc)
2813 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2814 call error_handler(
"IN FieldGet", rc)
2816 target_ptr = init_val
2818 print*,
"- CALL FieldCreate FOR TARGET GRID SKIN TEMPERATURE." 2820 typekind=esmf_typekind_r8, &
2821 name=
"skin_temp_target_grid", &
2822 staggerloc=esmf_staggerloc_center, rc=rc)
2823 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2824 call error_handler(
"IN FieldCreate", rc)
2826 print*,
"- INITIALIZE TARGET grid skin temp." 2828 farrayptr=target_ptr, rc=rc)
2829 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2830 call error_handler(
"IN FieldGet", rc)
2832 target_ptr = init_val
2834 print*,
"- CALL FieldCreate FOR TARGET GRID CANOPY MOISTURE CONTENT." 2836 typekind=esmf_typekind_r8, &
2837 name=
"canopy_mc_target_grid", &
2838 staggerloc=esmf_staggerloc_center, rc=rc)
2839 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2840 call error_handler(
"IN FieldCreate", rc)
2842 print*,
"- INITIALIZE TARGET grid canopy moisture." 2844 farrayptr=target_ptr, rc=rc)
2845 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2846 call error_handler(
"IN FieldGet", rc)
2848 target_ptr = init_val
2850 print*,
"- CALL FieldCreate FOR TARGET GRID LEAF AREA INDEX." 2852 typekind=esmf_typekind_r8, &
2853 name=
"lai_target_grid",&
2854 staggerloc=esmf_staggerloc_center, rc=rc)
2855 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2856 call error_handler(
"IN FieldCreate", rc)
2858 print*,
"- INITIALIZE TARGET leaf area index." 2860 farrayptr=target_ptr, rc=rc)
2861 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2862 call error_handler(
"IN FieldGet", rc)
2864 target_ptr = init_val
2866 print*,
"- CALL FieldCreate FOR TARGET GRID Z0." 2868 typekind=esmf_typekind_r8, &
2869 name=
"z0_target_grid", &
2870 staggerloc=esmf_staggerloc_center, rc=rc)
2871 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2872 call error_handler(
"IN FieldCreate", rc)
2874 print*,
"- INITIALIZE TARGET grid z0." 2876 farrayptr=target_ptr, rc=rc)
2877 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2878 call error_handler(
"IN FieldGet", rc)
2880 target_ptr = init_val
2882 print*,
"- CALL FieldCreate FOR INTERPOLATED TARGET GRID TERRAIN." 2884 typekind=esmf_typekind_r8, &
2885 name=
"terrain_from_input_grid", &
2886 staggerloc=esmf_staggerloc_center, rc=rc)
2887 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2888 call error_handler(
"IN FieldCreate", rc)
2890 print*,
"- INITIALIZE TARGET grid interpolated terrain." 2892 farrayptr=target_ptr, rc=rc)
2893 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2894 call error_handler(
"IN FieldGet", rc)
2896 target_ptr = init_val
2898 print*,
"- CALL FieldCreate FOR INTERPOLATED TARGET GRID SOIL TYPE." 2900 typekind=esmf_typekind_r8, &
2901 staggerloc=esmf_staggerloc_center, &
2902 name=
"soil_type_from_input_grid", rc=rc)
2903 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2904 call error_handler(
"IN FieldCreate", rc)
2906 print*,
"- INITIALIZE TARGET grid soil type" 2908 farrayptr=target_ptr, rc=rc)
2909 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2910 call error_handler(
"IN FieldGet", rc)
2912 target_ptr = init_val
2914 print*,
"- CALL FieldCreate FOR TARGET GRID SOIL TEMPERATURE." 2916 typekind=esmf_typekind_r8, &
2917 staggerloc=esmf_staggerloc_center, &
2918 name=
"soil_temp_target_grid", &
2919 ungriddedlbound=(/1/), &
2921 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2922 call error_handler(
"IN FieldCreate", rc)
2924 print*,
"- INITIALIZE TARGET grid soil temp" 2926 farrayptr=target_ptr_3d, rc=rc)
2927 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2928 call error_handler(
"IN FieldGet", rc)
2930 target_ptr_3d = init_val
2932 print*,
"- CALL FieldCreate FOR TARGET GRID TOTAL SOIL MOISTURE." 2934 typekind=esmf_typekind_r8, &
2935 staggerloc=esmf_staggerloc_center, &
2936 name=
"soilm_tot_target_grid", &
2937 ungriddedlbound=(/1/), &
2939 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2940 call error_handler(
"IN FieldCreate", rc)
2942 print*,
"- INITIALIZE TARGET grid soil moist" 2944 farrayptr=target_ptr_3d, rc=rc)
2945 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2946 call error_handler(
"IN FieldGet", rc)
2948 target_ptr_3d = init_val
2950 print*,
"- CALL FieldCreate FOR TARGET GRID LIQUID SOIL MOISTURE." 2952 typekind=esmf_typekind_r8, &
2953 staggerloc=esmf_staggerloc_center, &
2954 name=
"soilm_liq_target_grid", &
2955 ungriddedlbound=(/1/), &
2957 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2958 call error_handler(
"IN FieldCreate", rc)
2960 print*,
"- INITIALIZE TARGET grid soil liq" 2962 farrayptr=target_ptr_3d, rc=rc)
2963 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2964 call error_handler(
"IN FieldGet", rc)
2966 target_ptr_3d = init_val
2981 print*,
"- CALL FieldCreate FOR TARGET GRID C_D." 2983 typekind=esmf_typekind_r8, &
2985 staggerloc=esmf_staggerloc_center, rc=rc)
2986 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2987 call error_handler(
"IN FieldCreate", rc)
2989 print*,
"- CALL FieldCreate FOR TARGET GRID C_0." 2991 typekind=esmf_typekind_r8, &
2993 staggerloc=esmf_staggerloc_center, rc=rc)
2994 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2995 call error_handler(
"IN FieldCreate", rc)
2997 print*,
"- CALL FieldCreate FOR TARGET GRID D_CONV." 2999 typekind=esmf_typekind_r8, &
3001 staggerloc=esmf_staggerloc_center, rc=rc)
3002 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3003 call error_handler(
"IN FieldCreate", rc)
3005 print*,
"- CALL FieldCreate FOR TARGET GRID DT_COOL." 3007 typekind=esmf_typekind_r8, &
3009 staggerloc=esmf_staggerloc_center, rc=rc)
3010 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3011 call error_handler(
"IN FieldCreate", rc)
3013 print*,
"- CALL FieldCreate FOR TARGET GRID IFD." 3015 typekind=esmf_typekind_r8, &
3017 staggerloc=esmf_staggerloc_center, rc=rc)
3018 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3019 call error_handler(
"IN FieldCreate", rc)
3021 print*,
"- CALL FieldCreate FOR TARGET GRID QRAIN." 3023 typekind=esmf_typekind_r8, &
3025 staggerloc=esmf_staggerloc_center, rc=rc)
3026 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3027 call error_handler(
"IN FieldCreate", rc)
3029 print*,
"- CALL FieldCreate FOR TARGET GRID TREF." 3031 typekind=esmf_typekind_r8, &
3033 staggerloc=esmf_staggerloc_center, rc=rc)
3034 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3035 call error_handler(
"IN FieldCreate", rc)
3037 print*,
"- CALL FieldCreate FOR TARGET GRID W_D." 3039 typekind=esmf_typekind_r8, &
3041 staggerloc=esmf_staggerloc_center, rc=rc)
3042 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3043 call error_handler(
"IN FieldCreate", rc)
3045 print*,
"- CALL FieldCreate FOR TARGET GRID W_0." 3047 typekind=esmf_typekind_r8, &
3049 staggerloc=esmf_staggerloc_center, rc=rc)
3050 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3051 call error_handler(
"IN FieldCreate", rc)
3053 print*,
"- CALL FieldCreate FOR TARGET GRID XS." 3055 typekind=esmf_typekind_r8, &
3057 staggerloc=esmf_staggerloc_center, rc=rc)
3058 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3059 call error_handler(
"IN FieldCreate", rc)
3061 print*,
"- CALL FieldCreate FOR TARGET GRID XT." 3063 typekind=esmf_typekind_r8, &
3065 staggerloc=esmf_staggerloc_center, rc=rc)
3066 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3067 call error_handler(
"IN FieldCreate", rc)
3069 print*,
"- CALL FieldCreate FOR TARGET GRID XU." 3071 typekind=esmf_typekind_r8, &
3073 staggerloc=esmf_staggerloc_center, rc=rc)
3074 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3075 call error_handler(
"IN FieldCreate", rc)
3077 print*,
"- CALL FieldCreate FOR TARGET GRID XV." 3079 typekind=esmf_typekind_r8, &
3081 staggerloc=esmf_staggerloc_center, rc=rc)
3082 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3083 call error_handler(
"IN FieldCreate", rc)
3085 print*,
"- CALL FieldCreate FOR TARGET GRID XZ." 3087 typekind=esmf_typekind_r8, &
3089 staggerloc=esmf_staggerloc_center, rc=rc)
3090 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3091 call error_handler(
"IN FieldCreate", rc)
3093 print*,
"- CALL FieldCreate FOR TARGET GRID XTTS." 3095 typekind=esmf_typekind_r8, &
3097 staggerloc=esmf_staggerloc_center, rc=rc)
3098 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3099 call error_handler(
"IN FieldCreate", rc)
3101 print*,
"- CALL FieldCreate FOR TARGET GRID XZTS." 3103 typekind=esmf_typekind_r8, &
3105 staggerloc=esmf_staggerloc_center, rc=rc)
3106 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3107 call error_handler(
"IN FieldCreate", rc)
3109 print*,
"- CALL FieldCreate FOR TARGET GRID Z_C." 3111 typekind=esmf_typekind_r8, &
3113 staggerloc=esmf_staggerloc_center, rc=rc)
3114 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3115 call error_handler(
"IN FieldCreate", rc)
3117 print*,
"- CALL FieldCreate FOR TARGET GRID ZM." 3119 typekind=esmf_typekind_r8, &
3121 staggerloc=esmf_staggerloc_center, rc=rc)
3122 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3123 call error_handler(
"IN FieldCreate", rc)
3135 subroutine ij_to_i_j(ij, itile, jtile, i, j)
3139 integer(esmf_kind_i4),
intent(in) :: ij
3140 integer ,
intent(in) :: itile, jtile
3142 integer ,
intent(out) :: i, j
3145 integer :: pt_loc_this_tile
3147 tile_num = ((ij-1) / (itile*jtile))
3148 pt_loc_this_tile = ij - (tile_num * itile * jtile)
3151 j = (pt_loc_this_tile - 1) / itile + 1
3152 i = mod(pt_loc_this_tile, itile)
3170 subroutine regrid_many(bundle_pre,bundle_post, num_field,route,dozero, &
3171 unmapped_ptr,resetifd)
3179 integer,
intent(in) :: num_field
3180 type(esmf_routehandle),
intent(inout) :: route
3181 type(esmf_fieldbundle),
intent(in) :: bundle_pre, bundle_post
3182 logical,
intent(in) :: dozero(num_field)
3183 logical,
intent(in),
optional :: resetifd
3184 integer(esmf_kind_i4),
intent(inout),
optional :: unmapped_ptr(:)
3186 type(esmf_field) :: field_pre,field_post
3187 real(esmf_kind_r8),
pointer :: tmp_ptr(:,:)
3190 logical :: is2d(num_field)
3191 character(len=50) :: fname
3192 integer :: i, j, k, ij, ind_2d, ind_3d, rc, ndims,n2d, n3d,localpet, l(1), u(1)
3198 if(
present(unmapped_ptr))
then 3199 l = lbound(unmapped_ptr)
3200 u = ubound(unmapped_ptr)
3204 call esmf_fieldbundleget(bundle_pre,i,field_pre,rc=rc)
3205 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3206 call error_handler(
"IN FieldBundleGet", rc)
3208 call esmf_fieldbundleget(bundle_post,i,field_post,rc=rc)
3209 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3210 call error_handler(
"IN FieldBundleGet", rc)
3212 call esmf_fieldget(field_post,dimcount=ndims,name=fname,rc=rc)
3213 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3214 call error_handler(
"IN FieldGet", rc)
3216 call esmf_vmgetglobal(vm, rc=rc)
3217 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3218 call error_handler(
"IN VMGetGlobal", rc)
3219 call esmf_vmget(vm, localpet=localpet, rc=rc)
3220 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3221 call error_handler(
"IN VMGet", rc)
3222 if(localpet==0) print*,
"in regrid_many fname = ", fname, ndims
3223 if (ndims == 2) is2d(i) = .true.
3224 if (ndims == 3) is2d(i) = .false.
3227 call esmf_fieldregrid(field_pre, &
3229 routehandle=route, &
3230 termorderflag=esmf_termorder_srcseq, rc=rc)
3231 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3232 call error_handler(
"IN FieldRegrid", rc)
3234 call esmf_fieldregrid(field_pre, &
3236 routehandle=route, &
3237 zeroregion=esmf_region_select, &
3238 termorderflag=esmf_termorder_srcseq, rc=rc)
3239 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3240 call error_handler(
"IN FieldRegrid", rc)
3244 if (
present(resetifd))
then 3247 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3248 call error_handler(
"IN FieldGet", rc)
3249 tmp_ptr = float(nint(tmp_ptr))
3253 n2d = count(is2d(:))
3254 n3d = count(.not.is2d(:))
3255 if(localpet==0) print*, is2d(:)
3256 if (
present(unmapped_ptr))
then 3257 allocate(ptr_2d(n2d))
3258 if (n3d .ne. 0)
allocate(ptr_3d(n3d))
3262 call esmf_fieldbundleget(bundle_post,i,field_post,rc=rc)
3263 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3264 call error_handler(
"IN FieldBundleGet", rc)
3265 call esmf_fieldget(field_post, farrayptr=ptr_2d(ind_2d)%p, rc=rc)
3266 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3267 call error_handler(
"IN FieldGet", rc)
3268 call esmf_fieldget(field_post,name=fname,rc=rc)
3269 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3270 call error_handler(
"IN FieldGet", rc)
3271 if (localpet==0) print*,
"in doreplace loop, 2d field = ", trim(fname)
3274 call esmf_fieldbundleget(bundle_post,i,field_post,rc=rc)
3275 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3276 call error_handler(
"IN FieldBundleGet", rc)
3277 call esmf_fieldget(field_post,name=fname,rc=rc)
3278 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3279 call error_handler(
"IN FieldGet", rc)
3280 if (localpet==0) print*,
"in doreplace loop, 3d field = ", trim(fname)
3281 call esmf_fieldget(field_post, farrayptr=ptr_3d(ind_3d)%p, rc=rc)
3282 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3283 call error_handler(
"IN FieldGet", rc)
3290 ptr_2d(k)%p(i,j) = -9999.9
3293 ptr_3d(k)%p(i,j,:) = -9999.9
3297 if(n3d .ne. 0)
deallocate(ptr_3d)
3315 subroutine search_many(num_field,bundle_target,tile,search_nums,localpet,latitude, &
3316 terrain_land,soilt_climo, mask)
3324 integer,
intent(in) :: num_field
3325 type(esmf_fieldbundle),
intent(inout) :: bundle_target
3328 real(esmf_kind_r8),
intent(inout),
optional :: terrain_land(
i_target,
j_target)
3329 real(esmf_kind_r8),
intent(inout),
optional :: soilt_climo(
i_target,
j_target)
3332 real(esmf_kind_r8),
allocatable :: field_data_2d(:,:)
3333 real(esmf_kind_r8),
allocatable :: field_data_3d(:,:,:)
3334 integer,
intent(in) :: tile,localpet
3335 integer,
intent(inout) :: search_nums(num_field)
3337 type(esmf_field) :: temp_field
3338 character(len=50) :: fname
3339 integer,
parameter :: sotyp_land_field_num = 224
3340 integer,
parameter :: sst_field_num = 11
3341 integer,
parameter :: terrain_field_num= 7
3342 integer :: j,k, rc, ndims
3346 call esmf_fieldbundleget(bundle_target,k,temp_field, rc=rc)
3347 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3348 call error_handler(
"IN FieldGet", rc)
3349 call esmf_fieldget(temp_field, name=fname, dimcount=ndims,rc=rc)
3350 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3351 call error_handler(
"IN FieldGet", rc)
3352 if (localpet==0)
then 3355 allocate(field_data_2d(0,0))
3357 if (ndims .eq. 2)
then 3358 call esmf_fieldgather(temp_field,field_data_2d,rootpet=0,tile=tile, rc=rc)
3359 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3360 call error_handler(
"IN FieldGather", rc)
3361 if (localpet == 0)
then 3362 if (
present(latitude) .and. search_nums(k).eq.sst_field_num)
then 3365 elseif (
present(terrain_land) .and. search_nums(k) .eq. terrain_field_num)
then 3368 elseif (search_nums(k) .eq. sotyp_land_field_num)
then 3370 if (fname .eq.
"soil_type_target_grid")
then 3374 elseif (
present(soilt_climo))
then 3383 field_data_2d = soilt_climo
3392 call esmf_fieldscatter(temp_field, field_data_2d, rootpet=0, tile=tile,rc=rc)
3393 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3394 call error_handler(
"IN FieldScatter", rc)
3396 if (localpet==0)
then 3399 allocate(field_data_3d(0,0,0))
3403 call esmf_fieldgather(temp_field,field_data_3d,rootpet=0,tile=tile,rc=rc)
3404 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3405 call error_handler(
"IN FieldGather", rc)
3407 if (localpet==0)
then 3409 field_data_2d = field_data_3d(:,:,j)
3411 field_data_3d(:,:,j) = field_data_2d
3414 call esmf_fieldscatter(temp_field, field_data_3d, rootpet=0, tile=tile,rc=rc)
3415 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3416 call error_handler(
"IN FieldScatter", rc)
3417 deallocate(field_data_3d)
3419 deallocate(field_data_2d)
3436 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.
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, public search_many(num_field, bundle_target, tile, search_nums, localpet, latitude, terrain_land, soilt_climo, mask)
Execute the search function for multple fields.
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