Changeset 425


Ignore:
Timestamp:
2011-08-31T09:32:29+02:00 (13 years ago)
Author:
didier.solyga
Message:

Optimize allocation memory for pft parameters. Reorganize the algorithm for the externalization : the parameters can be read only if IMPOSE_PARAM is set to true. Rewrite a loop in slowproc.f90.

Location:
branches/ORCHIDEE_EXT/ORCHIDEE
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/ORCHIDEE_EXT/ORCHIDEE/src_parameters/pft_parameters.f90

    r360 r425  
    1818  ! PFT global 
    1919  !------------------------ 
    20   ! Number of vegetation types (see constantes_veg) 
    21   INTEGER(i_std) :: nvm = 13   
     20  ! Number of vegetation types 
     21  INTEGER(i_std), SAVE :: nvm = 13   
    2222  !- 
    2323  !Table of conversion : we associate one pft to one mtc 
     
    379379 
    380380 
    381  
    382381CONTAINS 
    383382 ! 
    384  SUBROUTINE pft_parameters_main  
    385    
     383 SUBROUTINE pft_parameters_main(ok_sechiba,ok_stomate)  
     384    
    386385   IMPLICIT NONE 
    387386 
    388    ! Local   
    389     INTEGER(i_std) :: i 
     387   ! 0.1 input 
     388    
     389   ! Is SECHIBA active ? 
     390   LOGICAL, INTENT(in) :: ok_sechiba 
     391   ! Is STOMATE active ? 
     392   LOGICAL, INTENT(in) :: ok_stomate 
     393    
     394   ! 0.4 local   
     395 
     396   ! Indice 
     397   INTEGER(i_std) :: i 
    390398 
    391399   !---------------------- 
     
    402410      ! 2. Memory allocation 
    403411      ! Allocation of memory for the pfts-parameters 
    404       CALL pft_parameters_alloc 
     412      CALL pft_parameters_alloc(ok_sechiba,ok_stomate) 
    405413 
    406414      ! 3. Correspondance table  
     
    408416      ! 3.1 Initialisation of the correspondance table 
    409417      ! Initialisation of the correspondance table 
    410       pft_to_mtc (:) = undef_int 
     418      pft_to_mtc(:) = undef_int 
    411419       
    412420      ! 3.2 Reading of the conrrespondance table in the .def file 
     
    459467    
    460468      ! 4.Initialisation of the pfts-parameters 
    461       CALL pft_parameters_init 
     469      CALL pft_parameters_init(ok_sechiba,ok_stomate) 
    462470 
    463471      ! 5. Useful data 
     
    483491      ! 6. Initialisation of 2D arrays used in the code 
    484492 
    485       !-alb_leaf 
    486       alb_leaf(:) = zero 
    487  
    488493      !- pref_soil_veg  
    489494      pref_soil_veg(:,:) = zero_int 
    490495 
    491       !- pheno_gdd_crit 
    492       pheno_gdd_crit(:,:) = zero  
    493       ! 
    494       !- senescence_temp 
    495       senescence_temp(:,:) = zero 
    496       ! 
    497       !- maint_resp_slope 
    498       maint_resp_slope(:,:) = zero 
    499       ! 
    500       !-coeff_maint_zero 
    501       coeff_maint_zero(:,:) = zero 
     496      IF (ok_sechiba) THEN 
     497         !-alb_leaf 
     498         alb_leaf(:) = zero 
     499      ENDIF 
     500 
     501      IF (ok_stomate) THEN 
     502         !- pheno_gdd_crit 
     503         pheno_gdd_crit(:,:) = zero  
     504         ! 
     505         !- senescence_temp 
     506         senescence_temp(:,:) = zero 
     507         ! 
     508         !- maint_resp_slope 
     509         maint_resp_slope(:,:) = zero 
     510         ! 
     511         !-coeff_maint_zero 
     512         coeff_maint_zero(:,:) = zero 
     513      ENDIF 
    502514 
    503515      ! 7. End message 
     
    518530 != 
    519531 ! 
    520  SUBROUTINE pft_parameters_init 
     532 SUBROUTINE pft_parameters_init(ok_sechiba,ok_stomate) 
    521533   
    522534   IMPLICIT NONE 
    523535    
    524    !------------ 
    525    ! local 
     536   ! 0.1 input 
     537    
     538   ! Is SECHIBA active ? 
     539   LOGICAL, INTENT(in) :: ok_sechiba 
     540   ! Is STOMATE active ? 
     541   LOGICAL, INTENT(in) :: ok_stomate 
     542 
     543   ! 0.4 local 
     544 
    526545   INTEGER(i_std) :: j,k 
    527    !------------ 
     546 
     547   !--------------------------------------------------------------- 
    528548 
    529549   ! 
     
    531551   ! 
    532552  
     553 
     554   ! 1.1 For parameters used anytime 
     555    
    533556   DO j= 1, nvm 
    534  
     557      !- 
    535558      PFT_name(j) = MTC_name(pft_to_mtc(j)) 
    536  
    537559      !- 
    538560      ! Vegetation structure  
     
    547569      type_of_lai(j) = type_of_lai_mtc(pft_to_mtc(j)) 
    548570      is_tree(j) = is_tree_mtc(pft_to_mtc(j)) 
    549       rveg_pft(j) = rveg_mtc(pft_to_mtc(j)) 
    550  
     571      natural(j) = natural_mtc(pft_to_mtc(j)) 
     572      ! 
     573      ! 2 .Stomate 
     574      ! 
    551575      !>> DS new for merge in the trunk   ! 15/06/2011  
    552576      ! Add for writing history files in stomate_lpj.f90 'treeFracPrimDec' and 'treeFracPrimEver' 
     
    554578      is_evergreen(j) = is_evergreen_mtc(pft_to_mtc(j)) 
    555579      is_c3(j) = is_c3(pft_to_mtc(j)) 
    556  
    557       ! 
    558       ! 2 .Stomate 
    559       ! 
    560       leaf_tab(j) = leaf_tab_mtc(pft_to_mtc(j)) 
    561       sla(j) = sla_mtc(pft_to_mtc(j)) 
    562       natural(j) = natural_mtc(pft_to_mtc(j)) 
    563  
    564       !- 
    565       ! Evapotranspiration -  sechiba 
    566       !- 
    567       rstruct_const(j) = rstruct_const_mtc(pft_to_mtc(j)) 
    568       kzero(j) = kzero_mtc(pft_to_mtc(j)) 
    569580      !- 
    570581      ! Water - sechiba 
    571582      !- 
    572       wmax_veg(j) = wmax_veg_mtc(pft_to_mtc(j)) 
    573583      humcste(j) = humcste_mtc(pft_to_mtc(j)) 
    574       throughfall_by_pft(j) = throughfall_by_mtc(pft_to_mtc(j)) 
    575       !- 
    576       ! Albedo - sechiba 
    577       !- 
    578       snowa_ini(j) = snowa_ini_mtc(pft_to_mtc(j)) 
    579       snowa_dec(j) = snowa_dec_mtc(pft_to_mtc(j))  
    580       alb_leaf_vis(j) = alb_leaf_vis_mtc(pft_to_mtc(j))   
    581       alb_leaf_nir(j) = alb_leaf_nir_mtc(pft_to_mtc(j)) 
    582584      !- 
    583585      !   Soil - vegetation 
     
    586588      pref_soil_veg_loan(j) = pref_soil_veg_loan_mtc(pft_to_mtc(j)) 
    587589      pref_soil_veg_clay(j) = pref_soil_veg_clay_mtc(pft_to_mtc(j)) 
    588  
    589590      !- 
    590591      ! Photosynthesis 
    591592      !- 
    592       ! 
    593       ! 1 .CO2 
    594       ! 
    595593      is_c4(j) = is_c4_mtc(pft_to_mtc(j)) 
    596594      gsslope(j) = gsslope_mtc(pft_to_mtc(j)) 
     
    601599      co2_topt_fix(j) = co2_topt_fix_mtc(pft_to_mtc(j)) 
    602600      co2_tmax_fix(j) = co2_tmax_fix_mtc(pft_to_mtc(j)) 
    603       ! 
    604       ! 2 .Stomate 
    605       ! 
    606601      ext_coeff(j) = ext_coeff_mtc(pft_to_mtc(j)) 
    607       vcmax_opt(j) = vcmax_opt_mtc(pft_to_mtc(j)) 
    608       vjmax_opt(j) = vjmax_opt_mtc(pft_to_mtc(j))  
    609       tphoto_min_a(j) = tphoto_min_a_mtc(pft_to_mtc(j))  
    610       tphoto_min_b(j) = tphoto_min_b_mtc(pft_to_mtc(j)) 
    611       tphoto_min_c(j) = tphoto_min_c_mtc(pft_to_mtc(j)) 
    612       tphoto_opt_a(j) = tphoto_opt_a_mtc(pft_to_mtc(j)) 
    613       tphoto_opt_b(j) = tphoto_opt_b_mtc(pft_to_mtc(j)) 
    614       tphoto_opt_c(j) = tphoto_opt_c_mtc(pft_to_mtc(j)) 
    615       tphoto_max_a(j) = tphoto_max_a_mtc(pft_to_mtc(j)) 
    616       tphoto_max_b(j) = tphoto_max_b_mtc(pft_to_mtc(j)) 
    617       tphoto_max_c(j) = tphoto_max_c_mtc(pft_to_mtc(j)) 
    618       !- 
    619       ! Respiration - stomate 
    620       !- 
    621       maint_resp_slope_c(j) = maint_resp_slope_c_mtc(pft_to_mtc(j))                
    622       maint_resp_slope_b(j) = maint_resp_slope_b_mtc(pft_to_mtc(j)) 
    623       maint_resp_slope_a(j) = maint_resp_slope_a_mtc(pft_to_mtc(j)) 
    624       cm_zero_leaf(j)= cm_zero_leaf_mtc(pft_to_mtc(j)) 
    625       cm_zero_sapabove(j) = cm_zero_sapabove_mtc(pft_to_mtc(j)) 
    626       cm_zero_sapbelow(j) = cm_zero_sapbelow_mtc(pft_to_mtc(j))  
    627       cm_zero_heartabove(j) = cm_zero_heartabove_mtc(pft_to_mtc(j))  
    628       cm_zero_heartbelow(j) = cm_zero_heartbelow_mtc(pft_to_mtc(j)) 
    629       cm_zero_root(j) = cm_zero_root_mtc(pft_to_mtc(j)) 
    630       cm_zero_fruit(j) = cm_zero_fruit_mtc(pft_to_mtc(j)) 
    631       cm_zero_carbres(j) = cm_zero_carbres_mtc(pft_to_mtc(j)) 
    632       !- 
    633       ! Fire - stomate 
    634       !- 
    635       flam(j) = flam_mtc(pft_to_mtc(j)) 
    636       resist(j) = resist_mtc(pft_to_mtc(j)) 
    637       !- 
    638       ! Flux - LUC 
    639       !- 
    640       coeff_lcchange_1(j) = coeff_lcchange_1_mtc(pft_to_mtc(j)) 
    641       coeff_lcchange_10(j) = coeff_lcchange_10_mtc(pft_to_mtc(j)) 
    642       coeff_lcchange_100(j) = coeff_lcchange_100_mtc(pft_to_mtc(j)) 
    643       !- 
    644       ! Phenology 
    645       !- 
    646       ! 
    647       ! 1 .Stomate 
    648       ! 
    649       lai_max(j) = lai_max_mtc(pft_to_mtc(j)) 
    650       pheno_model(j) = pheno_model_mtc(pft_to_mtc(j)) 
    651       pheno_type(j) = pheno_type_mtc(pft_to_mtc(j)) 
    652       ! 
    653       ! 2. Leaf Onset 
    654       ! 
    655       pheno_gdd_crit_c(j) = pheno_gdd_crit_c_mtc(pft_to_mtc(j)) 
    656       pheno_gdd_crit_b(j) = pheno_gdd_crit_b_mtc(pft_to_mtc(j))          
    657       pheno_gdd_crit_a(j) = pheno_gdd_crit_a_mtc(pft_to_mtc(j)) 
    658       ngd_crit(j) =  ngd_crit_mtc(pft_to_mtc(j)) 
    659       ncdgdd_temp(j) = ncdgdd_temp_mtc(pft_to_mtc(j))  
    660       hum_frac(j) = hum_frac_mtc(pft_to_mtc(j)) 
    661       lowgpp_time(j) = lowgpp_time_mtc(pft_to_mtc(j)) 
    662       hum_min_time(j) = hum_min_time_mtc(pft_to_mtc(j)) 
    663       tau_sap(j) = tau_sap_mtc(pft_to_mtc(j)) 
    664       tau_fruit(j) = tau_fruit_mtc(pft_to_mtc(j)) 
    665       ecureuil(j) = ecureuil_mtc(pft_to_mtc(j)) 
    666       alloc_min(j) = alloc_min_mtc(pft_to_mtc(j)) 
    667       alloc_max(j) = alloc_max_mtc(pft_to_mtc(j)) 
    668       demi_alloc(j) = demi_alloc_mtc(pft_to_mtc(j)) 
    669   !>> DS new for merge in the trunk   ! 15/06/2011  
    670       leaflife_tab(j) = leaflife_mtc(pft_to_mtc(j)) 
    671       ! 
    672       ! 3. Senescence 
    673       ! 
    674       leaffall(j) = leaffall_mtc(pft_to_mtc(j)) 
    675       leafagecrit(j) = leafagecrit_mtc(pft_to_mtc(j)) 
    676       senescence_type(j) = senescence_type_mtc(pft_to_mtc(j))  
    677       senescence_hum(j) = senescence_hum_mtc(pft_to_mtc(j))  
    678       nosenescence_hum(j) = nosenescence_hum_mtc(pft_to_mtc(j))  
    679       max_turnover_time(j) = max_turnover_time_mtc(pft_to_mtc(j)) 
    680       min_turnover_time(j) = min_turnover_time_mtc(pft_to_mtc(j)) 
    681       min_leaf_age_for_senescence(j) = min_leaf_age_for_senescence_mtc(pft_to_mtc(j)) 
    682       senescence_temp_c(j) = senescence_temp_c_mtc(pft_to_mtc(j)) 
    683       senescence_temp_b(j) = senescence_temp_b_mtc(pft_to_mtc(j)) 
    684       senescence_temp_a(j) = senescence_temp_a_mtc(pft_to_mtc(j)) 
    685       !- 
    686       ! DGVM 
    687       residence_time(j) = residence_time_mtc(pft_to_mtc(j)) 
    688       tmin_crit(j) = tmin_crit_mtc(pft_to_mtc(j)) 
    689       tcm_crit(j) = tcm_crit_mtc(pft_to_mtc(j)) 
    690        
    691    ENDDO ! end loop over nvm  
     602      !- 
     603   ENDDO 
     604 
     605   ! 1.2 For sechiba parameters 
     606 
     607   IF (ok_sechiba) THEN 
     608      !- 
     609      DO j =1 ,nvm 
     610         !- 
     611         ! Vegetation structure - sechiba 
     612         !- 
     613         rveg_pft(j) = rveg_mtc(pft_to_mtc(j)) 
     614         !- 
     615         ! Evapotranspiration -  sechiba 
     616         !- 
     617         rstruct_const(j) = rstruct_const_mtc(pft_to_mtc(j)) 
     618         kzero(j) = kzero_mtc(pft_to_mtc(j)) 
     619         !- 
     620         ! Water - sechiba 
     621         !- 
     622         wmax_veg(j) = wmax_veg_mtc(pft_to_mtc(j)) 
     623         throughfall_by_pft(j) = throughfall_by_mtc(pft_to_mtc(j)) 
     624         !- 
     625         ! Albedo - sechiba 
     626         !- 
     627         snowa_ini(j) = snowa_ini_mtc(pft_to_mtc(j)) 
     628         snowa_dec(j) = snowa_dec_mtc(pft_to_mtc(j))  
     629         alb_leaf_vis(j) = alb_leaf_vis_mtc(pft_to_mtc(j))   
     630         alb_leaf_nir(j) = alb_leaf_nir_mtc(pft_to_mtc(j)) 
     631      ENDDO 
     632      !- 
     633   ENDIF 
     634 
     635   ! 1.3 For stomate parameters 
     636 
     637   IF (ok_stomate) THEN 
     638      !- 
     639      DO j = 1,nvm 
     640         !- 
     641         ! Vegetation structure - stomate 
     642         !-  
     643         leaf_tab(j) = leaf_tab_mtc(pft_to_mtc(j)) 
     644         sla(j) = sla_mtc(pft_to_mtc(j)) 
     645         !- 
     646         ! Photosynthesis 
     647         !- 
     648         vcmax_opt(j) = vcmax_opt_mtc(pft_to_mtc(j)) 
     649         vjmax_opt(j) = vjmax_opt_mtc(pft_to_mtc(j))  
     650         tphoto_min_a(j) = tphoto_min_a_mtc(pft_to_mtc(j))  
     651         tphoto_min_b(j) = tphoto_min_b_mtc(pft_to_mtc(j)) 
     652         tphoto_min_c(j) = tphoto_min_c_mtc(pft_to_mtc(j)) 
     653         tphoto_opt_a(j) = tphoto_opt_a_mtc(pft_to_mtc(j)) 
     654         tphoto_opt_b(j) = tphoto_opt_b_mtc(pft_to_mtc(j)) 
     655         tphoto_opt_c(j) = tphoto_opt_c_mtc(pft_to_mtc(j)) 
     656         tphoto_max_a(j) = tphoto_max_a_mtc(pft_to_mtc(j)) 
     657         tphoto_max_b(j) = tphoto_max_b_mtc(pft_to_mtc(j)) 
     658         tphoto_max_c(j) = tphoto_max_c_mtc(pft_to_mtc(j)) 
     659         !- 
     660         ! Respiration - stomate 
     661         !- 
     662         maint_resp_slope_c(j) = maint_resp_slope_c_mtc(pft_to_mtc(j))                
     663         maint_resp_slope_b(j) = maint_resp_slope_b_mtc(pft_to_mtc(j)) 
     664         maint_resp_slope_a(j) = maint_resp_slope_a_mtc(pft_to_mtc(j)) 
     665         cm_zero_leaf(j)= cm_zero_leaf_mtc(pft_to_mtc(j)) 
     666         cm_zero_sapabove(j) = cm_zero_sapabove_mtc(pft_to_mtc(j)) 
     667         cm_zero_sapbelow(j) = cm_zero_sapbelow_mtc(pft_to_mtc(j))  
     668         cm_zero_heartabove(j) = cm_zero_heartabove_mtc(pft_to_mtc(j))  
     669         cm_zero_heartbelow(j) = cm_zero_heartbelow_mtc(pft_to_mtc(j)) 
     670         cm_zero_root(j) = cm_zero_root_mtc(pft_to_mtc(j)) 
     671         cm_zero_fruit(j) = cm_zero_fruit_mtc(pft_to_mtc(j)) 
     672         cm_zero_carbres(j) = cm_zero_carbres_mtc(pft_to_mtc(j)) 
     673         !- 
     674         ! Fire - stomate 
     675         !- 
     676         flam(j) = flam_mtc(pft_to_mtc(j)) 
     677         resist(j) = resist_mtc(pft_to_mtc(j)) 
     678         !- 
     679         ! Flux - LUC 
     680         !- 
     681         coeff_lcchange_1(j) = coeff_lcchange_1_mtc(pft_to_mtc(j)) 
     682         coeff_lcchange_10(j) = coeff_lcchange_10_mtc(pft_to_mtc(j)) 
     683         coeff_lcchange_100(j) = coeff_lcchange_100_mtc(pft_to_mtc(j)) 
     684         !- 
     685         ! Phenology 
     686         !- 
     687         ! 
     688         ! 1 .Stomate 
     689         ! 
     690         lai_max(j) = lai_max_mtc(pft_to_mtc(j)) 
     691         pheno_model(j) = pheno_model_mtc(pft_to_mtc(j)) 
     692         pheno_type(j) = pheno_type_mtc(pft_to_mtc(j)) 
     693         ! 
     694         ! 2. Leaf Onset 
     695         ! 
     696         pheno_gdd_crit_c(j) = pheno_gdd_crit_c_mtc(pft_to_mtc(j)) 
     697         pheno_gdd_crit_b(j) = pheno_gdd_crit_b_mtc(pft_to_mtc(j))          
     698         pheno_gdd_crit_a(j) = pheno_gdd_crit_a_mtc(pft_to_mtc(j)) 
     699         ngd_crit(j) =  ngd_crit_mtc(pft_to_mtc(j)) 
     700         ncdgdd_temp(j) = ncdgdd_temp_mtc(pft_to_mtc(j))  
     701         hum_frac(j) = hum_frac_mtc(pft_to_mtc(j)) 
     702         lowgpp_time(j) = lowgpp_time_mtc(pft_to_mtc(j)) 
     703         hum_min_time(j) = hum_min_time_mtc(pft_to_mtc(j)) 
     704         tau_sap(j) = tau_sap_mtc(pft_to_mtc(j)) 
     705         tau_fruit(j) = tau_fruit_mtc(pft_to_mtc(j)) 
     706         ecureuil(j) = ecureuil_mtc(pft_to_mtc(j)) 
     707         alloc_min(j) = alloc_min_mtc(pft_to_mtc(j)) 
     708         alloc_max(j) = alloc_max_mtc(pft_to_mtc(j)) 
     709         demi_alloc(j) = demi_alloc_mtc(pft_to_mtc(j)) 
     710         !>> DS new for merge in the trunk   ! 15/06/2011  
     711         leaflife_tab(j) = leaflife_mtc(pft_to_mtc(j)) 
     712         ! 
     713         ! 3. Senescence 
     714         ! 
     715         leaffall(j) = leaffall_mtc(pft_to_mtc(j)) 
     716         leafagecrit(j) = leafagecrit_mtc(pft_to_mtc(j)) 
     717         senescence_type(j) = senescence_type_mtc(pft_to_mtc(j))  
     718         senescence_hum(j) = senescence_hum_mtc(pft_to_mtc(j))  
     719         nosenescence_hum(j) = nosenescence_hum_mtc(pft_to_mtc(j))  
     720         max_turnover_time(j) = max_turnover_time_mtc(pft_to_mtc(j)) 
     721         min_turnover_time(j) = min_turnover_time_mtc(pft_to_mtc(j)) 
     722         min_leaf_age_for_senescence(j) = min_leaf_age_for_senescence_mtc(pft_to_mtc(j)) 
     723         senescence_temp_c(j) = senescence_temp_c_mtc(pft_to_mtc(j)) 
     724         senescence_temp_b(j) = senescence_temp_b_mtc(pft_to_mtc(j)) 
     725         senescence_temp_a(j) = senescence_temp_a_mtc(pft_to_mtc(j)) 
     726         !- 
     727         ! DGVM 
     728         residence_time(j) = residence_time_mtc(pft_to_mtc(j)) 
     729         tmin_crit(j) = tmin_crit_mtc(pft_to_mtc(j)) 
     730         tcm_crit(j) = tcm_crit_mtc(pft_to_mtc(j)) 
     731      ENDDO 
     732      !- 
     733   ENDIF 
    692734 
    693735 END SUBROUTINE pft_parameters_init 
     
    695737 != 
    696738 ! 
    697  SUBROUTINE pft_parameters_alloc 
     739 SUBROUTINE pft_parameters_alloc(ok_sechiba,ok_stomate) 
    698740 
    699741   IMPLICIT NONE 
    700    !------------------ 
    701    ! local 
    702     LOGICAL ::  l_error 
    703     INTEGER :: ier 
    704    !----------------- 
    705  
     742 
     743   ! 0.1 input 
     744    
     745   ! Is SECHIBA active ? 
     746   LOGICAL, INTENT(in) :: ok_sechiba 
     747   ! Is STOMATE active ? 
     748   LOGICAL, INTENT(in) :: ok_stomate 
     749 
     750   ! 0.4 local 
     751   LOGICAL ::  l_error 
     752   INTEGER :: ier 
     753 
     754   !--------------------------------------------- 
     755 
     756   ! 
     757   ! 1. Parameters used anytime 
     758   ! 
    706759   l_error = .FALSE. 
     760   !- 
    707761   ALLOCATE(pft_to_mtc(nvm),stat=ier) 
    708762   l_error = l_error .OR. (ier .NE. 0) 
    709763   ALLOCATE(PFT_name(nvm),stat=ier) 
    710764   l_error = l_error .OR. (ier .NE. 0) 
     765   ALLOCATE(height_presc(nvm),stat=ier) 
     766   l_error = l_error .OR. (ier .NE. 0) 
     767   ALLOCATE(is_tree(nvm),stat=ier) 
     768   l_error = l_error .OR. (ier .NE. 0)   
     769   ALLOCATE(natural(nvm),stat=ier) 
     770   l_error = l_error .OR. (ier .NE. 0) 
     771   ALLOCATE(is_c4(nvm),stat=ier) 
     772   l_error = l_error .OR. (ier .NE. 0) 
     773   ALLOCATE(gsslope(nvm),stat=ier) 
     774   l_error = l_error .OR. (ier .NE. 0) 
     775   ALLOCATE(gsoffset(nvm),stat=ier) 
     776   l_error = l_error .OR. (ier .NE. 0) 
     777   ALLOCATE(humcste(nvm),stat=ier) 
     778   l_error = l_error .OR. (ier .NE. 0) 
     779   ALLOCATE(ext_coeff(nvm),stat=ier) 
     780   l_error = l_error .OR. (ier .NE. 0) 
     781   !- 
     782   ALLOCATE(veget_ori_fixed_test_1(nvm),stat=ier) 
     783   l_error = l_error .OR. (ier .NE. 0) 
     784   ALLOCATE(llaimax(nvm),stat=ier) 
     785   l_error = l_error .OR. (ier .NE. 0) 
     786   ALLOCATE(llaimin(nvm),stat=ier) 
     787   l_error = l_error .OR. (ier .NE. 0) 
     788   ALLOCATE(type_of_lai(nvm),stat=ier) 
     789   l_error = l_error .OR. (ier .NE. 0) 
     790   ALLOCATE(vcmax_fix(nvm),stat=ier) 
     791   l_error = l_error .OR. (ier .NE. 0) 
     792   ALLOCATE(vjmax_fix(nvm),stat=ier) 
     793   l_error = l_error .OR. (ier .NE. 0) 
     794   ALLOCATE(co2_tmin_fix(nvm),stat=ier) 
     795   l_error = l_error .OR. (ier .NE. 0) 
     796   ALLOCATE(co2_topt_fix(nvm),stat=ier) 
     797   l_error = l_error .OR. (ier .NE. 0) 
     798   ALLOCATE(co2_tmax_fix(nvm),stat=ier) 
     799   l_error = l_error .OR. (ier .NE. 0) 
     800   !- 
     801   ALLOCATE(pref_soil_veg_sand(nvm),stat=ier) 
     802   l_error = l_error .OR. (ier .NE. 0) 
     803   ALLOCATE(pref_soil_veg_loan(nvm),stat=ier) 
     804   l_error = l_error .OR. (ier .NE. 0) 
     805   ALLOCATE(pref_soil_veg_clay(nvm),stat=ier) 
     806   l_error = l_error .OR. (ier .NE. 0) 
     807   ALLOCATE(pref_soil_veg(nvm,nstm),stat=ier) 
     808   l_error = l_error .OR. (ier .NE. 0) 
     809 
    711810   !- 
    712811   !>> DS new for merge in the trunk   ! 15/06/2011  
     
    718817   ALLOCATE(is_c3(nvm),stat=ier)   
    719818   l_error = l_error .OR. (ier .NE. 0) 
    720    ALLOCATE(leaflife_tab(nvm),stat=ier)    
    721    l_error = l_error .OR. (ier .NE. 0) 
    722819   ! >> END 
    723  
    724    ALLOCATE(veget_ori_fixed_test_1(nvm),stat=ier) 
    725    l_error = l_error .OR. (ier .NE. 0) 
    726    ALLOCATE(llaimax(nvm),stat=ier) 
    727    l_error = l_error .OR. (ier .NE. 0) 
    728    ALLOCATE(llaimin(nvm),stat=ier) 
    729    l_error = l_error .OR. (ier .NE. 0) 
    730    ALLOCATE(height_presc(nvm),stat=ier) 
    731    l_error = l_error .OR. (ier .NE. 0) 
    732    ALLOCATE(type_of_lai(nvm),stat=ier) 
    733    l_error = l_error .OR. (ier .NE. 0)    
    734    ALLOCATE(is_tree(nvm),stat=ier) 
    735    l_error = l_error .OR. (ier .NE. 0)    
    736    !- 
    737    ALLOCATE(leaf_tab(nvm),stat=ier) 
    738    l_error = l_error .OR. (ier .NE. 0) 
    739    ALLOCATE(sla(nvm),stat=ier) 
    740    l_error = l_error .OR. (ier .NE. 0)    
    741    ALLOCATE(natural(nvm),stat=ier) 
    742    l_error = l_error .OR. (ier .NE. 0) 
    743    !- 
    744    ALLOCATE(is_c4(nvm),stat=ier) 
    745    l_error = l_error .OR. (ier .NE. 0) 
    746    ALLOCATE(gsslope(nvm),stat=ier) 
    747    l_error = l_error .OR. (ier .NE. 0) 
    748    ALLOCATE(gsoffset(nvm),stat=ier) 
    749    l_error = l_error .OR. (ier .NE. 0) 
    750    ALLOCATE(vcmax_fix(nvm),stat=ier) 
    751    l_error = l_error .OR. (ier .NE. 0) 
    752    ALLOCATE(vjmax_fix(nvm),stat=ier) 
    753    l_error = l_error .OR. (ier .NE. 0) 
    754    ALLOCATE(co2_tmin_fix(nvm),stat=ier) 
    755    l_error = l_error .OR. (ier .NE. 0) 
    756    ALLOCATE(co2_topt_fix(nvm),stat=ier) 
    757    l_error = l_error .OR. (ier .NE. 0) 
    758    ALLOCATE(co2_tmax_fix(nvm),stat=ier) 
    759    l_error = l_error .OR. (ier .NE. 0) 
    760    !- 
    761    ALLOCATE(ext_coeff(nvm),stat=ier) 
    762    l_error = l_error .OR. (ier .NE. 0)  
    763    ALLOCATE(vcmax_opt(nvm),stat=ier) 
    764    l_error = l_error .OR. (ier .NE. 0)  
    765    ALLOCATE(vjmax_opt(nvm),stat=ier) 
    766    l_error = l_error .OR. (ier .NE. 0) 
    767    ALLOCATE(tphoto_min_a(nvm),stat=ier) 
    768    l_error = l_error .OR. (ier .NE. 0)  
    769    ALLOCATE(tphoto_min_b(nvm),stat=ier) 
    770    l_error = l_error .OR. (ier .NE. 0)  
    771    ALLOCATE(tphoto_min_c(nvm),stat=ier) 
    772    l_error = l_error .OR. (ier .NE. 0)  
    773    ALLOCATE(tphoto_opt_a(nvm),stat=ier) 
    774    l_error = l_error .OR. (ier .NE. 0)  
    775    ALLOCATE(tphoto_opt_b(nvm),stat=ier) 
    776    l_error = l_error .OR. (ier .NE. 0)  
    777    ALLOCATE(tphoto_opt_c(nvm),stat=ier) 
    778    l_error = l_error .OR. (ier .NE. 0)  
    779    ALLOCATE(tphoto_max_a(nvm),stat=ier) 
    780    l_error = l_error .OR. (ier .NE. 0)  
    781    ALLOCATE(tphoto_max_b(nvm),stat=ier) 
    782    l_error = l_error .OR. (ier .NE. 0)  
    783    ALLOCATE(tphoto_max_c(nvm),stat=ier) 
    784    l_error = l_error .OR. (ier .NE. 0)  
    785    !- 
    786    ALLOCATE(pheno_gdd_crit_c(nvm),stat=ier) 
    787    l_error = l_error .OR. (ier .NE. 0) 
    788    ALLOCATE(pheno_gdd_crit_b(nvm),stat=ier) 
    789    l_error = l_error .OR. (ier .NE. 0) 
    790    ALLOCATE(pheno_gdd_crit_a(nvm),stat=ier) 
    791    l_error = l_error .OR. (ier .NE. 0) 
    792    ALLOCATE(pheno_gdd_crit(nvm,3),stat=ier) 
    793    l_error = l_error .OR. (ier .NE. 0) 
    794    ALLOCATE(ngd_crit(nvm),stat=ier) 
    795    l_error = l_error .OR. (ier .NE. 0) 
    796    ALLOCATE(ncdgdd_temp(nvm),stat=ier) 
    797    l_error = l_error .OR. (ier .NE. 0) 
    798    ALLOCATE(hum_frac(nvm),stat=ier) 
    799    l_error = l_error .OR. (ier .NE. 0) 
    800    ALLOCATE(lowgpp_time(nvm),stat=ier) 
    801    l_error = l_error .OR. (ier .NE. 0) 
    802    ALLOCATE(hum_min_time(nvm),stat=ier) 
    803    l_error = l_error .OR. (ier .NE. 0) 
    804    ALLOCATE(tau_sap(nvm),stat=ier) 
    805    l_error = l_error .OR. (ier .NE. 0) 
    806    ALLOCATE(tau_fruit(nvm),stat=ier) 
    807    l_error = l_error .OR. (ier .NE. 0) 
    808    ALLOCATE(ecureuil(nvm),stat=ier) 
    809    l_error = l_error .OR. (ier .NE. 0) 
    810    ALLOCATE(alloc_min(nvm),stat=ier) 
    811    l_error = l_error .OR. (ier .NE. 0) 
    812    ALLOCATE(alloc_max(nvm),stat=ier) 
    813    l_error = l_error .OR. (ier .NE. 0) 
    814    ALLOCATE(demi_alloc(nvm),stat=ier) 
    815    l_error = l_error .OR. (ier .NE. 0) 
    816    !- 
    817    ALLOCATE(maint_resp_slope(nvm,3),stat=ier) 
    818    l_error = l_error .OR. (ier .NE. 0) 
    819    ALLOCATE(maint_resp_slope_c(nvm),stat=ier) 
    820    l_error = l_error .OR. (ier .NE. 0) 
    821    ALLOCATE(maint_resp_slope_b(nvm),stat=ier) 
    822    l_error = l_error .OR. (ier .NE. 0) 
    823    ALLOCATE(maint_resp_slope_a(nvm),stat=ier) 
    824    l_error = l_error .OR. (ier .NE. 0) 
    825    ALLOCATE(coeff_maint_zero(nvm,nparts),stat=ier) 
    826    l_error = l_error .OR. (ier .NE. 0) 
    827    ALLOCATE(cm_zero_leaf(nvm),stat=ier) 
    828    l_error = l_error .OR. (ier .NE. 0) 
    829    ALLOCATE(cm_zero_sapabove(nvm),stat=ier) 
    830    l_error = l_error .OR. (ier .NE. 0) 
    831    ALLOCATE(cm_zero_sapbelow(nvm),stat=ier) 
    832    l_error = l_error .OR. (ier .NE. 0) 
    833    ALLOCATE(cm_zero_heartabove(nvm),stat=ier) 
    834    l_error = l_error .OR. (ier .NE. 0) 
    835    ALLOCATE(cm_zero_heartbelow(nvm),stat=ier) 
    836    l_error = l_error .OR. (ier .NE. 0) 
    837    ALLOCATE(cm_zero_root(nvm),stat=ier) 
    838    l_error = l_error .OR. (ier .NE. 0) 
    839    ALLOCATE(cm_zero_fruit(nvm),stat=ier) 
    840    l_error = l_error .OR. (ier .NE. 0) 
    841    ALLOCATE(cm_zero_carbres(nvm),stat=ier) 
    842    l_error = l_error .OR. (ier .NE. 0) 
    843    !- 
    844    ALLOCATE(flam(nvm),stat=ier) 
    845    l_error = l_error .OR. (ier .NE. 0)  
    846    ALLOCATE(resist(nvm),stat=ier) 
    847    l_error = l_error .OR. (ier .NE. 0)  
    848    !- 
    849    ALLOCATE(coeff_lcchange_1(nvm),stat=ier) 
    850    l_error = l_error .OR. (ier .NE. 0) 
    851    ALLOCATE(coeff_lcchange_10(nvm),stat=ier) 
    852    l_error = l_error .OR. (ier .NE. 0) 
    853    ALLOCATE(coeff_lcchange_100(nvm),stat=ier) 
    854    l_error = l_error .OR. (ier .NE. 0) 
    855    !- 
    856    ALLOCATE(lai_max(nvm),stat=ier) 
    857    l_error = l_error .OR. (ier .NE. 0) 
    858    ALLOCATE(pheno_model(nvm),stat=ier) 
    859    l_error = l_error .OR. (ier .NE. 0)  
    860    ALLOCATE(pheno_type(nvm),stat=ier) 
    861    l_error = l_error .OR. (ier .NE. 0)  
    862    !- 
    863    ALLOCATE(leaffall(nvm),stat=ier) 
    864    l_error = l_error .OR. (ier .NE. 0) 
    865    ALLOCATE(leafagecrit(nvm),stat=ier) 
    866    l_error = l_error .OR. (ier .NE. 0) 
    867    ALLOCATE(senescence_type(nvm),stat=ier) 
    868    l_error = l_error .OR. (ier .NE. 0) 
    869    ALLOCATE(senescence_hum(nvm),stat=ier) 
    870    l_error = l_error .OR. (ier .NE. 0) 
    871    ALLOCATE(nosenescence_hum(nvm),stat=ier) 
    872    l_error = l_error .OR. (ier .NE. 0) 
    873    ALLOCATE(max_turnover_time(nvm),stat=ier) 
    874    l_error = l_error .OR. (ier .NE. 0) 
    875    ALLOCATE(min_turnover_time(nvm),stat=ier) 
    876    l_error = l_error .OR. (ier .NE. 0) 
    877    ALLOCATE(min_leaf_age_for_senescence(nvm),stat=ier) 
    878    l_error = l_error .OR. (ier .NE. 0) 
    879    ALLOCATE(senescence_temp_c(nvm),stat=ier) 
    880    l_error = l_error .OR. (ier .NE. 0) 
    881    ALLOCATE(senescence_temp_b(nvm),stat=ier) 
    882    l_error = l_error .OR. (ier .NE. 0) 
    883    ALLOCATE(senescence_temp_a(nvm),stat=ier) 
    884    l_error = l_error .OR. (ier .NE. 0) 
    885    ALLOCATE(senescence_temp(nvm,3),stat=ier) 
    886    l_error = l_error .OR. (ier .NE. 0) 
    887    !- 
    888    ALLOCATE(residence_time(nvm),stat=ier) 
    889    l_error = l_error .OR. (ier .NE. 0) 
    890    ALLOCATE(tmin_crit(nvm),stat=ier) 
    891    l_error = l_error .OR. (ier .NE. 0) 
    892    ALLOCATE(tcm_crit(nvm),stat=ier) 
    893    l_error = l_error .OR. (ier .NE. 0) 
    894    !- 
    895    ALLOCATE(rstruct_const(nvm),stat=ier) 
    896    l_error = l_error .OR. (ier .NE. 0) 
    897    ALLOCATE(kzero(nvm),stat=ier) 
    898    l_error = l_error .OR. (ier .NE. 0) 
    899    !- 
    900    ALLOCATE(wmax_veg(nvm),stat=ier) 
    901    l_error = l_error .OR. (ier .NE. 0) 
    902    ALLOCATE(humcste(nvm),stat=ier) 
    903    l_error = l_error .OR. (ier .NE. 0) 
    904    !- 
    905    ALLOCATE(snowa_ini(nvm),stat=ier) 
    906    l_error = l_error .OR. (ier .NE. 0)    
    907    ALLOCATE(snowa_dec(nvm),stat=ier) 
    908    l_error = l_error .OR. (ier .NE. 0) 
    909    ALLOCATE(alb_leaf_vis(nvm),stat=ier) 
    910    l_error = l_error .OR. (ier .NE. 0) 
    911    ALLOCATE(alb_leaf_nir(nvm),stat=ier) 
    912    l_error = l_error .OR. (ier .NE. 0) 
    913    ALLOCATE(alb_leaf(2*nvm),stat=ier) 
    914    l_error = l_error .OR. (ier .NE. 0) 
    915    !- 
    916    ALLOCATE(pref_soil_veg_sand(nvm),stat=ier) 
    917    l_error = l_error .OR. (ier .NE. 0) 
    918    ALLOCATE(pref_soil_veg_loan(nvm),stat=ier) 
    919    l_error = l_error .OR. (ier .NE. 0) 
    920    ALLOCATE(pref_soil_veg_clay(nvm),stat=ier) 
    921    l_error = l_error .OR. (ier .NE. 0) 
    922    ALLOCATE(pref_soil_veg(nvm,nstm),stat=ier) 
    923    l_error = l_error .OR. (ier .NE. 0) 
    924    !- 
    925    ALLOCATE(lai_initmin(nvm),stat=ier) 
    926    l_error = l_error .OR. (ier .NE. 0) 
    927    ALLOCATE(tree(nvm),stat=ier) 
    928    l_error = l_error .OR. (ier .NE. 0) 
    929    ALLOCATE(bm_sapl(nvm,nparts),stat=ier) 
    930    l_error = l_error .OR. (ier .NE. 0) 
    931    ALLOCATE(migrate(nvm),stat=ier) 
    932    l_error = l_error .OR. (ier .NE. 0) 
    933    ALLOCATE(maxdia(nvm),stat=ier) 
    934    l_error = l_error .OR. (ier .NE. 0) 
    935    ALLOCATE(cn_sapl(nvm),stat=ier) 
    936    l_error = l_error .OR. (ier .NE. 0) 
    937    ALLOCATE(leaf_timecst(nvm),stat=ier) 
    938    l_error = l_error .OR. (ier .NE. 0)  
    939    !- 
    940    ALLOCATE(throughfall_by_pft(nvm),stat=ier) 
    941    l_error = l_error .OR. (ier .NE. 0)     
    942    ALLOCATE (rveg_pft(nvm),stat=ier) 
    943    l_error = l_error .OR. (ier .NE. 0)  
     820    
     821   IF(l_error) THEN 
     822      STOP 'pft _alloc : error in memory allocation of pft parameters' 
     823   ENDIF 
     824    
     825   ! 
     826   ! 2. Parameters used if ok_sechiba only 
     827   ! 
     828   IF (ok_sechiba) THEN 
     829      l_error=.FALSE. 
     830      !- 
     831      ALLOCATE(rstruct_const(nvm),stat=ier) 
     832      l_error = l_error .OR. (ier .NE. 0) 
     833      ALLOCATE(kzero(nvm),stat=ier) 
     834      l_error = l_error .OR. (ier .NE. 0) 
     835      ALLOCATE (rveg_pft(nvm),stat=ier) 
     836      l_error = l_error .OR. (ier .NE. 0)  
     837      ALLOCATE(wmax_veg(nvm),stat=ier) 
     838      l_error = l_error .OR. (ier .NE. 0) 
     839      ALLOCATE(throughfall_by_pft(nvm),stat=ier) 
     840      l_error = l_error .OR. (ier .NE. 0) 
     841      !- 
     842      ALLOCATE(snowa_ini(nvm),stat=ier) 
     843      l_error = l_error .OR. (ier .NE. 0)  
     844      ALLOCATE(snowa_dec(nvm),stat=ier) 
     845      l_error = l_error .OR. (ier .NE. 0) 
     846      ALLOCATE(alb_leaf_vis(nvm),stat=ier) 
     847      l_error = l_error .OR. (ier .NE. 0) 
     848      ALLOCATE(alb_leaf_nir(nvm),stat=ier) 
     849      l_error = l_error .OR. (ier .NE. 0) 
     850      ALLOCATE(alb_leaf(2*nvm),stat=ier) 
     851      l_error = l_error .OR. (ier .NE. 0) 
     852   ENDIF 
     853 
     854   IF(l_error) THEN 
     855      WRITE(numout,*) 'Error in memory allocation for sechiba pft parameters' 
     856   ENDIF 
     857 
     858   ! 
     859   ! 3. Parameters used if ok_stomate only 
     860   ! 
     861   IF (ok_stomate) THEN 
     862      l_error=.FALSE. 
     863      !- 
     864      ALLOCATE(leaf_tab(nvm),stat=ier) 
     865      l_error = l_error .OR. (ier .NE. 0) 
     866      ALLOCATE(sla(nvm),stat=ier) 
     867      l_error = l_error .OR. (ier .NE. 0)    
     868      ALLOCATE(vcmax_opt(nvm),stat=ier) 
     869      l_error = l_error .OR. (ier .NE. 0)  
     870      ALLOCATE(vjmax_opt(nvm),stat=ier) 
     871      l_error = l_error .OR. (ier .NE. 0) 
     872      !- 
     873      ALLOCATE(tphoto_min_a(nvm),stat=ier) 
     874      l_error = l_error .OR. (ier .NE. 0)  
     875      ALLOCATE(tphoto_min_b(nvm),stat=ier) 
     876      l_error = l_error .OR. (ier .NE. 0)  
     877      ALLOCATE(tphoto_min_c(nvm),stat=ier) 
     878      l_error = l_error .OR. (ier .NE. 0)  
     879      ALLOCATE(tphoto_opt_a(nvm),stat=ier) 
     880      l_error = l_error .OR. (ier .NE. 0)  
     881      ALLOCATE(tphoto_opt_b(nvm),stat=ier) 
     882      l_error = l_error .OR. (ier .NE. 0)  
     883      ALLOCATE(tphoto_opt_c(nvm),stat=ier) 
     884      l_error = l_error .OR. (ier .NE. 0)  
     885      ALLOCATE(tphoto_max_a(nvm),stat=ier) 
     886      l_error = l_error .OR. (ier .NE. 0)  
     887      ALLOCATE(tphoto_max_b(nvm),stat=ier) 
     888      l_error = l_error .OR. (ier .NE. 0)  
     889      ALLOCATE(tphoto_max_c(nvm),stat=ier) 
     890      l_error = l_error .OR. (ier .NE. 0)  
     891      !- 
     892      ALLOCATE(pheno_gdd_crit_c(nvm),stat=ier) 
     893      l_error = l_error .OR. (ier .NE. 0) 
     894      ALLOCATE(pheno_gdd_crit_b(nvm),stat=ier) 
     895      l_error = l_error .OR. (ier .NE. 0) 
     896      ALLOCATE(pheno_gdd_crit_a(nvm),stat=ier) 
     897      l_error = l_error .OR. (ier .NE. 0) 
     898      ALLOCATE(pheno_gdd_crit(nvm,3),stat=ier) 
     899      l_error = l_error .OR. (ier .NE. 0) 
     900      ALLOCATE(ngd_crit(nvm),stat=ier) 
     901      l_error = l_error .OR. (ier .NE. 0) 
     902      ALLOCATE(ncdgdd_temp(nvm),stat=ier) 
     903      l_error = l_error .OR. (ier .NE. 0) 
     904      ALLOCATE(hum_frac(nvm),stat=ier) 
     905      l_error = l_error .OR. (ier .NE. 0) 
     906      ALLOCATE(lowgpp_time(nvm),stat=ier) 
     907      l_error = l_error .OR. (ier .NE. 0) 
     908      ALLOCATE(hum_min_time(nvm),stat=ier) 
     909      l_error = l_error .OR. (ier .NE. 0) 
     910      ALLOCATE(tau_sap(nvm),stat=ier) 
     911      l_error = l_error .OR. (ier .NE. 0) 
     912      ALLOCATE(tau_fruit(nvm),stat=ier) 
     913      l_error = l_error .OR. (ier .NE. 0) 
     914      ALLOCATE(ecureuil(nvm),stat=ier) 
     915      l_error = l_error .OR. (ier .NE. 0) 
     916      ALLOCATE(alloc_min(nvm),stat=ier) 
     917      l_error = l_error .OR. (ier .NE. 0) 
     918      ALLOCATE(alloc_max(nvm),stat=ier) 
     919      l_error = l_error .OR. (ier .NE. 0) 
     920      ALLOCATE(demi_alloc(nvm),stat=ier) 
     921      l_error = l_error .OR. (ier .NE. 0) 
     922      !- 
     923      ALLOCATE(maint_resp_slope(nvm,3),stat=ier) 
     924      l_error = l_error .OR. (ier .NE. 0) 
     925      ALLOCATE(maint_resp_slope_c(nvm),stat=ier) 
     926      l_error = l_error .OR. (ier .NE. 0) 
     927      ALLOCATE(maint_resp_slope_b(nvm),stat=ier) 
     928      l_error = l_error .OR. (ier .NE. 0) 
     929      ALLOCATE(maint_resp_slope_a(nvm),stat=ier) 
     930      l_error = l_error .OR. (ier .NE. 0) 
     931      ALLOCATE(coeff_maint_zero(nvm,nparts),stat=ier) 
     932      l_error = l_error .OR. (ier .NE. 0) 
     933      ALLOCATE(cm_zero_leaf(nvm),stat=ier) 
     934      l_error = l_error .OR. (ier .NE. 0) 
     935      ALLOCATE(cm_zero_sapabove(nvm),stat=ier) 
     936      l_error = l_error .OR. (ier .NE. 0) 
     937      ALLOCATE(cm_zero_sapbelow(nvm),stat=ier) 
     938      l_error = l_error .OR. (ier .NE. 0) 
     939      ALLOCATE(cm_zero_heartabove(nvm),stat=ier) 
     940      l_error = l_error .OR. (ier .NE. 0) 
     941      ALLOCATE(cm_zero_heartbelow(nvm),stat=ier) 
     942      l_error = l_error .OR. (ier .NE. 0) 
     943      ALLOCATE(cm_zero_root(nvm),stat=ier) 
     944      l_error = l_error .OR. (ier .NE. 0) 
     945      ALLOCATE(cm_zero_fruit(nvm),stat=ier) 
     946      l_error = l_error .OR. (ier .NE. 0) 
     947      ALLOCATE(cm_zero_carbres(nvm),stat=ier) 
     948      l_error = l_error .OR. (ier .NE. 0) 
     949      !- 
     950      ALLOCATE(flam(nvm),stat=ier) 
     951      l_error = l_error .OR. (ier .NE. 0)  
     952      ALLOCATE(resist(nvm),stat=ier) 
     953      l_error = l_error .OR. (ier .NE. 0)  
     954      !- 
     955      ALLOCATE(coeff_lcchange_1(nvm),stat=ier) 
     956      l_error = l_error .OR. (ier .NE. 0) 
     957      ALLOCATE(coeff_lcchange_10(nvm),stat=ier) 
     958      l_error = l_error .OR. (ier .NE. 0) 
     959      ALLOCATE(coeff_lcchange_100(nvm),stat=ier) 
     960      l_error = l_error .OR. (ier .NE. 0) 
     961      !- 
     962      ALLOCATE(lai_max(nvm),stat=ier) 
     963      l_error = l_error .OR. (ier .NE. 0) 
     964      ALLOCATE(pheno_model(nvm),stat=ier) 
     965      l_error = l_error .OR. (ier .NE. 0)  
     966      ALLOCATE(pheno_type(nvm),stat=ier) 
     967      l_error = l_error .OR. (ier .NE. 0)  
     968      !- 
     969      ALLOCATE(leaffall(nvm),stat=ier) 
     970      l_error = l_error .OR. (ier .NE. 0) 
     971      ALLOCATE(leafagecrit(nvm),stat=ier) 
     972      l_error = l_error .OR. (ier .NE. 0) 
     973      ALLOCATE(senescence_type(nvm),stat=ier) 
     974      l_error = l_error .OR. (ier .NE. 0) 
     975      ALLOCATE(senescence_hum(nvm),stat=ier) 
     976      l_error = l_error .OR. (ier .NE. 0) 
     977      ALLOCATE(nosenescence_hum(nvm),stat=ier) 
     978      l_error = l_error .OR. (ier .NE. 0) 
     979      ALLOCATE(max_turnover_time(nvm),stat=ier) 
     980      l_error = l_error .OR. (ier .NE. 0) 
     981      ALLOCATE(min_turnover_time(nvm),stat=ier) 
     982      l_error = l_error .OR. (ier .NE. 0) 
     983      ALLOCATE(min_leaf_age_for_senescence(nvm),stat=ier) 
     984      l_error = l_error .OR. (ier .NE. 0) 
     985      ALLOCATE(senescence_temp_c(nvm),stat=ier) 
     986      l_error = l_error .OR. (ier .NE. 0) 
     987      ALLOCATE(senescence_temp_b(nvm),stat=ier) 
     988      l_error = l_error .OR. (ier .NE. 0) 
     989      ALLOCATE(senescence_temp_a(nvm),stat=ier) 
     990      l_error = l_error .OR. (ier .NE. 0) 
     991      ALLOCATE(senescence_temp(nvm,3),stat=ier) 
     992      l_error = l_error .OR. (ier .NE. 0) 
     993      !- 
     994      ALLOCATE(residence_time(nvm),stat=ier) 
     995      l_error = l_error .OR. (ier .NE. 0) 
     996      ALLOCATE(tmin_crit(nvm),stat=ier) 
     997      l_error = l_error .OR. (ier .NE. 0) 
     998      ALLOCATE(tcm_crit(nvm),stat=ier) 
     999      l_error = l_error .OR. (ier .NE. 0) 
     1000      !- 
     1001      ALLOCATE(lai_initmin(nvm),stat=ier) 
     1002      l_error = l_error .OR. (ier .NE. 0) 
     1003      ALLOCATE(tree(nvm),stat=ier) 
     1004      l_error = l_error .OR. (ier .NE. 0) 
     1005      ALLOCATE(bm_sapl(nvm,nparts),stat=ier) 
     1006      l_error = l_error .OR. (ier .NE. 0) 
     1007      ALLOCATE(migrate(nvm),stat=ier) 
     1008      l_error = l_error .OR. (ier .NE. 0) 
     1009      ALLOCATE(maxdia(nvm),stat=ier) 
     1010      l_error = l_error .OR. (ier .NE. 0) 
     1011      ALLOCATE(cn_sapl(nvm),stat=ier) 
     1012      l_error = l_error .OR. (ier .NE. 0) 
     1013      ALLOCATE(leaf_timecst(nvm),stat=ier) 
     1014      l_error = l_error .OR. (ier .NE. 0)  
     1015      ALLOCATE(leaflife_tab(nvm),stat=ier)    
     1016      l_error = l_error .OR. (ier .NE. 0) 
     1017   ENDIF 
    9441018   ! 
    9451019   IF (l_error) THEN 
    946        STOP 'pft _alloc : error in memory allocation' 
     1020       STOP 'pft _alloc : error in memory allocation of stomate pft parameters' 
    9471021   ENDIF 
    9481022 
     
    17761850   
    17771851END SUBROUTINE getin_stomate_pft_parameters 
    1778  ! 
    1779  != 
    1780  ! 
     1852! 
     1853!= 
     1854! 
    17811855 SUBROUTINE pft_parameters_clear 
    17821856    
     
    17861860   IF(ALLOCATED(PFT_name))DEALLOCATE(PFT_name) 
    17871861   !- 
    1788    !>> DS new for merge in the trunk   ! 15/06/2011  
    1789    ! Add for writing history files in stomate_lpj.f90 'treeFracPrimDec' and 'treeFracPrimEver' 
    1790    IF(ALLOCATED(is_deciduous))DEALLOCATE(is_deciduous) 
    1791    IF(ALLOCATED(is_evergreen))DEALLOCATE(is_evergreen) 
    1792    IF(ALLOCATED(leaflife_tab))DEALLOCATE(leaflife_tab) 
    1793    IF(ALLOCATED(is_c3))DEALLOCATE(is_c3)   
    1794    !- 
    17951862   IF(ALLOCATED(veget_ori_fixed_test_1))DEALLOCATE(veget_ori_fixed_test_1)    
    17961863   IF(ALLOCATED(llaimax))DEALLOCATE(llaimax) 
     
    17991866   IF(ALLOCATED(type_of_lai))DEALLOCATE(type_of_lai) 
    18001867   IF(ALLOCATED(is_tree))DEALLOCATE(is_tree) 
    1801    !- 
    1802    IF(ALLOCATED(leaf_tab))DEALLOCATE(leaf_tab) 
    1803    IF(ALLOCATED(sla))DEALLOCATE(sla) 
    18041868   IF(ALLOCATED(natural))DEALLOCATE(natural) 
     1869   !- 
     1870   !>> DS new for merge in the trunk   ! 15/06/2011  
     1871   ! Add for writing history files in stomate_lpj.f90 'treeFracPrimDec' and 'treeFracPrimEver' 
     1872   IF(ALLOCATED(is_deciduous))DEALLOCATE(is_deciduous) 
     1873   IF(ALLOCATED(is_evergreen))DEALLOCATE(is_evergreen) 
     1874   IF(ALLOCATED(is_c3))DEALLOCATE(is_c3)   
     1875   !- 
     1876   IF(ALLOCATED(humcste))DEALLOCATE(humcste) 
     1877   !- 
     1878   IF(ALLOCATED(pref_soil_veg_sand))DEALLOCATE(pref_soil_veg_sand) 
     1879   IF(ALLOCATED(pref_soil_veg_loan))DEALLOCATE(pref_soil_veg_loan) 
     1880   IF(ALLOCATED(pref_soil_veg_clay))DEALLOCATE(pref_soil_veg_clay) 
     1881   IF(ALLOCATED(pref_soil_veg))DEALLOCATE(pref_soil_veg) 
    18051882   !- 
    18061883   IF(ALLOCATED(is_c4))DEALLOCATE(is_c4)   
     
    18121889   IF(ALLOCATED(co2_topt_fix))DEALLOCATE(co2_topt_fix) 
    18131890   IF(ALLOCATED(co2_tmax_fix))DEALLOCATE(co2_tmax_fix)  
    1814    !- 
    18151891   IF(ALLOCATED(ext_coeff))DEALLOCATE(ext_coeff) 
     1892   !- 
     1893   IF(ALLOCATED(rveg_pft))DEALLOCATE(rveg_pft) 
     1894   !- 
     1895   IF(ALLOCATED(rstruct_const))DEALLOCATE(rstruct_const) 
     1896   IF(ALLOCATED(kzero))DEALLOCATE(kzero) 
     1897   !- 
     1898   IF(ALLOCATED(wmax_veg))DEALLOCATE(wmax_veg) 
     1899   IF(ALLOCATED(throughfall_by_pft))DEALLOCATE(throughfall_by_pft) 
     1900   !- 
     1901   IF(ALLOCATED(snowa_ini))DEALLOCATE(snowa_ini) 
     1902   IF(ALLOCATED(snowa_dec))DEALLOCATE(snowa_dec) 
     1903   IF(ALLOCATED(alb_leaf_vis))DEALLOCATE(alb_leaf_vis) 
     1904   IF(ALLOCATED(alb_leaf_nir))DEALLOCATE(alb_leaf_nir)    
     1905   IF(ALLOCATED(alb_leaf))DEALLOCATE(alb_leaf) 
     1906   !- 
     1907   IF(ALLOCATED(leaf_tab))DEALLOCATE(leaf_tab) 
     1908   IF(ALLOCATED(sla))DEALLOCATE(sla) 
     1909   !- 
    18161910   IF(ALLOCATED(vcmax_opt))DEALLOCATE(vcmax_opt) 
    18171911   IF(ALLOCATED(vjmax_opt))DEALLOCATE(vjmax_opt) 
     
    18661960   IF(ALLOCATED(alloc_max))DEALLOCATE(alloc_max) 
    18671961   IF(ALLOCATED(demi_alloc))DEALLOCATE(demi_alloc) 
     1962   !>> DS new for merge in the trunk   ! 15/06/2011  
     1963   IF(ALLOCATED(leaflife_tab))DEALLOCATE(leaflife_tab) 
    18681964   !- 
    18691965   IF(ALLOCATED(leaffall))DEALLOCATE(leaffall) 
     
    18851981   IF(ALLOCATED(tcm_crit))DEALLOCATE(tcm_crit) 
    18861982   !- 
    1887    IF(ALLOCATED(rstruct_const))DEALLOCATE(rstruct_const) 
    1888    IF(ALLOCATED(kzero))DEALLOCATE(kzero) 
    1889    !- 
    1890    IF(ALLOCATED(wmax_veg))DEALLOCATE(wmax_veg) 
    1891    IF(ALLOCATED(humcste))DEALLOCATE(humcste) 
    1892    !- 
    1893    IF(ALLOCATED(snowa_ini))DEALLOCATE(snowa_ini) 
    1894    IF(ALLOCATED(snowa_dec))DEALLOCATE(snowa_dec) 
    1895    IF(ALLOCATED(alb_leaf_vis))DEALLOCATE(alb_leaf_vis) 
    1896    IF(ALLOCATED(alb_leaf_nir))DEALLOCATE(alb_leaf_nir)    
    1897    IF(ALLOCATED(alb_leaf))DEALLOCATE(alb_leaf) 
    1898    !- 
    1899    IF(ALLOCATED(pref_soil_veg_sand))DEALLOCATE(pref_soil_veg_sand) 
    1900    IF(ALLOCATED(pref_soil_veg_loan))DEALLOCATE(pref_soil_veg_loan) 
    1901    IF(ALLOCATED(pref_soil_veg_clay))DEALLOCATE(pref_soil_veg_clay) 
    1902    IF(ALLOCATED(pref_soil_veg))DEALLOCATE(pref_soil_veg) 
    1903    !- 
    19041983   IF(ALLOCATED(lai_initmin))DEALLOCATE(lai_initmin) 
    19051984   IF(ALLOCATED(tree))DEALLOCATE(tree) 
     
    19091988   IF(ALLOCATED(cn_sapl))DEALLOCATE(cn_sapl) 
    19101989   IF(ALLOCATED(leaf_timecst))DEALLOCATE(leaf_timecst) 
    1911    !- 
    1912    IF(ALLOCATED(throughfall_by_pft))DEALLOCATE(throughfall_by_pft) 
    1913    IF(ALLOCATED(rveg_pft))DEALLOCATE(rveg_pft) 
    19141990    
    19151991 END SUBROUTINE pft_parameters_clear 
  • branches/ORCHIDEE_EXT/ORCHIDEE/src_sechiba/intersurf.f90

    r407 r425  
    6969  ! 
    7070!!$ DS : ajout du flag IMPOSE_PARAM 
    71  ! Flag impos_param : it is set to true by default 
     71  ! Flag impos_param : it is set to true by default 
    7272  LOGICAL, SAVE :: impose_param = .TRUE. 
    7373  ! 
     
    27592759    TYPE(control_type), INTENT(out)            :: control_flags !! Flags that (de)activate parts of the model 
    27602760 
    2761  
    2762     ! 
    2763     !Config Key  = NVM 
    2764     !Config Desc = number of PFTs   
    2765     !Config  if  = ANYTIME 
    2766     !Config  Def  = 13 
    2767     !Config  Help = The number of vegetation types define by the user 
    2768     !Config  Units = NONE 
    2769     CALL getin_p('NVM',nvm) 
    2770     WRITE(numout,*)'the number of pfts is : ', nvm 
    27712761    ! 
    27722762    !Config Key  = LONGPRINT 
     
    28232813    ENDIF 
    28242814 
    2825     !Config Key  = IMPOSE_PARAM 
    2826     !Config Desc = Do you impose the values of the parameters? 
    2827     !Config  if  = ANYTIME 
    2828     !Config  Def  = y 
    2829     !Config  Help = This flag can deactivate the reading of some paramters. 
    2830     !               Useful if you want to use the standard values without commenting the run.def 
    2831     !Config  Units = NONE 
    2832     CALL getin_p('IMPOSE_PARAM',impose_param) 
    2833  
    2834     ! Read and allocate the pft parameters 
    2835     CALL pft_parameters_main   
    2836  
    28372815    ! 
    28382816    !Config Key  = RIVER_ROUTING 
     
    28472825    WRITE(numout,*) "RIVER routing is activated : ",control_flags%river_routing 
    28482826    ! 
    2849 !!$    DS : reading of parameters associated to river_routing 
    2850     IF ( control_flags%river_routing ) THEN 
    2851        CALL getin_routing_parameters 
    2852     ENDIF 
    28532827 
    28542828    ! 
     
    28702844    ENDIF 
    28712845    ! 
    2872 !!$    DS : reading of parameters associated to hydrol_cwrr 
    2873     IF ( control_flags%hydrol_cwrr ) THEN 
    2874        CALL getin_hydrol_cwrr_parameters 
    2875     ELSE 
    2876        CALL getin_hydrolc_parameters 
    2877        ! we read the parameters for the choisnel hydrology 
    2878     ENDIF 
    28792846 
    28802847    ! 
     
    28882855    WRITE(numout,*) 'photosynthesis: ', control_flags%ok_co2 
    28892856    ! 
    2890 !!$    DS : reading of parameters associated to ok_co2 
    2891     IF ( control_flags%ok_co2 ) THEN 
    2892        CALL getin_co2_parameters 
    2893     ENDIF 
    28942857 
    28952858    ! 
     
    29032866    WRITE(numout,*) 'STOMATE is activated: ',control_flags%ok_stomate 
    29042867    ! 
    2905 !!$    DS : reading of parameters associated to ok_stomate 
    2906     IF ( control_flags%ok_stomate ) THEN 
    2907        CALL getin_stomate_parameters 
    2908        IF ( impose_param ) THEN       
    2909           CALL getin_stomate_pft_parameters 
    2910           WRITE(numout,*)'    some stomate_pft_parameters have been imposed ' 
    2911        ELSE  
    2912           WRITE(numout,*)'    all stomate_pft_parameters are set to default values' 
    2913        ENDIF 
    2914     ENDIF 
    29152868 
    29162869    ! 
     
    29272880    ! 
    29282881    control_flags%ok_sechiba = .TRUE. 
    2929 !!$    DS : reading of parameters associated to ok_sechiba 
    2930     IF ( control_flags%ok_sechiba ) THEN 
    2931        CALL getin_sechiba_parameters 
    2932        IF ( impose_param ) THEN       
    2933           CALL getin_sechiba_pft_parameters 
    2934           WRITE(numout,*)'    some sechiba_pft_parameters have been imposed ' 
    2935        ELSE  
    2936           WRITE(numout,*)'    all sechiba_pft_parameters are set to default values' 
    2937        ENDIF 
    2938     ENDIF 
    2939  
    29402882    ! 
    29412883    ! 
     
    29652907    control_flags%ok_pheno = .TRUE. 
    29662908    ! 
    2967 !>> july 2011 
    2968     ! DS: activation of sub-models of ORCHIDEE 
     2909 
     2910!>> DS 08/2011 : for externalisation 
     2911 
     2912    ! 1. Number of PFTs defined by the user 
     2913 
     2914    !Config Key  = NVM 
     2915    !Config Desc = number of PFTs   
     2916    !Config if  = ANYTIME 
     2917    !Config Def  = 13 
     2918    !Config Help = The number of vegetation types define by the user 
     2919    !Config Units = NONE 
     2920    CALL getin_p('NVM',nvm) 
     2921    WRITE(numout,*)'the number of pfts is : ', nvm 
     2922 
     2923    ! 2. Should we read the parameters in the run.def file ? 
     2924 
     2925    !Config Key  = IMPOSE_PARAM 
     2926    !Config Desc = Do you impose the values of the parameters? 
     2927    !Config if  = ANYTIME 
     2928    !Config Def  = y 
     2929    !Config Help = This flag can deactivate the reading of some parameters. 
     2930    !               Useful if you want to use the standard values without commenting the run.def 
     2931    !Config Units = NONE 
     2932    ! 
     2933    CALL getin_p('IMPOSE_PARAM',impose_param) 
     2934 
     2935    ! 3. Allocate and intialize the pft parameters 
     2936 
     2937    CALL pft_parameters_main(control_flags%ok_sechiba,control_flags%ok_stomate) 
     2938 
     2939    ! 4. Activation sub-models of ORCHIDEE 
     2940 
    29692941    CALL activate_sub_models(control_flags%ok_sechiba, control_flags%river_routing,control_flags%ok_stomate) 
    2970     ! Vegetation configuration(impose_veg, land_use, lcchange...previously in slowproc) 
     2942 
     2943    ! 5. Vegetation configuration (impose_veg, land_use, lcchange...previously in slowproc) 
     2944 
    29712945    CALL veget_config 
     2946 
     2947    ! 6. Read the parameters in the run.def file  according the flags 
     2948 
     2949    IF ( control_flags%ok_sechiba .AND. impose_param ) THEN 
     2950       CALL getin_sechiba_parameters 
     2951       CALL getin_sechiba_pft_parameters 
     2952       WRITE(numout,*)'    some sechiba_pft_parameters have been imposed ' 
     2953    ELSE  
     2954       WRITE(numout,*)'    all sechiba_pft_parameters are set to default values' 
     2955    ENDIF 
     2956 
     2957    IF ( control_flags%ok_co2 .AND. impose_param ) THEN 
     2958       CALL getin_co2_parameters 
     2959    ENDIF 
     2960 
     2961    IF ( control_flags%hydrol_cwrr .AND. impose_param ) THEN 
     2962       CALL getin_hydrol_cwrr_parameters 
     2963    ELSE 
     2964       IF (impose_param) THEN 
     2965          CALL getin_hydrolc_parameters 
     2966          ! we read the parameters for the choisnel hydrology 
     2967       ENDIF 
     2968    ENDIF 
     2969 
     2970    IF ( control_flags%river_routing .AND. impose_param ) THEN 
     2971       CALL getin_routing_parameters 
     2972    ENDIF 
     2973 
     2974    IF ( control_flags%ok_stomate .AND. impose_param ) THEN 
     2975       CALL getin_stomate_parameters 
     2976       CALL getin_stomate_pft_parameters 
     2977       WRITE(numout,*)'    some stomate_pft_parameters have been imposed ' 
     2978    ELSE  
     2979       WRITE(numout,*)'    all stomate_pft_parameters are set to default values' 
     2980    ENDIF 
     2981 
     2982     IF ( control_flags%ok_dgvm .AND. impose_param ) THEN 
     2983       CALL getin_dgvm_parameters 
     2984    ENDIF     
     2985 
     2986!>> END DS 
     2987    ! 
    29722988    ! 
    29732989    RETURN 
  • branches/ORCHIDEE_EXT/ORCHIDEE/src_sechiba/slowproc.f90

    r386 r425  
    946946             IF (.NOT. agriculture) THEN 
    947947                DO jv = 2, nvm   
    948                    DO ji = 1, kjpindex 
    949                       IF ( .NOT. natural (jv))  THEN 
     948                   IF ( .NOT. natural (jv))  THEN 
     949                      DO ji = 1, kjpindex 
    950950                         veget_max(ji,1) = veget_max(ji,1) + veget_max(ji,jv) 
    951951                         veget_max(ji,jv) = zero 
    952                       ENDIF 
    953                    ENDDO 
     952                      ENDDO 
     953                   ENDIF 
    954954                ENDDO 
    955955             ENDIF 
Note: See TracChangeset for help on using the changeset viewer.