source: branches/publications/ORCHIDEE_gmd-2018-57/src_parameters/control.f90

Last change on this file was 4482, checked in by fuxing.wang, 7 years ago

Modifing testrouting to make it work for XIOS. Finding the usable GRDC observation stations by comparing upstream basin area and distance between GRDC and model subbasin. The GRDC and the corresponding model subbasion information (Lon, Lat, Area, Discharge, etc.) is then written into river_grdc_XXXX.nc output. This nc file also contains the information of the pre-defined number of largest river basins. Another output grdc_river_desc.nc describes the all the matched GRDC river basins (for post-processing).

File size: 18.7 KB
Line 
1! =================================================================================================================================
2! MODULE       : control
3!
4! CONTACT      : orchidee-help _at_ ipsl.jussieu.fr
5!
6! LICENCE      : IPSL (2006)
7! This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
8!
9!>\BRIEF        "control" module contains subroutines to initialize run time control parameters.
10!!
11!!\n DESCRIPTION:
12!!
13!! SVN          :
14!! $HeadURL:
15!! $Date: 
16!! $Revision:
17!! \n
18!_ ================================================================================================================================
19
20MODULE control
21 
22  USE constantes_soil
23  USE constantes_var
24  USE pft_parameters
25  USE vertical_soil
26
27  IMPLICIT NONE
28
29CONTAINS
30!! ================================================================================================================================
31!! SUBROUTINE   : control_initialize
32!!
33!>\BRIEF        This subroutine reads the configuration flags which control the behaviour of the model
34!!              This subroutine was previsouly named intsurf_config and located in intersurf module.
35!!
36!! DESCRIPTION  : None
37!!
38!! RECENT CHANGE(S): None
39!!
40!! MAIN OUTPUT VARIABLE(S): None
41!!
42!! REFERENCE(S) : None
43!!
44!! FLOWCHART    : None
45!! \n
46!_ ================================================================================================================================
47
48  SUBROUTINE control_initialize(dt)
49
50    IMPLICIT NONE
51   
52    REAL(r_std), INTENT(in)                    :: dt            !! Time step in seconds
53    INTEGER(i_std)                             :: jv            !! Local index variable
54    INTEGER(i_std)                             :: ier           !! Error handeling
55
56    ! Archive the sechiba time step into module constantes_var
57    dt_sechiba=dt
58
59    ! Start reading options from parameter file
60
61    !Config Key   = SOILTYPE_CLASSIF
62    !Config Desc  = Type of classification used for the map of soil types
63    !Config Def   = zobler
64    !Config If    = !IMPOSE_VEG
65    !Config Help  = The classification used in the file that we use here
66    !Config         There are three classification supported: 
67    !Config         Zobler (7 converted to 3) and USDA (12)
68    !Config Units = [-]
69    !
70    !-tdo- Suivant le type de classification utilisee pour le sol, on adapte nscm
71    soil_classif = 'zobler'
72    CALL getin_p('SOILTYPE_CLASSIF',soil_classif)
73    SELECTCASE (soil_classif)
74    CASE ('zobler','none')
75       nscm = nscm_fao
76    CASE ('usda')
77       nscm = nscm_usda
78    CASE DEFAULT
79       WRITE(numout,*) "Unsupported soil type classification: soil_classif=",soil_classif
80       WRITE(numout,*) "Choose between zobler, usda and none according to the map"
81       CALL ipslerr_p(3,'control_initialize','Bad choice of soil_classif','Choose between zobler, usda and none','')
82    ENDSELECT
83
84
85    !Config Key   = RIVER_ROUTING
86    !Config Desc  = Decides if we route the water or not
87    !Config If    = OK_SECHIBA
88    !Config Def   = n
89    !Config Help  = This flag allows the user to decide if the runoff
90    !Config         and drainage should be routed to the ocean
91    !Config         and to downstream grid boxes.
92    !Config Units = [FLAG]
93    !
94    river_routing = .FALSE.
95    CALL getin_p('RIVER_ROUTING', river_routing)
96    !
97    !Config Key   = ROUTING_REGIONAL
98    !Config Desc  = Decides if we use the global or regional routing
99    !Config If    = RIVER_ROUTING
100    !Config Def   = n
101    !Config Help  = This flag allows the user to decide if the runoff
102    !Config         will be routed with the global module (routing.f90)
103    !Config         or with the its regional counterpart (routing_reg.f90)
104    !Config Units = [FLAG]
105    !
106    river_routingreg = .FALSE.
107    CALL getin_p('ROUTING_REGIONAL', river_routingreg)
108    !
109    ! Conistency checks :
110    !
111    IF ( .NOT. river_routing ) THEN
112       river_routingreg = .FALSE.
113    ENDIF
114    !
115    IF ( river_routing ) THEN
116       WRITE(numout,*) "RIVER routing is activated : ",river_routing
117       IF ( river_routingreg ) THEN
118          WRITE(numout,*) "REGIONAL RIVER routing is activated : ", river_routingreg
119       ELSE
120          WRITE(numout,*) "Only the coarse routing is activated : "
121       ENDIF
122    ENDIF
123    !
124    !Config key   = HYDROL_CWRR
125    !Config Desc  = Allows to switch on the multilayer hydrology of CWRR
126    !Config If    = OK_SECHIBA
127    !Config Def   = n
128    !Config Help  = This flag allows the user to decide if the vertical
129    !Config         hydrology should be treated using the multi-layer
130    !Config         diffusion scheme adapted from CWRR by Patricia de Rosnay.
131    !Config         by default the Choisnel hydrology is used.
132    !Config Units = [FLAG]
133    !
134    hydrol_cwrr = .FALSE.
135    CALL getin_p('HYDROL_CWRR', hydrol_cwrr)
136    WRITE(numout,*) "CWRR hydrology is activated : ",hydrol_cwrr
137
138    !Config Key   = DO_IRRIGATION
139    !Config Desc  = Should we compute an irrigation flux
140    !Config If    = RIVER_ROUTING
141    !Config Def   = n
142    !Config Help  = This parameters allows the user to ask the model
143    !Config         to compute an irigation flux. This performed for the
144    !Config         on very simple hypothesis. The idea is to have a good
145    !Config         map of irrigated areas and a simple function which estimates
146    !Config         the need to irrigate.
147    !Config Units = [FLAG]
148    !
149    do_irrigation = .FALSE.
150    IF ( river_routing ) CALL getin_p('DO_IRRIGATION', do_irrigation)
151    !
152    !Config Key   = DO_FLOODPLAINS
153    !Config Desc  = Should we include floodplains
154    !Config If    = RIVER_ROUTING
155    !Config Def   = n
156    !Config Help  = This parameters allows the user to ask the model
157    !Config         to take into account the flood plains and return
158    !Config         the water into the soil moisture. It then can go
159    !Config         back to the atmopshere. This tried to simulate
160    !Config         internal deltas of rivers.
161    !Config Units = [FLAG] 
162    !
163    do_floodplains = .FALSE.
164    IF ( river_routing ) CALL getin_p('DO_FLOODPLAINS', do_floodplains)
165    !
166    !Config Key   = CHECK_WATERBAL
167    !Config Desc  = Should we check the global water balance
168    !Config If    = OK_SECHIBA
169    !Config Def   = n
170    !Config Help  = This parameters allows the user to check
171    !Config         the integrated water balance at the end
172    !Config         of each time step
173    !Config Units = [FLAG] 
174    !
175    check_waterbal = .FALSE.
176    CALL getin_p('CHECK_WATERBAL', check_waterbal)
177
178    !Config Key   = OK_EXPLICITSNOW
179    !Config Desc  = Activate explict snow scheme
180    !Config If    = OK_SECHIBA
181    !Config Def   = FALSE
182    !Config Help  = Activate explicit snow scheme instead of default snow scheme
183    !Config Units = [FLAG]
184    ok_explicitsnow = .FALSE.
185    CALL getin_p('OK_EXPLICITSNOW', ok_explicitsnow)
186
187    !
188    !Config Key   = STOMATE_OK_STOMATE
189    !Config Desc  = Activate STOMATE?
190    !Config If    = OK_SECHIBA
191    !Config Def   = n
192    !Config Help  = set to TRUE if STOMATE is to be activated
193    !Config Units = [FLAG]
194    !
195    ok_stomate = .FALSE.
196    CALL getin_p('STOMATE_OK_STOMATE',ok_stomate)
197    WRITE(numout,*) 'STOMATE is activated: ',ok_stomate
198
199
200    IF ( ok_stomate ) THEN
201       ok_co2 = .TRUE.
202    ELSE
203       !Config Key   = STOMATE_OK_CO2
204       !Config Desc  = Activate CO2?
205       !Config If    = OK_SECHIBA
206       !Config Def   = y if OK_STOMATE else n
207       !Config Help  = set to TRUE if photosynthesis is to be activated
208       !Config Units = [FLAG]
209       ok_co2 = .FALSE.
210       CALL getin_p('STOMATE_OK_CO2', ok_co2)
211    END IF
212    WRITE(numout,*) 'photosynthesis: ', ok_co2
213
214    !
215    !Config Key   = STOMATE_OK_DGVM
216    !Config Desc  = Activate DGVM?
217    !Config If    = OK_STOMATE
218    !Config Def   = n
219    !Config Help  = set to TRUE if DGVM is to be activated
220    !Config Units = [FLAG]
221    !
222    ok_dgvm = .FALSE.
223    CALL getin_p('STOMATE_OK_DGVM',ok_dgvm)
224    !
225    !Config Key   = CHEMISTRY_BVOC
226    !Config Desc  = Activate calculations for BVOC
227    !Config If    = OK_SECHIBA
228    !Config Def   = n
229    !Config Help  = set to TRUE if biogenic emissions calculation is to be activated
230    !Config Units = [FLAG]
231    !
232    ok_bvoc = .FALSE.
233    CALL getin_p('CHEMISTRY_BVOC', ok_bvoc)
234    WRITE(numout,*) 'Biogenic emissions: ', ok_bvoc
235
236    IF ( ok_bvoc ) THEN
237       ok_leafage         = .TRUE. 
238       ok_radcanopy       = .TRUE. 
239       ok_multilayer      = .TRUE.
240       ok_pulse_NOx       = .TRUE.
241       ok_bbgfertil_NOx   = .TRUE.
242       ok_cropsfertil_NOx = .TRUE.
243    ELSE
244       ok_leafage         = .FALSE. 
245       ok_radcanopy       = .FALSE. 
246       ok_multilayer      = .FALSE.
247       ok_pulse_NOx       = .FALSE.
248       ok_bbgfertil_NOx   = .FALSE.
249       ok_cropsfertil_NOx = .FALSE.
250    ENDIF
251    !
252    !Config Key   = CHEMISTRY_LEAFAGE
253    !Config Desc  = Activate LEAFAGE?
254    !Config If    = CHEMISTRY_BVOC
255    !Config Def   = n
256    !Config Help  = set to TRUE if biogenic emissions calculation takes leaf age into account
257    !Config Units = [FLAG]
258    !
259    CALL getin_p('CHEMISTRY_LEAFAGE', ok_leafage)
260    WRITE(numout,*) 'Leaf Age: ', ok_leafage
261    !
262    !Config Key   = CANOPY_EXTINCTION
263    !Config Desc  = Use canopy radiative transfer model?
264    !Config If    = CHEMISTRY_BVOC
265    !Config Def   = n
266    !Config Help  = set to TRUE if canopy radiative transfer model is used for biogenic emissions
267    !Config Units = [FLAG]
268    !
269    CALL getin_p('CANOPY_EXTINCTION', ok_radcanopy)
270    WRITE(numout,*) 'Canopy radiative transfer model: ', ok_radcanopy
271    !
272    !Config Key   = CANOPY_MULTILAYER
273    !Config Desc  = Use canopy radiative transfer model with multi-layers
274    !Config If    = CANOPY_EXTINCTION
275    !Config Def   = n
276    !Config Help  = set to TRUE if canopy radiative transfer model is with multiple layers
277    !Config Units = [FLAG]
278    !
279    CALL getin_p('CANOPY_MULTILAYER', ok_multilayer)
280    WRITE(numout,*) 'Multi-layer Canopy model: ', ok_multilayer
281    !
282    !Config Key   = NOx_RAIN_PULSE
283    !Config Desc  = Calculate NOx emissions with pulse?
284    !Config If    = CHEMISTRY_BVOC
285    !Config Def   = n
286    !Config Help  = set to TRUE if NOx rain pulse is taken into account
287    !Config Units = [FLAG]
288    !
289    CALL getin_p('NOx_RAIN_PULSE', ok_pulse_NOx)
290    WRITE(numout,*) 'Rain NOx pulsing: ', ok_pulse_NOx
291    !
292    !Config Key   = NOx_BBG_FERTIL
293    !Config Desc  = Calculate NOx emissions with bbg fertilizing effect?
294    !Config If    = CHEMISTRY_BVOC
295    !Config Def   = n
296    !Config Help  = set to TRUE if NOx emissions are calculated with bbg effect
297    !Config         Fertil effect of bbg on NOx soil emissions
298    !Config Units = [FLAG]
299    !
300    CALL getin_p('NOx_BBG_FERTIL', ok_bbgfertil_NOx)
301    WRITE(numout,*) 'NOx bbg fertil effect: ', ok_bbgfertil_NOx
302    !
303    !Config Key   = NOx_FERTILIZERS_USE
304    !Config Desc  = Calculate NOx emissions with fertilizers use?
305    !Config If    = CHEMISTRY_BVOC
306    !Config Def   = n
307    !Config Help  = set to TRUE if NOx emissions are calculated with fertilizers use
308    !Config         Fertilizers use effect on NOx soil emissions 
309    !Config Units = [FLAG]
310    !
311    CALL getin_p('NOx_FERTILIZERS_USE', ok_cropsfertil_NOx)
312    WRITE(numout,*) 'NOx Fertilizers use: ', ok_cropsfertil_NOx
313    !Config Key  = Is CO2 impact on BVOC accounted for using Possell 2005 ?
314    !Config Desc = In this case we use Possell 2005 parameterisation
315    !Config Desc = to take into account the impact of CO2 on biogenic emissions for
316    !Config Desc = isoprene
317    !Config Def  = n
318    !Config Help = set to TRUE if Possell parameterisation has to be considered for the CO2 impact
319    !
320    ok_co2bvoc_poss = .FALSE.
321    CALL getin_p('CO2_FOR_BVOC_POSSELL', ok_co2bvoc_poss)
322    WRITE(*,*) 'CO2 impact on BVOC - Possell parameterisation: ', ok_co2bvoc_poss
323    !
324    !Config Key  = Is CO2 impact on BVOC accounted for using Wilkinson 2009 ?
325    !Config Desc = In this case we use Wilkinson 2009 parameterisation
326    !Config Desc = to take into account the impact of CO2 on biogenic emissions for
327    !Config Desc = isoprene
328    !Config Def  = n
329    !Config Help = set to TRUE if Wilkinson parameterisation has to be considered for the CO2 impact
330    !
331    ok_co2bvoc_wilk = .FALSE.
332    CALL getin_p('CO2_FOR_BVOC_WILKINSON', ok_co2bvoc_wilk)
333    WRITE(*,*) 'CO2 impact on BVOC - Wilkinson parameterisation: ', ok_co2bvoc_wilk
334    !
335
336    !
337    ! control initialisation with sechiba
338    !
339    ok_sechiba = .TRUE.
340    !
341    !
342    ! Ensure consistency
343    !
344    IF ( ok_dgvm ) ok_stomate = .TRUE.
345    IF ( ok_multilayer .AND. .NOT.(ok_radcanopy) ) THEN
346       ok_radcanopy  = .TRUE.
347       WRITE(numout,*) 'You want to use the multilayer model without activating the flag CANOPY_EXTINCTION'
348       WRITE(numout,*) 'We set CANOPY_EXTINCTION to TRUE to ensure consistency'
349    ENDIF
350
351
352
353    !
354    ! Here we need the same initialisation as above
355    !
356    ok_pheno = .TRUE.
357
358    !
359    ! Configuration : number of PFTs and parameters
360    !
361
362    ! 1. Number of PFTs defined by the user
363
364    !Config Key   = NVM
365    !Config Desc  = number of PFTs 
366    !Config If    = OK_SECHIBA or OK_STOMATE
367    !Config Def   = 13
368    !Config Help  = The number of vegetation types define by the user
369    !Config Units = [-]
370    !
371    CALL getin_p('NVM',nvm)
372    WRITE(numout,*)'the number of pfts used by the model is : ', nvm
373
374    ! 2. Should we read the parameters in the run.def file ?
375
376    !Config Key   = IMPOSE_PARAM
377    !Config Desc  = Do you impose the values of the parameters?
378    !Config if    = OK_SECHIBA or OK_STOMATE
379    !Config Def   = y
380    !Config Help  = This flag can deactivate the reading of some parameters.
381    !               Useful if you want to use the standard values without commenting the run.def
382    !Config Units = [FLAG]
383    !
384    CALL getin_p('IMPOSE_PARAM',impose_param)
385
386
387    !! Initialize vertical discretization
388    IF (hydrol_cwrr) THEN
389       !! Case CWRR : All initialization is done in the vertical module
390       !! Calculate ngrnd and nslm
391       CALL vertical_soil_init
392    ELSE
393       !! Case Choisnel : get depth of soil and number of soil levels
394       ! Remove Config Key description because this was already done in vertical_soil_init.
395       !Config Def   = 2.0 or 4.0 depending on hydrol_cwrr flag
396       !Config Help  = Maximum depth of soil for soil moisture
397       !Config Units = m
398       zmaxh=4.0
399       CALL getin_p("DEPTH_MAX_H",zmaxh)
400
401       !Config Key   = THERMOSOIL_NBLEV
402       !Config Desc  = Number of soil level
403       !Config If    = HDYROL_CWRR=FALSE
404       !Config Def   = 7
405       !Config Help  = Use at least 11 for long term simulation where soil thermal inertia matters
406       !Config Units = (-)
407       ngrnd=7
408       CALL getin_p("THERMOSOIL_NBLEV",ngrnd)
409
410       ! Define nslm, number of levels in CWRR. This variable will not be used for Choisnel but needs to be initialized.
411       nslm=11
412    END IF
413
414    ! 3. Allocate and intialize the pft parameters
415
416    CALL pft_parameters_main()
417
418    ! 4. Activation sub-models of ORCHIDEE
419
420    CALL activate_sub_models()
421
422    ! 5. Vegetation configuration
423
424    CALL veget_config
425
426    ! 6. Read the parameters in the run.def file  according the flags
427
428    IF (impose_param ) THEN
429       CALL config_pft_parameters
430    ENDIF
431
432    IF ( ok_sechiba ) THEN
433       IF (impose_param ) THEN
434          IF (printlev>=2) WRITE(numout,*)'In control_initialize: call config_sechiba_parameters and config_sechiba_pft_parameters'
435          CALL config_sechiba_parameters
436          CALL config_sechiba_pft_parameters()
437       ENDIF
438    ENDIF
439
440
441    !! Initialize variables in constantes_soil
442    CALL config_soil_parameters()
443
444
445    !! Coherence check for depth of thermosoil for long term simulation where soil thermal inertia matters
446    !! ok_freeze_thermix is defined in config_soil_parameters
447    IF (hydrol_cwrr) THEN
448       ! Case CWRR
449       IF (ok_freeze_thermix .AND. zmaxt < 11) THEN
450          WRITE(numout,*) 'ERROR : Incoherence between ok_freeze_thermix activated and soil depth too small. '
451          WRITE(numout,*) 'Here a soil depth of ', zmaxt, 'm is used for the soil thermodynamics'
452          WRITE(numout,*) 'Set DEPTH_MAX_T=11 or higher in run.def parameter file or deactivate soil freezing'
453          CALL ipslerr_p(3,'control_initialize','Too shallow soil chosen for the thermodynamic for soil freezing', &
454               'Adapt run.def with at least DEPTH_MAX=11','')
455       END IF
456    ELSE
457       ! Case Choisnel
458       IF (ok_freeze_thermix .AND. ngrnd < 11) THEN
459          WRITE(numout,*) 'ERROR : Incoherence between ok_freeze_thermix activated and ngrnd to small. Here used ngrnd=',ngrnd
460          WRITE(numout,*) 'Set THERMOSOIL_NBLEV=11 or higher in run.def parameter file or deactivate soil freezing'
461          CALL ipslerr_p(3,'control_initialize','Not enough thermodynamic soil levels for soil freezing', &
462               'Adapt run.def with at least THERMOSOIL_NBLEV=11','')
463       END IF
464    END IF
465       
466    ! Define diaglev
467    ! We take the top nslm (number of layer in CWRR) layer of the thermodynamics
468    ! for the diagnostics. The layers in the hydrology and the thermodynamics are
469    ! placed a the same depth (the top nslm layers) but the upper boundary condition
470    ! is simpler in the thermodynamics.
471    nbdl = nslm
472    ALLOCATE(diaglev(nbdl), stat=ier)
473    IF (ier /= 0) CALL ipslerr_p(3,'control_initialize','Pb in allocation of diaglev','','')
474
475    IF ( hydrol_cwrr ) THEN
476       ! Get diaglev from module vertical for CWRR
477       diaglev=znt(1:nbdl)
478    ELSE
479       ! Calculate diaglev for Choisnel
480       DO jv = 1, nbdl-1
481           diaglev(jv) = zmaxh/(2**(nbdl-1) -1) * ( ( 2**(jv-1) -1) + ( 2**(jv)-1) ) / deux
482      ENDDO
483      diaglev(nbdl) = zmaxh
484    END IF
485    IF (printlev>=2) WRITE(numout,*) 'In control_initialize, diaglev = ',diaglev
486
487    IF ( ok_co2 ) THEN
488       IF ( impose_param ) THEN
489          IF (printlev>=2) WRITE(numout,*)'In control_initialize: call config_co2_parameters'
490          CALL config_co2_parameters
491       ENDIF
492    ENDIF
493   
494    IF ( ok_stomate ) THEN
495       IF ( impose_param ) THEN
496          IF (printlev>=2) WRITE(numout,*)'In control_initialize: call config_stomate_parameters and config_stomate_pft_parameters'
497          CALL config_stomate_parameters
498          CALL config_stomate_pft_parameters
499       ENDIF
500    ENDIF
501   
502    IF ( ok_dgvm ) THEN
503       IF ( impose_param ) THEN
504          IF (printlev>=2) WRITE(numout,*)'In control_initialize: call config_dgvm_parameters'
505          CALL config_dgvm_parameters
506       ENDIF
507    ENDIF   
508
509    ok_grdc = .FALSE.
510    !IF ( river_routing )
511    CALL getin_p('OK_GRDC', ok_grdc)
512    WRITE(numout, *) 'ok_grdc=', ok_grdc
513
514    ok_largest = .FALSE.
515    CALL getin_p('OK_LARGEST', ok_largest)
516    WRITE(numout, *) 'ok_largest=', ok_largest
517
518    ok_calendar = .FALSE.
519    CALL getin_p('OK_CALENDAR', ok_calendar)
520    WRITE(numout, *) 'ok_calendar=', ok_calendar
521
522
523  END SUBROUTINE control_initialize
524 
525END MODULE control
Note: See TracBrowser for help on using the repository browser.