source: CONFIG/publications/ICOLMDZORINCA_CO2_Transport_GMD_2023/INCA/src/INCA_SRC/chemini.F90 @ 6610

Last change on this file since 6610 was 6610, checked in by acosce, 10 months ago

INCA used for ICOLMDZORINCA_CO2_Transport_GMD_2023

File size: 12.7 KB
Line 
1!$Id: chemini.F90 163 2010-02-22 15:41:45Z acosce $
2!! =========================================================================
3!! INCA - INteraction with Chemistry and Aerosols
4!!
5!! Copyright Laboratoire des Sciences du Climat et de l'Environnement (LSCE)
6!!           Unite mixte CEA-CNRS-UVSQ
7!!
8!! Contributors to this INCA subroutine:
9!!
10!! Didier Hauglustaine, LSCE, hauglustaine@cea.fr
11!! Stacy Walters, NCAR, stacy@ucar.edu
12!!
13!! Anne Cozic, LSCE, anne.cozic@cea.fr
14!! Yann Meurdesoif, LSCE, yann.meurdesoif@cea.fr
15!!
16!! This software is a computer program whose purpose is to simulate the
17!! atmospheric gas phase and aerosol composition. The model is designed to be
18!! used within a transport model or a general circulation model. This version
19!! of INCA was designed to be coupled to the LMDz GCM. LMDz-INCA accounts
20!! for emissions, transport (resolved and sub-grid scale), photochemical
21!! transformations, and scavenging (dry deposition and washout) of chemical
22!! species and aerosols interactively in the GCM. Several versions of the INCA
23!! model are currently used depending on the envisaged applications with the
24!! chemistry-climate model.
25!!
26!! This software is governed by the CeCILL  license under French law and
27!! abiding by the rules of distribution of free software.  You can  use,
28!! modify and/ or redistribute the software under the terms of the CeCILL
29!! license as circulated by CEA, CNRS and INRIA at the following URL
30!! "http://www.cecill.info".
31!!
32!! As a counterpart to the access to the source code and  rights to copy,
33!! modify and redistribute granted by the license, users are provided only
34!! with a limited warranty  and the software's author,  the holder of the
35!! economic rights,  and the successive licensors  have only  limited
36!! liability.
37!!
38!! In this respect, the user's attention is drawn to the risks associated
39!! with loading,  using,  modifying and/or developing or reproducing the
40!! software by the user in light of its specific status of free software,
41!! that may mean  that it is complicated to manipulate,  and  that  also
42!! therefore means  that it is reserved for developers  and  experienced
43!! professionals having in-depth computer knowledge. Users are therefore
44!! encouraged to load and test the software's suitability as regards their
45!! requirements in conditions enabling the security of their systems and/or
46!! data to be ensured and,  more generally, to use and operate it in the
47!! same conditions as regards security.
48!!
49!! The fact that you are presently reading this means that you have had
50!! knowledge of the CeCILL license and that you accept its terms.
51!! =========================================================================
52
53#include <inca_define.h>
54
55SUBROUTINE CHEMINI( &
56   xgravit  ,&
57   xrearth  ,&
58   xlatwts  ,&
59   latgcm   ,&
60   longcm   ,&
61   presnivs ,&
62   calday   ,&
63   klon     ,&
64   nqmax    ,&
65   nqo      ,&
66   pdtphys  ,&
67   annee_ref ,& 
68   year_cur, &
69   day_ref  ,&
70   day_ini, &
71   start_time, &
72   itau_phy ,&
73   date0,    &
74   io_lon   ,&
75   io_lat   ,&
76   chemistry_couple, &
77   init_source, init_tauinca, init_pizinca, init_cginca,init_ccm)
78  !-----------------------------------------------------------------------
79  !     ... Chemistry module intialization
80  ! Didier Hauglustaine and Stacy Walters, 1999.
81  !-----------------------------------------------------------------------
82
83  USE CONST_MOD
84  USE CONST_LMDZ
85  USE CHEM_CONS
86  USE CHEM_TRACNM
87  USE INCA_DIM
88  USE PARAM_CHEM, ONLY : flag_o3, flag_plane
89  USE  MOD_CONST_MPI_INCA
90  USE AEROSOL_DIAG, ONLY :  naero_grp, nbands
91
92#ifdef GES
93  USE CARBONATOR
94#endif
95
96  USE SURF_CHEM_MOD
97  USE PRINT_INCA
98#ifdef STRAT
99  USE HETCHEM
100#endif
101  USE IOIPSL
102#ifdef XIOS
103  USE xios
104  USE xios_inca
105#endif
106  USE INCA_DATA_PARA
107
108  IMPLICIT NONE
109
110  !-----------------------------------------------------------------------
111  !     ... Dummy arguments
112  !-----------------------------------------------------------------------
113  REAL, INTENT(in) ::  xgravit
114  REAL, INTENT(in) ::  xrearth
115  REAL, INTENT(in) ::  calday
116  REAL, INTENT(in) ::  latgcm(PLON)
117  REAL, INTENT(in) ::  longcm(PLON)
118  REAL, INTENT(in) ::  presnivs(PLEV)
119  REAL, INTENT(in) ::  xlatwts(PLON)
120  INTEGER, INTENT(in) :: klon
121  INTEGER, INTENT(in) :: nqmax  ! nombre total de traceurs = inca + lmdz
122  INTEGER, INTENT(in) :: nqo ! nombre de traceurs lus dans traceur.def
123  REAL, INTENT(in) :: pdtphys
124  INTEGER, INTENT(in) :: annee_ref, year_cur
125  INTEGER, INTENT(in) :: day_ref, day_ini
126  REAL, INTENT(in) :: start_time
127  INTEGER, INTENT(in) :: itau_phy
128  REAL,INTENT(IN) :: io_lat(jjm_glo-1/(iim_glo*(jjm_glo-1))) ! latitudes (of global grid)
129  REAL,INTENT(IN) :: io_lon(iim_glo) ! longitudes (of global grid)
130  REAL,INTENT(IN):: date0
131  LOGICAL, INTENT(IN) :: chemistry_couple 
132
133  REAL, DIMENSION(PLON,PCNST),INTENT(OUT) :: init_source
134  REAL, DIMENSION(PLON,PLEV,naero_grp,nbands),INTENT(OUT) :: init_tauinca
135  REAL, DIMENSION(PLON,PLEV,naero_grp,nbands),INTENT(OUT) :: init_pizinca
136  REAL, DIMENSION(PLON,PLEV,naero_grp,nbands),INTENT(OUT) :: init_cginca
137  REAL, DIMENSION(PLON,PLEV,nbands),INTENT(OUT) :: init_ccm
138  !-----------------------------------------------------------------------
139  !     ... Local variables
140  !-----------------------------------------------------------------------
141  INTEGER :: grid_id, vert_id          ! axes ID
142  INTEGER :: unit
143
144  !-----------------------------------------------------------------------
145  !     ... Function declarations
146  !-----------------------------------------------------------------------
147  INTEGER  ::  NAVU
148  REAL     ::  TSECND
149  INTEGER :: x_an, x_mois, x_jour
150  real :: x_heure, zjulian, zjulian_start
151  INTEGER :: ini_an, ini_mois, ini_jour
152  REAL :: ini_heure
153
154  init_source = 0. 
155  init_tauinca =  0. 
156  init_pizinca = 0. 
157  init_cginca = 0. 
158  init_ccm = 0. 
159
160
161  !
162  ! Initialisation de xios
163  !
164  CALL conf_chem(chemistry_couple) 
165
166
167  ! -----------------------------------------------------------------------
168  ! initialisation des autres parametres pour le couplage avec la vegetation
169  ! ------------------------------------------------------------------------
170  call INIT_SURF_CHEM_MOD
171
172  !-----------------------------------------------------------------------
173  !     ... Readin chemistry simulation specific data
174  !-----------------------------------------------------------------------
175  CALL CHEM_INTI()
176
177
178  ! Initialisation de XIOS
179
180#ifdef XIOS
181  CALL ymds2ju(annee_ref, 1, day_ref, 0.0, zjulian)
182  CALL ju2ymds(zjulian, x_an, x_mois, x_jour, x_heure)
183
184  CALL ymds2ju(annee_ref, 1, day_ini, start_time, zjulian_start)
185  CALL ju2ymds(zjulian_start, ini_an, ini_mois, ini_jour, ini_heure)
186
187
188  call xios_inca_init(COMM_INCA , pdtphys, x_an, x_mois,x_jour, x_heure, &
189       ini_an, ini_mois, ini_jour, ini_heure, io_lon, io_lat, presnivs) 
190
191
192#endif
193
194  ! lecture du restart
195  CALL xios_chem_read_restart(init_source, init_tauinca, init_pizinca, init_cginca,init_ccm)
196
197  !-----------------------------------------------------------------------
198  !     ... Parameters initialisation
199  !-----------------------------------------------------------------------
200
201#ifdef STRAT
202  CALL init_hetchem
203#endif
204
205  !-----------------------------------------------------------------------
206  !       ... Make sure LMDz and INCA resolutions are identical
207  !-----------------------------------------------------------------------
208
209  IF ( (klon /= PLON) .OR. ( (nqmax-nqo) /= PCNST) ) THEN
210     WRITE(lunout,*) '          [klon,  plon]  ', klon, PLON
211     WRITE(lunout,*) '          [nqmax-nqo, pcnst, nqo] ', nqmax-nqo, PCNST, nqo
212     CALL print_err(3, 'chemini', 'LMDZ-INCA resolution mismatch -- Abort.', &
213          'check klon,plon', 'and nqmax-nqo, pcnst')
214  END IF
215
216  CALL suphel_I
217
218
219
220  !-----------------------------------------------------------------------
221  !     ... Initialize chemistry variables
222  !-----------------------------------------------------------------------
223  d2r = pi / 180.
224  r2d = 1. / d2r
225  rearth = xrearth
226  phi(:) = latgcm(:) * d2r
227  lambda(:) = longcm(:) * d2r
228  latwts(:) = xlatwts(:)
229
230
231  !-----------------------------------------------------------------------
232  !     ... Diagnostics initialization
233  !-----------------------------------------------------------------------
234  !DH   call DIAGS_INTI( solsym )
235#ifndef DUSS
236# if CLSCNT4 != 0
237  !-----------------------------------------------------------------------
238  !     ... Implicit solver initialization
239  !-----------------------------------------------------------------------
240  call IMP_SLV_INTI()
241# endif
242#endif
243  unit = NAVU()
244
245#ifndef DUSS
246#if defined(AERONLY) || defined(GES)
247  !-----------------------------------------------------------------------
248  !     ... Initialize photorate module
249  !-----------------------------------------------------------------------
250  CALL PRATE_INTI( unit )
251#else
252  !-----------------------------------------------------------------------
253  !     ... Initialize photorate module
254  !-----------------------------------------------------------------------
255  CALL PRATE_INTI( unit )
256
257  !-----------------------------------------------------------------------
258  !       ... Read time-dependent airplane emissions
259  !-----------------------------------------------------------------------
260  IF (flag_plane .ne. 0) then
261     CALL AIRPL_SRC  (  'aircraft_mth.nc', 'aircraft_hour.nc' )
262     IF (flag_plane .eq. 3) then
263        CALL AIRPL_SRC_HS  (  'aircraft_hs.nc' )
264     ENDIF
265  ENDIF
266
267#endif
268#endif
269
270
271
272
273# ifdef SFLUX
274  !-----------------------------------------------------------------------
275  !     ... Read time-dependent surface flux dataset
276  !-----------------------------------------------------------------------
277#ifndef DUSS
278  CALL XIOS_SFLX_INTI  ()
279#ifdef GES
280  CALL CARBONATOR_INTI(itau_phy,date0,pdtphys)
281#endif
282!  CALL DVEL_INTI  (  'landuse.nc' )
283#ifndef AERONLY
284!  CALL NPP_INTI   (  'npp.nc' )
285#endif
286#endif
287# endif     
288  call xios_npp_landuse_inti()
289
290  !-----------------------------------------------------------------------
291  !     ... Read time-dependent data sets
292  !-----------------------------------------------------------------------
293
294#ifndef DUSS
295#if defined(AERONLY) || defined(GES)
296!  CALL OXYDANT_INTI ('oxydants.nc')
297 
298#else
299#ifndef AER
300  CALL SULF_INTI   ('so4.nc')
301#endif
302  if (trim(flag_o3) .eq. 'o3clim') then
303     CALL OZCLIM_INTI ('o3clim.nc')
304  endif
305  if (trim(flag_o3) .eq. 'o3lin') then
306     CALL OZLIN_INTI ('o3lin.nc')
307  endif
308
309#ifdef STRAT
310  CALL SAD_INTI ('sad.nc')
311  CALL LGLIVED('lglived.dat',year_cur)
312#endif
313
314#endif
315#endif
316
317!  CALL xios_chem_read_restart()
318
319
320#ifdef XIOS
321  call xios_inca_change_context("LMDZ")
322#endif
323!  CALL xios_chem_read_restart()
324END SUBROUTINE CHEMINI
325
326SUBROUTINE check_err(iret, name, string)
327
328  USE PRINT_INCA
329   IMPLICIT NONE
330
331  !----------------------------------------------------------------------
332  !       ... netCDF error check
333  !----------------------------------------------------------------------
334
335  INTEGER :: iret
336  CHARACTER(LEN=*) :: name, string
337  INCLUDE 'netcdf.inc'
338  IF (iret /= NF_NOERR) THEN
339     WRITE(lunout, *) 'netCDF error ', nf_strerror(iret), ' : ', &
340          ' in Routine : ', name,' ', string(:LEN_TRIM(string))
341     WRITE(*,'("Fatal error from INCA. Read INCA output text")')
342     flush(lunout)
343#ifdef CPP_PARA
344     call MPI_ABORT(3)
345#endif
346     STOP
347  ENDIF
348
349END SUBROUTINE check_err
350
351  !----------------------------------------------------------------------
352  !       ... Print error message
353  !----------------------------------------------------------------------
354SUBROUTINE print_err(lev,name,str1,str2,str3) 
355!---------------------------------------------------------------------
356!! The "print_err" routine
357!! allows to handle the messages to the user.
358!!
359!! parallel version of IOIPSL ipslerr
360!!
361!! INPUT
362!!
363!! lev   : Category of message to be reported to the user
364!!          1 = Note to the user
365!!          2 = Warning to the user
366!!          3 = Fatal error
367!! name : Name of subroutine which has called ipslerr
368!! str1   
369!! str2  : Strings containing the explanations to the user
370!! str3
371!---------------------------------------------------------------------
372  USE PRINT_INCA
373   IMPLICIT NONE
374
375   INTEGER :: lev
376   CHARACTER(LEN=*) :: name,str1,str2,str3
377!-
378   CHARACTER(LEN=30),DIMENSION(3) :: pemsg = &
379  &  (/ "NOTE TO THE USER FROM ROUTINE ", &
380  &     "WARNING FROM ROUTINE          ", &
381  &     "FATAL ERROR FROM ROUTINE      " /)
382!---------------------------------------------------------------------
383   IF ( (lev >= 1).AND.(lev <= 3) ) THEN
384     WRITE(lunout,'(/,A," ",A)') TRIM(pemsg(lev)),TRIM(name)
385     WRITE(lunout,'(3(" --> ",A,/))') TRIM(str1),TRIM(str2),TRIM(str3)
386   ENDIF
387   IF (lev == 3) THEN
388     WRITE(*,'("Fatal error from INCA. Go to Read DEBUG INCA output text")')
389     flush(lunout)
390#ifdef CPP_PARA
391    CALL MPI_ABORT(lev)
392#endif     
393    STOP
394   ENDIF
395!---------------------
396 
397END SUBROUTINE print_err
Note: See TracBrowser for help on using the repository browser.