[CP2K-user] [CP2K:11011] ASE CP2K interface
Geng Sun
sungen... at gmail.com
Fri Dec 7 20:52:04 UTC 2018
Hello,
Finally, I found the possible reasons for this problem:
It seems that MPI will only read parts of the stdin, only part of the data
in the PIPE is consumed.
THE MPICH2 user guide saied: "the redirection of large amounts of data to
stdin is discouraged, and may cause unexpected results"
So I have to write the coordiates to a file in cp2k.py and read the
positions from cp2k_shell.F instead of the stdin (codes are shown below)
Now everything loosk correct.
Geng
IF (para_env%mepos==para_env%source) THEN
!READ (*,*,iostat=iostat) n_atom2
!IF (iostat/=0) CPABORT('setpos read n_atom')
!IF (n_atom2/=SIZE(pos)) THEN
! CALL my_assert(.FALSE.,'setpos invalid number of atoms',
failure)
! DO i=1,n_atom
! READ(*,'(a)',iostat=iostat) cmdStr
! CALL compress(cmdStr,full=.TRUE.)
! CALL uppercase(cmdStr)
! IF (cmdStr=='*END') EXIT
! END DO
! GOTO 10
!END IF
!READ (*,*,iostat=iostat) pos
!IF (iostat/=0) CPABORT('setpos read coord')
inquire(unit=201,opened=unitalive)
if (unitalive) CPABORT('UNIT 201 is being used')
inquire(file="CP2K_POSITIONS",exist=filepresence)
if (.not. filepresence) CPABORT('FILE CP2K_POSITIONS NOT EXIST')
open(201,action='READ',file="CP2K_POSITIONS",iostat=iostat,
status='OLD',form='FORMATTED',ACCESS='SEQUENTIAL')
if (iostat/=0) CPABORT('read CP2K_POSITIONS')
READ(201,*,iostat=iostat) n_atom2
IF (iostat/=0) CPABORT('setpos read n_atom2')
IF (n_atom2/=SIZE(pos)) THEN
CALL my_assert(.FALSE.,'setpos invalid number of atoms',
failure)
DO i=1,n_atom
READ(201,'(a)',iostat=iostat) cmdStr
CALL compress(cmdStr,full=.TRUE.)
CALL uppercase(cmdStr)
IF (cmdStr=='*END') EXIT
END DO
GOTO 10
END IF
READ (201,*,iostat=iostat) pos
CLOSE(201)
IF (iostat/=0) CPABORT('setpos read coord')
pos(:) = pos(:)/pos_fact
READ(*,'(a)',iostat=iostat) cmdStr
CALL compress(cmdStr,full=.TRUE.)
CALL uppercase(cmdStr)
CALL my_assert(cmdStr=='*END',' missing *END',failure)
END IF
在 2018年12月4日星期二 UTC-8下午12:59:20,Ole Schütt写道:
>
> Hi Geng,
>
> are you using MPI? Then this is probably where the buffering happens.
> Depending on which MPI implementation you are using there might be a way
> to tweak its stdin/out forwarding.
>
> Out of curiosity, how many atoms does your system have? Maybe the
> Fortran side simple tries to read too many values?
>
> -Ole
>
>
> On 2018-12-04 21:27, Geng Sun wrote:
> > Hello Ole,
> >
> > Thank you very much for your reply:
> > I changed the code as you suggested (below), but the problem is still
> > present in the test.
> >
> > Best
> >
> > Geng
> >
> > def send(self, line):
> > """Send a line to the cp2k_shell"""
> > assert self._child.poll() is None # child process still
> > alive?
> > if self._debug:
> > #print('Sending: ' + line)
> > sys.stderr.write("Sending: {}\n".format(line))
> > sys.stderr.flush()
> >
> > if self.version < 2.1 and len(line) >= 80:
> > raise Exception('Buffer overflow, upgrade CP2K to r16779
> > or later')
> > assert(len(line) < 800) # new input buffer size
> > self.isready = False
> > self._child.stdin.write(line + '\n')
> > self._child.stdin.flush()
> >
> > 在 2018年12月4日星期二 UTC-8上午11:05:43,Ole
> > Schütt写道:
> >
> >> Hi Geng,
> >>
> >> this sounds indeed like a buffering issue. Could you once try to add
> >> a
> >> flush() on the python side.
> >>
> >> Basically add the following line after cp2k.py:498.
> >>
> >> self._child.stdin.write(line + '\n')
> >> + self._child.stdin.flush()
> >>
> >> This is probably quite inefficient. So, if it works I'll add some
> >> logic
> >> to flush only when recv() follows a send().
> >>
> >> -Ole
> >>
> >> On 2018-12-04 18:08, Geng Sun wrote:
> >>> Dear CP2K users,
> >>>
> >>> In the past several weeks, I frequently faced a problem when I
> >> use
> >>> the CP2K -ASE interface.
> >>>
> >>> The calculations frequently got stuck during the calculations.
> >>>
> >>> 1) Firstly I switched on the debug=True option in the ASE-CP2K
> >>> calculator and I found that the calculation always gets stuck at a
> >>
> >>> line with *END after sending the positions to the subroutine
> >>> cp2k_shell.popt (I printed the information to the standard error,
> >> so
> >>> they are not buffered)
> >>>
> >>> 2) Then, I modified the cp2k_shell.F to print a lot of "labels".
> >> Then
> >>> I found that the code may get stuck at the line of "READ
> >>> (*,*,iostat=iostat) pos" like below. I can always get "begin to
> >> read
> >>> pos" in the standard error, but I can not reach "LABEL-1".
> >>>
> >>> WRITE(0,*) "begin to read pos"
> >>> CALL m_flush(0)
> >>> READ (*,*,iostat=iostat) pos
> >>> WRITE(0,*) "LABEL-1"
> >>> CALL m_flush(0)
> >>>
> >>> I attached the modified cp2k_shell.F and the standard out/error
> >>> generated by the slurm batch system with this post. You can see
> >> that
> >>> the program get stuck at the second optimization step just after
> >>> sending the positions.
> >>>
> >>> I greatly appreciate your suggestions for fixing this confusing
> >> bugs.
> >>>
> >>> Thanks in advance.
> >>>
> >>> Geng
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>
> >>> Groups "cp2k" group.
> >>> To unsubscribe from this group and stop receiving emails from it,
> >> send
> >>> an email to cp2k+... at googlegroups.com.
> >>> To post to this group, send email to cp... at googlegroups.com.
> >>> Visit this group at https://groups.google.com/group/cp2k [1].
> >>> For more options, visit https://groups.google.com/d/optout [2].
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "cp2k" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to cp2k+... at googlegroups.com <javascript:>.
> > To post to this group, send email to cp... at googlegroups.com
> <javascript:>.
> > Visit this group at https://groups.google.com/group/cp2k.
> > For more options, visit https://groups.google.com/d/optout.
> >
> >
> > Links:
> > ------
> > [1] https://groups.google.com/group/cp2k
> > [2] https://groups.google.com/d/optout
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cp2k.org/archives/cp2k-user/attachments/20181207/2956351e/attachment.htm>
More information about the CP2K-user
mailing list