Changeset 6892


Ignore:
Timestamp:
2020-10-08T11:15:45+02:00 (4 years ago)
Author:
bertrand.guenet
Message:

restore previous version commit on this branch by mistake

Location:
branches/publications/ORCHIDEE-PEAT_r5488
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/publications/ORCHIDEE-PEAT_r5488/src_driver/forcesoil.f90

    r6890 r6892  
    4141  USE netcdf 
    4242  !- 
    43   !USE grid 
    4443  USE utils 
    4544  USE defprec 
     
    4948  USE constantes_soil 
    5049  USE pft_parameters  
    51   USE control 
    5250  USE stomate_data 
    5351  USE ioipsl_para 
     
    5856  USE stomate 
    5957  USE stomate_io_carbon_permafrost 
    60   USE xios_orchidee 
    61   USE pft_parameters_var 
    62   USE vertical_soil 
    63   USE vertical_soil_var 
    64  
    6558#ifdef CPP_PARA 
    6659  USE mpi 
    6760#endif 
    68  
    6961  !- 
    7062  IMPLICIT NONE 
     
    10395 
    10496 
    105   INTEGER                                    :: i,j,m,iatt,iv,iyear    !! counters (unitless) 
     97  INTEGER                                    :: i,m,iatt,iv,iyear      !! counters (unitless) 
    10698!!!qcj++ test                                                                        
    10799!  INTEGER                                    :: pft,pool 
     
    138130  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:)  :: clay_g                 !! clay fraction (nbpglo) (unitless) 
    139131                                                                       !! (\f$gC m^{-2} dt_forcesoil^{-1}\f$)  
    140   REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:)  :: bulk_dens_g            !! bulk_dens (nbpglo) (unitless) 
    141                                                                        !! (\f$gC m^{-2} dt_forcesoil^{-1}\f$)  
    142   REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:)  :: soil_ph_g              !! soil_ph (nbpglo) (unitless) 
    143                                                                        !! (\f$gC m^{-2} dt_forcesoil^{-1}\f$)  
    144   REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:)  :: poor_soils_g           !! poor_soils (nbpglo) (unitless) 
    145                                                                        !! (\f$gC m^{-2} dt_forcesoil^{-1}\f$)  
    146 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: veget_max_g 
    147 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:,:,:,:) :: soilcarbon_input_DOC_g 
    148 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:,:,:) :: floodcarbon_input_g 
    149 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:,:,:) :: litter_above_g 
    150 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:,:,:,:) :: litter_below_g 
    151 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: lignin_struc_above_g 
    152 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:,:) :: lignin_struc_below_g 
    153 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: runoff_per_soil_g 
    154 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: runoff2peat_g 
    155 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: drainage_per_soil_g 
    156 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:,:) :: wat_flux_g 
    157 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:,:) :: soil_mc_32l_g 
    158 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:,:) :: soil_mc_g 
    159 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: DOC_to_topsoil_g 
    160 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: precip2ground_g 
    161 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:,:) :: interception_storage_g 
    162 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:,:,:) :: biomass_g 
    163 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:) :: fastr_g 
    164 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: precip2canopy_g 
    165 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: canopy2ground_g 
    166 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: DOC_to_subsoil_g 
    167 !  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:) :: flood_frac_g 
    168  
    169132  REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE   :: control_temp_g         !! Temperature control (nbp_glo,above/below,time) on OM decomposition  
    170133                                                                       !! (unitless) 
     
    172135                                                                       !! ?? Should be defined per PFT as well (unitless) 
    173136  REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE   :: carbon_g               !! Soil carbon stocks (nbp_glo,ncarb,nvm) (\f$gC m^{-2}\f$) 
    174   REAL(r_std),DIMENSION(:,:,:,:),ALLOCATABLE   :: carbon_32l_g 
    175   REAL(r_std),DIMENSION(:,:,:,:,:,:),ALLOCATABLE   :: DOC_g                                                                     
     137                                                                        
    176138  REAL(r_std),ALLOCATABLE :: clay(:)                                   !! clay fraction (nbp_loc) (unitless) 
    177   REAL(r_std),ALLOCATABLE :: bulk_dens(:)                              !! bulk_dens (nbp_loc) (unitless) 
    178   REAL(r_std),ALLOCATABLE :: soil_ph(:)                                !! soil_ph (nbp_loc) (unitless) 
    179   REAL(r_std),ALLOCATABLE :: poor_soils(:)                             !! poor_soils (nbp_loc) (unitless) 
    180139  REAL(r_std),ALLOCATABLE :: soilcarbon_input(:,:,:,:)                 !! soil carbon input (nbp_loc,ncarb,nvm,time)  
    181140                                                                       !! (\f$gC m^{-2} dt_forcesoil^{-1}\f$)  
    182 !  REAL(r_std),ALLOCATABLE :: veget_max(:,:,:) 
    183   REAL(r_std),ALLOCATABLE :: soilcarbon_input_DOC(:,:,:,:,:,:) 
    184   REAL(r_std),ALLOCATABLE :: floodcarbon_input(:,:,:,:,:) 
    185   REAL(r_std),ALLOCATABLE :: litter_above(:,:,:,:,:) 
    186   REAL(r_std),ALLOCATABLE :: litter_below(:,:,:,:,:,:) 
    187   REAL(r_std),ALLOCATABLE :: lignin_struc_above(:,:,:) 
    188   REAL(r_std),ALLOCATABLE :: lignin_struc_below(:,:,:,:) 
    189   REAL(r_std),ALLOCATABLE :: runoff_per_soil(:,:,:) 
    190   REAL(r_std),ALLOCATABLE :: runoff2peat(:,:,:) 
    191   REAL(r_std),ALLOCATABLE :: drainage_per_soil(:,:,:) 
    192   REAL(r_std),ALLOCATABLE :: wat_flux(:,:,:,:) 
    193   REAL(r_std),ALLOCATABLE :: soil_mc_32l(:,:,:,:) 
    194   REAL(r_std),ALLOCATABLE :: soil_mc(:,:,:,:) 
    195   REAL(r_std),ALLOCATABLE :: DOC_to_topsoil(:,:,:) 
    196   REAL(r_std),ALLOCATABLE :: precip2ground(:,:,:) 
    197   REAL(r_std),ALLOCATABLE :: interception_storage(:,:,:,:) 
    198   REAL(r_std),ALLOCATABLE :: biomass(:,:,:,:,:) 
    199   REAL(r_std),ALLOCATABLE :: fastr(:,:) 
    200   REAL(r_std),ALLOCATABLE :: precip2canopy(:,:,:) 
    201   REAL(r_std),ALLOCATABLE :: canopy2ground(:,:,:) 
    202   REAL(r_std),ALLOCATABLE :: DOC_to_subsoil(:,:,:) 
    203   REAL(r_std),ALLOCATABLE :: flood_frac(:,:) 
    204  
    205141  REAL(r_std),ALLOCATABLE :: control_temp(:,:,:)                       !! Temperature control (nbp_loc,above/below,time) on OM decomposition  
    206142                                                                       !! (unitless) 
     
    208144                                                                       !! ?? Should be defined per PFT as well (unitless) 
    209145  REAL(r_std),ALLOCATABLE :: carbon(:,:,:)                             !! Soil carbon stocks (nbp_loc,ncarb,nvm) (\f$gC m^{-2}\f$) 
    210   REAL(r_std),DIMENSION(:,:,:,:),ALLOCATABLE   :: carbon_32l 
    211   REAL(r_std),DIMENSION(:,:,:,:,:,:),ALLOCATABLE   :: DOC 
    212146  REAL(r_std),DIMENSION(:,:),ALLOCATABLE     :: resp_hetero_soil       !! Heterotrophic respiration (\f$gC m^{-2} dt_forcesoil^{-1}\f$)  
    213147                                                                       !! (requested by soilcarbon routine but not used here)  
    214   REAL(r_std),DIMENSION(:,:),ALLOCATABLE     :: resp_flood_soil 
    215   REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE     :: dry_dep_canopy 
    216   REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE     :: DOC_precip2ground 
    217   REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE     :: DOC_precip2canopy 
    218   REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE     :: DOC_canopy2ground 
    219   REAL(r_std),DIMENSION(:,:,:,:,:),ALLOCATABLE     :: DOC_EXP 
    220  
    221148 
    222149  INTEGER(i_std)                             :: printlev_loc           !! Local write level                                                                      
     
    286213  REAL(r_std), DIMENSION(:,:,:),  ALLOCATABLE  :: carbon_surf_g 
    287214  REAL(r_std), DIMENSION(:,:,:),  ALLOCATABLE  :: carbon_surf                 !! vertically-integrated (diagnostic) soil carbon pool: active, slow, or passive, (gC/(m**2 of ground)) 
    288   REAL(R_STD), DIMENSION(:,:), ALLOCATABLE     :: fixed_cryoturbation_depth  !! depth to hold cryoturbation to for fixed runs 
     215  REAL(R_STD), ALLOCATABLE, DIMENSION(:,:)      :: fixed_cryoturbation_depth  !! depth to hold cryoturbation to for fixed runs 
    289216  LOGICAL, SAVE                             :: satsoil = .FALSE. 
    290217  LOGICAL                                   :: reset_soilc = .false. 
    291   LOGICAL                                   :: force_soil = .TRUE. 
     218 
    292219  INTEGER(i_std)                            :: start_2d(2), count_2d(2)  
    293220  INTEGER(i_std)                            :: start_4d(4), count_4d(4), start_3d(3), count_3d(3) 
    294   INTEGER(i_std)                            :: start_5d(5), count_5d(5), start_6d(6), count_6d(6) 
    295221!_ ================================================================================================================================= 
    296222  
     
    308234  CALL getin_p('OK_PC',ok_pc) 
    309235 
    310   ok_leak=.FALSE. 
    311   CALL getin_p('OK_LEAK',ok_leak) 
    312236!!!qcj++ peatland 
    313237  ok_peat=.FALSE. 
     
    317241  CALL getin_p('PERMA_PEAT', perma_peat) 
    318242 
    319 !>BG Ok_leak 
    320   ok_leak=.FALSE. 
    321   CALL getin_p('OK_LEAK',ok_leak) 
    322  
     243 
     244  ! 1. Read the number of PFTs 
     245  ! 
     246  !Config Key   = NVM 
     247  !Config Desc  = number of PFTs   
     248  !Config If    = OK_SECHIBA or OK_STOMATE 
     249  !Config Def   = 13 
     250  !Config Help  = The number of vegetation types define by the user 
     251  !Config Units = [-] 
     252  CALL getin_p('NVM',nvm) 
     253 
     254  ! 2. Allocation 
     255  ALLOCATE(pft_to_mtc(nvm),stat=ier) 
     256  IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'pft_to_mtc : error in memory allocation', '', '') 
     257 
     258  ! 3. Initialisation of the correspondance table 
     259  pft_to_mtc(:) = undef_int 
     260   
     261  ! 4.Reading of the conrrespondance table in the .def file 
     262  ! 
     263  !Config Key   = PFT_TO_MTC 
     264  !Config Desc  = correspondance array linking a PFT to MTC 
     265  !Config if    = OK_SECHIBA or OK_STOMATE 
     266  !Config Def   = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 
     267  !Config Help  = 
     268  !Config Units = [-] 
     269  CALL getin_p('PFT_TO_MTC',pft_to_mtc) 
     270 
     271 
     272  ! 4.1 if nothing is found, we use the standard configuration 
     273!!!qcj++ peatland 
     274  IF (ok_peat .OR. perma_peat) THEN 
     275     IF(nvm <= nvmc ) THEN 
     276       IF(pft_to_mtc(1) == undef_int) THEN 
     277          pft_to_mtc(:) = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ,15/) 
     278       ENDIF  
     279     ENDIF 
     280  ELSE 
     281     IF(nvm <= nvmc ) THEN 
     282        IF(pft_to_mtc(1) == undef_int) THEN 
     283           WRITE(numout,*) 'Note to the user : we will use ORCHIDEE to its standard configuration' 
     284           pft_to_mtc(:) = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 /) 
     285        ENDIF 
     286     ELSE 
     287        IF(pft_to_mtc(1) == undef_int) THEN 
     288           WRITE(numout,*)' The array PFT_TO_MTC is empty : we stop' 
     289        ENDIF 
     290     ENDIF 
     291  ENDIF 
     292 
     293  
     294  ! 4.2 What happened if pft_to_mtc(j) > nvmc (if the mtc doesn't exist)? 
     295  DO i = 1, nvm 
     296     IF(pft_to_mtc(i) > nvmc) THEN 
     297        CALL ipslerr_p(3, 'forcesoil', 'the MTC you chose doesnt exist', 'we stop reading pft_to_mtc', '') 
     298     ENDIF 
     299  ENDDO 
     300   
     301  ! 4.3 Check if pft_to_mtc(1) = 1  
     302  IF(pft_to_mtc(1) /= 1) THEN 
     303     CALL ipslerr_p(3, 'forcesoil', 'the first pft has to be the bare soil', 'we stop reading next values of pft_to_mtc', '') 
     304  ENDIF 
     305 
     306  DO i = 2,nvm 
     307     IF(pft_to_mtc(i) == 1) THEN 
     308        CALL ipslerr_p(3, 'forcesoil', 'only pft_to_mtc(1) has to be the bare soil', 'we stop reading next values of pft_to_mtc', '') 
     309     ENDIF 
     310  ENDDO 
     311   
     312  ! 5. Allocate and initialize natural and is_c4 
     313   
     314  ! 5.1 Memory allocation 
     315  ALLOCATE(natural(nvm),stat=ier) 
     316  IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'natural : error in memory allocation', '', '') 
     317 
     318  ALLOCATE(is_c4(nvm),stat=ier) 
     319  IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'is_c4 : error in memory allocation', '', '') 
     320 
     321  ALLOCATE(permafrost_veg_exists(nvm),stat=ier) 
     322  IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'permafrost_veg_exists : error in memory allocation', '', '') 
     323 
     324!!!qcj++ peatland 
     325  ALLOCATE(is_peat(nvm),stat=ier) 
     326  IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'is_peat : error in memory allocation', '', '') 
     327  DO i = 1, nvm 
     328     is_peat(i) = is_peat_mtc(pft_to_mtc(i)) 
     329  ENDDO 
     330 
     331 
     332  ! 5.2 Initialisation 
     333  DO i = 1, nvm 
     334     natural(i) = natural_mtc(pft_to_mtc(i)) 
     335     is_c4(i) = is_c4_mtc(pft_to_mtc(i)) 
     336  ENDDO 
     337 
     338  DO i = 1, nvm 
     339     permafrost_veg_exists(i) = permafrost_veg_exists_mtc(pft_to_mtc(i)) 
     340  ENDDO 
    323341  !!-  
    324342  !! 1. Initialisation stage 
     
    337355     CALL getin ('STOMATE_RESTART_FILEOUT',sto_restname_out) 
    338356     WRITE(numout,*) 'STOMATE OUTPUT RESTART_FILE: ',TRIM(sto_restname_out) 
    339      !IF (ok_pc) CALL getin ('satsoil', satsoil) 
    340      CALL getin ('satsoil', satsoil) 
     357     IF (ok_pc) CALL getin ('satsoil', satsoil) 
    341358     !- 
    342359     ! Open the input file and Get some Dimension and Attributes ID's  
     
    348365     CALL nccheck( NF90_GET_ATT (rest_id_sto, iv, 'calendar',thecalendar)) 
    349366     CALL nccheck( NF90_CLOSE (rest_id_sto)) 
    350  
    351367     i=INDEX(thecalendar,ACHAR(0)) 
    352368     IF ( i > 0 ) THEN 
     
    380396  CALL ioconf_startdate(date0) 
    381397  ! 
    382   !IF (ok_pc) THEN 
    383   !       !- Permafrost variables (zz_deep and zz_coef_deep are constants) 
     398  IF (ok_pc) THEN 
     399         !- Permafrost variables (zz_deep and zz_coef_deep are constants) 
    384400         ALLOCATE (zz_deep(ndeep), stat=ier) 
    385401         IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'zz_deep : error in memory allocation', '', '') 
    386402         ALLOCATE (zz_coef_deep(ndeep), stat=ier) 
    387403         IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'zz_coef_deep : error in memory allocation', '', '') 
    388   !ENDIF 
     404  ENDIF 
    389405 
    390406  !- 
     
    409425     ! and allocate variables. 
    410426     !- 
    411  
    412427     CALL nccheck( NF90_OPEN (TRIM(Cforcing_name),NF90_NOWRITE,Cforcing_id)) 
    413428     !- 
     
    428443     ALLOCATE (clay_g(nbp_glo), stat=ier) 
    429444     IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'clay_g : error in memory allocation', '', '') 
    430      ALLOCATE (bulk_dens_g(nbp_glo), stat=ier) 
    431      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'bulk_dens_g : error in memory allocation', '', '') 
    432      ALLOCATE (soil_ph_g(nbp_glo), stat=ier) 
    433      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'soil_ph_g : error in memory allocation', '', '') 
    434      ALLOCATE (poor_soils_g(nbp_glo), stat=ier) 
    435      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'poor_soils_g : error in memory allocation', '', '') 
    436  
    437  
    438  
    439445     !- 
    440446     ALLOCATE (x_indices_g(nbp_glo),stat=ier) 
     
    448454     CALL nccheck( NF90_INQ_VARID (Cforcing_id,'clay',v_id)) 
    449455     CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,clay_g)) 
    450      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'bulk_dens',v_id)) 
    451      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,bulk_dens_g)) 
    452      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'soil_ph',v_id)) 
    453      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,soil_ph_g)) 
    454      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'poor_soils',v_id)) 
    455      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,poor_soils_g)) 
    456      !- 
    457      !IF (ok_pc) THEN 
     456     !- 
     457     IF (ok_pc) THEN 
    458458         !- Permafrost variables (zz_deep and zz_coef_deep are constants) 
    459          !ALLOCATE (zz_deep(ndeep)) 
    460          !ALLOCATE (zz_coef_deep(ndeep)) 
     459!         ALLOCATE (zz_deep(ndeep)) 
     460!         ALLOCATE (zz_coef_deep(ndeep)) 
    461461         ALLOCATE (z_organic_g(nbp_glo), stat=ier) 
    462462         IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'z_organic_g : error in memory allocation', '', '') 
    463463         CALL nccheck( NF90_INQ_VARID (Cforcing_id,'zz_deep',v_id)) 
    464          CALL nccheck( NF90_GET_VAR (Cforcing_id,v_id,zz_deep, start=(/1/) , count=(/ndeep/))) 
     464         CALL nccheck( NF90_GET_VAR (Cforcing_id,v_id,zz_deep)) 
    465465         CALL nccheck( NF90_INQ_VARID (Cforcing_id,'zz_coef_deep',v_id)) 
    466          CALL nccheck( NF90_GET_VAR (Cforcing_id,v_id,zz_coef_deep, start=(/1/) , count=(/ndeep/))) 
    467      IF (ok_pc) THEN 
     466         CALL nccheck( NF90_GET_VAR (Cforcing_id,v_id,zz_coef_deep)) 
    468467         CALL nccheck( NF90_INQ_VARID (Cforcing_id,'z_organic',v_id)) 
    469468         CALL nccheck( NF90_GET_VAR (Cforcing_id,v_id,z_organic_g)) 
     
    485484        IF (.NOT. ok_peat) THEN 
    486485            taboo_vars ='$lon$ $lat$ $lev$ $nav_lon$ $nav_lat$ $nav_lev$ $time$ $time_steps$ '// & 
    487               &             '$day_counter$ $dt_days$ $date$  $carbon_32l_a$ $carbon_32l_s$ '// & 
    488               &             '$carbon_32l_p$ $freedoc$ $adsdoc$ $altmax$ '  
     486              &             '$day_counter$ $dt_days$ $date$ $carbon$ ' 
    489487        ENDIF 
    490488        IF (ok_peat) THEN 
    491489           taboo_vars = '$lon$ $lat$ $lev$ $nav_lon$ $nav_lat$ $nav_lev$ $time$ $time_steps$'// & 
    492            &            '$day_counter$ $dt_days$ $date$ $carbon_32l_a$ $carbon_32l_s$ '// & 
    493            &            '$carbon_32l_p$ $freedoc$ $adsdoc$ $carbon_acro$ $carbon_cato$ $height_acro$ '// & 
    494            &            '$altmax$ $deepC_peat$' 
     490           &            '$day_counter$ $dt_days$ $date$ $carbon$'// & 
     491           &            '$carbon_acro$ $carbon_cato$ $height_acro$ ' 
    495492        ENDIF 
    496493         !- 
     
    630627     CALL tlen2itau(time_str, dt_forcesoil*one_day, date0, itau_len) 
    631628     write(numout,*) 'Number of time steps to do: ',itau_len 
    632      CALL control_initialize(dt_sechiba) 
    633  
    634   ! 1. Read the number of PFTs 
    635   ! 
    636   !Config Key   = NVM 
    637   !Config Desc  = number of PFTs   
    638   !Config If    = OK_SECHIBA or OK_STOMATE 
    639   !Config Def   = 13 
    640   !Config Help  = The number of vegetation types define by the user 
    641   !Config Units = [-] 
    642   CALL getin_p('NVM',nvm) 
    643  
    644  
    645   ! 2. Allocation 
    646  ! ALLOCATE(pft_to_mtc(nvm),stat=ier) 
    647  ! IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'pft_to_mtc : error in memory allocation', '', '') 
    648  
    649   ! 3. Initialisation of the correspondance table 
    650   pft_to_mtc(:) = undef_int 
    651  
    652   ! 4.Reading of the conrrespondance table in the .def file 
    653   ! 
    654   !Config Key   = PFT_TO_MTC 
    655   !Config Desc  = correspondance array linking a PFT to MTC 
    656   !Config if    = OK_SECHIBA or OK_STOMATE 
    657   !Config Def   = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 
    658   !Config Help  = 
    659   !Config Units = [-] 
    660   CALL getin_p('PFT_TO_MTC',pft_to_mtc) 
    661  
    662  
    663   ! 4.1 if nothing is found, we use the standard configuration 
    664 !!!qcj++ peatland 
    665   IF (ok_peat .OR. perma_peat) THEN 
    666      IF(nvm <= nvmc ) THEN 
    667        IF(pft_to_mtc(1) == undef_int) THEN 
    668           pft_to_mtc(:) = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ,15/) 
    669        ENDIF 
    670      ENDIF 
    671   ELSE 
    672      IF(nvm <= nvmc ) THEN 
    673         IF(pft_to_mtc(1) == undef_int) THEN 
    674            WRITE(numout,*) 'Note to the user : we will use ORCHIDEE to its standard configuration' 
    675            pft_to_mtc(:) = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 /) 
    676         ENDIF 
    677      ELSE 
    678         IF(pft_to_mtc(1) == undef_int) THEN 
    679            WRITE(numout,*)' The array PFT_TO_MTC is empty : we stop' 
    680         ENDIF 
    681      ENDIF 
    682   ENDIF 
    683  
    684  
    685   ! 4.2 What happened if pft_to_mtc(j) > nvmc (if the mtc doesn't exist)? 
    686   DO i = 1, nvm 
    687      IF(pft_to_mtc(i) > nvmc) THEN 
    688         CALL ipslerr_p(3, 'forcesoil', 'the MTC you chose doesnt exist', 'we stop reading pft_to_mtc', '') 
    689      ENDIF 
    690   ENDDO 
    691  
    692   ! 4.3 Check if pft_to_mtc(1) = 1  
    693   IF(pft_to_mtc(1) /= 1) THEN 
    694      CALL ipslerr_p(3, 'forcesoil', 'the first pft has to be the bare soil', 'we stop reading next values of pft_to_mtc', '') 
    695   ENDIF 
    696  
    697   DO i = 2,nvm 
    698      IF(pft_to_mtc(i) == 1) THEN 
    699         CALL ipslerr_p(3, 'forcesoil', 'only pft_to_mtc(1) has to be the bare soil', 'we stop reading next values of pft_to_mtc', '') 
    700      ENDIF 
    701   ENDDO 
    702  
    703   ! 5. Allocate and initialize natural and is_c4 
    704  
    705   ! 5.1 Memory allocation 
    706   !ALLOCATE(natural(nvm),stat=ier) 
    707   !IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'natural : error in memory allocation', '', '') 
    708  
    709   !ALLOCATE(is_c4(nvm),stat=ier) 
    710   !IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'is_c4 : error in memory allocation', '', '') 
    711  
    712   !ALLOCATE(permafrost_veg_exists(nvm),stat=ier) 
    713   !IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'permafrost_veg_exists : error in memory allocation', '', '') 
    714  
    715 !!!qcj++ peatland 
    716   !ALLOCATE(is_peat(nvm),stat=ier) 
    717   !IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'is_peat : error in memory allocation', '', '') 
    718   DO i = 1, nvm 
    719      is_peat(i) = is_peat_mtc(pft_to_mtc(i)) 
    720   ENDDO 
    721  
    722  
    723   ! 5.2 Initialisation 
    724   DO i = 1, nvm 
    725      natural(i) = natural_mtc(pft_to_mtc(i)) 
    726      is_c4(i) = is_c4_mtc(pft_to_mtc(i)) 
    727   ENDDO 
    728  
    729   DO i = 1, nvm 
    730      permafrost_veg_exists(i) = permafrost_veg_exists_mtc(pft_to_mtc(i)) 
    731   ENDDO 
     629 
    732630 
    733631     ! read soil carbon stocks values stored in the input restart file 
    734632     !- 
    735633     IF (.NOT. ok_pc) THEN 
    736            ALLOCATE(carbon_32l_g(nbp_glo,ncarb,nvm,ndeep), stat=ier) 
    737            IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'carbon_32l_g : error in memory allocation', '', '') 
    738            carbon_32l_g(:,:,:,:) = val_exp 
    739            var_name = 'carbon_32l_a' 
    740            CALL restget (rest_id_sto, var_name, nbp_glo, nvm, ndeep, itau_dep, & 
    741                 &               .TRUE., carbon_32l_g(:,iactive,:,:), 'gather', nbp_glo, indices_g) 
    742  
    743            var_name = 'carbon_32l_s' 
    744            CALL restget (rest_id_sto, var_name, nbp_glo,  nvm, ndeep, itau_dep, & 
    745                 &               .TRUE., carbon_32l_g(:,islow,:,:), 'gather', nbp_glo, indices_g) 
    746            var_name = 'carbon_32l_p' 
    747            CALL restget (rest_id_sto, var_name, nbp_glo,  nvm, ndeep, itau_dep, & 
    748                 &               .TRUE., carbon_32l_g(:,ipassive,:,:), 'gather', nbp_glo, indices_g) 
    749            IF (ALL(carbon_32l_g == val_exp)) carbon_32l_g = zero 
    750  
    751  
    752            ALLOCATE(DOC_g(nbp_glo,nvm,ndeep,ndoc,npool,nelements), stat=ier) 
    753            IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'DOC_g : error in memory allocation', '', '') 
    754            DOC_g(:,:,:,:,:,:) = val_exp 
    755            var_name = 'freedoc' 
    756            CALL restget (rest_id_sto, var_name, nbp_glo, nvm, ndeep, npool, nelements, itau_dep, & 
    757                 &                   .TRUE., DOC_g(:,:,:,ifree,:,:), 'gather', nbp_glo, indices_g) 
    758            IF (ALL(DOC_g(:,:,:,ifree,:,:)== val_exp))DOC_g(:,:,:,ifree,:,:) = zero 
    759  
    760            var_name = 'adsdoc' 
    761            CALL restget (rest_id_sto, var_name, nbp_glo, nvm ,ndeep, npool, nelements, itau_dep, & 
    762                 &                   .TRUE., DOC_g(:,:,:,iadsorbed,:,:), 'gather', nbp_glo, indices_g) 
    763            IF (ALL(DOC_g(:,:,:,iadsorbed,:,:)== val_exp))DOC_g(:,:,:,iadsorbed,:,:) = zero 
    764  
    765            ALLOCATE(altmax_g(nbp_glo,nvm), stat=ier) 
    766            IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'altmax_g : error in memory allocation', '', '') 
    767            var_name= 'altmax' 
    768            altmax_g(:,:) = val_exp 
    769            CALL restget (rest_id_sto, var_name, nbp_glo, nvm, 1, itau_dep, .TRUE., altmax_g, "gather", nbp_glo, indices_g) 
    770            IF ( ALL( altmax_g(:,:) .EQ. val_exp ) ) THEN 
    771                CALL ipslerr(3, 'forcesoil', 'altmax is not found in stomate restart file', '', '') 
    772            END IF 
    773  
    774 !           ALLOCATE(carbon_g(nbp_glo,ncarb,nvm), stat=ier) 
    775 !           IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'carbon_g : error in memory allocation', '', '') 
    776 !           carbon_g(:,:,:) = val_exp 
    777 !           CALL restget & 
    778 !                &    (rest_id_sto, 'carbon', nbp_glo, ncarb , nvm, itau_dep, & 
    779 !                &     .TRUE., carbon_g, 'gather', nbp_glo, indices_g) 
    780 !           IF (ALL(carbon_g == val_exp)) carbon_g = zero 
     634           ALLOCATE(carbon_g(nbp_glo,ncarb,nvm), stat=ier) 
     635           IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'carbon_g : error in memory allocation', '', '') 
     636           carbon_g(:,:,:) = val_exp 
     637           CALL restget & 
     638                &    (rest_id_sto, 'carbon', nbp_glo, ncarb , nvm, itau_dep, & 
     639                &     .TRUE., carbon_g, 'gather', nbp_glo, indices_g) 
     640           IF (ALL(carbon_g == val_exp)) carbon_g = zero 
    781641!           WRITE(numout,*) "date0 : ",date0, itau_dep 
    782642 
     
    950810     ALLOCATE(control_moist(kjpindex,nlevs,nparan*nbyear), stat=ier) 
    951811     IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'control_moist : error in memory allocation', '', '') 
    952      ALLOCATE(tprof(kjpindex,ndeep,nvm,nparan*nbyear), stat=ier) 
    953      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'tprof : error in memory allocation', '', '') 
    954      ALLOCATE(fbact(kjpindex,ndeep,nvm,nparan*nbyear), stat=ier) 
    955      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'fbact : error in memory allocation', '', '') 
    956      ALLOCATE(snowdz(kjpindex,nsnow,nparan*nbyear), stat=ier) 
    957      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'snowdz_ : error in memory allocation', '', '') 
    958      ALLOCATE(veget_max(kjpindex,nvm,nparan*nbyear), stat=ier) 
    959      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'veget_max : error in memory allocation', '', '') 
    960812     ALLOCATE(soilcarbon_input(kjpindex,ncarb,nvm,nparan*nbyear), stat=ier) 
    961813     IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'soilcarbon_input : error in memory allocation', '', '') 
    962      ALLOCATE(soilcarbon_input_DOC(kjpindex,nvm,ndeep,npool,nelements,nparan*nbyear), stat=ier) 
    963      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'soilcarbon_input_DOC : error in memory allocation', '', '') 
    964      ALLOCATE(floodcarbon_input(kjpindex,nvm,npool,nelements,nparan*nbyear), stat=ier) 
    965      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'floodcarbon_input : error in memory allocation', '', '') 
    966      ALLOCATE(litter_above(kjpindex,nlitt,nvm,nelements,nparan*nbyear), stat=ier) 
    967      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'litter_above : error in memory allocation', '', '') 
    968      ALLOCATE(litter_below(kjpindex,nlitt,nvm,ndeep,nelements,nparan*nbyear), stat=ier) 
    969      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'litter_below : error in memory allocation', '', '') 
    970      ALLOCATE(lignin_struc_above(kjpindex,nvm,nparan*nbyear), stat=ier) 
    971      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'lignin_struc_above : error in memory allocation', '', '') 
    972      ALLOCATE(lignin_struc_below(kjpindex,nvm,ndeep,nparan*nbyear), stat=ier) 
    973      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'lignin_struc_below : error in memory allocation', '', '') 
    974      ALLOCATE(runoff_per_soil(kjpindex,nstm,nparan*nbyear), stat=ier) 
    975      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'runoff_per_soil : error in memory allocation', '', '') 
    976      ALLOCATE(runoff2peat(kjpindex,nstm,nparan*nbyear), stat=ier) 
    977      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'runoff2peat : error in memory allocation', '', '') 
    978      ALLOCATE(drainage_per_soil(kjpindex,nstm,nparan*nbyear), stat=ier) 
    979      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'drainage_per_soil : error in memory allocation', '', '') 
    980      ALLOCATE(wat_flux(kjpindex,nslm,nstm,nparan*nbyear), stat=ier) 
    981      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'wat_flux : error in memory allocation', '', '') 
    982      ALLOCATE(soil_mc_32l(kjpindex,ndeep,nstm,nparan*nbyear), stat=ier) 
    983      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'soil_mc_32l : error in memory allocation', '', '') 
    984      ALLOCATE(soil_mc(kjpindex,nslm,nstm,nparan*nbyear), stat=ier) 
    985      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'soil_mc : error in memory allocation', '', '') 
    986      ALLOCATE(DOC_to_topsoil(kjpindex,nflow,nparan*nbyear), stat=ier) 
    987      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'DOC_to_topsoil : error in memory allocation', '', '') 
    988      ALLOCATE(precip2ground(kjpindex,nvm,nparan*nbyear), stat=ier) 
    989      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'precip2ground : error in memory allocation', '', '') 
    990      ALLOCATE(interception_storage(kjpindex,nvm,nelements,nparan*nbyear), stat=ier) 
    991      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'interception_storage : error in memory allocation', '', '') 
    992      ALLOCATE(biomass(kjpindex,nvm,nparts,nelements,nparan*nbyear), stat=ier) 
    993      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'biomass : error in memory allocation', '', '') 
    994      ALLOCATE(fastr(kjpindex,nparan*nbyear), stat=ier) 
    995      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'fastr : error in memory allocation', '', '') 
    996      ALLOCATE(precip2canopy(kjpindex,nvm,nparan*nbyear), stat=ier) 
    997      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'precip2canopy : error in memory allocation', '', '') 
    998      ALLOCATE(canopy2ground(kjpindex,nvm,nparan*nbyear), stat=ier) 
    999      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'canopy2ground : error in memory allocation', '', '') 
    1000      ALLOCATE(DOC_to_subsoil(kjpindex,nflow,nparan*nbyear), stat=ier) 
    1001      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'DOC_to_subsoil : error in memory allocation', '', '') 
    1002      ALLOCATE(flood_frac(kjpindex,nparan*nbyear), stat=ier) 
    1003      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'flood_frac : error in memory allocation', '', '') 
    1004      ALLOCATE(lalo(kjpindex,2), stat=ier) 
    1005      IF (ier /= 0) CALL ipslerr(3, 'forcesoil', 'lalo : error in memory allocation', '', '') 
    1006814     !- 
    1007815!!!qcj++ peatland 
     
    1016824     ENDIF 
    1017825 
    1018         start_2d=(/ nbp_mpi_para_begin(mpi_rank), 1 /) 
    1019         count_2d=(/  nbp_mpi_para(mpi_rank), nparan*nbyear /) 
    1020         CALL nccheck( NF90_INQ_VARID (Cforcing_id,'fastr',v_id)) 
    1021         CALL nccheck( NF90_GET_VAR (Cforcing_id,v_id,fastr, & 
    1022                      & start=start_2d, count=count_2d)) 
    1023  
    1024         start_2d=(/ nbp_mpi_para_begin(mpi_rank), 1 /) 
    1025         count_2d=(/  nbp_mpi_para(mpi_rank), nparan*nbyear /) 
    1026         CALL nccheck( NF90_INQ_VARID (Cforcing_id,'flood_frac',v_id)) 
    1027         CALL nccheck( NF90_GET_VAR (Cforcing_id,v_id,flood_frac, & 
    1028                      & start=start_2d, count=count_2d)) 
    1029  
    1030         start_2d=(/ nbp_mpi_para_begin(mpi_rank), 1 /) 
    1031         count_2d=(/  nbp_mpi_para(mpi_rank), 2 /) 
    1032         CALL nccheck( NF90_INQ_VARID (Cforcing_id,'lalo',v_id)) 
    1033         CALL nccheck( NF90_GET_VAR (Cforcing_id,v_id,lalo, & 
    1034                      & start=start_2d, count=count_2d)) 
    1035  
    1036      start_3d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1 /) 
    1037      count_3d = (/ nbp_mpi_para(mpi_rank), nflow, nparan*nbyear /) 
    1038      CALL nccheck( NF90_INQ_VARID (Cforcing_id,   'DOC_to_subsoil',v_id)) 
    1039      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,DOC_to_subsoil, & 
    1040                        & start = start_3d, count = count_3d)) 
    1041      CALL nccheck( NF90_INQ_VARID (Cforcing_id,   'DOC_to_topsoil',v_id)) 
    1042      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,DOC_to_topsoil, & 
    1043                        & start = start_3d, count = count_3d)) 
    1044      start_3d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1 /) 
    1045      count_3d = (/ nbp_mpi_para(mpi_rank), nvm, nparan*nbyear /) 
    1046      CALL nccheck( NF90_INQ_VARID (Cforcing_id,   'canopy2ground',v_id)) 
    1047      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,canopy2ground, & 
    1048                        & start = start_3d, count = count_3d)) 
    1049      CALL nccheck( NF90_INQ_VARID (Cforcing_id,   'precip2canopy',v_id)) 
    1050      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,precip2canopy, & 
    1051                        & start = start_3d, count = count_3d)) 
    1052      CALL nccheck( NF90_INQ_VARID (Cforcing_id,   'veget_max',v_id)) 
    1053      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,veget_max, & 
    1054                        & start = start_3d, count = count_3d)) 
    1055      CALL nccheck( NF90_INQ_VARID (Cforcing_id,   'precip2ground',v_id)) 
    1056      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,precip2ground, & 
    1057                        & start = start_3d, count = count_3d)) 
    1058      CALL nccheck( NF90_INQ_VARID (Cforcing_id,   'lignin_struc_above',v_id)) 
    1059      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,lignin_struc_above, & 
    1060                        & start = start_3d, count = count_3d)) 
    1061      start_3d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1 /) 
    1062      count_3d = (/ nbp_mpi_para(mpi_rank), nstm, nparan*nbyear /) 
    1063      CALL nccheck( NF90_INQ_VARID (Cforcing_id,   'drainage_per_soil',v_id)) 
    1064      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,drainage_per_soil, & 
    1065                        & start = start_3d, count = count_3d)) 
    1066      CALL nccheck( NF90_INQ_VARID (Cforcing_id,   'runoff2peat',v_id)) 
    1067      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,runoff2peat, & 
    1068                        & start = start_3d, count = count_3d)) 
    1069      CALL nccheck( NF90_INQ_VARID (Cforcing_id,   'runoff_per_soil',v_id)) 
    1070      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,runoff_per_soil, & 
    1071                        & start = start_3d, count = count_3d)) 
    1072      ! 
    1073826     start_4d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1, 1 /) 
    1074      count_4d = (/ nbp_mpi_para(mpi_rank), nslm, nstm, nparan*nbyear /) 
    1075      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'wat_flux',v_id)) 
    1076      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,wat_flux,  & 
    1077                     &  start = start_4d, count = count_4d )) 
    1078  
    1079      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'soil_mc',v_id)) 
    1080      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,soil_mc,  & 
    1081                     &  start = start_4d, count = count_4d )) 
    1082  
    1083      start_4d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1, 1 /) 
    1084      count_4d = (/ nbp_mpi_para(mpi_rank), ndeep, nstm, nparan*nbyear /) 
    1085      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'soil_mc_32l',v_id)) 
    1086      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,soil_mc_32l,  & 
    1087                     &  start = start_4d, count = count_4d )) 
    1088  
    1089      start_4d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1, 1 /) 
    1090      count_4d = (/ nbp_mpi_para(mpi_rank), nvm, nelements, nparan*nbyear /) 
    1091      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'interception_storage',v_id)) 
    1092      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,interception_storage,  & 
    1093                     &  start = start_4d, count = count_4d )) 
    1094  
    1095      start_4d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1, 1 /) 
    1096      count_4d = (/ nbp_mpi_para(mpi_rank), nvm, ndeep, nparan*nbyear /) 
    1097      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'lignin_struc_below',v_id)) 
    1098      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,lignin_struc_below,  & 
     827     count_4d = (/ nbp_mpi_para(mpi_rank), ncarb, nvm, nparan*nbyear /) 
     828     CALL nccheck( NF90_INQ_VARID (Cforcing_id,'soilcarbon_input',v_id)) 
     829     CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,soilcarbon_input,  & 
    1099830                    &  start = start_4d, count = count_4d )) 
    1100831     ! 
    1101      start_5d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1, 1, 1 /) 
    1102      count_5d = (/ nbp_mpi_para(mpi_rank), nvm, nparts, nelements, nparan*nbyear /) 
    1103      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'biomass',v_id)) 
    1104      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,biomass,  & 
    1105                     &  start = start_5d, count = count_5d )) 
    1106  
    1107      start_5d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1, 1, 1 /) 
    1108      count_5d = (/ nbp_mpi_para(mpi_rank), nlitt, nvm, nelements, nparan*nbyear /) 
    1109      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'litter_above',v_id)) 
    1110      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,litter_above,  & 
    1111                     &  start = start_5d, count = count_5d )) 
    1112  
    1113      start_5d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1, 1, 1 /) 
    1114      count_5d = (/ nbp_mpi_para(mpi_rank), nvm, npool, nelements, nparan*nbyear /) 
    1115      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'floodcarbon_input',v_id)) 
    1116      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,floodcarbon_input,  & 
    1117                     &  start = start_5d, count = count_5d )) 
    1118      start_6d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1, 1, 1, 1 /) 
    1119      count_6d = (/ nbp_mpi_para(mpi_rank), nvm, ndeep, npool, nelements, nparan*nbyear /) 
    1120      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'soilcarbon_input_DOC',v_id)) 
    1121      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,soilcarbon_input_DOC,  & 
    1122                     &  start = start_6d, count = count_6d )) 
    1123  
    1124      start_6d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1, 1, 1, 1 /) 
    1125      count_6d = (/ nbp_mpi_para(mpi_rank), nlitt, nvm, ndeep, nelements, nparan*nbyear /) 
    1126      CALL nccheck( NF90_INQ_VARID (Cforcing_id,'litter_below',v_id)) 
    1127      CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,litter_below,  & 
    1128                     &  start = start_6d, count = count_6d )) 
    1129 !     start_3d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1 /) 
    1130 !     count_3d = (/ nbp_mpi_para(mpi_rank), nlevs, nparan*nbyear /) 
    1131 !     CALL nccheck( NF90_INQ_VARID (Cforcing_id,   'control_moist',v_id)) 
    1132 !     CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,control_moist, & 
    1133 !                       & start = start_3d, count = count_3d)) 
    1134 !     CALL nccheck( NF90_INQ_VARID (Cforcing_id,    'control_temp',v_id)) 
    1135 !     CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,control_temp, & 
    1136 !                       & start = start_3d, count = count_3d)) 
     832     start_3d = (/ nbp_mpi_para_begin(mpi_rank), 1, 1 /) 
     833     count_3d = (/ nbp_mpi_para(mpi_rank), nlevs, nparan*nbyear /) 
     834     CALL nccheck( NF90_INQ_VARID (Cforcing_id,   'control_moist',v_id)) 
     835     CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,control_moist, & 
     836                       & start = start_3d, count = count_3d)) 
     837     CALL nccheck( NF90_INQ_VARID (Cforcing_id,    'control_temp',v_id)) 
     838     CALL nccheck( NF90_GET_VAR   (Cforcing_id,v_id,control_temp, & 
     839                       & start = start_3d, count = count_3d)) 
    1137840     !- Close Netcdf carbon permafrost file reference 
    1138841     CALL nccheck( NF90_CLOSE (Cforcing_id)) 
     
    1196899  ALLOCATE(clay(kjpindex), stat=ier) 
    1197900  IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'clay : error in memory allocation', '', '') 
    1198   ALLOCATE(bulk_dens(kjpindex), stat=ier) 
    1199   IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'bulk_dens : error in memory allocation', '', '') 
    1200   ALLOCATE(soil_ph(kjpindex), stat=ier) 
    1201   IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'soil_ph : error in memory allocation', '', '') 
    1202   ALLOCATE(poor_soils(kjpindex), stat=ier) 
    1203   IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'poor_soils : error in memory allocation', '', '') 
    1204901  ALLOCATE(carbon(kjpindex,ncarb,nvm), stat=ier) 
    1205902  IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'indices : error in memory allocation', '', '') 
    1206   ALLOCATE(carbon_32l(kjpindex,ncarb,nvm,ndeep), stat=ier) 
    1207   IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'indices : error in memory allocation', '', '') 
    1208   ALLOCATE(DOC(kjpindex,nvm,ndeep,ndoc,npool,nelements), stat=ier) 
    1209   IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'indices : error in memory allocation', '', '') 
    1210  
    1211903  !- 
    1212904  IF (.NOT. ok_pc) THEN 
     
    1215907  !   ALLOCATE(control_moist(kjpindex,nlevs,nparan*nbyear), stat=ier) 
    1216908  !   IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'control_moist : error in memory allocation', '', '') 
    1217      ALLOCATE(resp_flood_soil(kjpindex,nvm), stat=ier) 
    1218      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'resp_flood_soil : error in memory allocation', '', '') 
    1219      ALLOCATE(dry_dep_canopy(kjpindex,nvm,nelements), stat=ier) 
    1220      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'dry_dep_canopy : error in memory allocation', '', '') 
    1221      ALLOCATE(DOC_precip2ground(kjpindex,nvm,nelements), stat=ier) 
    1222      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'DOC_precip2ground : error in memory allocation', '', '') 
    1223      ALLOCATE(DOC_precip2canopy(kjpindex,nvm,nelements), stat=ier) 
    1224      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'DOC_precip2canopy : error in memory allocation', '', '') 
    1225      ALLOCATE(DOC_canopy2ground(kjpindex,nvm,nelements), stat=ier) 
    1226      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'DOC_canopy2ground : error in memory allocation', '', '') 
    1227      ALLOCATE(DOC_EXP(kjpindex,nvm,nexp,npool,nelements), stat=ier) 
    1228      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'DOC_EXP : error in memory allocation', '', '') 
    1229      ALLOCATE(altmax(kjpindex,nvm), stat=ier) 
    1230      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'altmax : error in memory allocation', '', '') 
     909     ALLOCATE(resp_hetero_soil(kjpindex,nvm), stat=ier) 
     910     IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'resp_hetero_soil : error in memory allocation', '', '') 
    1231911     ALLOCATE(matrixA(kjpindex,nvm,nbpools,nbpools), stat=ier) 
    1232912     IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'matrixA : error in memory allocation', '', '') 
    1233      IF (perma_peat) THEN 
    1234         ALLOCATE(deepC_peat(kjpindex,ndeep,nvm), stat=ier) 
    1235         IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'deepC_peat : error in memory allocation', '', '') 
    1236      ENDIF 
    1237      !ALLOCATE(diaglev(nslm), stat=ier) 
    1238      !IF (ier /= 0) CALL ipslerr_p(3,'forcesoil','Pb in allocation of diaglev','','') 
    1239      !diaglev=znt(1:nslm) 
    1240  
    1241913     DO i = 1,nbpools 
    1242914        matrixA(:,:,i,i) = un 
     
    1289961  !- 
    1290962  CALL Scatter(clay_g,clay) 
    1291   CALL Scatter(bulk_dens_g,bulk_dens) 
    1292   CALL Scatter(soil_ph_g,soil_ph) 
    1293   CALL Scatter(poor_soils_g,poor_soils) 
    1294   CALL Scatter(altmax_g,altmax) 
    1295  
    1296   DO i=1,nelements 
    1297      DO j= 1,npool 
    1298         CALL Scatter(DOC_g(:,:,:,:,j,i),DOC(:,:,:,:,j,i)) 
    1299      ENDDO 
    1300   ENDDO 
    1301   CALL Scatter(carbon_32l_g,carbon_32l) 
    1302 !  CALL Scatter(carbon_g,carbon) 
     963  CALL Scatter(carbon_g,carbon) 
    1303964!!!qcj peatland++ 
    1304965  IF (ok_peat) THEN 
     
    14171078  !!- 
    14181079 
    1419       ALLOCATE(fixed_cryoturbation_depth(kjpindex,nvm), stat=ier) 
    1420       IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', '2fixed_cryoturbation_depth : error in memory allocation', '', '') 
    1421       ALLOCATE(resp_hetero_soil(kjpindex, nvm), stat=ier) 
    1422       IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'resp_hetero_soil : error in memory allocation', '', '') 
    1423       IF (ok_pc) THEN 
    1424          ALLOCATE(heat_Zimov(kjpindex,ndeep,nvm), stat=ier) 
    1425          IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'heat_Zimov : error in memory allocation', '', '') 
    1426          ALLOCATE(sfluxCH4_deep(kjpindex), stat=ier) 
    1427          IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'sfluxCH4_deep : error in memory allocation', '', '') 
    1428          ALLOCATE(sfluxCO2_deep(kjpindex), stat=ier) 
    1429          IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'sfluxCO2_deep : error in memory allocation', '', '') 
    1430       ENDIF 
    1431  
    1432   IF (.NOT. ok_pc) THEN 
     1080 
     1081  IF (.NOT.ok_pc) THEN 
    14331082      iatt=0 
    14341083      iyear=1 
     
    14361085         iatt = iatt+1 
    14371086         IF (iatt > nparan*nbyear) THEN 
    1438             IF (printlev>=3) WRITE(*,*) "iyear",iyear 
    1439             IF (printlev>=3) WRITE(*,*) "iatt",iatt 
    1440             IF (printlev>=3) WRITE(*,*) "nparan*nbyear",nparan*nbyear 
     1087            IF (printlev>=3) WRITE(numout,*) iyear 
    14411088            iatt = 1 
    14421089            iyear=iyear+1 
    14431090         ENDIF 
    1444          IF (ok_leak) THEN 
    1445 !WRITE(*,*) "altmax",altmax(:,:) 
    1446 !WRITE(*,*) "altmax_g",altmax_g(:,:) 
    1447 !WRITE(*,*) "zz_coef_deep",zz_coef_deep(:) 
    1448 !WRITE(*,*) "diaglev",diaglev(:) 
    1449 !WRITE(*,*) "lalo", lalo(:,:) 
    1450 !WRITE(*,*) "nslm",nslm 
    1451 !WRITE(*,*) "nstm",nstm 
    1452 !WRITE(*,*) "nvm",nvm 
    1453 !WRITE(*,*) " nparts",nparts 
    1454 !WRITE(*,*) " nelements",nelements 
    1455 !WRITE(*,*) " ndeep",ndeep 
    1456           CALL soilcarbon_leak (kjpindex, dt_forcesoil*one_day, zz_coef_deep, clay, force_soil, & 
    1457              soilcarbon_input(:,:,:,iatt), soilcarbon_input_DOC(:,:,:,:,:,iatt), floodcarbon_input(:,:,:,:,iatt), & 
    1458              carbon, carbon_32l, & 
    1459              resp_hetero_soil, resp_flood_soil, & 
    1460 !!Permafrost carbon variables added here: 
    1461              altmax, lalo, & 
    1462              iatt, zz_deep, & 
    1463              snowdz(:,:,iatt), fixed_cryoturbation_depth, & 
    1464 !!MICT END 
    1465              litter_above(:,:,:,:,iatt),litter_below(:,:,:,:,:,iatt),& 
    1466              DOC, DOC_EXP, & 
    1467              lignin_struc_above(:,:,iatt), lignin_struc_below(:,:,:,iatt), & 
    1468              runoff_per_soil(:,:,iatt), runoff2peat(:,:,iatt), drainage_per_soil(:,:,iatt), wat_flux(:,:,:,iatt), & 
    1469              bulk_dens, soil_ph, poor_soils, veget_max, fbact(:,:,:,iatt), tprof(:,:,:,iatt), & 
    1470              soil_mc_32l(:,:,:,iatt), soil_mc(:,:,:,iatt),& 
    1471              DOC_to_topsoil(:,:,iatt), DOC_to_subsoil(:,:,iatt), flood_frac(:,iatt), & 
    1472              precip2ground(:,:,iatt), precip2canopy(:,:,iatt), canopy2ground(:,:,iatt), & 
    1473              dry_dep_canopy, DOC_precip2ground, DOC_precip2canopy, DOC_canopy2ground, & 
    1474              interception_storage, biomass, fastr,& 
    1475              deepC_peat) 
    1476          ELSE 
    1477  
    1478             CALL soilcarbon & 
    1479                  &    (kjpindex, dt_forcesoil, clay, & 
    1480                  &     soilcarbon_input(:,:,:,iatt), & 
    1481                  &     control_temp(:,:,iatt), control_moist(:,:,iatt), & 
    1482                  &     carbon, resp_hetero_soil, & 
    1483                  &     matrixA, & 
    1484 !!!qcj++ peatland 
    1485                  & height_acro,height_cato,carbon_acro,carbon_cato,tcarbon_acro,tcarbon_cato,resp_acro_oxic,& 
    1486                  & resp_acro_anoxic,resp_cato,acro_to_cato,litter_to_acro, wtp_pt(:,iatt)) 
    1487          ENDIF 
     1091         CALL soilcarbon & 
     1092              &    (kjpindex, dt_forcesoil, clay, & 
     1093              &     soilcarbon_input(:,:,:,iatt), & 
     1094              &     control_temp(:,:,iatt), control_moist(:,:,iatt), & 
     1095              &     carbon, resp_hetero_soil, & 
     1096              &     matrixA, & 
     1097!!!qcj++ peatland 
     1098              & height_acro,height_cato,carbon_acro,carbon_cato,tcarbon_acro,tcarbon_cato,resp_acro_oxic,& 
     1099              & resp_acro_anoxic,resp_cato,acro_to_cato,litter_to_acro, wtp_pt(:,iatt)) 
     1100 
    14881101      ENDDO 
    14891102      WRITE(numout,*) "End of soilcarbon LOOP." 
     
    14921105      !these variables are only ouputs from deep_carbcycle (thus not necessary for 
    14931106      !Gather and Scatter) 
    1494 !      ALLOCATE(heat_Zimov(kjpindex,ndeep,nvm), stat=ier) 
    1495 !      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'heat_Zimov : error in memory allocation', '', '') 
    1496 !      ALLOCATE(sfluxCH4_deep(kjpindex), stat=ier) 
    1497 !      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'sfluxCH4_deep : error in memory allocation', '', '') 
    1498 !      ALLOCATE(sfluxCO2_deep(kjpindex), stat=ier) 
    1499 !      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'sfluxCO2_deep : error in memory allocation', '', '') 
    1500 !      ALLOCATE(fixed_cryoturbation_depth(kjpindex,nvm), stat=ier) 
    1501 !      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', '2fixed_cryoturbation_depth : error in memory allocation', '', '') 
    1502 !      ALLOCATE(resp_hetero_soil(kjpindex, nvm), stat=ier) 
    1503 !      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'resp_hetero_soil : error in memory allocation', '', '') 
     1107      ALLOCATE(heat_Zimov(kjpindex,ndeep,nvm), stat=ier) 
     1108      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'heat_Zimov : error in memory allocation', '', '') 
     1109      ALLOCATE(sfluxCH4_deep(kjpindex), stat=ier) 
     1110      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'sfluxCH4_deep : error in memory allocation', '', '') 
     1111      ALLOCATE(sfluxCO2_deep(kjpindex), stat=ier) 
     1112      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'sfluxCO2_deep : error in memory allocation', '', '') 
     1113      ALLOCATE(fixed_cryoturbation_depth(kjpindex,nvm), stat=ier) 
     1114      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'fixed_cryoturbation_depth : error in memory allocation', '', '') 
     1115      ALLOCATE(resp_hetero_soil(kjpindex, nvm), stat=ier) 
     1116      IF (ier /= 0) CALL ipslerr_p(3, 'forcesoil', 'resp_hetero_soil : error in memory allocation', '', '') 
    15041117     
    15051118      iatt = 0 
     
    15281141  !! 3. write new carbon stocks into the ouput restart file 
    15291142  !!- 
    1530 !  CALL restput_p (rest_id_sto, 'carbon', nbp_glo, ncarb , nvm, itau_dep, & 
    1531 !         &     carbon, 'scatter', nbp_glo, indices_g) 
    1532  
    1533   CALL restput_p (rest_id_sto, 'carbon_32l_a', nbp_glo, nvm, ndeep, itau_dep, & 
    1534          &     carbon_32l(:,iactive,:,:), 'scatter', nbp_glo, indices_g) 
    1535   CALL restput_p (rest_id_sto, 'carbon_32l_s', nbp_glo, nvm, ndeep, itau_dep, & 
    1536          &     carbon_32l(:,islow,:,:), 'scatter', nbp_glo, indices_g) 
    1537   CALL restput_p (rest_id_sto, 'carbon_32l_p', nbp_glo, nvm, ndeep, itau_dep, & 
    1538          &     carbon_32l(:,ipassive,:,:), 'scatter', nbp_glo, indices_g) 
    1539   CALL restput_p (rest_id_sto, 'freedoc', nbp_glo, nvm , ndeep, npool, nelements, itau_dep, & 
    1540          &     DOC(:,:,:,ifree,:,:), 'scatter', nbp_glo, indices_g) 
    1541   CALL restput_p (rest_id_sto, 'adsdoc', nbp_glo, nvm , ndeep, npool, nelements, itau_dep, & 
    1542          &     DOC(:,:,:,iadsorbed,:,:), 'scatter', nbp_glo, indices_g) 
     1143  CALL restput_p (rest_id_sto, 'carbon', nbp_glo, ncarb , nvm, itau_dep, & 
     1144         &     carbon, 'scatter', nbp_glo, indices_g) 
    15431145 
    15441146!!!qcj++ peatland 
     
    15681170            &               CH4_snow, 'scatter', nbp_glo, indices_g) 
    15691171     CALL restput_p (rest_id_sto, 'altmax', nbp_glo, nvm, 1, itau_dep,     & 
    1570             &               altmax, 'scatter', nbp_glo, indices_g) 
    1571   ENDIF 
    1572  
     1172            &               altmax, 'scatter',  nbp_glo, indices_g) 
    15731173     IF (perma_peat) THEN 
    15741174        CALL restput_p (rest_id_sto, 'deepC_peat', nbp_glo, ndeep, nvm, itau_dep, & 
    15751175                            deepC_peat, 'scatter', nbp_glo, indices_g) 
    15761176     ENDIF 
    1577    
     1177  ENDIF 
    15781178  !- 
    15791179  IF (is_root_prc) THEN 
     
    15861186  CALL MPI_FINALIZE(ier) 
    15871187#endif 
    1588   WRITE(*,*) "End of forcesoil." 
     1188  WRITE(numout,*) "End of forcesoil." 
    15891189  !-------------------- 
    15901190END PROGRAM forcesoil 
  • branches/publications/ORCHIDEE-PEAT_r5488/src_stomate/lpj_cover.f90

    r6890 r6892  
    176176 
    177177       DO j = 2,nvm ! loop over PFTs 
    178           IF ( natural(j) .AND. .NOT. pasture(j) .AND. .NOT. is_peat(j)) THEN 
     178          IF ( natural(j) .AND. .NOT. pasture(j) ) THEN 
    179179              
    180180             ! Summation of individual tree crown area to get total foliar projected coverage 
     
    198198 
    199199             DO j = 2,nvm ! loop over PFTs 
    200                 IF( natural(j) .AND. .NOT. pasture(j) .AND. .NOT. is_peat(j)) THEN 
     200                IF( natural(j) .AND. .NOT. pasture(j)) THEN 
    201201                   veget_max(i,j) =  veget_max(i,j) * frac_nat(i) / sum_veget_natveg(i) 
    202202                ENDIF 
Note: See TracChangeset for help on using the changeset viewer.