field_of_cfield Function

public pure function field_of_cfield() result(f)

Return colour field named by st%cfield, 1..nfields, or 0.

Exact source column name first, then a few aliases against readers' canonical names.

Arguments

None

Return Value integer(kind=int32)


Source Code

   pure function field_of_cfield() result(f)
      !! Return colour field named by `st%cfield`, `1..nfields`, or 0.
      !!
      !! Exact source column name first, then a few aliases against readers' canonical names.
      integer(int32) :: f, k
      character(len=len(st%cfield)) :: want
      f = 0
      if (.not. allocated(field_names)) return
      want = trim(st%cfield)
      do k = 1, nfields
         if (trim(field_names(k)) == want) then
            f = k
            return
         end if
      end do
      ! aliases: try each canonical name a group maps to, first present wins
      select case (want)
      case ('temperature', 'temp', 'T')
         f = first_field(['T_K   ', 'logT  ', 'T     '])
      case ('density', 'rho', 'Rho')
         f = first_field(['rho_gcc', 'logRho ', 'rho    '])
      case ('luminosity', 'lum', 'L')
         f = first_field(['L_erg_s   ', 'logL      ', 'luminosity'])
      case ('pressure', 'P')
         f = first_field(['logP    ', 'pressure'])
      end select
   end function field_of_cfield