module generic_tracer_index_mod !======================================================================C ! ! This module is to get back the index of a generic condensable tracer ! for both the vap & ice parts of the tracer ! ! call_ice_gas_generic is a boolean which tells if the tracer is condensable ! and allows, if it is condensable, to call the vap/ice pair ! ! Noé Clément & Lucas Teinturier (2022) ! !======================================================================C implicit none contains subroutine generic_tracer_index(nq,iq,igcm_generic_gas,igcm_generic_ice,call_ice_gas_generic) USE tracer_h, only: noms, is_condensable integer nq,iq, igcm_generic_gas, igcm_generic_ice, i_shortname, ii logical call_ice_gas_generic character(len=10) :: shortname if((is_condensable(iq)==1) .and. (index(noms(iq),"gas") .ne. 0) & .and. (index(noms(iq),"h2o") .eq. 0) .and. (index(noms(iq),"n2") .eq. 0)) then ! Let's get the index of our tracers (we look for igcm _generic_gas and igcm_generic_ice) igcm_generic_gas = iq igcm_generic_ice = -1 ! ! ! We look for the corresponding ice traceur (before or after in the list of traceurs, maybe could be generalised to the whole list) ! ! if (iq .ne. nq) then ! ! if ((noms(iq)(1:len(trim(noms(iq)))-4) .eq. noms(iq+1)(1:len(trim(noms(iq+1)))-4)) .and. (index(noms(iq+1),"ice") .ne. 0)) then ! ! igcm_generic_ice = iq+1 ! ! end if ! ! end if ! ! if ((iq .gt. 1)) then ! ! if ((noms(iq)(1:len(trim(noms(iq)))-4) .eq. noms(iq-1)(1:len(trim(noms(iq-1)))-4)) .and. (index(noms(iq-1),"ice") .ne. 0)) then ! ! igcm_generic_ice = iq-1 ! ! end if ! ! end if ! ! if (igcm_generic_ice .eq. -1) then ! ! write(*,*) "ERROR : You set a vap traceur but you forgot to set the corresponding ice traceur, & ! ! or the pair vap/ice is not written one after another in traceur.def" ! ! endif ! ! call_ice_gas_generic = .true. i_shortname = index(noms(iq),'_')-1 shortname=noms(iq)(1:i_shortname) ! We look for the corresponding ice traceur, first if it's before the vap traceur in pq if (iq>1 ) then do ii=1,iq-1 if (index(noms(ii),adjustl(trim(shortname))) .ne. 0) then igcm_generic_ice=ii exit endif ENDDO endif ! if we didn't find it before, we look after the vap tracer in pq if (igcm_generic_ice .eq. -1 .and. (iq