#ls2(research/Memo/ECPC)

* River Routing [#s4bb83f1]

#contents

** General Info [#ke796975]
- Only for GSM (RSM version is under development).

  river discharge estimation coded by kei yoshimura (07/02/09)
 
  compute river discharge by TRIP (Oki and Sud, 1998)
     S(t+1)=S(t)*exp(-dc*dt)+(1-exp(-dc*dt))*I/dc
     O=(S(t+1)-S(t))/dt+I
     S:river storage 
     O:river discharge
     I:input to the flow (inflow from upstream and total runoff 
       accumulated in a grid)
     dc=v/l (v: flow velocity, l: flowpath length)
 
     input runoff are taken from LSM and output river discharge etc.
     are written to riv.ftXX in grib format.
 
  variables:
     gdriv: river storage [kg/m/m]
     rflow: river discharge [kg/s]
     imap : flow direction (0:sea, 9:rivermouth)
           8  1  2
           7  *  3
           6  5  4
     roff : converted runoff [kg/m/m/s]
 
  initial and restart file:
     rivi (if not exsited, all river channel storage is assumed
           to have 10mm water)
** Specification [#q2ed960c]
-New codes/scripts/data
-- src/fcst/pgriv.F : river routine.
-- src/fcst/gau2llc.F : horizontal interpolation for a grid center.
-- src/share/gribit2.F : called from wriflx for gribing river variables.
-- src/include/comfriv.h : 
-- con/flwdirGSWP2.one.Z : 1.0 degree digital river map (Oki and Sud, 1998)
-- con/flwdirGSWP2.hlf.Z : 0.5 degree digital river map (Okada, 2000)
-Modified codes/scripts/data
-- src/fcst/gsmstep.F : call pgriv and write restart file (rivi)
-- src/fcst/gbphys.F : calculate total runoff (surface+subsurface)
-- src/fcst/wriflx.F : writing to riv.ftXX in grib format.
-- src/share/idsdef.F : define output variable IDs. gdriv(199), rflow(200), imap(202), roff(203)
-- src/fcst/Makefile.in : add pgriv.o and gau2llc.o
-- src/share/Makefile.in : add gribit2.o
-- def/cvar.F 
-- def/misc.h : add RIV1 and RIV05 definitions.
-- def/depend.h : add IO2 and JO2 definitions.
-- configure-model : add --enable-riv1 or riv05 option.
-- configure-scr
-- install : add --enable-riv1 or riv05 option.
-- runscr/fcst.in : add a link from digital river map.
-- CVSROOT/modules : add flwdir data.

** Automatic Installation [#y3560302]
- When you install gsm, just add --enable-riv1 for 1deg or --enable-riv05 for 0.5deg.

 mkdir rivtest
 cd rivtest
 cvs co install
 ./install --model=gsm --enable-riv1
** Step by step [#y41f3bbb]
1. Make executables. 
-You should rerun configure-model in gsm/ with option "--enable-riv1" or "--enable-riv05". 

 cd gsm
 ./configure-model --enable-riv05
 make clean
 make
  # you need to make at least fcst and share.

2. Get digital river map. 
- The digital river maps are on courtesy of Oki Lab, IIS, UT.

 cd libs
 cvs co con/flwdirGSWP2.one.Z con/flwdirGSWP2.hlf.Z
 uncompress con/flwdir*.Z

3. Soft-link the river map as "fort.93"
- It is better to add "ln" command in gruns/runscr/fcst. Such as,

  (in case of riv05)
 ln -fs con/flwdirGSWP2.hlf              fort.93
  (in case of riv1)
 ln -fs con/flwdirGSWP2.one              fort.93

4. Modify the main script.
- Nothing for river routing.
- As usual. Simulation period, initial files, boundary files, etc.etc.

5. Execution.
- If you have initial river storage in appropriate resolution, copy it as "rivi".
- Output will be "riv.ftXX". Restart file is named as "rivi".

 gsm
** Notes [#a9a30764]
  Note1: 
     Calculation is in a single processor 
     (Same as I/O process. Does not influence to other routines.)
  Note2: 
     Map(s) of riverflow direction is very important.
     Currently, 1deg x 1deg version (Oki and Sud, 1996) and
     0.5deg x 0.5deg version (Okada, 1999) are available.
     The map should be placed/linked as fort.93
  Note3: 
     io_ and jo_ in paramodel.h are used as io2_ and jo2_.
     t126 (io_=360,jo_=181) and t248 (io_=720,jo_=361) are
     usable in default, but other resolution io2_ and jo2_ 
     needs to be selected manually. => in comfriv.h and gau2llc.F
 
     Grid coordination (1deg) is centered, such as 
     (0.5E, 89.5N)  - (0.5W, 89.5N) ; i=1,io_
                    :               ; j=1,jo_-1
     (0.5E, 89.5S)  - (0.5W, 89.5S) 
     (        dummy column        ) ; j=jo_