anchor.diff:      enddo
   
   
  -    ! End the parallel do loop
  -    !$OMP END DO
  -
  -    ! Stop parallelizing - the rest of the calculation for this station is serial
  -    !$OMP END PARALLEL
  -
  +    !! End the parallel do loop
  +    !!$OMP END DO
  +
  +    !! Stop parallelizing - the rest of the calculation for this station is serial
  +    !!$OMP END PARALLEL
  +
  +
  +    ! Enforce that the output is ordered the same way as it would be in a serial run.
  +    ! This slows things down, but is more practical for my use cases.
  +    !$OMP ORDERED
   
   
       if (debug_mode.eq.'calc_deformation'.or.debug_mode.eq.'all') then
  
positive.code:     endif
  
  
      ! Parallelize the calculation of deformation at each station with OpenMP.
      ! The following block of code will be executed by multiple threads if o92util is compiled with
      ! OpenMP enabled (-fopenmp -frecursive options in the GNU compiler).
      ! SHARED variables are shared across threads.
      ! PRIVATE variables are uninitialized and isolated to each thread.
      ! FIRSTPRIVATE variables are initialized with their existing value and isolated to each thread.
      ! REDUCTION defines the operation for shared (deformation) variables.
      !$OMP PARALLEL SHARED(nfaults,ntensile,faults,tensile,stations,lame,shearmod), &
      !$OMP          SHARED(fault_type,coord_type,iWantDisp,iWantStrain,coordTypeWarning,debug_mode), &
      !$OMP&         PRIVATE(iFlt,ierr), &
      !$OMP&         PRIVATE(evlo,evla,evdp,str,dip,rak,slip_mag,wid,len,dist,az,test_dist), &
      !$OMP&         PRIVATE(slip,mom,disptmp,stntmp), &
      !$OMP&         FIRSTPRIVATE(iSta,sta_coord,warn_dist), &
      !$OMP&         REDUCTION(+:disp), REDUCTION(+:stn), &
      !$OMP&         DEFAULT(NONE)
  
      ! The following loop is executed in parallel
      !$OMP DO
  
  
      ! Calculate deformation from each fault and tensile source at the station
  
negative.code:             call usage('calc_deformation: error in progress_indicator (usage:none)')
          endif
      endif
  
  
      ! End the ordered directive, so threads can be FREE!!!!
      !$OMP END ORDERED
  
  
  enddo
  
  
  ! End the parallel do loop
  !$OMP END DO
  
  ! Stop parallelizing - the rest of the subroutine is serial
  !$OMP END PARALLEL
  
  
  ! Close files that were opened for writing
  inquire(file=displacement_file,number=file_unit,opened=isThisUnitOpen)
  