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

Last change on this file since 1644 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
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
[1315]22!$OMP MASTER
[716]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
[253]34
[716]35     print*,ngasmx, " gases found in gases.def. Allocating names and molar fractions..."
[471]36
[716]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
[253]45
[716]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
[253]54
[716]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
[253]65
[716]66     enddo                  !of do igas=1,ngasmx
67
68
69     ! assign the 'igas_X' labels
70     count=0
71     do igas=1,ngasmx
[869]72        if (trim(gnom(igas)).eq."H2_" .or. trim(gnom(igas)).eq."H2") then
[716]73           igas_H2=igas
74           count=count+1
[869]75        elseif (trim(gnom(igas)).eq."He_" .or. trim(gnom(igas)).eq."He") then
[716]76           igas_He=igas
77           count=count+1
[869]78        elseif (trim(gnom(igas)).eq."H2O") then
[716]79           igas_H2O=igas
80           count=count+1
[869]81        elseif (trim(gnom(igas)).eq."CO2") then
[716]82           igas_CO2=igas
83           count=count+1
[869]84        elseif (trim(gnom(igas)).eq."CO_" .or. trim(gnom(igas)).eq."CO") then
[716]85           igas_CO=igas
86           count=count+1
[869]87        elseif (trim(gnom(igas)).eq."N2_" .or. trim(gnom(igas)).eq."N2") then
[716]88           igas_N2=igas
89           count=count+1
[869]90        elseif (trim(gnom(igas)).eq."O2_" .or. trim(gnom(igas)).eq."O2") then
[716]91           igas_O2=igas
92           count=count+1
[869]93        elseif (trim(gnom(igas)).eq."SO2") then
[716]94           igas_SO2=igas
95           count=count+1
[869]96        elseif (trim(gnom(igas)).eq."H2S") then
[716]97           igas_H2S=igas
98           count=count+1
[869]99        elseif (trim(gnom(igas)).eq."CH4") then
[716]100           igas_CH4=igas
101           count=count+1
[869]102        elseif (trim(gnom(igas)).eq."NH3") then
[716]103           igas_NH3=igas
104           count=count+1
[869]105        elseif (trim(gnom(igas)).eq."C2H6") then
106           igas_C2H6=igas
[868]107           count=count+1
[869]108        elseif (trim(gnom(igas)).eq."C2H2") then
109           igas_C2H2=igas
[868]110           count=count+1
[716]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)
[1315]125!$OMP END MASTER
126!$OMP BARRIER
[716]127
[253]128end subroutine su_gases
Note: See TracBrowser for help on using the repository browser.