source: tags/ORCHIDEE_1_9_6/ORCHIDEE_OL/forcesoil.f90 @ 3850

Last change on this file since 3850 was 868, checked in by nicolas.vuichard, 12 years ago

correct bug for reading of a multi-annual Cforcing file. See ticket #12

File size: 18.1 KB
Line 
1PROGRAM forcesoil
2  !---------------------------------------------------------------------
3  ! This program reads a forcing file for STOMATE's soil carbon routine
4  ! which was created with STOMATE.
5  ! It then integrates STOMATE's soil carbon parameterizations
6  ! for a given number of years using this forcing.
7  !---------------------------------------------------------------------
8  !- IPSL (2006)
9  !-  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
10  USE netcdf
11  !-
12  USE defprec
13  USE constantes
14  USE constantes_mtc
15  USE pft_parameters 
16  USE stomate_data
17  USE ioipsl
18  USE stomate_soilcarbon
19  USE parallel
20  !-
21  IMPLICIT NONE
22  !-
23  CHARACTER(LEN=80)          :: sto_restname_in,sto_restname_out
24  INTEGER(i_std)             :: iim,jjm
25
26  INTEGER(i_std),PARAMETER   :: llm = 1
27  INTEGER(i_std)             :: kjpindex
28
29  INTEGER(i_std)             :: itau_dep,itau_len
30  CHARACTER(LEN=30)          :: time_str
31  REAL(r_std)                :: dt_files
32  REAL(r_std)                :: date0
33  INTEGER(i_std)             :: rest_id_sto
34  CHARACTER(LEN=20), SAVE    :: thecalendar = 'noleap'
35  !-
36  CHARACTER(LEN=100)         :: Cforcing_name
37  INTEGER                    :: Cforcing_id
38  INTEGER                    :: v_id
39  REAL(r_std)                :: dt_forcesoil
40  INTEGER                    :: nparan, nbyear
41
42  INTEGER(i_std),DIMENSION(:),ALLOCATABLE    :: indices
43  INTEGER(i_std),DIMENSION(:),ALLOCATABLE    :: indices_g
44  REAL(r_std),DIMENSION(:),ALLOCATABLE       :: x_indices_g
45  REAL(r_std),DIMENSION(:,:),ALLOCATABLE     :: lon, lat
46  REAL(r_std),DIMENSION(llm)                 :: lev
47
48
49  INTEGER                                    :: i,m,iatt,iv,iyear
50
51  CHARACTER(LEN=80)                          :: var_name
52  CHARACTER(LEN=800)                         :: taboo_vars
53  REAL(r_std),DIMENSION(1)                   :: xtmp
54  INTEGER(i_std),PARAMETER                   :: nbvarmax=300
55  INTEGER(i_std)                             :: nbvar
56  CHARACTER(LEN=50),DIMENSION(nbvarmax)      :: varnames
57  INTEGER(i_std)                             :: varnbdim
58  INTEGER(i_std),PARAMETER                   :: varnbdim_max=20
59  INTEGER,DIMENSION(varnbdim_max)            :: vardims
60  LOGICAL                                    :: l1d
61  REAL(r_std),DIMENSION(:,:),ALLOCATABLE     :: var_3d
62  REAL(r_std)                                :: x_tmp
63  ! string suffix indicating an index
64  CHARACTER(LEN=10)                          :: part_str
65  !
66  ! clay fraction
67  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:)  :: clay_g
68  REAL(r_std),DIMENSION(:,:,:,:),ALLOCATABLE :: soilcarbon_input_g
69  REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE   :: control_temp_g
70  REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE   :: control_moist_g
71  REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE   :: carbon_g
72
73  REAL(r_std),ALLOCATABLE :: clay(:)
74  REAL(r_std),ALLOCATABLE :: soilcarbon_input(:,:,:,:)
75  REAL(r_std),ALLOCATABLE :: control_temp(:,:,:)
76  REAL(r_std),ALLOCATABLE :: control_moist(:,:,:)
77  REAL(r_std),ALLOCATABLE :: carbon(:,:,:)
78  REAL(r_std),DIMENSION(:,:),ALLOCATABLE     :: resp_hetero_soil
79
80  INTEGER(i_std)                             :: ier,iret
81
82  CHARACTER(LEN=30) :: temp_name 
83  LOGICAL :: debug
84  LOGICAL :: l_error
85 
86  CALL Init_para(.FALSE.) 
87  CALL init_timer
88
89!-
90! Configure the number of PFTS
91!-
92 
93  ! 1. Read the number of PFTs
94  !
95  !Config Key   = NVM
96  !Config Desc  = number of PFTs 
97  !Config If    = OK_SECHIBA or OK_STOMATE
98  !Config Def   = 13
99  !Config Help  = The number of vegetation types define by the user
100  !Config Units = [-]
101  CALL getin_p('NVM',nvm)
102
103  ! 2. Allocation
104  l_error = .FALSE.
105  ALLOCATE(pft_to_mtc(nvm),stat=ier)
106  l_error = l_error .OR. (ier .NE. 0)
107  IF (l_error) THEN
108     STOP 'pft_to_mtc (forcesoil only) : error in memory allocation'
109  ENDIF
110
111  ! 3. Initialisation of the correspondance table
112  pft_to_mtc(:) = undef_int
113 
114  ! 4.Reading of the conrrespondance table in the .def file
115  !
116  !Config Key   = PFT_TO_MTC
117  !Config Desc  = correspondance array linking a PFT to MTC
118  !Config if    = OK_SECHIBA or OK_STOMATE
119  !Config Def   = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
120  !Config Help  =
121  !Config Units = [-]
122  CALL getin_p('PFT_TO_MTC',pft_to_mtc)
123
124  ! 4.1 if nothing is found, we use the standard configuration
125  IF(nvm .EQ. nvmc ) THEN
126     IF(pft_to_mtc(1) .EQ. undef_int) THEN
127        WRITE(numout,*) 'Note to the user : we will use ORCHIDEE to its standard configuration'
128        pft_to_mtc(:) = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 /)
129     ENDIF
130  ELSE   
131     IF(pft_to_mtc(1) .EQ. undef_int) THEN
132        WRITE(numout,*)' The array PFT_TO_MTC is empty : we stop'
133     ENDIF
134  ENDIF
135 
136  ! 4.2 What happened if pft_to_mtc(j) > nvmc (if the mtc doesn't exist)?
137  DO i = 1, nvm
138     IF(pft_to_mtc(i) .GT. nvmc) THEN
139        WRITE(numout,*) "the MTC you chose doesn't exist"
140        STOP 'we stop reading pft_to_mtc'
141     ENDIF
142  ENDDO
143 
144  ! 4.3 Check if pft_to_mtc(1) = 1
145  IF(pft_to_mtc(1) .NE. 1) THEN
146     WRITE(numout,*) 'the first pft has to be the bare soil'
147     STOP 'we stop reading next values of pft_to_mtc'
148  ELSE
149     DO i = 2,nvm
150        IF(pft_to_mtc(i) .EQ.1) THEN
151           WRITE(numout,*) 'only pft_to_mtc(1) has to be the bare soil'
152           STOP 'we stop reading pft_to_mtc'
153        ENDIF
154     ENDDO
155  ENDIF
156 
157  ! 5. Allocate and initialize natural ans is_c4
158 
159  ! 5.1 Memory allocation
160  l_error = .FALSE.
161  ALLOCATE(natural(nvm),stat=ier)
162  l_error = l_error .OR. (ier .NE. 0)
163  ALLOCATE(is_c4(nvm),stat=ier)
164
165  IF (l_error) THEN
166     STOP 'natural or is_c4 (forcesoil only) : error in memory allocation'
167  ENDIF
168
169  ! 5.2 Initialisation
170  DO i = 1, nvm
171     natural(i) = natural_mtc(pft_to_mtc(i))
172     is_c4(i) = is_c4_mtc(pft_to_mtc(i))
173  ENDDO
174
175!-
176!-
177! set debug to have more information
178!-
179  !Config Key   = DEBUG_INFO
180  !Config Desc  = Flag for debug information
181  !Config If    =
182  !Config Def   = n
183  !Config Help  = This option allows to switch on the output of debug
184  !Config         information without recompiling the code.
185  !Config Units = [FLAG]
186!-
187  debug = .FALSE.
188  CALL getin_p('DEBUG_INFO',debug)
189  !-
190  ! Stomate's restart files
191  !-
192  IF (is_root_prc) THEN
193     sto_restname_in = 'stomate_start.nc'
194     CALL getin ('STOMATE_RESTART_FILEIN',sto_restname_in)
195     WRITE(numout,*) 'STOMATE INPUT RESTART_FILE: ',TRIM(sto_restname_in)
196     sto_restname_out = 'stomate_rest_out.nc'
197     CALL getin ('STOMATE_RESTART_FILEOUT',sto_restname_out)
198     WRITE(numout,*) 'STOMATE OUTPUT RESTART_FILE: ',TRIM(sto_restname_out)
199     !-
200     ! We need to know iim_g, jjm.
201     ! Get them from the restart files themselves.
202     !-
203     iret = NF90_OPEN (sto_restname_in, NF90_NOWRITE, rest_id_sto)
204     iret = NF90_INQUIRE_DIMENSION (rest_id_sto,1,len=iim_g)
205     iret = NF90_INQUIRE_DIMENSION (rest_id_sto,2,len=jjm_g)
206     iret = NF90_INQ_VARID (rest_id_sto, "time", iv)
207     iret = NF90_GET_ATT (rest_id_sto, iv, 'calendar',thecalendar)
208     iret = NF90_CLOSE (rest_id_sto)
209     i=INDEX(thecalendar,ACHAR(0))
210     IF ( i > 0 ) THEN
211        thecalendar(i:20)=' '
212     ENDIF
213     !-
214     ! Allocate longitudes and latitudes
215     !-
216     ALLOCATE (lon(iim_g,jjm_g))
217     ALLOCATE (lat(iim_g,jjm_g))
218     lon(:,:) = zero
219     lat(:,:) = zero
220     lev(1)   = zero
221     !-
222     CALL restini &
223          & (sto_restname_in, iim_g, jjm_g, lon, lat, llm, lev, &
224          &  sto_restname_out, itau_dep, date0, dt_files, rest_id_sto)
225  ENDIF
226  CALL bcast(date0)
227  CALL bcast(thecalendar)
228  WRITE(numout,*) "calendar = ",thecalendar
229  !-
230  ! calendar
231  !-
232  CALL ioconf_calendar (thecalendar)
233  CALL ioget_calendar  (one_year,one_day)
234  CALL ioconf_startdate(date0)
235  !
236  IF (is_root_prc) THEN
237     !-
238     ! open FORCESOIL's forcing file to read some basic info
239     !-
240     Cforcing_name = 'NONE'
241     CALL getin ('STOMATE_CFORCING_NAME',Cforcing_name)
242     !-
243     iret = NF90_OPEN (TRIM(Cforcing_name),NF90_NOWRITE,Cforcing_id)
244     IF (iret /= NF90_NOERR) THEN
245        CALL ipslerr (3,'forcesoil', &
246             &        'Could not open file : ', &
247             &          Cforcing_name,'(Do you have forget it ?)')
248     ENDIF
249     !-
250     ier = NF90_GET_ATT (Cforcing_id,NF90_GLOBAL,'kjpindex',x_tmp)
251     nbp_glo = NINT(x_tmp)
252     ier = NF90_GET_ATT (Cforcing_id,NF90_GLOBAL,'nparan',x_tmp)
253     nparan = NINT(x_tmp)
254     ier = NF90_GET_ATT (Cforcing_id,NF90_GLOBAL,'nbyear',x_tmp)
255     nbyear = NINT(x_tmp)
256     !-
257     ALLOCATE (indices_g(nbp_glo))
258     ALLOCATE (clay_g(nbp_glo))
259     !-
260     ALLOCATE (x_indices_g(nbp_glo),stat=ier)
261     ier = NF90_INQ_VARID (Cforcing_id,'index',v_id)
262     ier = NF90_GET_VAR   (Cforcing_id,v_id,x_indices_g)
263     indices_g(:) = NINT(x_indices_g(:))
264     WRITE(numout,*) mpi_rank,"indices globaux : ",indices_g
265     DEALLOCATE (x_indices_g)
266     !-
267     ier = NF90_INQ_VARID (Cforcing_id,'clay',v_id)
268     ier = NF90_GET_VAR   (Cforcing_id,v_id,clay_g)
269     !-
270     ! time step of forcesoil
271     !-
272     dt_forcesoil = one_year / FLOAT(nparan)
273     WRITE(numout,*) 'time step (d): ',dt_forcesoil
274     WRITE(numout,*) 'nparan: ',nparan
275     WRITE(numout,*) 'nbyear: ',nbyear   
276     !-
277     ! read (and partially write) the restart file
278     !-
279     ! read and write the variables we do not need
280     !-
281     taboo_vars ='$lon$ $lat$ $lev$ $nav_lon$ $nav_lat$ $nav_lev$ $time$ $time_steps$ '// &
282          &             '$day_counter$ $dt_days$ $date$ '
283     !-
284     DO m = 1,nvm
285        WRITE(part_str,'(I2)') m
286        IF (m < 10) part_str(1:1) = '0'
287        temp_name = '$carbon_'//part_str(1:LEN_TRIM(part_str))//'$'
288        taboo_vars = TRIM(taboo_vars)//' '//TRIM(temp_name)
289     ENDDO
290     !-
291     CALL ioget_vname(rest_id_sto, nbvar, varnames)
292     !-
293     ! read and write some special variables (1D or variables that we need)
294     !-
295     var_name = 'day_counter'
296     CALL restget (rest_id_sto, var_name, 1, 1, 1, itau_dep, .TRUE., xtmp)
297     CALL restput (rest_id_sto, var_name, 1, 1, 1, itau_dep, xtmp)
298     !-
299     var_name = 'dt_days'
300     CALL restget (rest_id_sto, var_name, 1, 1, 1, itau_dep, .TRUE., xtmp)
301     CALL restput (rest_id_sto, var_name, 1, 1, 1, itau_dep, xtmp)
302     !-
303     var_name = 'date'
304     CALL restget (rest_id_sto, var_name, 1, 1, 1, itau_dep, .TRUE., xtmp)
305     CALL restput (rest_id_sto, var_name, 1, 1, 1, itau_dep, xtmp)
306     !-
307     DO iv=1,nbvar
308        !-- check if the variable is to be written here
309        IF (INDEX(taboo_vars,'$'//TRIM(varnames(iv))//'$') == 0 ) THEN
310           !---- get variable dimensions, especially 3rd dimension
311           CALL ioget_vdim &
312                &      (rest_id_sto, varnames(iv), varnbdim_max, varnbdim, vardims)
313           l1d = ALL(vardims(1:varnbdim) == 1)
314           !---- read it
315           IF (l1d) THEN
316              CALL restget &
317                   &        (rest_id_sto, TRIM(varnames(iv)), 1, vardims(3), &
318                   &         1, itau_dep, .TRUE., xtmp)
319           ELSE
320              ALLOCATE( var_3d(nbp_glo,vardims(3)), stat=ier)
321              IF (ier /= 0) STOP 'ALLOCATION PROBLEM'
322              !----
323              CALL restget &
324                   &        (rest_id_sto, TRIM(varnames(iv)), nbp_glo, vardims(3), &
325                   &         1, itau_dep, .TRUE., var_3d, "gather", nbp_glo, indices_g)
326           ENDIF
327           !---- write it
328           IF (l1d) THEN
329              CALL restput &
330                   &        (rest_id_sto, TRIM(varnames(iv)), 1, vardims(3), &
331                   &         1, itau_dep, xtmp)
332           ELSE
333              CALL restput &
334                   &        (rest_id_sto, TRIM(varnames(iv)), nbp_glo, vardims(3), &
335                   &         1, itau_dep, var_3d, 'scatter',  nbp_glo, indices_g)
336              !----
337              DEALLOCATE(var_3d)
338           ENDIF
339        ENDIF
340     ENDDO
341     !-
342     ! read soil carbon
343     !-
344     ALLOCATE(carbon_g(nbp_glo,ncarb,nvm))
345     carbon_g(:,:,:) = val_exp
346     DO m = 1, nvm
347        WRITE (part_str, '(I2)') m
348        IF (m<10) part_str(1:1)='0'
349        var_name = 'carbon_'//part_str(1:LEN_TRIM(part_str))
350        CALL restget &
351             &    (rest_id_sto, var_name, nbp_glo, ncarb , 1, itau_dep, &
352             &     .TRUE., carbon_g(:,:,m), 'gather', nbp_glo, indices_g)
353        IF (ALL(carbon_g(:,:,m) == val_exp)) carbon_g(:,:,m) = zero
354        !-- do not write this variable: it will be modified.
355     ENDDO
356     WRITE(numout,*) "date0 : ",date0, itau_dep
357     !-
358     ! Length of run
359     !-
360     WRITE(time_str,'(a)') '10000Y'
361     CALL getin('TIME_LENGTH', time_str)
362     write(numout,*) 'Number of years for carbon spinup : ',time_str
363     ! transform into itau
364     CALL tlen2itau(time_str, dt_forcesoil*one_day, date0, itau_len)
365     write(numout,*) 'Number of time steps to do: ',itau_len
366     !-
367     ! read the rest of the forcing file and store forcing in an array.
368     ! We read an average year.
369     !-
370     ALLOCATE(soilcarbon_input_g(nbp_glo,ncarb,nvm,nparan*nbyear))
371     ALLOCATE(control_temp_g(nbp_glo,nlevs,nparan*nbyear))
372     ALLOCATE(control_moist_g(nbp_glo,nlevs,nparan*nbyear))
373     !-
374     ier = NF90_INQ_VARID (Cforcing_id,'soilcarbon_input',v_id)
375     ier = NF90_GET_VAR   (Cforcing_id,v_id,soilcarbon_input_g)
376     ier = NF90_INQ_VARID (Cforcing_id,   'control_moist',v_id)
377     ier = NF90_GET_VAR   (Cforcing_id,v_id,control_moist_g)
378     ier = NF90_INQ_VARID (Cforcing_id,    'control_temp',v_id)
379     ier = NF90_GET_VAR   (Cforcing_id,v_id,control_temp_g)
380     !-
381     ier = NF90_CLOSE (Cforcing_id)
382     !-
383  ENDIF
384  CALL bcast(nparan)
385  CALL bcast(nbyear)
386  CALL bcast(dt_forcesoil)
387  CALL bcast(iim_g)
388  CALL bcast(jjm_g)
389  CALL bcast(nbp_glo)
390  CALL bcast(itau_dep)
391  CALL bcast(itau_len)
392  !
393  ! We must initialize data_para :
394     !
395     !
396  CALL init_data_para(iim_g,jjm_g,nbp_glo,indices_g)
397
398  kjpindex=nbp_loc
399  jjm=jj_nb
400  iim=iim_g
401  IF (debug) WRITE(numout,*) "Local grid : ",kjpindex,iim,jjm
402
403  !---
404  !--- Create the index table
405  !---
406  !--- This job return a LOCAL kindex
407  !---
408  ALLOCATE (indices(kjpindex),stat=ier)
409  CALL scatter(indices_g,indices)
410  indices(1:kjpindex)=indices(1:kjpindex)-(jj_begin-1)*iim_g
411  IF (debug) WRITE(numout,*) mpi_rank,"indices locaux = ",indices(1:kjpindex)
412  !-
413  !-
414  ! there we go: time loop
415  !-
416  ALLOCATE(clay(kjpindex))
417  ALLOCATE(soilcarbon_input(kjpindex,ncarb,nvm,nparan*nbyear))
418  ALLOCATE(control_temp(kjpindex,nlevs,nparan*nbyear))
419  ALLOCATE(control_moist(kjpindex,nlevs,nparan*nbyear))
420  ALLOCATE(carbon(kjpindex,ncarb,nvm))
421  ALLOCATE(resp_hetero_soil(kjpindex,nvm))
422  iatt = 0
423
424  CALL Scatter(clay_g,clay)
425  CALL Scatter(soilcarbon_input_g,soilcarbon_input)
426  CALL Scatter(control_temp_g,control_temp)
427  CALL Scatter(control_moist_g,control_moist)
428  CALL Scatter(carbon_g,carbon)
429
430!-
431! Configuration of the parameters
432!-
433
434  !Config Key   = FRAC_CARB_AP
435  !Config Desc  = frac carb coefficients from active pool: depends on clay content
436  !Config if    = OK_STOMATE
437  !Config Def   = 0.004
438  !Config Help  = fraction of the active pool going to the passive pool
439  !Config Units = [-]
440  CALL getin_p('FRAC_CARB_AP',frac_carb_ap) 
441  !
442  !Config Key   = FRAC_CARB_SA
443  !Config Desc  = frac_carb_coefficients from slow pool
444  !Config if    = OK_STOMATE
445  !Config Def   = 0.42
446  !Config Help  = fraction of the slow pool going to the active pool
447  !Config Units = [-]
448  CALL getin_p('FRAC_CARB_SA',frac_carb_sa)
449  !
450  !Config Key   = FRAC_CARB_SP
451  !Config Desc  = frac_carb_coefficients from slow pool
452  !Config if    = OK_STOMATE
453  !Config Def   = 0.03
454  !Config Help  = fraction of the slow pool going to the passive pool
455  !Config Units = [-]
456  CALL getin_p('FRAC_CARB_SP',frac_carb_sp)
457  !
458  !Config Key   = FRAC_CARB_PA
459  !Config Desc  = frac_carb_coefficients from passive pool
460  !Config if    = OK_STOMATE
461  !Config Def   = 0.45
462  !Config Help  = fraction of the passive pool going to the passive pool
463  !Config Units = [-]
464  CALL getin_p('FRAC_CARB_PA',frac_carb_pa)
465  !
466  !Config Key   = FRAC_CARB_PS
467  !Config Desc  = frac_carb_coefficients from passive pool
468  !Config if    = OK_STOMATE
469  !Config Def   = 0.0
470  !Config Help  = fraction of the passive pool going to the passive pool
471  !Config Units = [-]
472  CALL getin_p('FRAC_CARB_PS',frac_carb_ps)
473  !
474  !Config Key   = ACTIVE_TO_PASS_CLAY_FRAC
475  !Config Desc  =
476  !Config if    = OK_STOMATE
477  !Config Def   =  .68 
478  !Config Help  =
479  !Config Units = [-]
480  CALL getin_p('ACTIVE_TO_PASS_CLAY_FRAC',active_to_pass_clay_frac)
481  !
482  !Config Key   = CARBON_TAU_IACTIVE
483  !Config Desc  = residence times in carbon pools
484  !Config if    = OK_STOMATE
485  !Config Def   = 0.149
486  !Config Help  =
487  !Config Units = [days]
488  CALL getin_p('CARBON_TAU_IACTIVE',carbon_tau_iactive)
489  !
490  !Config Key   = CARBON_TAU_ISLOW
491  !Config Desc  = residence times in carbon pools
492  !Config if    = OK_STOMATE
493  !Config Def   = 5.48
494  !Config Help  =
495  !Config Units = [days]
496  CALL getin_p('CARBON_TAU_ISLOW',carbon_tau_islow)
497  !
498  !Config Key   = CARBON_TAU_IPASSIVE
499  !Config Desc  = residence times in carbon pools
500  !Config if    = OK_STOMATE
501  !Config Def   = 241.
502  !Config Help  =
503  !Config Units = [days]
504  CALL getin_p('CARBON_TAU_IPASSIVE',carbon_tau_ipassive)
505  !
506  !Config Key   = FLUX_TOT_COEFF
507  !Config Desc  =
508  !Config if    = OK_STOMATE
509  !Config Def   = 1.2, 1.4,.75
510  !Config Help  =
511  !Config Units = [days]
512  CALL getin_p('FLUX_TOT_COEFF',flux_tot_coeff)
513
514  iyear=1
515  DO i=1,itau_len
516     iatt = iatt+1
517     IF (iatt > nparan*nbyear) THEN
518        IF (debug) WRITE(numout,*) iyear
519        iatt = 1
520        iyear=iyear+1
521     ENDIF
522     CALL soilcarbon &
523          &    (kjpindex, dt_forcesoil, clay, &
524          &     soilcarbon_input(:,:,:,iatt), &
525          &     control_temp(:,:,iatt), control_moist(:,:,iatt), &
526          &     carbon, resp_hetero_soil)
527  ENDDO
528  WRITE(numout,*) "End of soilcarbon LOOP."
529  CALL Gather(carbon,carbon_g)
530  !-
531  ! write new carbon into restart file
532  !-
533  IF (is_root_prc) THEN
534     DO m=1,nvm
535        WRITE (part_str, '(I2)') m
536        IF (m<10) part_str(1:1)='0'
537        var_name = 'carbon_'//part_str(1:LEN_TRIM(part_str))
538        CALL restput &
539             &    (rest_id_sto, var_name, nbp_glo, ncarb , 1, itau_dep, &
540             &     carbon_g(:,:,m), 'scatter', nbp_glo, indices_g)
541     ENDDO
542     !-
543     CALL getin_dump
544     CALL restclo
545  ENDIF
546#ifdef CPP_PARA
547  CALL MPI_FINALIZE(ier)
548#endif
549  WRITE(numout,*) "End of forcesoil."
550  !--------------------
551END PROGRAM forcesoil
Note: See TracBrowser for help on using the repository browser.