SUBROUTINE CalcCell !Detemines the cell size for a given cutoff and lattice type integer :: ii, jj, kk, EE logical :: under_cutoff if (real_lattice_type == "sc" .OR. dimen < 3) then NMAXX = int(sqrt(orbEcutoff)) + 1 if (dimen > 1) NMAXY = int(sqrt(orbEcutoff)) + 1 if (dimen > 2) NMAXZ = int(sqrt(orbEcutoff)) + 1 else if (real_lattice_type == "bcc" .or. real_lattice_type == "fcc") then ! calculate needed cell size ii = 0 ! ii is always positiv. jj varies from -ii to ii, kk from -|jj| to |jj| under_cutoff = .true. do while (ii <= int(orbEcutoff) .and. under_cutoff) !until no E < cutoff was found under_cutoff = .false. jj = -ii do while (abs(jj) <= abs(ii) .and. .not. under_cutoff) !until E < cutoff is found or jj =ii kk = -abs(jj) do while (abs(kk) <= abs(jj) .and. .not. under_cutoff)!until E < cutoff is found or kk=jj !calculate unscaled energy for ii, jj, kk EE = (k_lattice_vectors(1, 1) * ii + k_lattice_vectors(2, 1) * jj + k_lattice_vectors(3, 1) * kk)**2 EE = EE + (k_lattice_vectors(1, 2) * ii + k_lattice_vectors(2, 2) * jj + k_lattice_vectors(3, 2) * kk)**2 EE = EE + (k_lattice_vectors(1, 3) * ii + k_lattice_vectors(2, 3) * jj + k_lattice_vectors(3, 3) * kk)**2 if (EE <= orbEcutoff) under_cutoff = .true. kk = kk + 1 end do jj = jj + 1 end do ii = ii + 1 end do NMAXX = ii!-1 NMAXY = ii!-1 NMAXZ = ii!-1 end if ! lattice type return END SUBROUTINE CalcCell