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