[253] | 1 | subroutine 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 | !================================================================== |
---|
[3653] | 21 | |
---|
[253] | 22 | |
---|
[1315] | 23 | !$OMP MASTER |
---|
[716] | 24 | ! load gas names from file 'gases.def' |
---|
| 25 | open(90,file='gases.def',status='old',form='formatted',iostat=ierr) |
---|
| 26 | if (ierr.eq.0) then |
---|
| 27 | write(*,*) "sugases.F90: reading file gases.def" |
---|
| 28 | read(90,*) |
---|
| 29 | read(90,*,iostat=ierr) ngasmx |
---|
| 30 | if (ierr.ne.0) then |
---|
| 31 | write(*,*) "sugases.F90: error reading number of gases" |
---|
| 32 | write(*,*) " (first line of gases.def) " |
---|
| 33 | call abort |
---|
| 34 | endif |
---|
[253] | 35 | |
---|
[716] | 36 | print*,ngasmx, " gases found in gases.def. Allocating names and molar fractions..." |
---|
[471] | 37 | |
---|
[716] | 38 | if (.not.allocated(gnom)) allocate(gnom(ngasmx)) |
---|
| 39 | do igas=1,ngasmx |
---|
| 40 | read(90,*,iostat=ierr) gnom(igas) |
---|
| 41 | if (ierr.ne.0) then |
---|
| 42 | write(*,*) 'sugases.F90: error reading gas names in gases.def...' |
---|
| 43 | call abort |
---|
| 44 | endif |
---|
| 45 | enddo !of do igas=1,ngasmx |
---|
[253] | 46 | |
---|
[716] | 47 | vgas=0 |
---|
| 48 | if(.not.allocated(gfrac)) allocate(gfrac(ngasmx)) |
---|
| 49 | do igas=1,ngasmx |
---|
| 50 | read(90,*,iostat=ierr) gfrac(igas) |
---|
| 51 | if (ierr.ne.0) then |
---|
| 52 | write(*,*) 'sugases.F90: error reading gas molar fractions in gases.def...' |
---|
| 53 | call abort |
---|
| 54 | endif |
---|
[253] | 55 | |
---|
[716] | 56 | ! find variable gas (if any) |
---|
| 57 | if(gfrac(igas).eq.-1.0)then |
---|
| 58 | if(vgas.eq.0)then |
---|
| 59 | vgas=igas |
---|
| 60 | else |
---|
| 61 | print*,'You seem to be choosing two variable gases' |
---|
| 62 | print*,'Check that gases.def is correct' |
---|
| 63 | call abort |
---|
| 64 | endif |
---|
| 65 | endif |
---|
[253] | 66 | |
---|
[716] | 67 | enddo !of do igas=1,ngasmx |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | ! assign the 'igas_X' labels |
---|
| 71 | count=0 |
---|
[3653] | 72 | IF (.NOT.ALLOCATED(massmol)) ALLOCATE(massmol(ngasmx)) |
---|
[716] | 73 | do igas=1,ngasmx |
---|
[869] | 74 | if (trim(gnom(igas)).eq."H2_" .or. trim(gnom(igas)).eq."H2") then |
---|
[716] | 75 | igas_H2=igas |
---|
[3653] | 76 | massmol(igas_H2)=2.016 |
---|
[716] | 77 | count=count+1 |
---|
[869] | 78 | elseif (trim(gnom(igas)).eq."He_" .or. trim(gnom(igas)).eq."He") then |
---|
[716] | 79 | igas_He=igas |
---|
[3653] | 80 | massmol(igas_He)=4.002602 |
---|
[716] | 81 | count=count+1 |
---|
[869] | 82 | elseif (trim(gnom(igas)).eq."H2O") then |
---|
[716] | 83 | igas_H2O=igas |
---|
[3653] | 84 | massmol(igas_H2O)=18.01528 |
---|
[716] | 85 | count=count+1 |
---|
[869] | 86 | elseif (trim(gnom(igas)).eq."CO2") then |
---|
[716] | 87 | igas_CO2=igas |
---|
[3653] | 88 | massmol(igas_CO2)=44.010 |
---|
[716] | 89 | count=count+1 |
---|
[869] | 90 | elseif (trim(gnom(igas)).eq."CO_" .or. trim(gnom(igas)).eq."CO") then |
---|
[716] | 91 | igas_CO=igas |
---|
[3653] | 92 | massmol(igas_CO)=28.010 |
---|
[716] | 93 | count=count+1 |
---|
[869] | 94 | elseif (trim(gnom(igas)).eq."N2_" .or. trim(gnom(igas)).eq."N2") then |
---|
[716] | 95 | igas_N2=igas |
---|
[3653] | 96 | massmol(igas_N2)=28.0134 |
---|
[716] | 97 | count=count+1 |
---|
[869] | 98 | elseif (trim(gnom(igas)).eq."O2_" .or. trim(gnom(igas)).eq."O2") then |
---|
[716] | 99 | igas_O2=igas |
---|
[3653] | 100 | massmol(igas_O2)=31.998 |
---|
[716] | 101 | count=count+1 |
---|
[869] | 102 | elseif (trim(gnom(igas)).eq."SO2") then |
---|
[716] | 103 | igas_SO2=igas |
---|
[3653] | 104 | massmol(igas_SO2)=64.066 |
---|
[716] | 105 | count=count+1 |
---|
[869] | 106 | elseif (trim(gnom(igas)).eq."H2S") then |
---|
[716] | 107 | igas_H2S=igas |
---|
[3653] | 108 | massmol(igas_H2S)=34.082 |
---|
[716] | 109 | count=count+1 |
---|
[869] | 110 | elseif (trim(gnom(igas)).eq."CH4") then |
---|
[716] | 111 | igas_CH4=igas |
---|
[3653] | 112 | massmol(igas_CH4)=16.0425 |
---|
[716] | 113 | count=count+1 |
---|
[869] | 114 | elseif (trim(gnom(igas)).eq."NH3") then |
---|
[716] | 115 | igas_NH3=igas |
---|
[3653] | 116 | massmol(igas_NH3)=17.031 |
---|
[716] | 117 | count=count+1 |
---|
[869] | 118 | elseif (trim(gnom(igas)).eq."C2H6") then |
---|
| 119 | igas_C2H6=igas |
---|
[3653] | 120 | massmol(igas_C2H6)=30.069 |
---|
[868] | 121 | count=count+1 |
---|
[869] | 122 | elseif (trim(gnom(igas)).eq."C2H2") then |
---|
| 123 | igas_C2H2=igas |
---|
[3653] | 124 | massmol(igas_C2H2)=26.038 |
---|
[868] | 125 | count=count+1 |
---|
[3653] | 126 | elseif (trim(gnom(igas)).eq."Ar") then |
---|
| 127 | igas_Ar=igas |
---|
| 128 | massmol(igas_Ar)=39.948 |
---|
| 129 | count=count+1 |
---|
[2831] | 130 | !! GG MODIF 11 Jan 2019 |
---|
| 131 | elseif (trim(gnom(igas)).eq."OCS") then |
---|
| 132 | igas_OCS=igas |
---|
[3653] | 133 | massmol(igas_OCS)=60.075 |
---|
[2831] | 134 | count=count+1 |
---|
| 135 | elseif (trim(gnom(igas)).eq."HCl") then |
---|
| 136 | igas_HCl=igas |
---|
[3653] | 137 | massmol(igas_HCl)=36.461 |
---|
[2831] | 138 | count=count+1 |
---|
| 139 | elseif (trim(gnom(igas)).eq."HF") then |
---|
| 140 | igas_HF=igas |
---|
[3653] | 141 | massmol(igas_HF)=20.00634 |
---|
[2831] | 142 | count=count+1 |
---|
[716] | 143 | endif |
---|
| 144 | enddo |
---|
| 145 | |
---|
| 146 | if(count.ne.ngasmx)then |
---|
| 147 | print*,'Mismatch between ngas and number of recognised gases in sugas_corrk.F90.' |
---|
| 148 | print*,'Either we haven`t managed to assign all the gases, or there are duplicates.' |
---|
| 149 | print*,'Please try again.' |
---|
| 150 | endif |
---|
| 151 | |
---|
| 152 | else |
---|
| 153 | write(*,*) 'Cannot find required file "gases.def"' |
---|
| 154 | call abort |
---|
| 155 | endif |
---|
| 156 | close(90) |
---|
[1315] | 157 | !$OMP END MASTER |
---|
| 158 | !$OMP BARRIER |
---|
[716] | 159 | |
---|
[253] | 160 | end subroutine su_gases |
---|