Modification to PAW fine mesh generation
Posted: Wed Aug 04, 2010 10:09 pm
In the ground state forum, I discussed a seg fault error that results from a fine mesh that has a dimension that is coarser than the coarse mesh. This creates a problem in the indgrid.F90 subroutine, because you end up with an incomplete coatofin vector, which causes transgrid to corrupt memory and segfault when transferring rhog from the coarse to fine grid. I created a patch that changes getng.F90 such that the invars2m.F90 can pass the coarse mesh as an input parameter, and getng will use that as an initial guess for calculating the fine mesh. This helps ensure that the fine grid will be at a minimum as fine as the coarse grid in every dimension.
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:
"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.
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.