@PierU, @ivanpribec and others are giving you good advice!
In our code, we always use !$OMP PARALLEL DEFAULT(SHARED)
and then go through the parallel section with a fine-tooth comb and declare all variables which should be exclusive to each thread with !$OMP PRIVATE
. This is required because the compiler would have a hard time figuring out our intent for each variable.
Interestingly, your variables i
and j
are private by default because they are loop variables. See here.