Skip to content

Commit 94eeddf

Browse files
authored
Merge pull request #10 from nichollsh/hn/fixgases
Fix places where the new gases were not neglected
2 parents a6807e6 + f09bcb4 commit 94eeddf

File tree

8 files changed

+373
-115
lines changed

8 files changed

+373
-115
lines changed

README.md

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ Rehosted from the original Met Office source [1] with modifications by Harrison
77
### Contents
88
0. Licence
99
1. What's included?
10-
2. [Omitted in this redistribution of the code]
11-
3. Compiling the source code externally
12-
4. Compilation of scripts in sbin
13-
5. Running the code
14-
6. Tested compilers
15-
7. Contributors
10+
2. Compiling the source code externally
11+
3. Running the code
12+
4. Tested compilers
13+
5. Contributors
14+
6. Adding a new gas
1615

1716

1817
--------------------------------
@@ -41,24 +40,15 @@ For further details please refer to the file COPYRIGHT.txt which you should have
4140

4241
`spectraltools/` contains new addons to the code which allow for streamlined and flexible creation of spectral files from precomputed cross-sections.
4342

44-
### 3) Compiling the source code externally
43+
### 2) Compiling the source code externally
4544

4645
The following commands can be run to build the suite and setup your path to the executables and man pages:
4746

4847
1. `./configure`
4948
2. `./build_code`
5049
3. `source ./set_rad_env`
5150

52-
53-
### 4) Compilation of scripts in sbin
54-
55-
There are a small number of utilities in `sbin/` which are written in C and require compilation. A Makefile has been provided:
56-
57-
1. `cd $RAD_SCRIPT`
58-
2. `make`
59-
60-
61-
### 5) Running the code
51+
### 3) Running the code
6252

6353
Once you have set your path to the man pages (see section 2/3) you can find up-to-date instructions for running the following routines:
6454

@@ -86,22 +76,39 @@ These scripts are a command line interface to interactive routines in the `bin/`
8676
It is very useful to study the examples/ directory for common usage of the code.
8777

8878

89-
### 6) Tested compilers
79+
### 4) Tested compilers
9080

9181
The full suite has been tested with the following compilers:
9282
* Intel ifort 17.0.7
93-
* GCC gfortran 9.4.0
94-
95-
### 7) Contributors
83+
* GNU gfortran 9.4.0
9684

97-
Significant contributors include:
85+
### 5) Contributors
9886
* J. Edwards
9987
* A. Slingo
10088
* J. Manners
89+
* S. Havemann
90+
* S. Mullerworth
91+
* D. Sergeev
92+
* H. Nicholls
93+
94+
### 6) Adding a new gas
95+
96+
This has to be done manually and will require editing a lot of files. The easiest thing to
97+
do is to search for the gas "ho2no2" across all files and copy what you see. Always add
98+
new gases to the end of the existing lists. This will require changing function calls,
99+
various hardcoded arrays and variables. You should expect to edit these files:
100+
* `julia/src/SOCRATES_C.f90`
101+
* `julia/src/SOCRATES.jl`
102+
* `spectraltools/src/phys.py`
103+
* `spectraltools/src/utils.py`
104+
* `src/interface_core/socrates_set_spectrum.F90`
105+
* `src/modules_gen/input_head_pcf.f90`
106+
* `src/radiance_core/def_control.F90`
107+
* `src/radiance_core/gas_list_pcf.F90`
101108

102109

103110
### References
104111
* [1] https://code.metoffice.gov.uk/trac/socrates
105112
* [2] https://doi.org/10.1002/qj.49712253107
106113
* [3] https://doi.org/10.1051/0004-6361/201323169
107-
* [4]
114+
* [4] https://doi.org/10.5194/gmd-16-5601-2023

julia/src/SOCRATES.jl

Lines changed: 200 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -93,31 +93,81 @@ function set_spectrum(;
9393
spectrum::Union{StrSpecData, Ptr{Nothing}} = C_NULL,
9494
spectrum_name::Union{AbstractString, Ptr{Nothing}} = C_NULL,
9595
spectral_file::Union{AbstractString, Ptr{Nothing}} = C_NULL,
96-
l_h2o = C_NULL,
97-
l_co2::Union{Bool, Ptr{Nothing}} = C_NULL,
98-
l_o3::Union{Bool, Ptr{Nothing}} = C_NULL,
99-
l_o2::Union{Bool, Ptr{Nothing}} = C_NULL,
100-
l_n2o::Union{Bool, Ptr{Nothing}} = C_NULL,
101-
l_ch4::Union{Bool, Ptr{Nothing}} = C_NULL,
102-
l_so2::Union{Bool, Ptr{Nothing}} = C_NULL,
103-
l_cfc11::Union{Bool, Ptr{Nothing}} = C_NULL,
104-
l_cfc12::Union{Bool, Ptr{Nothing}} = C_NULL,
105-
l_cfc113::Union{Bool, Ptr{Nothing}} = C_NULL,
106-
l_cfc114::Union{Bool, Ptr{Nothing}} = C_NULL,
107-
l_hcfc22::Union{Bool, Ptr{Nothing}} = C_NULL,
108-
l_hfc125::Union{Bool, Ptr{Nothing}} = C_NULL,
109-
l_hfc134a::Union{Bool, Ptr{Nothing}} = C_NULL,
110-
l_co::Union{Bool, Ptr{Nothing}} = C_NULL,
111-
l_nh3::Union{Bool, Ptr{Nothing}} = C_NULL,
112-
l_tio::Union{Bool, Ptr{Nothing}} = C_NULL,
113-
l_vo::Union{Bool, Ptr{Nothing}} = C_NULL,
114-
l_h2::Union{Bool, Ptr{Nothing}} = C_NULL,
115-
l_he::Union{Bool, Ptr{Nothing}} = C_NULL,
116-
l_na::Union{Bool, Ptr{Nothing}} = C_NULL,
117-
l_k::Union{Bool, Ptr{Nothing}} = C_NULL,
118-
l_li::Union{Bool, Ptr{Nothing}} = C_NULL,
119-
l_rb::Union{Bool, Ptr{Nothing}} = C_NULL,
120-
l_cs::Union{Bool, Ptr{Nothing}} = C_NULL,
96+
l_h2o ::Union{Bool, Ptr{Nothing}} = C_NULL,
97+
l_co2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
98+
l_o3 ::Union{Bool, Ptr{Nothing}} = C_NULL,
99+
l_n2o ::Union{Bool, Ptr{Nothing}} = C_NULL,
100+
l_co ::Union{Bool, Ptr{Nothing}} = C_NULL,
101+
l_ch4 ::Union{Bool, Ptr{Nothing}} = C_NULL,
102+
l_o2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
103+
l_no ::Union{Bool, Ptr{Nothing}} = C_NULL,
104+
l_so2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
105+
l_no2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
106+
l_nh3 ::Union{Bool, Ptr{Nothing}} = C_NULL,
107+
l_hno3 ::Union{Bool, Ptr{Nothing}} = C_NULL,
108+
l_n2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
109+
l_cfc11 ::Union{Bool, Ptr{Nothing}} = C_NULL,
110+
l_cfc12 ::Union{Bool, Ptr{Nothing}} = C_NULL,
111+
l_cfc113 ::Union{Bool, Ptr{Nothing}} = C_NULL,
112+
l_hcfc22 ::Union{Bool, Ptr{Nothing}} = C_NULL,
113+
l_hfc125 ::Union{Bool, Ptr{Nothing}} = C_NULL,
114+
l_hfc134a ::Union{Bool, Ptr{Nothing}} = C_NULL,
115+
l_cfc114 ::Union{Bool, Ptr{Nothing}} = C_NULL,
116+
l_tio ::Union{Bool, Ptr{Nothing}} = C_NULL,
117+
l_vo ::Union{Bool, Ptr{Nothing}} = C_NULL,
118+
l_h2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
119+
l_he ::Union{Bool, Ptr{Nothing}} = C_NULL,
120+
l_ocs ::Union{Bool, Ptr{Nothing}} = C_NULL,
121+
l_na ::Union{Bool, Ptr{Nothing}} = C_NULL,
122+
l_k ::Union{Bool, Ptr{Nothing}} = C_NULL,
123+
l_feh ::Union{Bool, Ptr{Nothing}} = C_NULL,
124+
l_crh ::Union{Bool, Ptr{Nothing}} = C_NULL,
125+
l_li ::Union{Bool, Ptr{Nothing}} = C_NULL,
126+
l_rb ::Union{Bool, Ptr{Nothing}} = C_NULL,
127+
l_cs ::Union{Bool, Ptr{Nothing}} = C_NULL,
128+
l_ph3 ::Union{Bool, Ptr{Nothing}} = C_NULL,
129+
l_c2h2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
130+
l_hcn ::Union{Bool, Ptr{Nothing}} = C_NULL,
131+
l_h2s ::Union{Bool, Ptr{Nothing}} = C_NULL,
132+
l_ar ::Union{Bool, Ptr{Nothing}} = C_NULL,
133+
l_o ::Union{Bool, Ptr{Nothing}} = C_NULL,
134+
l_n ::Union{Bool, Ptr{Nothing}} = C_NULL,
135+
l_no3 ::Union{Bool, Ptr{Nothing}} = C_NULL,
136+
l_n2o5 ::Union{Bool, Ptr{Nothing}} = C_NULL,
137+
l_hono ::Union{Bool, Ptr{Nothing}} = C_NULL,
138+
l_ho2no2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
139+
l_h2o2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
140+
l_c2h6 ::Union{Bool, Ptr{Nothing}} = C_NULL,
141+
l_ch3 ::Union{Bool, Ptr{Nothing}} = C_NULL,
142+
l_h2co ::Union{Bool, Ptr{Nothing}} = C_NULL,
143+
l_ho2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
144+
l_hdo ::Union{Bool, Ptr{Nothing}} = C_NULL,
145+
l_hcl ::Union{Bool, Ptr{Nothing}} = C_NULL,
146+
l_hf ::Union{Bool, Ptr{Nothing}} = C_NULL,
147+
l_cosso ::Union{Bool, Ptr{Nothing}} = C_NULL,
148+
l_tosso ::Union{Bool, Ptr{Nothing}} = C_NULL,
149+
l_yosos ::Union{Bool, Ptr{Nothing}} = C_NULL,
150+
l_ch3cho ::Union{Bool, Ptr{Nothing}} = C_NULL,
151+
l_ch3ooh ::Union{Bool, Ptr{Nothing}} = C_NULL,
152+
l_ch3coch3 ::Union{Bool, Ptr{Nothing}} = C_NULL,
153+
l_ch3cocho ::Union{Bool, Ptr{Nothing}} = C_NULL,
154+
l_chocho ::Union{Bool, Ptr{Nothing}} = C_NULL,
155+
l_c2h5cho ::Union{Bool, Ptr{Nothing}} = C_NULL,
156+
l_hoch2cho ::Union{Bool, Ptr{Nothing}} = C_NULL,
157+
l_c2h5coch3::Union{Bool, Ptr{Nothing}} = C_NULL,
158+
l_mvk ::Union{Bool, Ptr{Nothing}} = C_NULL,
159+
l_macr ::Union{Bool, Ptr{Nothing}} = C_NULL,
160+
l_pan ::Union{Bool, Ptr{Nothing}} = C_NULL,
161+
l_ch3ono2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
162+
l_sio ::Union{Bool, Ptr{Nothing}} = C_NULL,
163+
l_sio2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
164+
l_fe ::Union{Bool, Ptr{Nothing}} = C_NULL,
165+
l_feo ::Union{Bool, Ptr{Nothing}} = C_NULL,
166+
l_na2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
167+
l_nao ::Union{Bool, Ptr{Nothing}} = C_NULL,
168+
l_mg ::Union{Bool, Ptr{Nothing}} = C_NULL,
169+
l_mg2 ::Union{Bool, Ptr{Nothing}} = C_NULL,
170+
l_mgo ::Union{Bool, Ptr{Nothing}} = C_NULL,
121171
l_all_gasses::Union{Bool, Ptr{Nothing}} = C_NULL,
122172
wavelength_blue::Union{Float64, Ptr{Nothing}} = C_NULL,
123173
)
@@ -158,37 +208,137 @@ function set_spectrum(;
158208
Ref{Cuchar},
159209
Ref{Cuchar},
160210
Ref{Cuchar},
211+
Ref{Cuchar},
212+
Ref{Cuchar},
213+
Ref{Cuchar},
214+
Ref{Cuchar},
215+
Ref{Cuchar},
216+
Ref{Cuchar},
217+
Ref{Cuchar},
218+
Ref{Cuchar},
219+
Ref{Cuchar},
220+
Ref{Cuchar},
221+
Ref{Cuchar},
222+
Ref{Cuchar},
223+
Ref{Cuchar},
224+
Ref{Cuchar},
225+
Ref{Cuchar},
226+
Ref{Cuchar},
227+
Ref{Cuchar},
228+
Ref{Cuchar},
229+
Ref{Cuchar},
230+
Ref{Cuchar},
231+
Ref{Cuchar},
232+
Ref{Cuchar},
233+
Ref{Cuchar},
234+
Ref{Cuchar},
235+
Ref{Cuchar},
236+
Ref{Cuchar},
237+
Ref{Cuchar},
238+
Ref{Cuchar},
239+
Ref{Cuchar},
240+
Ref{Cuchar},
241+
Ref{Cuchar},
242+
Ref{Cuchar},
243+
Ref{Cuchar},
244+
Ref{Cuchar},
245+
Ref{Cuchar},
246+
Ref{Cuchar},
247+
Ref{Cuchar},
248+
Ref{Cuchar},
249+
Ref{Cuchar},
250+
Ref{Cuchar},
251+
Ref{Cuchar},
252+
Ref{Cuchar},
253+
Ref{Cuchar},
254+
Ref{Cuchar},
255+
Ref{Cuchar},
256+
Ref{Cuchar},
257+
Ref{Cuchar},
258+
Ref{Cuchar},
259+
Ref{Cuchar},
260+
Ref{Cuchar},
161261
Ptr{Cvoid}, # Ref{Cdouble} doesn't work (can't be set to C_NULL) ???
162262
),
163263
n_instances,
164264
spectrum === C_NULL ? C_NULL : spectrum.cptr,
165265
spectrum_name,
166266
spectral_file,
167-
l_h2o,
168-
l_co2,
169-
l_o3,
170-
l_o2,
171-
l_n2o,
172-
l_ch4,
173-
l_so2,
174-
l_cfc11,
175-
l_cfc12,
176-
l_cfc113,
177-
l_cfc114,
178-
l_hcfc22,
179-
l_hfc125,
180-
l_hfc134a,
181-
l_co,
182-
l_nh3,
183-
l_tio,
184-
l_vo,
185-
l_h2,
186-
l_he,
187-
l_na,
188-
l_k,
189-
l_li,
190-
l_rb,
191-
l_cs,
267+
l_h2o ,
268+
l_co2 ,
269+
l_o3 ,
270+
l_n2o ,
271+
l_co ,
272+
l_ch4 ,
273+
l_o2 ,
274+
l_no ,
275+
l_so2 ,
276+
l_no2 ,
277+
l_nh3 ,
278+
l_hno3 ,
279+
l_n2 ,
280+
l_cfc11 ,
281+
l_cfc12 ,
282+
l_cfc113 ,
283+
l_hcfc22 ,
284+
l_hfc125 ,
285+
l_hfc134a ,
286+
l_cfc114 ,
287+
l_tio ,
288+
l_vo ,
289+
l_h2 ,
290+
l_he ,
291+
l_ocs ,
292+
l_na ,
293+
l_k ,
294+
l_feh ,
295+
l_crh ,
296+
l_li ,
297+
l_rb ,
298+
l_cs ,
299+
l_ph3 ,
300+
l_c2h2 ,
301+
l_hcn ,
302+
l_h2s ,
303+
l_ar ,
304+
l_o ,
305+
l_n ,
306+
l_no3 ,
307+
l_n2o5 ,
308+
l_hono ,
309+
l_ho2no2 ,
310+
l_h2o2 ,
311+
l_c2h6 ,
312+
l_ch3 ,
313+
l_h2co ,
314+
l_ho2 ,
315+
l_hdo ,
316+
l_hcl ,
317+
l_hf ,
318+
l_cosso ,
319+
l_tosso ,
320+
l_yosos ,
321+
l_ch3cho ,
322+
l_ch3ooh ,
323+
l_ch3coch3 ,
324+
l_ch3cocho ,
325+
l_chocho ,
326+
l_c2h5cho ,
327+
l_hoch2cho ,
328+
l_c2h5coch3 ,
329+
l_mvk ,
330+
l_macr ,
331+
l_pan ,
332+
l_ch3ono2 ,
333+
l_sio ,
334+
l_sio2 ,
335+
l_fe ,
336+
l_feo ,
337+
l_na2 ,
338+
l_nao ,
339+
l_mg ,
340+
l_mg2 ,
341+
l_mgo ,
192342
l_all_gasses,
193343
wavelength_blue === C_NULL ? C_NULL : Ref{Cdouble}(wavelength_blue),
194344
)

0 commit comments

Comments
 (0)