My only concern is whether this method might cause some meshes to end up finer than needed, even if the mesh was perfectly okay anyway. Based on how it searches for the optimal mesh in getng, I don't believe this will be an issue. It should only make a difference if the fine mesh were problematic, in which case this is necessary. Does anyone know if this will be an issue? The section where it changes getng.F90 is show below:
Code: Select all
@@ -206,8 +207,14 @@
!Save input values of ngfft
ngsav(1:3) = ngfft(1:3)
-!Give an initial guess at ngfft and iterate
- ngfft(1:3)=2
+!As an initial guess for ngfft, use the provided coarse mesh grid
+ if (PRESENT(ngfftc)) then
+ ngfft(1:3)=ngfftc(1:3)
+ call wrtout(std_out,' Using supplied coarse mesh as initial guess.','COLL')
+ else
+ ngfft(1:3)=2
+ end if
+
"getng" is modified to accept an optional argument, ngfftc, the coarse mesh grid dimensions. If not supplied, it uses (2,2,2) as the initial guess, but if it is supplied, it uses ngfftc as the initial guess.
The patch also modifies indgrid.F90 to check to make sure there are no zeros in coatofin. Even with the modified getng algorithm, it may be possible for the user to specify an ngfftdg in the input file which will cause the crash to occur. The patch fixes it to detect the problem and break with an error message.