source: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/su_gases.F90 @ 222

Last change on this file since 222 was 222, checked in by ymipsl, 10 years ago

Creating temporary dynamico/lmdz/saturn branche

YM

  • Property svn:executable set to *
File size: 3.8 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  ! 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 (trim(gnom(igas)).eq."H2_" .or. trim(gnom(igas)).eq."H2") then
72           igas_H2=igas
73           count=count+1
74        elseif (trim(gnom(igas)).eq."He_" .or. trim(gnom(igas)).eq."He") then
75           igas_He=igas
76           count=count+1
77        elseif (trim(gnom(igas)).eq."H2O") then
78           igas_H2O=igas
79           count=count+1
80        elseif (trim(gnom(igas)).eq."CO2") then
81           igas_CO2=igas
82           count=count+1
83        elseif (trim(gnom(igas)).eq."CO_" .or. trim(gnom(igas)).eq."CO") then
84           igas_CO=igas
85           count=count+1
86        elseif (trim(gnom(igas)).eq."N2_" .or. trim(gnom(igas)).eq."N2") then
87           igas_N2=igas
88           count=count+1
89        elseif (trim(gnom(igas)).eq."O2_" .or. trim(gnom(igas)).eq."O2") then
90           igas_O2=igas
91           count=count+1
92        elseif (trim(gnom(igas)).eq."SO2") then
93           igas_SO2=igas
94           count=count+1
95        elseif (trim(gnom(igas)).eq."H2S") then
96           igas_H2S=igas
97           count=count+1
98        elseif (trim(gnom(igas)).eq."CH4") then
99           igas_CH4=igas
100           count=count+1
101        elseif (trim(gnom(igas)).eq."NH3") then
102           igas_NH3=igas
103           count=count+1
104        elseif (trim(gnom(igas)).eq."C2H6") then
105           igas_C2H6=igas
106           count=count+1
107        elseif (trim(gnom(igas)).eq."C2H2") then
108           igas_C2H2=igas
109           count=count+1
110        endif
111     enddo
112
113     if(count.ne.ngasmx)then
114        print*,'Mismatch between ngas and number of recognised gases in sugas_corrk.F90.'
115        print*,'Either we haven`t managed to assign all the gases, or there are duplicates.'
116        print*,'Please try again.'
117     endif
118
119  else
120     write(*,*) 'Cannot find required file "gases.def"'
121     call abort
122  endif
123  close(90)
124
125end subroutine su_gases
Note: See TracBrowser for help on using the repository browser.