source: trunk/LMDZ.GENERIC/libf/phystd/su_gases.F90 @ 868

Last change on this file since 868 was 868, checked in by aslmd, 13 years ago

LMDZ.GENERIC. Added patches for large domains. Added C2H2 and C2H6 which must be named 2H2 and 2H6 in gases.def

  • Property svn:executable set to *
File size: 3.7 KB
RevLine 
[253]1subroutine su_gases
2
[471]3  use gases_h
4
[253]5  implicit none
6
[716]7  integer igas, ierr, count
[253]8
[716]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  !==================================================================
[253]21
[716]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
[253]33
[716]34     print*,ngasmx, " gases found in gases.def. Allocating names and molar fractions..."
[471]35
[716]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
[253]44
[716]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
[253]53
[716]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
[253]64
[716]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
[868]104        elseif (gnom(igas).eq."2H6") then
105           ! this is ethane
106           igas_2H6=igas
107           count=count+1
108        elseif (gnom(igas).eq."2H2") then
109           ! this is acetylene
110           igas_2H2=igas
111           count=count+1
[716]112        endif
113     enddo
114
115     if(count.ne.ngasmx)then
116        print*,'Mismatch between ngas and number of recognised gases in sugas_corrk.F90.'
117        print*,'Either we haven`t managed to assign all the gases, or there are duplicates.'
118        print*,'Please try again.'
119     endif
120
121  else
122     write(*,*) 'Cannot find required file "gases.def"'
123     call abort
124  endif
125  close(90)
126
[253]127end subroutine su_gases
Note: See TracBrowser for help on using the repository browser.