title: How to compare Fortran c_ptr with null
body: <p>I've got some Fortran and C code that need to be combined.</p>
  
  <p>I'm using a Fortran interface that looks mostly like this:</p>
  
  <pre class="lang-pascal prettyprint-override"><code>module bridge
    use, intrinsic::iso_c_binding, only : c_ptr, c_null_ptr
    implicit none
  
    type(c_ptr) :: instance
  
    interface
  
      function c_init() result(this) bind(C, name="bridge_init")
        import
        type(c_ptr) :: this
      end function c_init
  
    end interface
  
  contains
  
      subroutine init() 
        instance = c_init()
      end subroutine init
  
  end module bridge
  </code></pre>
  
  <p>My problem is that I'd like to put a check for initialization in the <code>init</code> subroutine, something like </p>
  
  <pre class="lang-pascal prettyprint-override"><code>subroutine init()
    if( instance .eq. c_null_ptr ) then
      instance = c_init()
    end if
  end subroutine
  </code></pre>
  
  <p>But this gives me a <code>Syntax error, found END-OF-STATEMENT when expecting one of: BLOCK BLOCKDATA PROGRAM MODULE TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS</code> followed by <code>This binary operation is invalid for this data type.</code> </p>
  
  <p>So what should I be using instead?</p>