Commit 40b39836 authored by Juan Caneses Marin (nfc)'s avatar Juan Caneses Marin (nfc)
Browse files

Continue optmizing openMP, still not working well

parent a9bde8c4
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
&in_nml
! Simulation name:
! ===============
in%fileDescriptor = '2021_01_29k',
in%fileDescriptor = '2021_02_02b',

! Magnetic field input data:
! =========================
@@ -12,16 +12,16 @@ in%nz = 501, ! N

! Simulation conditions:
! =====================
in%Nparts = 80000,                                                              ! Total number of particles
in%Nsteps = 6000,                                                               ! Total number of time steps
in%Nparts = 500000,                                                              ! Total number of particles
in%Nsteps = 5000,                                                               ! Total number of time steps
in%dt     = 0.5E-7,                                                             ! Time step in [s]
in%zmax = +5.0,
in%zmin = -5.0,
in%threads_request = 10,
in%threads_request = 8,

in%iSave = .true.,
in%iPush = .true.,                                                             ! Enable RK4 particle pusher
in%iColl = .true.,                                                             ! Collisions or no collisions
in%iColl = .false.,                                                             ! Collisions or no collisions
in%iHeat = .false.,                                                            ! Enable RF heating operator
in%iPotential = .false.,                                                       ! Enable electric potential
in%iDrag = .false.,                                                            ! Enable plasma drag
@@ -29,8 +29,8 @@ in%iDrag = .false., !
! Time steps to record:
! ==============
in%jstart = 1,                                                                  ! start frame
in%jend   = 6000,                                                               ! end frame
in%jincr  = 12,                                                                 ! increment
in%jend   = 5000,                                                               ! end frame
in%jincr  = 10,                                                                 ! increment

! Collision operator conditions:
! ==============================
@@ -55,7 +55,7 @@ in%zp_init = 0.0, !
in%zp_init_std = 0.3,                                                          ! STD of particle injection
in%Ep_init = 1000.,                                                            ! Drift kinetic energy
in%Tp_init = 10.;                                                               ! Thermal kinetic energy
in%xip_init = 0.707,                                                           ! Mean pitch angle where xip = cos(theta) = vpar/v
in%xip_init = 0.9240,                                                           ! Mean pitch angle where xip = cos(theta) = vpar/v

! RF heating operator conditions:
! ===============================
+14 −22
Original line number Diff line number Diff line
@@ -232,23 +232,6 @@ ecount1 = 0; ecount2 = 0; ecount3 = 0; ecount4 = 0
! ==============================================================================
! Set the number of threads:
CALL OMP_SET_NUM_THREADS(in%threads_request)
in%threads_given = OMP_GET_NUM_THREADS()
WRITE(*,*) ''
WRITE(*,*) '*********************************************************************'
WRITE(*,*) "number of threads given: ", in%threads_given
WRITE(*,*) '*********************************************************************'
WRITE(*,*) ''

!$OMP PARALLEL PRIVATE(id)
    !id = OMP_GET_THREAD_NUM()
    !if (id .EQ. 0) then
    !	WRITE(*,*) ''
    !	WRITE(*,*) '*********************************************************************'
    !	WRITE(*,*) "number of threads given: ", in%threads_given
    !	WRITE(*,*) '*********************************************************************'
    !	WRITE(*,*) ''
  !  end if
!$OMP END PARALLEL

! Loop over time:
! ==============================================================================
@@ -265,9 +248,18 @@ TimeStepping: do j = 1,in%Nsteps

          ! Loop over particles:
          ! ==============================================================================
          !$OMP DO
          !$OMP DO SCHEDULE(STATIC,in%Nparts/in%threads_request)
              AllParticles: do i = 1,in%Nparts
		
		if (j .EQ. 1 .AND. i .EQ. 1) then
		  in%threads_given = OMP_GET_NUM_THREADS()
		  WRITE(*,*) ''
		  WRITE(*,*) '*********************************************************************'
		  WRITE(*,*) "Number of threads given: ", in%threads_given
		  WRITE(*,*) '*********************************************************************'
		  WRITE(*,*) ''
		end if 

                ! Calculate Cyclotron resonance number:
                ! ------------------------------------------------------------------------
                if (in%iHeat) CALL CyclotronResonanceNumber(zp(i),kep(i),xip(i),fcurr(i),in,spline_Bz)
@@ -306,7 +298,7 @@ TimeStepping: do j = 1,in%Nsteps
              end do AllParticles
          !$OMP END DO

          !$OMP CRITICAL AccumulateCounters
          !$OMP CRITICAL
          ecount1(j) = ecount1(j) + ecnt1
          ecount2(j) = ecount2(j) + ecnt2
          ecount3(j) = ecount3(j) + ecnt3
@@ -315,7 +307,7 @@ TimeStepping: do j = 1,in%Nsteps
          pcount2(j) = pcount2(j) + pcnt2
          pcount3(j) = pcount3(j) + pcnt3
          pcount4(j) = pcount4(j) + pcnt4
          !$OMP END CRITICAL AccumulateCounters
          !$OMP END CRITICAL

    !$OMP END PARALLEL

@@ -348,7 +340,7 @@ TimeStepping: do j = 1,in%Nsteps
    ! =====================================================================
    id = OMP_GET_THREAD_NUM()
    if (id .EQ. 0) then
      if (j .EQ. 50) then
      if (j .EQ. 10) then
	       oend_estimate = OMP_GET_WTIME()
         WRITE(*,*) 'Estimated compute time: ', in%Nsteps*(oend_estimate-ostart)/j,' [s]'
      end if