1 | subroutine su_gases |
---|
2 | |
---|
3 | use gases_h |
---|
4 | |
---|
5 | implicit none |
---|
6 | |
---|
7 | integer igas, ierr, count |
---|
8 | |
---|
9 | !================================================================== |
---|
10 | ! |
---|
11 | ! Purpose |
---|
12 | ! ------- |
---|
13 | ! Load atmospheric composition info |
---|
14 | ! |
---|
15 | ! Authors |
---|
16 | ! ------- |
---|
17 | ! R. Wordsworth (2011) |
---|
18 | ! Allocatable arrays by A. Spiga (2011) |
---|
19 | ! |
---|
20 | !================================================================== |
---|
21 | |
---|
22 | ! load gas names from file 'gases.def' |
---|
23 | open(90,file='gases.def',status='old',form='formatted',iostat=ierr) |
---|
24 | if (ierr.eq.0) then |
---|
25 | write(*,*) "sugases.F90: reading file gases.def" |
---|
26 | read(90,*) |
---|
27 | read(90,*,iostat=ierr) ngasmx |
---|
28 | if (ierr.ne.0) then |
---|
29 | write(*,*) "sugases.F90: error reading number of gases" |
---|
30 | write(*,*) " (first line of gases.def) " |
---|
31 | call abort |
---|
32 | endif |
---|
33 | |
---|
34 | print*,ngasmx, " gases found in gases.def. Allocating names and molar fractions..." |
---|
35 | |
---|
36 | if (.not.allocated(gnom)) allocate(gnom(ngasmx)) |
---|
37 | do igas=1,ngasmx |
---|
38 | read(90,*,iostat=ierr) gnom(igas) |
---|
39 | if (ierr.ne.0) then |
---|
40 | write(*,*) 'sugases.F90: error reading gas names in gases.def...' |
---|
41 | call abort |
---|
42 | endif |
---|
43 | enddo !of do igas=1,ngasmx |
---|
44 | |
---|
45 | vgas=0 |
---|
46 | if(.not.allocated(gfrac)) allocate(gfrac(ngasmx)) |
---|
47 | do igas=1,ngasmx |
---|
48 | read(90,*,iostat=ierr) gfrac(igas) |
---|
49 | if (ierr.ne.0) then |
---|
50 | write(*,*) 'sugases.F90: error reading gas molar fractions in gases.def...' |
---|
51 | call abort |
---|
52 | endif |
---|
53 | |
---|
54 | ! find variable gas (if any) |
---|
55 | if(gfrac(igas).eq.-1.0)then |
---|
56 | if(vgas.eq.0)then |
---|
57 | vgas=igas |
---|
58 | else |
---|
59 | print*,'You seem to be choosing two variable gases' |
---|
60 | print*,'Check that gases.def is correct' |
---|
61 | call abort |
---|
62 | endif |
---|
63 | endif |
---|
64 | |
---|
65 | enddo !of do igas=1,ngasmx |
---|
66 | |
---|
67 | |
---|
68 | ! assign the 'igas_X' labels |
---|
69 | count=0 |
---|
70 | do igas=1,ngasmx |
---|
71 | if (gnom(igas).eq."H2_") then |
---|
72 | igas_H2=igas |
---|
73 | count=count+1 |
---|
74 | elseif (gnom(igas).eq."He_") then |
---|
75 | igas_He=igas |
---|
76 | count=count+1 |
---|
77 | elseif (gnom(igas).eq."H2O") then |
---|
78 | igas_H2O=igas |
---|
79 | count=count+1 |
---|
80 | elseif (gnom(igas).eq."CO2") then |
---|
81 | igas_CO2=igas |
---|
82 | count=count+1 |
---|
83 | elseif (gnom(igas).eq."CO_") then |
---|
84 | igas_CO=igas |
---|
85 | count=count+1 |
---|
86 | elseif (gnom(igas).eq."N2_") then |
---|
87 | igas_N2=igas |
---|
88 | count=count+1 |
---|
89 | elseif (gnom(igas).eq."O2_") then |
---|
90 | igas_O2=igas |
---|
91 | count=count+1 |
---|
92 | elseif (gnom(igas).eq."SO2") then |
---|
93 | igas_SO2=igas |
---|
94 | count=count+1 |
---|
95 | elseif (gnom(igas).eq."H2S") then |
---|
96 | igas_H2S=igas |
---|
97 | count=count+1 |
---|
98 | elseif (gnom(igas).eq."CH4") then |
---|
99 | igas_CH4=igas |
---|
100 | count=count+1 |
---|
101 | elseif (gnom(igas).eq."NH3") then |
---|
102 | igas_NH3=igas |
---|
103 | count=count+1 |
---|
104 | endif |
---|
105 | enddo |
---|
106 | |
---|
107 | if(count.ne.ngasmx)then |
---|
108 | print*,'Mismatch between ngas and number of recognised gases in sugas_corrk.F90.' |
---|
109 | print*,'Either we haven`t managed to assign all the gases, or there are duplicates.' |
---|
110 | print*,'Please try again.' |
---|
111 | endif |
---|
112 | |
---|
113 | else |
---|
114 | write(*,*) 'Cannot find required file "gases.def"' |
---|
115 | call abort |
---|
116 | endif |
---|
117 | close(90) |
---|
118 | |
---|
119 | end subroutine su_gases |
---|