[135] | 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, corrkdir, banddir |
---|
| 26 | use radcommon_h, only: BWNV,BLAMV,WNOV,DWNV,WAVEV, & |
---|
[484] | 27 | STELLARF,TAURAY |
---|
[374] | 28 | use datafile_mod, only: datadir |
---|
[135] | 29 | |
---|
| 30 | implicit none |
---|
| 31 | |
---|
| 32 | #include "comcstfi.h" |
---|
| 33 | #include "callkeys.h" |
---|
| 34 | |
---|
| 35 | logical file_ok |
---|
| 36 | |
---|
| 37 | integer N, M, file_entries |
---|
| 38 | |
---|
| 39 | character(len=30) :: temp1 |
---|
| 40 | character(len=100) :: file_id |
---|
| 41 | character(len=100) :: file_path |
---|
| 42 | |
---|
| 43 | real*8 :: lastband(2) |
---|
| 44 | |
---|
| 45 | real*8 STELLAR(L_NSPECTV) |
---|
| 46 | real*8 sum |
---|
| 47 | |
---|
| 48 | !======================================================================= |
---|
| 49 | ! Set up spectral bands - wavenumber [cm^(-1)]. Go from smaller to |
---|
| 50 | ! larger wavenumbers, the same as in the IR. |
---|
| 51 | |
---|
| 52 | write(temp1,'(i2.2)') L_NSPECTV |
---|
| 53 | file_id='/corrk_data/'//trim(adjustl(banddir))//'/narrowbands_VI.in' |
---|
[374] | 54 | file_path=TRIM(datadir)//TRIM(file_id) |
---|
[135] | 55 | |
---|
| 56 | ! check that the file exists |
---|
| 57 | inquire(FILE=file_path,EXIST=file_ok) |
---|
| 58 | if(.not.file_ok) then |
---|
[374] | 59 | write(*,*)'The file ',TRIM(file_path) |
---|
[135] | 60 | write(*,*)'was not found by setspv.F90, exiting.' |
---|
[374] | 61 | write(*,*)'Check that your path to datagcm:',trim(datadir) |
---|
| 62 | write(*,*)' is correct. You can change it in callphys.def with:' |
---|
| 63 | write(*,*)' datadir = /absolute/path/to/datagcm' |
---|
| 64 | write(*,*)'Also check that the corrkdir you chose in callphys.def exists.' |
---|
[135] | 65 | call abort |
---|
| 66 | endif |
---|
| 67 | |
---|
| 68 | ! check that the file contains the right number of bands |
---|
| 69 | call system('wc -l '//file_path//' > bandlen.txt') |
---|
| 70 | open(131,file='bandlen.txt', form='formatted') |
---|
| 71 | read(131,*) file_entries |
---|
| 72 | close(131) |
---|
| 73 | call system('rm -f bandlen.txt') |
---|
| 74 | |
---|
| 75 | if(file_entries-1.ne.L_NSPECTV) then |
---|
[374] | 76 | write(*,*) 'setspv: L_NSPECTV = ',L_NSPECTV, 'in the model, but there are ' |
---|
[135] | 77 | write(*,*) file_entries-1,'entries in ', & |
---|
[374] | 78 | TRIM(file_path),', exiting.' |
---|
[135] | 79 | call abort |
---|
| 80 | endif |
---|
| 81 | |
---|
| 82 | ! load and display the data |
---|
| 83 | open(111,file=file_path,form='formatted') |
---|
| 84 | read(111,*) |
---|
| 85 | do M=1,L_NSPECTV-1 |
---|
| 86 | read(111,*) BWNV(M) |
---|
| 87 | end do |
---|
| 88 | read(111,*) lastband |
---|
| 89 | close(111) |
---|
| 90 | BWNV(L_NSPECTV) =lastband(1) |
---|
| 91 | BWNV(L_NSPECTV+1)=lastband(2) |
---|
| 92 | |
---|
| 93 | |
---|
[374] | 94 | print*,'setspv: VI band limits:' |
---|
[135] | 95 | do M=1,L_NSPECTV+1 |
---|
| 96 | print*,m,'-->',BWNV(M),' cm^-1' |
---|
| 97 | end do |
---|
| 98 | print*,' ' |
---|
| 99 | |
---|
| 100 | ! Set up mean wavenumbers and wavenumber deltas. Units of |
---|
| 101 | ! wavenumbers is cm^(-1); units of wavelengths is microns. |
---|
| 102 | |
---|
| 103 | do M=1,L_NSPECTV |
---|
| 104 | WNOV(M) = 0.5*(BWNV(M+1)+BWNV(M)) |
---|
| 105 | DWNV(M) = BWNV(M+1)-BWNV(M) |
---|
| 106 | WAVEV(M) = 1.0E+4/WNOV(M) |
---|
| 107 | BLAMV(M) = 0.01/BWNV(M) |
---|
| 108 | end do |
---|
| 109 | BLAMV(M) = 0.01/BWNV(M) ! wavelength in METERS for aerosol stuff |
---|
| 110 | ! note M=L_NSPECTV+1 after loop due to Fortran bizarreness |
---|
| 111 | |
---|
| 112 | !======================================================================= |
---|
| 113 | ! Set up stellar spectrum |
---|
| 114 | |
---|
[374] | 115 | write(*,*)'setspv: Interpolating stellar spectrum from the hires data...' |
---|
[253] | 116 | call ave_stelspec(STELLAR) |
---|
[135] | 117 | |
---|
| 118 | ! Sum the stellar flux, and write out the result. |
---|
| 119 | sum = 0.0 |
---|
| 120 | do N=1,L_NSPECTV |
---|
| 121 | STELLARF(N) = STELLAR(N) * Fat1AU |
---|
| 122 | sum = sum+STELLARF(N) |
---|
| 123 | end do |
---|
[374] | 124 | write(6,'("setspv: Stellar flux at 1 AU = ",f7.2," W m-2")') sum |
---|
[135] | 125 | print*,' ' |
---|
| 126 | |
---|
[253] | 127 | |
---|
[135] | 128 | !======================================================================= |
---|
| 129 | ! Set up the wavelength independent part of the Rayleigh scattering. |
---|
| 130 | ! The pressure dependent part will be computed elsewhere (OPTCV). |
---|
| 131 | ! WAVEV is in microns. There is no Rayleigh scattering in the IR. |
---|
| 132 | |
---|
| 133 | if(rayleigh) then |
---|
| 134 | call calc_rayleigh |
---|
| 135 | else |
---|
[374] | 136 | print*,'setspv: No Rayleigh scattering, check for NaN in output!' |
---|
[135] | 137 | do N=1,L_NSPECTV |
---|
| 138 | TAURAY(N) = 1E-16 |
---|
| 139 | end do |
---|
| 140 | endif |
---|
| 141 | |
---|
| 142 | RETURN |
---|
| 143 | END subroutine setspv |
---|