EUROPEAN ORGANIZATION FOR NUCLEAR RESEARCH

Rules for Fortran routines for MAD-X

Example

      integer function type(s_length, s_type)
*++ Purpose: returns an integer type code for certain elements
*-- input:
*   s_length   length of s_type
*   s_type     string containing type
*-- return values:
*   1   for s_type == 'drift'
*   2   for s_type == 'sbend'
*   3   for s_type == 'rbend'
*   5   for s-type == 'quadrupole'
*   0   else
*++
      implicit none
      integer s_length
      character *(*) s_type

      if (s_type(:s_length) .eq. 'drift')  then
        type = 1
      elseif (s_type(:s_length) .eq. 'sbend')  then
        type = 2
      elseif (s_type(:s_length) .eq. 'rbend')  then
        type = 3
      elseif (s_type(:s_length) .eq. 'quadrupole')  then
        type = 5
      else
        type = 0
      endif
      end


Hans Grote
2001-01-22