source: trunk/LMDZ.GENERIC/libf/phystd/setspv.F90 @ 3817

Last change on this file since 3817 was 3654, checked in by gmilcareck, 4 months ago

Generic PCM:
Rewriting of the rayleigh scattering module. Before the commit, the Rayleigh scattering was separated into a constant part and a wavelength-dependent part.
However, in the constant part, because everything was added up/multiplied together before being added to the module,
we lose the information about where these numbers come from and if we want to add a new molecule or update a molecule... well... good luck.
Now, each molecule depends only on 2 physical parameters: the refractive index and the King Factor.
If you want add another molecule, you just need to add these 2 parameters and the references (please).
For water, the rayleigh scattering now depends on temperature and pressure.
GM

File size: 3.9 KB
Line 
1      subroutine setspv
2
3!==================================================================
4!     
5!     Purpose
6!     -------
7!     Set up spectral intervals and stellar spectrum in the shortwave.
8!     
9!     Authors
10!     -------
11!     Adapted from setspv in the NASA Ames radiative code by
12!     Robin Wordsworth (2009).
13!
14!     Called by
15!     ---------
16!     callcorrk.F
17!     
18!     Calls
19!     -----
20!     ave_stelspec.F
21!     
22!==================================================================
23
24      use radinc_h,    only: L_NSPECTV, corrkdir, banddir
25      use radcommon_h, only: BWNV,BLAMV,WNOV,DWNV,WAVEV, &
26                             STELLARF
27      use datafile_mod, only: datadir
28      use callkeys_mod, only: Fat1AU
29
30      implicit none
31
32      logical file_ok
33
34      integer N, M, file_entries
35
36      character(len=30)  :: temp1
37      character(len=200) :: file_id
38      character(len=200) :: file_path
39
40      real*8 :: lastband(2)
41
42      real*8 STELLAR(L_NSPECTV)
43      real*8 sum, dummy
44
45      !! used to count lines
46      integer :: nb
47      integer :: ierr
48
49!=======================================================================
50!     Set up spectral bands - wavenumber [cm^(-1)]. Go from smaller to
51!     larger wavenumbers, the same as in the IR.
52
53      write(temp1,'(i2.2)') L_NSPECTV
54      file_id='/corrk_data/'//trim(adjustl(banddir))//'/narrowbands_VI.in'
55      file_path=TRIM(datadir)//TRIM(file_id)
56
57      ! check that the file exists
58      inquire(FILE=file_path,EXIST=file_ok)
59      if(.not.file_ok) then
60         write(*,*)'The file ',TRIM(file_path)
61         write(*,*)'was not found by setspv.F90, exiting.'
62         write(*,*)'Check that your path to datagcm:',trim(datadir)
63         write(*,*)' is correct. You can change it in callphys.def with:'
64         write(*,*)' datadir = /absolute/path/to/datagcm'
65         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
66         call abort
67      endif
68       
69!$OMP MASTER       
70      nb=0
71      ierr=0
72      ! check that the file contains the right number of bands
73      open(131,file=file_path,form='formatted')
74      read(131,*,iostat=ierr) file_entries
75      do while (ierr==0)
76        read(131,*,iostat=ierr) dummy
77        if (ierr==0) nb=nb+1
78      enddo
79      close(131)
80
81      write(*,*) 'setspv: L_NSPECTV = ',L_NSPECTV, 'in the model '
82      write(*,*) '        there are   ',nb, 'entries in ',TRIM(file_path)
83      if(nb.ne.L_NSPECTV) then
84         write(*,*) 'MISMATCH !! I stop here'
85         call abort
86      endif
87
88      ! load and display the data
89      open(111,file=file_path,form='formatted')
90      read(111,*)
91       do M=1,L_NSPECTV-1
92         read(111,*) BWNV(M)
93      end do
94      read(111,*) lastband
95      close(111)
96      BWNV(L_NSPECTV)  =lastband(1)
97      BWNV(L_NSPECTV+1)=lastband(2)
98!$OMP END MASTER
99!$OMP BARRIER
100
101      print*,'setspv: VI band limits:'
102      do M=1,L_NSPECTV+1
103         print*,m,'-->',BWNV(M),' cm^-1'
104      end do
105      print*,' '
106
107!     Set up mean wavenumbers and wavenumber deltas.  Units of
108!     wavenumbers is cm^(-1); units of wavelengths is microns.
109
110      do M=1,L_NSPECTV
111         WNOV(M)  = 0.5*(BWNV(M+1)+BWNV(M))
112         DWNV(M)  = BWNV(M+1)-BWNV(M)
113         WAVEV(M) = 1.0E+4/WNOV(M)
114         BLAMV(M) = 0.01/BWNV(M)
115      end do
116      BLAMV(M) = 0.01/BWNV(M) ! wavelength in METERS for aerosol stuff
117!     note M=L_NSPECTV+1 after loop due to Fortran bizarreness
118
119!=======================================================================
120!     Set up stellar spectrum
121
122      write(*,*)'setspv: Interpolating stellar spectrum from the hires data...'
123      call ave_stelspec(STELLAR)
124
125!     Sum the stellar flux, and write out the result. 
126      sum = 0.0 
127      do N=1,L_NSPECTV
128         STELLARF(N) = STELLAR(N) * Fat1AU
129         sum         = sum+STELLARF(N)
130      end do
131      write(6,'("setspv: Stellar flux at 1 AU = ",f9.2," W m-2")') sum
132      print*,' '
133
134      RETURN
135    END subroutine setspv
Note: See TracBrowser for help on using the repository browser.