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

Last change on this file since 1974 was 1315, checked in by milmd, 10 years ago

LMDZ.GENERIC. OpenMP directives added in generic physic. When running in pure OpenMP or hybrid OpenMP/MPI, may have some bugs with condense_cloud and wstats routines.

  • Property svn:executable set to *
File size: 3.9 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."CO2") then
82           igas_CO2=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        endif
112     enddo
113
114     if(count.ne.ngasmx)then
115        print*,'Mismatch between ngas and number of recognised gases in sugas_corrk.F90.'
116        print*,'Either we haven`t managed to assign all the gases, or there are duplicates.'
117        print*,'Please try again.'
118     endif
119
120  else
121     write(*,*) 'Cannot find required file "gases.def"'
122     call abort
123  endif
124  close(90)
125!$OMP END MASTER
126!$OMP BARRIER
127
128end subroutine su_gases
Note: See TracBrowser for help on using the repository browser.