Skip to content

Commit 973e59c

Browse files
Yujin ZengYujin Zeng
authored andcommitted
using the sum of tile area to represent catchment area for cube-shpere grid
1 parent f951c93 commit 973e59c

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSroute_GridComp/GEOS_RouteGridComp.F90

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ subroutine INITIALIZE (GC,IMPORT, EXPORT, CLOCK, RC )
478478
type (RROUTE_wrap) :: wrap
479479
real, allocatable :: tmp_real(:)
480480
integer, allocatable :: tmp_int(:)
481-
real, allocatable :: areacat_glob(:)
482481

483482

484483
type(ESMF_Time) :: CurrentTime
@@ -616,12 +615,9 @@ subroutine INITIALIZE (GC,IMPORT, EXPORT, CLOCK, RC )
616615
route%reservoir = Reservoir(GC, use_res, _RC)
617616
if(mapl_am_I_root()) print *,"reservoir init success"
618617

619-
allocate(areacat_glob(n_pfaf_g))
620-
call ESMFL_FCollect(pfaf_tilegrid, areacat_glob, AREA_CATCH_RS, RC=STATUS)
621618
call MAPL_GetResource (MAPL, TILE_PFAF_File, label = 'TILE_PFAF_FILE:', default = '../input/tile_pfaf.nc4', RC=STATUS )
622619
call create_mapping_handler(trim(TILE_PFAF_File), tilegrid, pfaf_tilegrid, _RC)
623620
call setup_exchange_water(pfaf_tilegrid, _RC)
624-
deallocate(areacat_glob)
625621

626622
RETURN_(ESMF_SUCCESS)
627623

@@ -676,6 +672,7 @@ subroutine create_mapping_handler(tile_pfaf_file, tilegrid, pfaf_tilegrid, rc)
676672
integer, allocatable :: srcIndices(:), positions(:), factorIndexList(:,:)
677673
real, allocatable :: weights(:), global_frac(:), global_area(:)
678674
integer, allocatable :: local_src(:), local_dst(:), global_src(:), global_dst(:)
675+
real, allocatable :: areacat_glob(:)
679676
integer :: unit,ii,dst
680677
integer, pointer :: pfaf_index(:), local_id(:)
681678
real , pointer :: tilearea(:),frac_tot(:),fscale(:)
@@ -719,23 +716,15 @@ subroutine create_mapping_handler(tile_pfaf_file, tilegrid, pfaf_tilegrid, rc)
719716
global_src = global_id
720717
call ESMFL_Fcollect(tilegrid, global_dst, pfaf_index, _RC)
721718
call ESMFL_Fcollect(tilegrid, global_area, tilearea, _RC)
722-
global_frac = global_area*MAPL_RADIUS**2/areacat_glob(global_dst)
723-
allocate(frac_tot(N_pfaf_g),fscale(N_pfaf_g))
724-
frac_tot=0.
719+
global_area = global_area*MAPL_RADIUS**2
720+
allocate(areacat_glob(N_pfaf_g),source=0.)
725721
do ii=1,nWeights
726-
frac_tot(global_dst(ii))=frac_tot(global_dst(ii))+global_frac(ii)
722+
dst=global_dst(ii)
723+
areacat_glob(dst)=areacat_glob(dst)+global_area(ii)
727724
enddo
728-
fscale = 1.
729-
do ii = 1, N_pfaf_g
730-
if (frac_tot(ii) > 0.) then
731-
fscale(ii) = 1. / frac_tot(ii)
732-
endif
733-
enddo
734-
do ii = 1, nWeights
735-
dst = global_dst(ii)
736-
global_frac(ii) = global_frac(ii) * fscale(dst)
737-
enddo
738-
deallocate(global_area,frac_tot,fscale)
725+
where(areacat_glob==0.) areacat_glob=1.
726+
global_frac = global_area/areacat_glob(global_dst)
727+
deallocate(areacat_glob)
739728
endif
740729

741730
allocate(mask(nWeights))

GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSroute_GridComp/reservoir.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ module reservoirMod
5656

5757
function new_Reservoir(GC, use_res, rc) result (res)
5858

59-
type(RES_STATE) :: res
59+
type(RES_STATE) :: res
6060
type(ESMF_GridComp), intent(inout) :: GC
61-
logical, intent(in) :: use_res
61+
logical, intent(in) :: use_res
6262

63-
integer, optional, intent(out) :: rc
63+
integer, optional, intent(out) :: rc
6464

6565
! ---------------
6666
type(MAPL_MetaComp), pointer :: MAPL

0 commit comments

Comments
 (0)