fpakc/src/fpakc.f90
2021-04-03 09:20:46 +02:00

121 lines
2.4 KiB
Fortran

! FPAKC main program
PROGRAM fpakc
USE moduleInput
USE moduleErrors
USE moduleInject
USE moduleSolver
USE moduleMesh
USE moduleCompTime
USE moduleCaseParam
USE OMP_LIB
IMPLICIT NONE
! t = time step
INTEGER:: t = 0
! arg1 = Input argument 1 (input file)
CHARACTER(200):: arg1
! inputFile = path+name of input file
CHARACTER(:), ALLOCATABLE:: inputFile
tStep = omp_get_wtime()
!Gets the input file
CALL getarg(1, arg1)
inputFile = TRIM(arg1)
!If no input file is declared, a critical error is called
IF (inputFile == "") CALL criticalError("No input file provided", "fpakc")
!Reads the json configuration file
CALL readConfig(inputFile)
!$OMP PARALLEL DEFAULT(SHARED)
!$OMP SINGLE
CALL verboseError("Initial scatter of particles...")
!$OMP END SINGLE
CALL doScatter()
!$OMP SINGLE
CALL verboseError("Calculating initial EM field...")
!$OMP END SINGLE
CALL doEMField()
!$OMP END PARALLEL
tStep = omp_get_wtime() - tStep
!Output initial state
CALL doOutput(t)
CALL verboseError('Starting main loop...')
!$OMP PARALLEL DEFAULT(SHARED)
DO t = 1, tmax
!Insert new particles and push them
!$OMP SINGLE
tStep = omp_get_wtime()
!Checks if a species needs to me moved in this iteration
CALL solver%updatePushSpecies(t)
tPush = omp_get_wtime()
!$OMP END SINGLE
!Injects new particles
CALL doInjects()
!Push old particles
CALL doPushes()
!$OMP SINGLE
tPush = omp_get_wtime() - tPush
!Collisions
tColl = omp_get_wtime()
!$OMP END SINGLE
IF (ASSOCIATED(meshForMCC)) CALL meshForMCC%doCollisions()
!$OMP SINGLE
tColl = omp_get_wtime() - tColl
!Coulomb scattering
tCoul = omp_get_wTime()
!$OMP END SINGLE
IF (ASSOCIATED(mesh%doCoulomb)) CALL mesh%doCoulomb()
!$OMP SINGLE
tCoul = omp_get_wTime() - tCoul
!Reset particles
tReset = omp_get_wtime()
!$OMP END SINGLE
CALL doReset()
!$OMP SINGLE
tReset = omp_get_wtime() - tReset
!Weight
tWeight = omp_get_wtime()
!$OMP END SINGLE
CALL doScatter()
!$OMP SINGLE
tWeight = omp_get_wtime() - tWeight
tEMField = omp_get_wtime()
!$OMP END SINGLE
CALL doEMField()
!$OMP SINGLE
tEMField = omp_get_wtime() - tEMField
tStep = omp_get_wtime() - tStep
!Output data
CALL doOutput(t)
!$OMP END SINGLE
END DO
!$OMP END PARALLEL
END PROGRAM fpakc