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