source: trunk/LMDZ.PLUTO/libf/phypluto/su_gases.F90 @ 3754

Last change on this file since 3754 was 3691, checked in by afalco, 3 months ago

Pluto: added HCN;
some comments about what variables actually do in optcv.
AF

  • Property svn:executable set to *
File size: 4.3 KB
Line 
1subroutine 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!$OMP MASTER
23  ! load gas names from file 'gases.def'
24  open(90,file='gases.def',status='old',form='formatted',iostat=ierr)
25  if (ierr.eq.0) then
26     write(*,*) "sugases.F90: reading file gases.def"
27     read(90,*)
28     read(90,*,iostat=ierr) ngasmx
29     if (ierr.ne.0) then
30        write(*,*) "sugases.F90: error reading number of gases"
31        write(*,*) "   (first line of gases.def) "
32        call abort
33     endif
34
35     print*,ngasmx, " gases found in gases.def. Allocating names and molar fractions..."
36
37     if (.not.allocated(gnom)) allocate(gnom(ngasmx))
38     do igas=1,ngasmx
39        read(90,*,iostat=ierr) gnom(igas)
40        if (ierr.ne.0) then
41           write(*,*) 'sugases.F90: error reading gas names in gases.def...'
42           call abort
43        endif
44     enddo                  !of do igas=1,ngasmx
45
46     vgas=0
47     if(.not.allocated(gfrac)) allocate(gfrac(ngasmx))
48     do igas=1,ngasmx
49        read(90,*,iostat=ierr) gfrac(igas)
50        if (ierr.ne.0) then
51           write(*,*) 'sugases.F90: error reading gas molar fractions in gases.def...'
52           call abort
53        endif
54
55        ! find variable gas (if any)
56        if(gfrac(igas).eq.-1.0)then
57           if(vgas.eq.0)then
58              vgas=igas
59           else
60              print*,'You seem to be choosing two variable gases'
61              print*,'Check that gases.def is correct'
62              call abort
63           endif
64        endif
65
66     enddo                  !of do igas=1,ngasmx
67
68
69     ! assign the 'igas_X' labels
70     count=0
71     do igas=1,ngasmx
72        if (trim(gnom(igas)).eq."H2_" .or. trim(gnom(igas)).eq."H2") then
73           igas_H2=igas
74           count=count+1
75        elseif (trim(gnom(igas)).eq."He_" .or. trim(gnom(igas)).eq."He") then
76           igas_He=igas
77           count=count+1
78        elseif (trim(gnom(igas)).eq."H2O") then
79           igas_H2O=igas
80           count=count+1
81        elseif (trim(gnom(igas)).eq."N2") then
82           igas_N2=igas
83           count=count+1
84        elseif (trim(gnom(igas)).eq."CO_" .or. trim(gnom(igas)).eq."CO") then
85           igas_CO=igas
86           count=count+1
87        elseif (trim(gnom(igas)).eq."N2_" .or. trim(gnom(igas)).eq."N2") then
88           igas_N2=igas
89           count=count+1
90        elseif (trim(gnom(igas)).eq."O2_" .or. trim(gnom(igas)).eq."O2") then
91           igas_O2=igas
92           count=count+1
93        elseif (trim(gnom(igas)).eq."SO2") then
94           igas_SO2=igas
95           count=count+1
96        elseif (trim(gnom(igas)).eq."H2S") then
97           igas_H2S=igas
98           count=count+1
99        elseif (trim(gnom(igas)).eq."CH4") then
100           igas_CH4=igas
101           count=count+1
102        elseif (trim(gnom(igas)).eq."NH3") then
103           igas_NH3=igas
104           count=count+1
105        elseif (trim(gnom(igas)).eq."C2H6") then
106           igas_C2H6=igas
107           count=count+1
108        elseif (trim(gnom(igas)).eq."C2H2") then
109           igas_C2H2=igas
110           count=count+1
111        elseif (trim(gnom(igas)).eq."C2H4") then
112           igas_C2H4=igas
113           count=count+1
114        elseif (trim(gnom(igas)).eq."OCS") then
115           igas_OCS=igas
116           count=count+1
117        elseif (trim(gnom(igas)).eq."HCl") then
118           igas_HCl=igas
119           count=count+1
120        elseif (trim(gnom(igas)).eq."HCN") then
121           igas_HCN=igas
122           count=count+1
123        elseif (trim(gnom(igas)).eq."HF") then
124           igas_HF=igas
125           count=count+1
126        endif
127     enddo
128
129     if(count.ne.ngasmx)then
130        print*,'Mismatch between ngas and number of recognised gases in sugas_corrk.F90.'
131        print*,'Either we haven`t managed to assign all the gases, or there are duplicates.'
132        print*,'Please try again.'
133     endif
134
135  else
136     write(*,*) 'Cannot find required file "gases.def"'
137     call abort
138  endif
139  close(90)
140!$OMP END MASTER
141!$OMP BARRIER
142
143end subroutine su_gases
Note: See TracBrowser for help on using the repository browser.