2

I have an Abaqus/Explicit model which currently uses 3 subroutines: VEXTERNALDB, VUAMP, and VDLOAD. VEXTERNALDB is used to read an externally generated text file and save the values such that they can be read by the other two subroutines.

I would like to add additional complexity to the model, which requires that one of the imported values will now instead be determined internally and vary based on the state of the model in each increment.

I am planning to implement this capability using a module as outlined here. However, due to general ignorance on Fortran/multithreading I am concerned about thread-safety. My questions are as follows:

  1. Is the same module variable global between all threads, or is it defined on a per thread basis?
  2. If the variable is shared between threads is a MUTEX on any write command an acceptable solution?
  3. Would it be better to define the variable as an array and only allow each thread to change a single value in the array?
Ian Bush
  • 6,996
  • 1
  • 21
  • 27
Acrimmon
  • 31
  • 3
  • by definition module variables are global in its module. if you are implementing parallelization with omp you can `use` them in the outer scope and set define their attributes explicitly, e.g. via `private, shared` etc. – jack Nov 11 '20 at 08:27
  • it would be best to supply a _minimal_ working example. this way we can give more detailed answers. – jack Nov 11 '20 at 08:28
  • In very general terms how are you planning to implement the multithreading? OpenMP? – Ian Bush Nov 11 '20 at 08:42
  • @IanBush I don't actually know how it is handled internally, I simply call the Abaqus solver with an argument specifying the number of processors to use. I know the subroutines are called by each individual thread, sometimes multiple times per increment, but I don't define the multithreading behavior myself. – Acrimmon Nov 11 '20 at 20:03
  • Processes or threads? They are different. This is important. – Ian Bush Nov 11 '20 at 20:05
  • I think the default is separate processes using MPI, but you can choose to use a thread-based implementation if needed. From the manual: "...Each domain is serviced by a separate MPI process. Abaqus provides well-defined synchronization points at which it is possible to exchange information across all MPI ranks, using the MPI communications facilities. In addition, for cases of hybrid execution, user subroutines and any subroutines called by them must be thread safe. This precludes the use of common blocks, data statements, and save statements..." – Acrimmon Nov 11 '20 at 20:41

0 Answers0