New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
trcini_medusa.F90 in branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/TOP_SRC/MEDUSA – NEMO

source: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcini_medusa.F90 @ 9385

Last change on this file since 9385 was 9385, checked in by marc, 6 years ago

GMED ticket 380. Merge changes from Julien's branches/NERC/dev_r5518_GO6_CO2_cmip.

File size: 22.4 KB
Line 
1MODULE trcini_medusa
2   !!======================================================================
3   !!                         ***  MODULE trcini_medusa  ***
4   !! TOP :   initialisation of the MEDUSA tracers
5   !!======================================================================
6   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec) Original code
7   !!              -   !  2008-08  (K. Popova) adaptation for MEDUSA
8   !!              -   !  2008-11  (A. Yool) continuing adaptation for MEDUSA
9   !!              -   !  2010-03  (A. Yool) updated for branch inclusion
10   !!              -   !  2011-04  (A. Yool) updated for ROAM project
11   !!----------------------------------------------------------------------
12#if defined key_medusa
13   !!----------------------------------------------------------------------
14   !!   'key_medusa'                                         MEDUSA tracers
15   !!----------------------------------------------------------------------
16   !! trc_ini_medusa   : MEDUSA model initialisation
17   !!----------------------------------------------------------------------
18   USE par_trc         ! TOP parameters
19   USE oce_trc
20   USE trc
21   USE in_out_manager
22   !! AXY (04/11/13): add this in for initialisation stuff
23   USE iom
24   USE par_medusa
25   !! AXY (13/01/12): add this in for sediment variables
26   USE sms_medusa
27   !! AXY (04/11/13): add this in for initialisation stuff
28   USE trcsed_medusa
29   USE sbc_oce, ONLY: lk_oasis
30   USE oce,     ONLY: CO2Flux_out_cpl, DMS_out_cpl, chloro_out_cpl  !! Coupling variable
31
32
33   IMPLICIT NONE
34   PRIVATE
35
36   PUBLIC   trc_ini_medusa   ! called by trcini.F90 module
37
38   !! AXY (25/02/10)
39   LOGICAL, PUBLIC ::                  &
40      bocalccd = .TRUE.
41   !! JPALM (14/09/15)
42   LOGICAL, PUBLIC ::                  &
43      ln_ccd = .TRUE.
44
45   INTEGER ::                          &
46      numccd
47
48   !! AXY (25/02/10)
49   INTEGER ::                          &
50      numriv
51
52   !!----------------------------------------------------------------------
53   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007)
54   !! $Id$
55   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
56   !!----------------------------------------------------------------------
57
58CONTAINS
59
60   SUBROUTINE trc_ini_medusa
61      !!----------------------------------------------------------------------
62      !!                     ***  trc_ini_medusa  *** 
63      !!
64      !! ** Purpose :   initialization for MEDUSA model
65      !!
66      !! ** Method  : - Read the namcfc namelist and check the parameter values
67      !!----------------------------------------------------------------------
68      !!----------------------------------------------------------------------
69
70      !! vertical array index
71      INTEGER  ::    jk, ierr
72      !! AXY (19/07/12): added jk2 to set up friver_dep array
73      INTEGER            :: jk2
74      !! AXY (19/07/12): added tfthk to set up friver_dep array
75      REAL(wp)           :: fthk, tfthk
76      !! AXY (04/11/13): add in temporary variables for checks
77      REAL(wp)           :: fq0, fq1, fq2
78
79      IF(lwp) WRITE(numout,*)
80      IF(lwp) WRITE(numout,*) ' trc_ini_medusa: initialisation of MEDUSA model'
81      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
82# if defined key_debug_medusa
83            CALL flush(numout)
84# endif
85
86                                           ! Allocate MEDUSA arrays
87      ierr =         sms_medusa_alloc()
88# if defined key_debug_medusa
89            IF (lwp) write (numout,*) '------------------------------'
90            IF (lwp) write (numout,*) 'Jpalm - debug'
91            IF (lwp) write (numout,*) 'in trc_ini_medusa, just after array allocate'
92            IF (lwp) write (numout,*) ' '
93            CALL flush(numout)
94# endif
95
96!!
97!! AXY (19/07/12): setup array to control distribution of river nutrients
98      friver_dep(:,:) = 0.
99      DO jk = 1,jpk
100         tfthk = 0.
101         DO jk2 = 1,jriver_dep
102            fthk  = e3t_1d(jk2)
103            if (jk2 .le. jk) then
104               tfthk = tfthk + fthk
105               friver_dep(jk2,jk) = fthk
106            endif
107         ENDDO
108         DO jk2 = 1,jriver_dep
109            friver_dep(jk2,jk) = friver_dep(jk2,jk) / tfthk
110         ENDDO
111      ENDDO
112!!
113!! Have a look at the result of this for a single depth (jriver_dep + 1)
114      IF(lwp) THEN
115          WRITE(numout,*) '=== River nutrient fraction by depth (for a water column of jpk depth)'
116          DO jk = 1,jpk
117             WRITE(numout,*)     &
118             &   ' cell = ', jk, ', friver_dep value = ', friver_dep(jk,jpk)
119          ENDDO
120          IF(lwp) CALL flush(numout)
121       ENDIF
122
123#if defined key_roam
124!! ROAM 3D and 2D carbonate system fields (calculated on first time
125!! step, then monthly)
126      f3_pH(:,:,:)    = 0.
127      f3_h2co3(:,:,:) = 0.
128      f3_hco3(:,:,:)  = 0.
129      f3_co3(:,:,:)   = 0.
130      f3_omcal(:,:,:) = 0.
131      f3_omarg(:,:,:) = 0.
132!!
133      f2_ccd_cal(:,:) = 0.
134      f2_ccd_arg(:,:) = 0.
135      IF(lwp) WRITE(numout,*) ' trc_ini_medusa: carbonate fields initialised to zero'
136#endif
137      IF(lwp) CALL flush(numout)
138
139      !!----------------------------------------------------------------------
140      !! State variable initial conditions (all mmol / m3)
141      !!----------------------------------------------------------------------
142      !!     
143      !! biological and detrital components are initialised to nominal
144      !! values above 100 m depth and zero below; the latter condition
145      !! is applied since non-linear loss processes allow significant
146      !! concentrations of these components to persist at depth
147      !!
148      trn(:,:,:,jpchn) = 0.
149      trn(:,:,:,jpchd) = 0.
150      trn(:,:,:,jpphn) = 0.
151      trn(:,:,:,jpphd) = 0.
152      trn(:,:,:,jppds) = 0.
153      trn(:,:,:,jpzmi) = 0.
154      trn(:,:,:,jpzme) = 0.
155      trn(:,:,:,jpdet) = 0.
156      !!
157      DO jk = 1,13
158         !! non-diatom chlorophyll         (nominal)
159         trn(:,:,jk,jpchn) = 0.01
160         !!
161         !! diatom chlorophyll             (nominal)
162         trn(:,:,jk,jpchd) = 0.01
163         !!
164         !! non-diatom                     (nominal)
165         trn(:,:,jk,jpphn) = 0.01
166         !!
167         !! diatom                         (nominal)
168         trn(:,:,jk,jpphd) = 0.01
169         !!
170         !! diatom silicon                 (nominal)
171         trn(:,:,jk,jppds) = 0.01
172         !!
173         !! microzooplankton               (nominal)
174         trn(:,:,jk,jpzmi) = 0.01
175         !!
176         !! mesozooplankton                (nominal)
177         trn(:,:,jk,jpzme) = 0.01
178         !!
179         !! detrital nitrogen              (nominal)
180         trn(:,:,jk,jpdet) = 0.01
181      ENDDO
182      !!
183      !! dissolved inorganic nitrogen     (nominal average value; typically initialised from climatology)
184      trn(:,:,:,jpdin) = 30.
185      !!
186      !! dissolved silicic acid           (nominal average value; typically initialised from climatology)
187      trn(:,:,:,jpsil) = 90.
188      !!
189      !! dissolved "total" iron           (nominal; typically initialised from model-derived climatology)
190      trn(:,:,:,jpfer) = 1.0e-4           !! = 0.1 umol Fe / m3
191      !!
192      IF(lwp) WRITE(numout,*) ' trc_ini_medusa: MEDUSA-1 fields initialised to defaults'
193# if defined key_roam
194      !!
195      !! detrital carbon                  (nominal)
196      trn(:,:,:,jpdtc) = 0.
197      DO jk = 1,13
198         trn(:,:,jk,jpdtc) = 0.06625
199      ENDDO
200      !!
201      !! dissolved inorganic carbon (DIC) (nominal average value; typically initialised from climatology)
202      trn(:,:,:,jpdic) = 2330.
203      !!
204      !! total alkalinity                 (nominal average value; typically initialised from climatology)
205      trn(:,:,:,jpalk) = 2450.
206      !!
207      !! dissolved oxygen                 (nominal average value; typically initialised from climatology)
208      trn(:,:,:,jpoxy) = 175.
209      !!
210      IF(lwp) WRITE(numout,*) ' trc_ini_medusa: MEDUSA-2 fields initialised to defaults'
211# endif
212      IF(lwp) CALL flush(numout)
213
214      !!----------------------------------------------------------------------
215      !! Sediment pools initial conditions (all mmol / m2)
216      !!----------------------------------------------------------------------
217      !!     
218      !! these pools store biogenic material that has sunk to the seabed,
219      !! and act as a temporary reservoir
220      zb_sed_n(:,:)  = 0.0  !! organic N
221      zn_sed_n(:,:)  = 0.0
222      za_sed_n(:,:)  = 0.0
223      zb_sed_fe(:,:) = 0.0  !! organic Fe
224      zn_sed_fe(:,:) = 0.0
225      za_sed_fe(:,:) = 0.0
226      zb_sed_si(:,:) = 0.0  !! inorganic Si
227      zn_sed_si(:,:) = 0.0
228      za_sed_si(:,:) = 0.0
229      zb_sed_c(:,:)  = 0.0  !! organic C
230      zn_sed_c(:,:)  = 0.0
231      za_sed_c(:,:)  = 0.0
232      zb_sed_ca(:,:) = 0.0  !! inorganic C
233      zn_sed_ca(:,:) = 0.0
234      za_sed_ca(:,:) = 0.0
235      !!
236      IF(lwp) WRITE(numout,*) ' trc_ini_medusa: benthic fields initialised to zero'
237      IF(lwp) CALL flush(numout)
238     
239      !!----------------------------------------------------------------------
240      !! Averaged properties for DMS calculations (various units)
241      !!----------------------------------------------------------------------
242      !!     
243      !! these store temporally averaged properties for DMS calculations (AXY, 07/07/15)
244      zb_dms_chn(:,:)  = 0.0  !! CHN
245      zn_dms_chn(:,:)  = 0.0
246      za_dms_chn(:,:)  = 0.0
247      zb_dms_chd(:,:)  = 0.0  !! CHD
248      zn_dms_chd(:,:)  = 0.0
249      za_dms_chd(:,:)  = 0.0
250      zb_dms_mld(:,:)  = 0.0  !! MLD
251      zn_dms_mld(:,:)  = 0.0
252      za_dms_mld(:,:)  = 0.0
253      zb_dms_qsr(:,:)  = 0.0  !! QSR
254      zn_dms_qsr(:,:)  = 0.0
255      za_dms_qsr(:,:)  = 0.0
256      zb_dms_din(:,:)  = 0.0  !! DIN
257      zn_dms_din(:,:)  = 0.0
258      za_dms_din(:,:)  = 0.0
259      !!
260      IF(lwp) WRITE(numout,*) ' trc_ini_medusa: average fields for DMS initialised to zero'
261      IF(lwp) CALL flush(numout)
262      !!
263      !!---------------------------------------------------------------------
264      !!JPALM (14-06-2016): init dms and co2 flux for coupling with atm (UKESM)
265      !!---------------------------------------------------------------------
266      !!
267      zb_co2_flx(:,:)  = 0.0  !! CO2 flx
268      zn_co2_flx(:,:)  = 0.0
269      za_co2_flx(:,:)  = 0.0
270      zb_dms_srf(:,:)  = 0.0  !! DMS srf
271      zn_dms_srf(:,:)  = 0.0
272      za_dms_srf(:,:)  = 0.0
273      zn_chl_srf(:,:)  = 2.0E-8 !! Chl cpl - set first as surf
274      !!
275      IF(lwp) WRITE(numout,*) ' trc_ini_medusa: DMS and CO2 flux (UKESM) initialised to zero'
276      IF(lwp) CALL flush(numout)
277      IF (lk_oasis) THEN
278         CO2Flux_out_cpl(:,:) =  zn_co2_flx(:,:)   !! Coupling variable
279         DMS_out_cpl(:,:)     =  zn_dms_srf(:,:)   !! Coupling variable
280         chloro_out_cpl(:,:)  =  zn_chl_srf(:,:) * scl_chl   !! Coupling variable
281      END IF
282      !!
283      !!----------------------------------------------------------------------
284      !! AXY (04/11/13): initialise fields previously done by trc_sed_medusa
285      !!----------------------------------------------------------------------
286      !!     
287      IF(lwp) WRITE(numout,*) ' trc_ini_medusa: initialising dust deposition fields'
288      CALL trc_sed_medusa_sbc( nit000 )
289      !!
290      IF(lwp) WRITE(numout,*) ' trc_ini_medusa: initialising ocean CCD array'
291      CALL trc_ini_medusa_ccd( nit000 )
292      fq0 = MINVAL(ocal_ccd(:,:))
293      fq1 = MAXVAL(ocal_ccd(:,:))
294      if (lwp) write (numout,'(a,f10.3,a,f10.3)') & 
295         & 'CCD: min ', fq0, ' max ', fq1
296      !!
297      IF(lwp) WRITE(numout,*) ' trc_ini_medusa: initialising riverine nutrient arrays'
298      riv_n(:,:)   = 0.0
299      riv_si(:,:)  = 0.0
300      riv_c(:,:)   = 0.0
301      riv_alk(:,:) = 0.0 
302      !!
303      CALL trc_ini_medusa_river( nit000 )
304      fq0 = MINVAL(riv_n(:,:))
305      fq1 = MAXVAL(riv_n(:,:))
306      if (lwp) write (numout,'(a,f10.3,a,f10.3)') & 
307         & 'RIV_N:   min ', fq0, ' max ', fq1
308      fq0 = MINVAL(riv_si(:,:))
309      fq1 = MAXVAL(riv_si(:,:))
310      if (lwp) write (numout,'(a,f10.3,a,f10.3)') & 
311         & 'RIV_SI:  min ', fq0, ' max ', fq1
312      fq0 = MINVAL(riv_c(:,:))
313      fq1 = MAXVAL(riv_c(:,:))
314      if (lwp) write (numout,'(a,f10.3,a,f10.3)') & 
315         & 'RIV_C:   min ', fq0, ' max ', fq1
316      fq0 = MINVAL(riv_alk(:,:))
317      fq1 = MAXVAL(riv_alk(:,:))
318      if (lwp) write (numout,'(a,f10.3,a,f10.3)') & 
319         & 'RIV_ALK: min ', fq0, ' max ', fq1
320      IF(lwp) CALL flush(numout)
321
322      IF(lwp) WRITE(numout,*)
323      IF(lwp) WRITE(numout,*) ' trc_ini_medusa: MEDUSA initialised'
324      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
325      IF(lwp) CALL flush(numout)
326      !!
327      !!----------------------------------------------------------------------
328      !! JPALM (23-01-2017): new way to initialize CO2-atm for cmip6
329      !!                     initially done in trcsms_medusa
330      !!----------------------------------------------------------------------
331      !!
332      IF( ( .NOT.lk_oasis ) .AND. ( .NOT.lk_pi_co2 ) ) THEN
333         IF(lwp) WRITE(numout,*) ' trc_ini_medusa: initialisating atm CO2 record'
334         CALL trc_ini_medusa_co2atm
335      ENDIF
336
337   END SUBROUTINE trc_ini_medusa
338
339   !! ======================================================================
340   !! ======================================================================
341   !! ======================================================================
342
343   !! AXY (25/02/10)
344   SUBROUTINE trc_ini_medusa_ccd(kt)
345
346      !!----------------------------------------------------------------------
347      !!                  ***  ROUTINE trc_ini_medusa_ccd  ***
348      !!
349      !! ** Purpose :   Read CCD field
350      !!
351      !! ** Method  :   Read the file
352      !!
353      !! ** input   :   external netcdf files
354      !!
355      !!----------------------------------------------------------------------
356      !! * arguments
357      INTEGER, INTENT( in  ) ::   kt   ! ocean time step
358
359      !!---------------------------------------------------------------------
360
361      !! Open the file
362      !! -------------
363      !!
364      !!!! JPALM -- 14-09-2015 --
365      !!!!       -- to test on ORCA2 with Christian, no file available, so initiate to 0
366      IF (ln_ccd) THEN
367         IF(lwp) WRITE(numout,*) ' '
368         IF(lwp) WRITE(numout,*) ' **** Routine trc_ini_medusa_ccd'
369         CALL iom_open ( 'ccd_ocal_nemo.nc', numccd )
370         IF(lwp) WRITE(numout,*) ' **** trc_ini_medusa_ccd: ccd_ocal_nemo.nc opened'
371
372      !! Read the data
373      !! -------------
374      !!
375         CALL iom_get ( numccd, jpdom_data, 'OCAL_CCD', ocal_ccd )
376         IF(lwp) WRITE(numout,*) ' **** trc_ini_medusa_ccd: data read'
377
378      !! Close the file
379      !! --------------
380      !!
381         CALL iom_close ( numccd )
382         IF(lwp) WRITE(numout,*) ' **** trc_ini_medusa_ccd: ccd_ocal_nemo.nc closed'
383         IF(lwp) CALL flush(numout)
384      ELSE
385         IF(lwp) WRITE(numout,*) ' '
386         IF(lwp) WRITE(numout,*) ' **** Routine trc_ini_medusa_ccd'
387         IF(lwp) WRITE(numout,*) ' **** trc_ini_medusa_ccd: do not read ccd_ocal_nemo.nc'
388         IF(lwp) WRITE(numout,*) ' **** ln_ccd = FALSE and ocal_ccd = 0.0 ---'
389         ocal_ccd(:,:) = 0.0 
390      ENDIF
391 
392   END SUBROUTINE trc_ini_medusa_ccd
393
394   !! ======================================================================
395   !! ======================================================================
396   !! ======================================================================
397
398   !! AXY (26/01/12)
399   SUBROUTINE trc_ini_medusa_river(kt)
400
401      !!----------------------------------------------------------------------
402      !!                  ***  ROUTINE trc_ini_medusa_river  ***
403      !!
404      !! ** Purpose :   Read riverine nutrient fields
405      !!
406      !! ** Method  :   Read the file
407      !!
408      !! ** input   :   external netcdf files
409      !!
410      !!----------------------------------------------------------------------
411      !! * arguments
412      INTEGER, INTENT( in  ) ::   kt   ! ocean time step
413
414      !!---------------------------------------------------------------------
415
416      IF(lwp) THEN
417         WRITE(numout,*) ' '
418         WRITE(numout,*) ' **** Routine trc_ini_medusa_river'
419         WRITE(numout,*) ' '
420      ENDIF
421
422      !! Open and read the files
423      !! -----------------------
424      !!
425      if (jriver_n.gt.0) then
426         if (jriver_n.eq.1) CALL iom_open ( 'river_N_conc_orca100.nc', numriv )
427         if (jriver_n.eq.2) CALL iom_open ( 'river_N_flux_orca100.nc', numriv )
428         CALL iom_get  ( numriv, jpdom_data, 'RIV_N', riv_n )
429         IF(lwp) THEN
430            if (jriver_n.eq.1) WRITE(numout,*) ' **** trc_ini_medusa_river: N CONC data read'
431            if (jriver_n.eq.2) WRITE(numout,*) ' **** trc_ini_medusa_river: N FLUX data read'
432         ENDIF
433         CALL iom_close ( numriv )
434         IF(lwp) WRITE(numout,*) ' **** trc_ini_medusa_river: river N file closed'
435      else
436         IF(lwp) THEN
437            WRITE(numout,*) ' **** trc_ini_medusa_river: N data NOT read'
438         ENDIF
439      endif
440      !!
441      if (jriver_si.gt.0) then
442         if (jriver_si.eq.1) CALL iom_open ( 'river_Si_conc_orca100.nc', numriv )
443         if (jriver_si.eq.2) CALL iom_open ( 'river_Si_flux_orca100.nc', numriv )
444         CALL iom_get  ( numriv, jpdom_data, 'RIV_SI', riv_si )
445         IF(lwp) THEN
446            if (jriver_si.eq.1) WRITE(numout,*) ' **** trc_ini_medusa_river: Si CONC data read'
447            if (jriver_si.eq.2) WRITE(numout,*) ' **** trc_ini_medusa_river: Si FLUX data read'
448         ENDIF
449         CALL iom_close ( numriv )
450         IF(lwp) WRITE(numout,*) ' **** trc_ini_medusa_river: river Si file closed'
451      else
452         IF(lwp) THEN
453            WRITE(numout,*) ' **** trc_ini_medusa_river: Si data NOT read'
454         ENDIF
455      endif
456      !!
457      if (jriver_c.gt.0) then
458         if (jriver_c.eq.1) CALL iom_open ( 'river_C_conc_orca100.nc', numriv )
459         if (jriver_c.eq.2) CALL iom_open ( 'river_C_flux_orca100.nc', numriv )
460         CALL iom_get  ( numriv, jpdom_data, 'RIV_C', riv_c )
461         IF(lwp) THEN
462            if (jriver_c.eq.1) WRITE(numout,*) ' **** trc_ini_medusa_river: C CONC data read'
463            if (jriver_c.eq.2) WRITE(numout,*) ' **** trc_ini_medusa_river: C FLUX data read'
464         ENDIF
465         CALL iom_close ( numriv )
466         IF(lwp) WRITE(numout,*) ' **** trc_ini_medusa_river: river C file closed'
467      else
468         IF(lwp) THEN
469            WRITE(numout,*) ' **** trc_ini_medusa_river: C data NOT read'
470         ENDIF
471      endif
472      !!
473      if (jriver_alk.gt.0) then
474         if (jriver_alk.eq.1) CALL iom_open ( 'river_alk_conc_orca100.nc', numriv )
475         if (jriver_alk.eq.2) CALL iom_open ( 'river_alk_flux_orca100.nc', numriv )
476         CALL iom_get  ( numriv, jpdom_data, 'RIV_ALK', riv_alk )
477         IF(lwp) THEN
478            if (jriver_alk.eq.1) WRITE(numout,*) ' **** trc_ini_medusa_river: alkalinity CONC data read'
479            if (jriver_alk.eq.2) WRITE(numout,*) ' **** trc_ini_medusa_river: alkalinity FLUX data read'
480         ENDIF
481         CALL iom_close ( numriv )
482         IF(lwp) WRITE(numout,*) ' **** trc_ini_medusa_river: river alkalinity file closed'
483      else
484         IF(lwp) THEN
485            WRITE(numout,*) ' **** trc_ini_medusa_river: alkalinity data NOT read'
486         ENDIF
487      endif
488      IF(lwp) CALL flush(numout)
489
490   END SUBROUTINE trc_ini_medusa_river
491   
492   SUBROUTINE trc_ini_medusa_co2atm
493      !!----------------------------------------------------------------------
494      !!                     ***  trc_ini_medusa_co2atm  *** 
495      !!
496      !! ** Purpose :   initialization atmospheric co2 record
497      !!
498      !! ** Method  : - Read the xco2 file
499      !!----------------------------------------------------------------------
500      INTEGER                       ::  jn, jm, io, ierr, inum, iostatus
501      INTEGER, PARAMETER            ::  iskip = 4   ! number of 1st descriptor lines
502      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)   ::   zyy !: xCO2 record years
503      CHARACTER (len=10), PARAMETER ::  clname = 'xco2.atm'  !! atm CO2 record file
504      !!----------------------------------------------------------------------
505
506      IF(lwp) WRITE(numout,*)
507      IF(lwp) WRITE(numout,*) ' trc_ini_medusa_co2atm: initialisation of atm CO2 historical record'
508      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~'
509
510
511      IF(lwp) WRITE(numout,*) 'read of formatted file xco2.atm'
512
513      CALL ctl_opn( inum, clname, 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
514      !!!
515      ! -Compute the number of year in the file
516      ! -File starts in co2_yinit, jn represents the record number in the file.
517      ! -Remove the file head (iskip lines) to jn
518      ! -The year is jn + yinit - 1
519      !! Determine the number of lines in xCO2 input file
520      iostatus = 0
521      jn = 1
522      DO WHILE ( iostatus == 0 )
523        READ(inum,'(1x)', IOSTAT=iostatus, END=100)
524        jn = jn + 1
525      ENDDO
526      IF( iostatus .NE. 0 ) THEN
527        !! Error while reading xCO2 input file
528        CALL ctl_stop('trc_ini_medusa_co2atm: &
529                      & Error on the 1st reading of xco2.atm')
530        RETURN
531      ENDIF
532 100  co2_rec = jn - 1 - iskip
533      IF ( lwp) WRITE(numout,*) '    ', co2_rec ,' years read in the file'
534      !                                ! Allocate CO2 hist arrays
535      ierr = 0 
536      ALLOCATE( hist_pco2(co2_rec),zyy(co2_rec), STAT=ierr )
537      IF( ierr > 0 ) THEN
538         CALL ctl_stop( 'trc_ini_medusa_co2atm: unable to allocate  array' ) 
539         RETURN
540      ENDIF
541
542      REWIND(inum)
543
544      DO jm = 1, iskip        ! Skip over 1st six descriptor lines
545         READ(inum,'(1x)')
546      END DO
547      ! file starts in 1931 do jn represent the year in the century.jhh
548      ! Read file till the end
549      ! allocate start and end year of the file
550      DO jn = 1, co2_rec
551        READ(inum,'(F6.1,F12.7)', IOSTAT=io) zyy(jn), hist_pco2(jn)
552        IF( io .NE. 0 ) THEN
553          !! Error while reading xCO2 input file
554          CALL ctl_stop('trc_ini_medusa_co2atm: &
555                        & Error on the 2nd reading of xco2.atm')
556          RETURN
557        ENDIF
558
559        IF(jn==1) co2_yinit = zyy(jn)
560      END DO
561      co2_yend = co2_yinit + real(co2_rec) - 1.
562
563      IF(lwp) THEN        ! Control print
564         WRITE(numout,*)
565         WRITE(numout,*) 'CO2 hist start year: ', co2_yinit
566         WRITE(numout,*) 'CO2 hist end   year: ', co2_yend
567         WRITE(numout,*) ' Year   xCO2 atm '
568         DO jn = 1, co2_rec
569            WRITE(numout, '(F6.1,F12.7)') zyy(jn), hist_pco2(jn)
570         END DO
571      ENDIF
572
573   END SUBROUTINE trc_ini_medusa_co2atm
574
575
576#else
577   !!----------------------------------------------------------------------
578   !!   Dummy module                                        No MEDUSA model
579   !!----------------------------------------------------------------------
580CONTAINS
581   SUBROUTINE trc_ini_medusa             ! Empty routine
582   END SUBROUTINE trc_ini_medusa
583#endif
584
585   !!======================================================================
586END MODULE trcini_medusa
Note: See TracBrowser for help on using the repository browser.