# Using libraries in parallel code with OpenMp

**URL:** <https://fortran-lang.discourse.group/t/using-libraries-in-parallel-code-with-openmp/762>\
**Category:** Help\
**Created:** [February 27, 2021, 5:28pm UTC](https://fortran-lang.discourse.group/t/using-libraries-in-parallel-code-with-openmp/762 "2021-02-27T17:28:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CConde](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@CConde](https://fortran-lang.discourse.group/u/CConde)\
**Post date:** [February 27, 2021, 5:28pm UTC](https://fortran-lang.discourse.group/t/using-libraries-in-parallel-code-with-openmp/762/1 "2021-02-27T17:28:44Z")

</div>

Dear friends,

I’m writing a parallel code using OpenMp. I have to assign a block of code to different threads, something like this:

program ABC  
use omp\_lib  
!$omp parallel sections  
!$omp section  
.  
.  
!$omp section  
.  
.  
!$end parallel section  
end program ABC

Each section needs to use an external library XYZ. My doubt is that I’m not very sure in which part of the code I should incorporate the command “use XYZ.” Could you please help me with this doubt?

Many thanks in advance.

---

<div class="post-metadata">

**Author:** ![Rob777](https://avatars.discourse-cdn.com/v4/letter/r/9e8a1a/32.png) [@Rob777](https://fortran-lang.discourse.group/u/Rob777)\
**Post date:** [February 27, 2021, 10:56pm UTC](https://fortran-lang.discourse.group/t/using-libraries-in-parallel-code-with-openmp/762/2 "2021-02-27T22:56:13Z")

</div>

You must declare the use association of XYZ at the beginning of the program, before implicit none, as you’ve done with omp\_lib.

---

<div class="post-metadata">

**Author:** ![CConde](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@CConde](https://fortran-lang.discourse.group/u/CConde)\
**Post date:** [February 28, 2021, 5:39pm UTC](https://fortran-lang.discourse.group/t/using-libraries-in-parallel-code-with-openmp/762/3 "2021-02-28T17:39:51Z")

</div>

@Rob777, many thanks for your help.
