=== modified file 'Docs/CHANGES' --- Docs/CHANGES 2013-11-15 15:22:09 +0000 +++ Docs/CHANGES 2013-11-22 14:32:39 +0000 @@ -6,6 +6,20 @@ ** CHANGES ALONG trunk ----------------------------------------------------------------------- +2013-11-22 15:30:00 GMT trunk-450 +Fix SiestaXC/mesh3d to avoid overflow of distributions and/or tasks + +(Thanks to Nick P. Andersen) + +Due to two bugs in mesh3d.F90, the number of mesh distributions +and/or communication tasks overflowed in some cases, specially +when using vdW and a variable cell. Fixed. + +modified: + Src/SiestaXC/cellxc.F90 : improved output to debugXC + Src/SiestaXC/mesh3d.F90 : bug fixes + improved debugXC output + +----------------------------------------------------------------------- 2013-11-15 15:20:00 GMT trunk-449 Fix Tbtrans runs at Gamma when using Transiesta k-point data === modified file 'Src/SiestaXC/cellxc.F90' --- Src/SiestaXC/cellxc.F90 2013-04-09 10:49:59 +0000 +++ Src/SiestaXC/cellxc.F90 2013-11-22 14:32:39 +0000 @@ -387,6 +387,7 @@ #ifdef DEBUG_XC integer :: iip, jjp, jq real(dp):: rmod, rvec(3) + integer,save:: myIter=0 #endif /* DEBUG_XC */ logical :: & GGA, GGAfunctl, VDW, VDWfunctl @@ -502,8 +503,10 @@ call de_alloc( workload, myName//'workload' ) call de_alloc( myDens, myName//'myDens' ) #ifdef DEBUG_XC + myIter = myIter+1 call myMeshBox( nMesh, myDistr, myBox ) - write(udebug,'(a,3(2x,2i4))') myName//'My new box =', myBox + write(udebug,'(a,i6,1x,3i5,3(1x,2i5))') & + myName//'Iter,nMesh,myBox=', myIter, nMesh, myBox #endif /* DEBUG_XC */ end if ! (nodes>1 .and. timeDisp/timeAvge>maxUnbalance) @@ -1317,7 +1320,7 @@ timeDisp = sqrt( max( sumTime2/nodes - timeAvge**2, 0._dp ) ) #ifdef DEBUG_XC - write(udebug,'(a,3f12.6)') & + write(udebug,'(a,3f12.6,/)') & myName//'My CPU time, avge, rel.disp =', & myTime, timeAvge, timeDisp/timeAvge #endif /* DEBUG_XC */ === modified file 'Src/SiestaXC/mesh3d.F90' --- Src/SiestaXC/mesh3d.F90 2013-10-31 17:59:54 +0000 +++ Src/SiestaXC/mesh3d.F90 2013-11-22 14:32:39 +0000 @@ -687,9 +687,9 @@ ! Private module parameters character(len=*),parameter:: moduleName = 'mesh3D ' - integer,parameter:: maxDistr = 100 ! Max. number of mesh distributions + integer,parameter:: maxDistr = 20 ! Max. number of mesh distributions ! allocated at any given time - integer,parameter:: maxTasks = 30 ! Max. number of communication tasks + integer,parameter:: maxTasks = 100 ! Max. number of communication tasks ! allocated at any given time integer,parameter:: maxDistrID = 20 ! Max. IDs assigned to the same distrib. integer,parameter:: maxTaskID = 10 ! Max. IDs assigned to the same task @@ -942,11 +942,19 @@ #ifdef DEBUG_XC ! if (present(distrID2)) then -! write(udebug,'(a,3(2x,2i4))') myName//'taskID,iTask,distrID,iDistr=', & +! write(udebug,'(a,2i4,2(2x,2i4))') & +! myName//'taskID,iTask,distrID,iDistr=', & ! taskID, iTask, distrID1, iDistr1, distrID2, iDistr2 +! write(udebug,'(a,i3,2x,25i3,/,(36x,25i3))') myName//'iDistr,tasks=', & +! iDistr1, pack(distr1%task,distr1%task>0) +! write(udebug,'(a,i3,2x,25i3,/,(36x,25i3))') myName//'iDistr,tasks=', & +! iDistr2, pack(distr2%task,distr2%task>0) ! else -! write(udebug,'(a,3(2x,2i4))') myName//'taskID,iTask,distrID,iDistr=', & +! write(udebug,'(a,2i4,2x,2i4)') & +! myName//'taskID,iTask,distrID,iDistr=', & ! taskID, iTask, distrID1, iDistr1 +! write(udebug,'(a,i3,2x,25i3,/,(36x,25i3))') myName//'iDistr,tasks=', & +! iDistr1, pack(distr1%task,distr1%task>0) ! end if #endif /* DEBUG_XC */ @@ -1320,7 +1328,7 @@ character(len=*),parameter:: errHead = myName//'ERROR: ' integer:: axis, axis1, axis2, axis3, axisNodes(3), box0(2,3), boxNodes(3), & iDistr, iNode, iNode1, iNode2, iNode3, jNode2, jNode3, & - node0, nodeSpan(3), rowMesh(3), rowNodes + node0, nodeSpan(3), oldDistr, rowMesh(3), rowNodes integer,allocatable:: subBox(:,:,:) logical:: found type(distrType),pointer:: distr @@ -1367,11 +1375,6 @@ ! Return already if axis distributions are not required if (.not.present(axisDistr)) return -! Initialize the axis distributions for the 1D FFT transforms - do axis = 1,3 - call initDistr( axisDistr(axis), nMesh, 0, totNodes ) - end do - ! Find span between nodes along each axis ! nodeSpan(1) = 1 ! nodeSpan(2) = axisNodes(1) @@ -1392,6 +1395,11 @@ ! Loop on the three cell axes do axis1 = 1,3 + ! (Re)initialize the axis distribution for the 1D FFT transforms + oldDistr = axisDistr(axis1) + call freeMeshDistr( axisDistr(axis1) ) + call initDistr( axisDistr(axis1), nMesh, 0, totNodes ) + ! Find the two other axes axis2 = modulo(axis1,3) + 1 axis3 = modulo(axis2,3) + 1 @@ -1462,8 +1470,9 @@ iDistr = indexDistr( axisDistr(axis1) ) distr => storedMeshDistr(iDistr) ! write(udebug,'(a,3i4)') myName//'axis1,axis2,axis3=', axis1, axis2, axis3 - write(udebug,'(a,2i6,3(2x,2i4))') myName//'distrID,iDistr,myBox=', & - axisDistr(axis1), iDistr, distr%box(:,:,myNode) + write(udebug,'(a,6x,3i4,3(2x,2i4))') & + myName//' old/newDistrID,iDistr,myBox=', & + oldDistr, axisDistr(axis1), iDistr, distr%box(:,:,myNode) #endif /* DEBUG_XC */ end do ! axis1 @@ -1486,6 +1495,7 @@ character(len=*),parameter:: myName = 'freeMeshDistr ' character(len=*),parameter:: errHead = myName//'ERROR: ' integer:: iDistr, iID, iNode, it, iTask, taskID + logical:: found type(distrType),pointer :: distr type(taskType),pointer :: task @@ -1495,7 +1505,6 @@ ! Check that distribution exists if (iDistr<1 .or. iDistr>maxDistr) return distr => storedMeshDistr(iDistr) ! Just a shorter name - if (.not.distr%defined) return ! Erase ID from the distribution do iID = 1,maxDistrID @@ -1508,17 +1517,25 @@ ! Free distribution if no other IDs are assigned to it if (all(distr%ID<0)) then ! First free all distribution tasks +#ifdef DEBUG_XC +! if (any(distr%task>0)) & +! write(udebug,'(a,i3,2x,25i3,/,(32x,25i3))') & +! myName//'iDistr,tasks=', iDistr, pack(distr%task,distr%task>0) +#endif /* DEBUG_XC */ do it = 1,maxDistrTasks iTask = distr%task(it) if (iTask>0) then task => storedMeshTask(iTask) + found = .false. do iID = 1,maxTaskID ! Find a valid ID of task, to call freeMeshTask taskID = task%ID(iID) if (taskID>0) then + found = .true. call freeMeshTask( taskID ) exit ! iID loop end if ! (taskID>0) end do ! iID + if (.not.found) call die(myName//'ERROR: no valid task ID found') end if ! (iTask>0) end do ! it ! Finally free distribution itself @@ -1551,10 +1568,9 @@ ! Check that task exists if (iTask<1 .or. iTask>maxTasks) return task => storedMeshTask(iTask) ! Just a shorter name - if (.not.task%defined) return #ifdef DEBUG_XC -! write(udebug,'(a,4i6)') & +! write(udebug,'(a,2i4,2x,2i4)') & ! myName//'taskID,iTask,task%distr=', taskID, iTask, task%distr #endif /* DEBUG_XC */ @@ -1706,7 +1722,7 @@ ! Find an available internal distribution slot found = .false. do iDistr = 1,maxDistr - if (.not.storedMeshDistr(iDistr)%defined) then ! Available (empty) slot + if (all(storedMeshDistr(iDistr)%ID<0)) then ! Available (empty) slot found = .true. exit ! iDistr loop end if @@ -1764,8 +1780,7 @@ ! Find an available internal distribution slot found = .false. do iTask = 1,maxTasks - if (.not.storedMeshTask(iTask)%defined .and. & - .not.storedMeshTask(iTask)%associated) then ! Available (empty) slot + if (all(storedMeshTask(iTask)%ID<0)) then ! Available (empty) slot found = .true. exit ! iTask loop end if @@ -2500,6 +2515,12 @@ task%srcBox = srcBoxes task%dstBox = dstBoxes task%defined = .true. +#ifdef DEBUG_XC +! write(udebug,'(a,2i4,3(2x,2i4))') & +! myName//'taskID,iTask,srcBox=', taskID, iTask, srcBox +! write(udebug,'(31x,a,2i4,3(2x,2i4))') & +! 'dstBox=', taskID, iTask, dstBox +#endif /* DEBUG_XC */ end if end if @@ -2910,6 +2931,7 @@ nFactors, node0, nParts, nRem, nBlocks, newDistrID, & oldDistrID, partSize, power(maxFactors) logical:: found + character(len=5):: dat ! Make sure that myNode and totNodes are defined call parallel_init() @@ -3105,8 +3127,18 @@ #ifdef DEBUG_XC iDistr = indexDistr( distrID ) distr => storedMeshDistr(iDistr) - write(udebug,'(a,2i6,3(2x,2i4))') myName//'distrID,iDistr,myBox=', & - distrID, iDistr, distr%Box(:,:,myNode) + if (present(box)) then + dat = 'box' + elseif (present(workload)) then + dat = 'wkld' + elseif (present(nNodesX)) then + dat = 'xNod' + else + dat = 'none' + endif + write(udebug,'(a,a6,3i4,3(2x,2i4))') & + myName//'dat,old/newDistrID,iDistr,myBox=', & + dat, oldDistrID, newDistrID, iDistr, distr%Box(:,:,myNode) #endif /* DEBUG_XC */ end if === modified file 'version.info' --- version.info 2013-11-15 15:22:09 +0000 +++ version.info 2013-11-22 14:32:39 +0000 @@ -1,3 +1,3 @@ -siesta-trunk-449 +siesta-trunk-450