title: OpenMP calling subroutines in threads
body: <p>The problem I'm facing is as outlined below:</p>
  
  <pre><code>module k
    integer :: l,m
  end module k
  
  program p4
    use k
    integer :: i,j,omp_get_thread_num,cr
  
    i = 2
    j = 3
  
    !$omp parallel num_threads(2) shared(l,m) private(i,j,cr)
    cr = omp_get_thread_num()
    if (cr == 0) goto 1111
    call sub1(i)
    write(*,*) l
    goto 2222
  1111 call sub2(j)
    write(*,*) m
  2222 continue
    !$omp end parallel
  end program p4
  
  subroutine sub1(a)
    use k
    integer :: a
  
    l = a**2
    write(*,*) 'entered sub1'
  end subroutine sub1
  
  subroutine sub2(b)
    use k
    integer :: b
  
    m = b**2
    write(*,*) 'entered sub2'
  end subroutine sub2
  </code></pre>
  
  <p>I've tried to parallelize a serial, (which after parallelization looks as written above). I want essentially the same operation performed twice. So Ideally, I want the output to be </p>
  
  <pre><code>entered sub1
  4
  enterer sub2
  9
  </code></pre>
  
  <p>but the output is</p>
  
  <pre><code>entered sub2
             0
  entered sub1
     923239424
  </code></pre>
  
  <p>I'm new to parallel programming, (my actual problem is a more complicated version of the one I've outlined). Can anyone point out the mistakes and suggest improvements. Thanks</p>