Changeset 1648 for trunk/LMDZ.TITAN/libf/phytitan/su_gases.F90
- Timestamp:
- Jan 19, 2017, 2:46:53 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.TITAN/libf/phytitan/su_gases.F90
r1647 r1648 1 subroutine su_gases 1 subroutine su_gases(nlayer,tracer) 2 2 3 3 use gases_h … … 5 5 implicit none 6 6 7 integer igas, ierr, count 8 7 integer,intent(in) :: nlayer 8 logical,intent(in) :: tracer 9 10 integer igas, ierr 11 9 12 !================================================================== 10 13 ! … … 17 20 ! R. Wordsworth (2011) 18 21 ! Allocatable arrays by A. Spiga (2011) 19 ! 22 ! Titan's version : J. Vatant d'Ollone (2017) 23 ! * force igas_X labels and def gnom for N2,CH4,H2 24 ! * get rid of variable species ( enrichment dimension will be set in corrk routines ) 25 ! 20 26 !================================================================== 21 27 22 28 !$OMP MASTER 23 ! load gas names from file 'gases.def' 29 30 31 ngasmx = 3 ! N2, CH4, H2 32 33 34 ! load reference level and reference molar fractions from file 'gases.def' 24 35 open(90,file='gases.def',status='old',form='formatted',iostat=ierr) 36 25 37 if (ierr.eq.0) then 26 38 write(*,*) "sugases.F90: reading file gases.def" 27 read(90,*) 28 read(90,*,iostat=ierr) ngasmx 39 read(90,*) ! header 40 41 ! We allocate gfrac and we set gas molar fractions for the reference level only. 42 ! This will be useful for the cpp_mu and rayleigh routines 43 ! Other gas molar fractions are now set in routine callprofilgases 44 45 write(*,*) 'sugases.F90: allocating and reading gas molar fractions from reference level in gases.def...' 46 47 if(.not.allocated(gfrac)) allocate(gfrac(ngasmx,nlayer)) 48 49 read(90,*,iostat=ierr) nivref 29 50 if (ierr.ne.0) then 30 write(*,*) "sugases.F90: error reading number of gases"51 write(*,*) "sugases.F90: error reading reference level" 31 52 write(*,*) " (first line of gases.def) " 32 53 call abort 33 54 endif 34 35 print*,ngasmx, " gases found in gases.def. Allocating names and molar fractions..." 36 37 if (.not.allocated(gnom)) allocate(gnom(ngasmx)) 55 56 print*, "layer", nivref, "is reference level found in gases.def ..." 57 38 58 do igas=1,ngasmx 39 read(90,*,iostat=ierr) g nom(igas)59 read(90,*,iostat=ierr) gfrac(igas,nivref) 40 60 if (ierr.ne.0) then 41 write(*,*) 'sugases.F90: error reading gas names in gases.def...'61 write(*,*) 'sugases.F90: error reading reference gas molar fractions in gases.def... aborting' 42 62 call abort 43 63 endif 44 64 enddo !of do igas=1,ngasmx 45 65 46 vgas=047 if(.not.allocated(gfrac)) allocate(gfrac(ngasmx))48 do igas=1,ngasmx49 read(90,*,iostat=ierr) gfrac(igas)50 if (ierr.ne.0) then51 write(*,*) 'sugases.F90: error reading gas molar fractions in gases.def...'52 call abort53 endif54 66 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 ! We force gnom = (N2, CH4, H2) and igas_X for Titan 68 69 igas_N2 = 1 70 igas_CH4 = 2 71 igas_H2 = 3 67 72 68 73 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."N2_" .or. trim(gnom(igas)).eq."N2") then 76 igas_N2=igas 77 count=count+1 78 elseif (trim(gnom(igas)).eq."CH4") then 79 igas_CH4=igas 80 count=count+1 81 elseif (trim(gnom(igas)).eq."C2H6") then 82 igas_C2H6=igas 83 count=count+1 84 elseif (trim(gnom(igas)).eq."C2H2") then 85 igas_C2H2=igas 86 count=count+1 87 endif 88 enddo 89 90 if(count.ne.ngasmx)then 91 print*,'Mismatch between ngas and number of recognised gases in sugas_corrk.F90.' 92 print*,'Either we haven`t managed to assign all the gases, or there are duplicates.' 93 print*,'Please try again.' 94 endif 95 74 if (.not.allocated(gnom)) allocate(gnom(ngasmx)) 75 gnom(igas_N2) = "N2_" 76 gnom(igas_CH4) = "CH4" 77 gnom(igas_H2) = "H2_" 78 79 96 80 else 97 81 write(*,*) 'Cannot find required file "gases.def"' 98 82 call abort 99 83 endif 84 100 85 close(90) 101 86 !$OMP END MASTER
Note: See TracChangeset
for help on using the changeset viewer.