Ignore:
Timestamp:
Apr 29, 2025, 3:17:22 PM (8 weeks ago)
Author:
emillour
Message:

Generic PCM:
Minor fix in interpolate_continuum: handle the extreme case when temperature
is below minimum value in the table.
EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.GENERIC/libf/phystd/interpolate_continuum.F90

    r3713 r3746  
    5353
    5454      character(len=512) :: line
     55      character(len=21),parameter :: rname="interpolate_continuum"
    5556
    5657      integer i, pos, iT, iW, iB, count_norm, igas
     
    224225            write(*,*) 'https://web.lmd.jussieu.fr/~lmdz/planets/generic/datagcm/continuum_data/'
    225226          endif
    226           call abort_physic("interpolate_continuum","missing input file",1)
     227          call abort_physic(rname,"missing input file",1)
    227228        endif
    228229
     
    473474          call interpolate_T_abs_coeff(z_temp,temp_arr_CO2CO2,num_T_CO2CO2,abs_coef,abs_arr_CO2CO2_VI(ind_WN,:))
    474475        else
    475           print*,'You must select visible (VI) or infrared (IR) canal.'
    476           stop
     476          print*,'You must select visible (VI) or infrared (IR) channel.'
     477          call abort_physic(rname,"CO2CO2 bad channel",1)
    477478        endif
    478479      elseif ((igas_X .eq. igas_N2) .and. (igas_Y .eq. igas_N2)) then
     
    483484          call interpolate_T_abs_coeff(z_temp,temp_arr_N2N2,num_T_N2N2,abs_coef,abs_arr_N2N2_VI(ind_WN,:))
    484485        else
    485           print*,'You must select visible (VI) or infrared (IR) canal.'
    486           stop
     486          print*,'You must select visible (VI) or infrared (IR) channel.'
     487          call abort_physic(rname,"N2N2 bad channel",1)
    487488        endif
    488489      elseif ((igas_X .eq. igas_O2) .and. (igas_Y .eq. igas_O2)) then
     
    493494          call interpolate_T_abs_coeff(z_temp,temp_arr_O2O2,num_T_O2O2,abs_coef,abs_arr_O2O2_VI(ind_WN,:))
    494495        else
    495           print*,'You must select visible (VI) or infrared (IR) canal.'
    496           stop
     496          print*,'You must select visible (VI) or infrared (IR) channel.'
     497          call abort_physic(rname,"O2O2 bad channel",1)
    497498        endif
    498499      elseif ((igas_X .eq. igas_CH4) .and. (igas_Y .eq. igas_CH4)) then
     
    503504          call interpolate_T_abs_coeff(z_temp,temp_arr_CH4CH4,num_T_CH4CH4,abs_coef,abs_arr_CH4CH4_VI(ind_WN,:))
    504505        else
    505           print*,'You must select visible (VI) or infrared (IR) canal.'
    506           stop
     506          print*,'You must select visible (VI) or infrared (IR) channel.'
     507          call abort_physic(rname,"CH4CH4 bad channel",1)
    507508        endif   
    508509      elseif ((igas_X .eq. igas_H2) .and. (igas_Y .eq. igas_H2)) then
     
    513514          call interpolate_T_abs_coeff(z_temp,temp_arr_H2H2,num_T_H2H2,abs_coef,abs_arr_H2H2_VI(ind_WN,:))
    514515        else
    515           print*,'You must select visible (VI) or infrared (IR) canal.'
    516           stop
     516          print*,'You must select visible (VI) or infrared (IR) channel.'
     517          call abort_physic(rname,"H2H2 bad channel",1)
    517518        endif
    518519      elseif ((igas_X .eq. igas_H2O) .and. (igas_Y .eq. igas_H2O)) then
     
    523524          call interpolate_T_abs_coeff(z_temp,temp_arr_H2OH2O,num_T_H2OH2O,abs_coef,abs_arr_H2OH2O_VI(ind_WN,:))
    524525        else
    525           print*,'You must select visible (VI) or infrared (IR) canal.'
    526           stop
     526          print*,'You must select visible (VI) or infrared (IR) channel.'
     527          call abort_physic(rname,"H2OH2O bad channel",1)
    527528        endif
    528529      elseif ((igas_X .eq. igas_N2) .and. (igas_Y .eq. igas_H2)) then
     
    533534          call interpolate_T_abs_coeff(z_temp,temp_arr_N2H2,num_T_N2H2,abs_coef,abs_arr_N2H2_VI(ind_WN,:))
    534535        else
    535           print*,'You must select visible (VI) or infrared (IR) canal.'
    536           stop
     536          print*,'You must select visible (VI) or infrared (IR) channel.'
     537          call abort_physic(rname,"N2H2 bad channel",1)
    537538        endif
    538539      elseif ((igas_X .eq. igas_N2) .and. (igas_Y .eq. igas_O2)) then
     
    543544          call interpolate_T_abs_coeff(z_temp,temp_arr_N2O2,num_T_N2O2,abs_coef,abs_arr_N2O2_VI(ind_WN,:))
    544545        else
    545           print*,'You must select visible (VI) or infrared (IR) canal.'
    546           stop
     546          print*,'You must select visible (VI) or infrared (IR) channel.'
     547          call abort_physic(rname,"N2O2 bad channel",1)
    547548        endif
    548549      elseif ((igas_X .eq. igas_N2) .and. (igas_Y .eq. igas_CH4)) then
     
    553554          call interpolate_T_abs_coeff(z_temp,temp_arr_N2CH4,num_T_N2CH4,abs_coef,abs_arr_N2CH4_VI(ind_WN,:))
    554555        else
    555           print*,'You must select visible (VI) or infrared (IR) canal.'
    556           stop
     556          print*,'You must select visible (VI) or infrared (IR) channel.'
     557          call abort_physic(rname,"N2CH4 bad channel",1)
    557558        endif
    558559      elseif ((igas_X .eq. igas_CO2) .and. (igas_Y .eq. igas_O2)) then
     
    563564          call interpolate_T_abs_coeff(z_temp,temp_arr_CO2O2,num_T_CO2O2,abs_coef,abs_arr_CO2O2_VI(ind_WN,:))
    564565        else
    565           print*,'You must select visible (VI) or infrared (IR) canal.'
    566           stop
     566          print*,'You must select visible (VI) or infrared (IR) channel.'
     567          call abort_physic(rname,"CO2O2 bad channel",1)
    567568        endif
    568569      elseif ((igas_X .eq. igas_H2) .and. (igas_Y .eq. igas_CH4)) then
     
    573574          call interpolate_T_abs_coeff(z_temp,temp_arr_H2CH4,num_T_H2CH4,abs_coef,abs_arr_H2CH4_VI(ind_WN,:))
    574575        else
    575           print*,'You must select visible (VI) or infrared (IR) canal.'
    576           stop
     576          print*,'You must select visible (VI) or infrared (IR) channel.'
     577          call abort_physic(rname,"H2CH4 bad channel",1)
    577578        endif
    578579      elseif ((igas_X .eq. igas_H2) .and. (igas_Y .eq. igas_He)) then
     
    583584          call interpolate_T_abs_coeff(z_temp,temp_arr_H2He,num_T_H2He,abs_coef,abs_arr_H2He_VI(ind_WN,:))
    584585        else
    585           print*,'You must select visible (VI) or infrared (IR) canal.'
    586           stop
     586          print*,'You must select visible (VI) or infrared (IR) channel.'
     587          call abort_physic(rname,"H2He bad channel",1)
    587588        endif   
    588589      elseif ((igas_X .eq. igas_H2O) .and. (igas_Y .eq. igas_N2)) then
     
    593594          call interpolate_T_abs_coeff(z_temp,temp_arr_H2ON2,num_T_H2ON2,abs_coef,abs_arr_H2ON2_VI(ind_WN,:))
    594595        else
    595           print*,'You must select visible (VI) or infrared (IR) canal.'
    596           stop
     596          print*,'You must select visible (VI) or infrared (IR) channel.'
     597          call abort_physic(rname,"H2ON2 bad channel",1)
    597598        endif   
    598599      elseif ((igas_X .eq. igas_H2O) .and. (igas_Y .eq. igas_O2)) then
     
    603604          call interpolate_T_abs_coeff(z_temp,temp_arr_H2OO2,num_T_H2OO2,abs_coef,abs_arr_H2OO2_VI(ind_WN,:))
    604605        else
    605           print*,'You must select visible (VI) or infrared (IR) canal.'
    606           stop
     606          print*,'You must select visible (VI) or infrared (IR) channel.'
     607          call abort_physic(rname,"H2OO2 bad channel",1)
    607608        endif   
    608609      elseif ((igas_X .eq. igas_H2O) .and. (igas_Y .eq. igas_CO2)) then
     
    613614          call interpolate_T_abs_coeff(z_temp,temp_arr_H2OCO2,num_T_H2OCO2,abs_coef,abs_arr_H2OCO2_VI(ind_WN,:))
    614615        else
    615           print*,'You must select visible (VI) or infrared (IR) canal.'
    616           stop
     616          print*,'You must select visible (VI) or infrared (IR) channel.'
     617          call abort_physic(rname,"H2OCO2 bad channel",1)
    617618        endif
    618619      elseif ((igas_X .eq. igas_CO2) .and. (igas_Y .eq. igas_H2)) then
     
    623624          call interpolate_T_abs_coeff(z_temp,temp_arr_CO2H2,num_T_CO2H2,abs_coef,abs_arr_CO2H2_VI(ind_WN,:))
    624625        else
    625           print*,'You must select visible (VI) or infrared (IR) canal.'
    626           stop
     626          print*,'You must select visible (VI) or infrared (IR) channel.'
     627          call abort_physic(rname,"CO2H2 bad channel",1)
    627628        endif   
    628629      elseif ((igas_X .eq. igas_CO2) .and. (igas_Y .eq. igas_CH4)) then
     
    633634          call interpolate_T_abs_coeff(z_temp,temp_arr_CO2CH4,num_T_CO2CH4,abs_coef,abs_arr_CO2CH4_VI(ind_WN,:))
    634635        else
    635           print*,'You must select visible (VI) or infrared (IR) canal.'
    636           stop
     636          print*,'You must select visible (VI) or infrared (IR) channel.'
     637          call abort_physic(rname,"CO2CH4 bad channel",1)
    637638        endif                                                                   
    638639      endif ! igas_X / igas_Y condition
     
    777778            print*, 'Maximum temperature is ', maxval(temp_arr), ' K'
    778779          endif
    779           call abort_physic(rname,"temperature too low",1)
     780          call abort_physic(rname,"temperature too high",1)
    780781        else
    781782          z_temp=maxval(temp_arr)
     
    803804     
    804805      integer iT
    805       double precision z_temp
    806       integer num_T
    807       double precision temp_arr(num_T)
    808      
    809       double precision abs_coef
    810       double precision abs_arr(num_T)
     806      double precision,intent(in) :: z_temp
     807      integer,intent(in) :: num_T
     808      double precision,intent(in) :: temp_arr(num_T)
     809     
     810      double precision,intent(out) :: abs_coef
     811      double precision,intent(in) :: abs_arr(num_T)
    811812     
    812813      ! Check where to interpolate
     
    816817      end do
    817818     
     819      ! If below lowest temperature in temp_arr()
     820      if (iT==1) then
     821        abs_coef=abs_arr(1)
     822        return
     823      endif
     824     
    818825      ! We proceed to a simple linear interpolation using the two most nearby temperatures
    819826      if(iT .lt. num_T) then
    820827        abs_coef=abs_arr(iT-1)+(abs_arr(iT)-abs_arr(iT-1))*(z_temp-temp_arr(iT-1))/(temp_arr(iT)-temp_arr(iT-1))
    821828      else
     829        ! If above highest temperature
    822830        abs_coef=abs_arr(iT)
    823831      endif
Note: See TracChangeset for help on using the changeset viewer.