SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
ch_init_depconst.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #########
6  SUBROUTINE ch_init_depconst(KCH,KLUOUT,HSV)
7 !! ##################################################
8 !!
9 !!*** *CH_INIT_DEPCONST*
10 !!
11 !! PURPOSE
12 !! -------
13 ! Read Henry Specific constant, Molecular Mass and Biological reactivity
14 !! factor.
15 !!
16 !!
17 !!** METHOD
18 !! ------
19 !
20 !! Chemical constant will be read from
21 !! the general purpose input file .
22 !!
23 !! chemical molecular diffusivity MASS_MOL
24 !! molecular reactivity factor REA_FACT
25 !! molecular effective Henry constant HENRY_SP
26 !!
27 !!
28 !! REFERENCE
29 !! ---------
30 !!
31 !! AUTHOR
32 !! ------
33 !! P. Tulet *Meteo France*
34 !!
35 !! MODIFICATIONS
36 !! -------------
37 !! Original 16/02/01
38 
39 !! EXTERNAL
40 !! --------
41 !!
42 ! open the general purpose ASCII input file
43 USE modi_ch_open_inputb
44 USE modd_ch_surf
45 !!
46 !! IMPLICIT ARGUMENTS
47 !! ------------------
48 !-------------------------------------------------------------------------------
49 !
50 !* 0. DECLARATIONS
51 ! ------------
52 !
53 USE yomhook ,ONLY : lhook, dr_hook
54 USE parkind1 ,ONLY : jprb
55 !
56 IMPLICIT NONE
57 !
58 !* 0.1 declarations of arguments
59 !
60 INTEGER, INTENT(IN) :: kch ! chemistry input namelist logical unit
61 INTEGER, INTENT(IN) :: kluout ! output listing channel
62  CHARACTER(LEN=*), DIMENSION(:), INTENT(IN) :: hsv ! name of chemical species
63 !
64 !* 0.2 declarations of local variables
65 !
66  CHARACTER(LEN=40) :: yformat
67  ! format for input
68  CHARACTER(LEN=40) :: youtformat = '(A32,2E15.5)'
69  ! format for output
70 !
71 INTEGER :: imass ! number of molecular diffusivity to be read
72  CHARACTER(LEN=40), DIMENSION(:), ALLOCATABLE :: ymassmolname !species names
73 REAL , DIMENSION(:), ALLOCATABLE :: zmassmolval
74  ! molecular diffusivity value
75 !
76 INTEGER :: ireact ! number of chemical reactivity factor to be read
77  CHARACTER(LEN=40), DIMENSION(:), ALLOCATABLE :: yreactname !species names
78 REAL , DIMENSION(:), ALLOCATABLE :: zreactval
79  ! chemical reactivity factor value
80 !
81 INTEGER :: ihenry ! number of chemical Henry constant to be read
82  CHARACTER(LEN=40), DIMENSION(:), ALLOCATABLE :: yhenryname !species names
83  character(len=50) :: yname
84 REAL , DIMENSION(:,:), ALLOCATABLE :: zhenryval
85  !chemical Henry constant value
86 !
87 INTEGER :: ji, jn, jnreal ! loop control variables
88 INTEGER :: inact ! array pointer
89 logical :: lopened
90 REAL(KIND=JPRB) :: zhook_handle
91 !
92 !-------------------------------------------------------------------------------
93 !
94 !* 1. ALLOCATE FIELD
95 ! --------------
96 !
97 IF (lhook) CALL dr_hook('CH_INIT_DEPCONST',0,zhook_handle)
98 !$OMP SINGLE
99 IF(.NOT. ALLOCATED(xsrealmassmolval)) ALLOCATE( xsrealmassmolval(SIZE(hsv,1)) )
100 IF(.NOT. ALLOCATED(xsrealreactval) ) ALLOCATE( xsrealreactval(SIZE(hsv,1)) )
101 IF(.NOT. ALLOCATED(xsrealhenryval) ) ALLOCATE( xsrealhenryval(SIZE(hsv,1),2) )
102 !
103 !
104 !* 2. read chemical molecular diffusivity MASS_MOL
105 !
106 ! open input file
107  WRITE(kluout,*) &
108  "CH_INIT_CONST: reading molar mass"
109  CALL ch_open_inputb("MASS_MOL", kch, kluout)
110 !
111 ! read number of molecular diffusivity IMASS
112  READ(kch, *) imass
113  WRITE(kluout,*) "number of molecular diffusivity: ", imass
114 !
115 ! read data input format
116  READ(kch,"(A)") yformat
117  WRITE(kluout,*) "input format is: ", yformat
118 !$OMP END SINGLE COPYPRIVATE(IMASS,YFORMAT)
119 !
120 ! allocate fields
121  ALLOCATE(ymassmolname(imass))
122  ALLOCATE(zmassmolval(imass))
123 !
124 inquire(kch,name=yname,opened=lopened)
125 ! read molecular diffusivity
126 !$OMP SINGLE
127  DO ji = 1, imass
128  READ(kch,yformat) ymassmolname(ji), zmassmolval(ji)
129  WRITE(kluout,yformat) ymassmolname(ji), zmassmolval(ji)
130  END DO
131 !
132 !
133  WRITE(kluout,'(A)') '----------------------------------------------------'
134  WRITE(kluout,'(A)') 'MASS_MOL'
135  WRITE(kluout,'(A)') 'molecular mass (in g/mol) for molecular diffusion'
136  WRITE(kluout,'(I4)') SIZE(hsv,1)
137  WRITE(kluout,'(A)') youtformat
138 !$OMP END SINGLE COPYPRIVATE(YMASSMOLNAME,ZMASSMOLVAL)
139 !
140  xsrealmassmolval(:) = 50. ! default molecular mass
141  DO jnreal = 1, SIZE(hsv,1)
142  inact = 0
143  search_loop3 : DO jn = 1, imass
144  IF (hsv(jnreal) .EQ. ymassmolname(jn)) THEN
145  inact = jn
146  EXIT search_loop3
147  END IF
148  END DO search_loop3
149  IF (inact .NE. 0) xsrealmassmolval(jnreal) = zmassmolval(inact)
150  WRITE(kluout,youtformat) hsv(jnreal), xsrealmassmolval(jnreal)
151  END DO
152 !
153 !
154 !-----------------------------------------------------------------------------
155 !
156 !* 3. read molecular reactivity factor REA_FACT
157 !
158 ! open input file
159 !$OMP SINGLE
160  WRITE(kluout,*) &
161  "CH_INIT_CONST: reading reactivity factor "
162  CALL ch_open_inputb("REA_FACT", kch, kluout)
163 !
164 ! read number of molecular diffusivity IREACT
165  READ(kch, *) ireact
166  WRITE(kluout,*) "number of reactivity factor : ", ireact
167 !
168 ! read data input format
169  READ(kch,"(A)") yformat
170  WRITE(kluout,*) "input format is: ", yformat
171 !$OMP END SINGLE COPYPRIVATE(IREACT,YFORMAT)
172 !
173 ! allocate fields
174  ALLOCATE(yreactname(ireact))
175  ALLOCATE(zreactval(ireact))
176 ! read reactivity factor
177 !$OMP SINGLE
178  DO ji = 1, ireact
179  READ(kch,yformat) yreactname(ji), zreactval(ji)
180  WRITE(kluout,yformat) yreactname(ji), zreactval(ji)
181  END DO
182 !
183  WRITE(kluout,'(A)') '----------------------------------------------------'
184  WRITE(kluout,'(A)') 'REA_FACT'
185  WRITE(kluout,'(A)') 'reactivity factor'
186  WRITE(kluout,'(I4)') SIZE(hsv,1)
187  WRITE(kluout,'(A)') youtformat
188 !$OMP END SINGLE COPYPRIVATE(YREACTNAME,ZREACTVAL)
189 !
190  xsrealreactval(:) = 0.0 ! default (high surface resistance)
191  DO jnreal = 1, SIZE(hsv,1)
192  inact = 0
193  search_loop4 : DO jn = 1, ireact
194  IF (hsv(jnreal) .EQ. yreactname(jn)) THEN
195  inact = jn
196  EXIT search_loop4
197  END IF
198  END DO search_loop4
199  IF (inact .NE. 0) xsrealreactval(jnreal) = zreactval(inact)
200  WRITE(kluout,youtformat) hsv(jnreal), xsrealreactval(jnreal)
201  END DO
202 !
203 !
204 !-----------------------------------------------------------------------------
205 !
206 !* 4. read molecular effective Henry constant HENRY_SP
207 !
208 ! open input file
209  WRITE(kluout,*) &
210  "CH_INIT_CONST: reading effective Henry constant", &
211  " and its temperature correction "
212 !$OMP SINGLE
213  CALL ch_open_inputb("HENRY_SP", kch, kluout)
214 !
215 ! read number of molecular diffusivity IHENRY
216  READ(kch, *) ihenry
217  WRITE(kluout,*) "number of reactivity factor : ", ihenry
218 !
219 ! read data input format
220  READ(kch,"(A)") yformat
221  WRITE(kluout,*) "input format is: ", yformat
222 !$OMP END SINGLE COPYPRIVATe(IHENRY,YFORMAT)
223 !
224 ! allocate fields
225  ALLOCATE(yhenryname(ihenry))
226  ALLOCATE(zhenryval(ihenry,2))
227 !
228 ! read reactivity factor
229 !$OMP SINGLE
230  DO jnreal = 1, ihenry
231  READ(kch,yformat) yhenryname(jnreal), zhenryval(jnreal,1),&
232  zhenryval(jnreal,2)
233  WRITE(kluout,yformat) yhenryname(jnreal), zhenryval(jnreal,1),&
234  zhenryval(jnreal,2)
235  END DO
236 !
237  WRITE(kluout,'(A)') '----------------------------------------------------'
238  WRITE(kluout,'(A)') 'HENRY_SP'
239  WRITE(kluout,'(A)') 'Henrys law constants factor / exponent'
240  WRITE(kluout,'(I4)') SIZE(hsv,1)
241  WRITE(kluout,'(A)') youtformat
242 !$OMP END SINGLE COPYPRIVATE(YHENRYNAME,ZHENRYVAL)
243 !
244  xsrealhenryval(:,1) = 1e-8 ! no deposition; low Henry constant
245  xsrealhenryval(:,2) = 0. !
246  DO jnreal = 1, SIZE(hsv,1)
247  inact = 0
248  search_loop5 : DO jn = 1, ihenry
249  IF (hsv(jnreal) .EQ. yhenryname(jn)) THEN
250  inact = jn
251  EXIT search_loop5
252  END IF
253  END DO search_loop5
254  IF (inact .NE. 0) xsrealhenryval(jnreal,1) = zhenryval(inact,1)
255  IF (inact .NE. 0) xsrealhenryval(jnreal,2) = zhenryval(inact,2)
256  WRITE(kluout,youtformat) hsv(jnreal), &
257  xsrealhenryval(jnreal,1),&
258  xsrealhenryval(jnreal,2)
259  END DO
260 IF (lhook) CALL dr_hook('CH_INIT_DEPCONST',1,zhook_handle)
261 !
262 END SUBROUTINE ch_init_depconst
subroutine ch_init_depconst(KCH, KLUOUT, HSV)