@@ -75,7 +75,9 @@ module GEOS_RouteGridCompMod
7575 real , pointer :: subarea(:,:) = > NULL () ! m2
7676 integer , pointer :: nsubt(:) = > NULL ()
7777 integer , pointer :: subit(:,:) = > NULL ()
78- real , pointer :: subareat(:,:) = > NULL () ! m2
78+ real , pointer :: subareat(:,:) = > NULL () ! frac
79+
80+ real , pointer :: catarea_global(:) = > NULL () ! m2
7981
8082 integer , pointer :: scounts_global(:) = > NULL ()
8183 integer , pointer :: rdispls_global(:) = > NULL ()
@@ -352,6 +354,7 @@ subroutine INITIALIZE (GC,IMPORT, EXPORT, CLOCK, RC )
352354 real , pointer :: subareat_global(:,:)= > NULL (),subareat(:,:)= > NULL () ! Arrays for sub-area and fractions
353355 integer , pointer :: subit_global(:,:)= > NULL (),subit(:,:)= > NULL ()
354356 integer , pointer :: nsubt_global(:)= > NULL (),nsubt(:)= > NULL ()
357+ real , pointer :: catarea_global(:)= > NULL ()
355358
356359 real , pointer :: area_cat_global(:)= > NULL (),area_cat(:)= > NULL ()
357360 integer , pointer :: scounts(:)= >NULL ()
@@ -447,15 +450,17 @@ subroutine INITIALIZE (GC,IMPORT, EXPORT, CLOCK, RC )
447450 route% maxCatch = maxCatch
448451
449452 ! Read sub-catchment data
450- allocate (nsub_global(N_CatG),subarea_global(nmax,N_CatG))
453+ allocate (nsub_global(N_CatG),subarea_global(nmax,N_CatG),catarea_global(N_CatG) )
451454 open (77 ,file= trim (inputdir)// " /Pfaf_nsub_" // trim (resname)// " .txt" ,status= " old" ,action= " read" ); read (77 ,* )nsub_global; close (77 )
452455 open (77 ,file= trim (inputdir)// " /Pfaf_asub_" // trim (resname)// " .txt" ,status= " old" ,action= " read" ); read (77 ,* )subarea_global; close (77 )
453456 allocate (nsub(ntiles),subarea(nmax,ntiles))
454457 nsub= nsub_global(minCatch:maxCatch)
458+ subarea_global= subarea_global* 1.e6 ! km2->m2
459+ catarea_global= sum (subarea_global,dim= 1 )
455460 subarea= subarea_global(:,minCatch:maxCatch)
456- subarea= subarea* 1.e6 ! km2->m2
457461 deallocate (nsub_global,subarea_global)
458462
463+ route% catarea_global = > catarea_global ! m2
459464 route% nsub = > nsub
460465 route% subarea = > subarea
461466
@@ -500,11 +505,11 @@ subroutine INITIALIZE (GC,IMPORT, EXPORT, CLOCK, RC )
500505 ! for output interpolated on model grid
501506 allocate (nsubt_global(nt_global),subareat_global(nmaxt,nt_global))
502507 open (77 ,file= trim (inputdir)// " /nsub_tile_" // trim (resname)// " .txt" ,status= " old" ,action= " read" ); read (77 ,* )nsubt_global; close (77 )
503- open (77 ,file= trim (inputdir)// " /areasub_tile_ " // trim (resname)// " .txt" ,status= " old" ,action= " read" ); read (77 ,* )subareat_global; close (77 )
508+ open (77 ,file= trim (inputdir)// " /fracsub_tile_ " // trim (resname)// " .txt" ,status= " old" ,action= " read" ); read (77 ,* )subareat_global; close (77 )
504509 allocate (nsubt(nt_local),subareat(nmaxt,nt_local))
505510 nsubt= nsubt_global(route% minNT:route% maxNT)
506- subareat= subareat_global(:,route% minNT:route% maxNT)
507- subareat= subareat* 1.e6 ! km2->m2
511+ subareat= subareat_global(:,route% minNT:route% maxNT) ! frac
512+ ! subareat=subareat*1.e6 !km2->m2
508513 deallocate (nsubt_global,subareat_global)
509514 route% nsubt = > nsubt
510515 route% subareat = > subareat
@@ -819,6 +824,7 @@ subroutine RUN2 (GC,IMPORT, EXPORT, CLOCK, RC )
819824 real , pointer :: WSTREAM_ACT(:)= >NULL ()
820825 real , pointer :: WRIVER_ACT(:) = >NULL ()
821826 type (RES_STATE), pointer :: res = > NULL ()
827+ real , pointer :: flow_riv(:)= >NULL ()
822828
823829 real , allocatable :: runoff_save_m3(:),runoff_global_m3(:),QOUTFLOW_GLOBAL(:),Qres_global(:)
824830 real , allocatable :: WTOT_BEFORE(:),WTOT_AFTER(:),QINFLOW_LOCAL(:),UNBALANCE(:),UNBALANCE_GLOBAL(:),ERROR(:),ERROR_GLOBAL(:)
@@ -1001,7 +1007,7 @@ subroutine RUN2 (GC,IMPORT, EXPORT, CLOCK, RC )
10011007 if (FirstTime)then
10021008 if (mapl_am_I_root()) istat = mkdir(" ../river" , int (o' 755' ,c_int16_t))
10031009 endif
1004- if (HH== 23 )then
1010+ if (HH== 23 )then
10051011 allocate (wriver_global(n_catg),wstream_global(n_catg),qoutflow_global(n_catg),qsflow_global(n_catg))
10061012 ! call MPI_allgatherv ( &
10071013 ! route%wriver_acc, route%scounts_cat(mype+1) ,MPI_REAL, &
@@ -1014,7 +1020,23 @@ subroutine RUN2 (GC,IMPORT, EXPORT, CLOCK, RC )
10141020 call MPI_allgatherv ( &
10151021 route% qoutflow_acc, route% scounts_cat(mype+1 ) ,MPI_REAL, &
10161022 qoutflow_global, route% scounts_cat, route% rdispls_cat,MPI_REAL, &
1017- MPI_COMM_WORLD, mpierr)
1023+ MPI_COMM_WORLD, mpierr)
1024+
1025+ allocate (flow_riv(nt_local))
1026+ flow_riv= 0 .
1027+ do i= 1 ,nt_local
1028+ do j= 1 ,nmaxt
1029+ it= route% subit(j,i)
1030+ if (it> 0 )then
1031+ if (route% catarea_global(it)>0 .)then
1032+ flow_riv(i)= flow_riv(i)+ route% subareat(j,i)* (qoutflow_global(it)/ route% catarea_global(it)* 1.e3 )
1033+ endif
1034+ endif
1035+ if (it== 0 )exit
1036+ enddo
1037+ enddo
1038+ deallocate (flow_riv)
1039+
10181040 ! call MPI_allgatherv ( &
10191041 ! route%qsflow_acc, route%scounts_cat(mype+1) ,MPI_REAL, &
10201042 ! qsflow_global, route%scounts_cat, route%rdispls_cat,MPI_REAL, &
@@ -1038,21 +1060,21 @@ subroutine RUN2 (GC,IMPORT, EXPORT, CLOCK, RC )
10381060 ! print *, "output stream storage is: ",sum(wstream_global)/1.e9
10391061 endif
10401062
1041- if (use_res .eqv. .True. )then
1042- allocate (qres_global(n_catg))
1043- call MPI_allgatherv ( &
1044- res% qres_acc, route% scounts_cat(mype+1 ) ,MPI_REAL, &
1045- qres_global, route% scounts_cat, route% rdispls_cat,MPI_REAL, &
1046- MPI_COMM_WORLD, mpierr)
1047- if (mapl_am_I_root())then
1048- open (92 ,file= " ../river/res_flow_" // trim (yr_s)// trim (mon_s)// trim (day_s)// " .txt" ,action= " write" )
1049- do i= 1 ,n_catg
1050- write (92 ,* )qres_global(i)
1051- enddo
1052- close (92 )
1053- endif
1054- deallocate (qres_global)
1055- endif
1063+ ! if(use_res .eqv. .True.)then
1064+ ! allocate(qres_global(n_catg))
1065+ ! call MPI_allgatherv ( &
1066+ ! res%qres_acc, route%scounts_cat(mype+1) ,MPI_REAL, &
1067+ ! qres_global, route%scounts_cat, route%rdispls_cat,MPI_REAL, &
1068+ ! MPI_COMM_WORLD, mpierr)
1069+ ! if(mapl_am_I_root())then
1070+ ! open(92,file="../river/res_flow_"//trim(yr_s)//trim(mon_s)//trim(day_s)//".txt",action="write")
1071+ ! do i=1,n_catg
1072+ ! write(92,*)qres_global(i)
1073+ ! enddo
1074+ ! close(92)
1075+ ! endif
1076+ ! deallocate(qres_global)
1077+ ! endif
10561078
10571079 deallocate (wriver_global,wstream_global,qoutflow_global,qsflow_global)
10581080 route% wriver_acc = 0 .
0 commit comments