# Copyright (c) 2002-08 Peter Guntert. All rights reserved. ## 7MACROS: forall - CYANA macro ## ## Parameters: ## save ## parallel ## skip ## ## This macro performs a loop over all selected structures, copies them into ## the structure memory #0, executes the user commands, and copies the ## structure back to the structure memory. Optionally, the structures are ## saved as angle files with name dnnnmmm.ang (nnn denotes the current ## process number, and mmm the structure number) before they are copied back. ## The calculation may be executed in parallel (if the Inclan variable nproc ## has a value larger than 1). ## ## forall parallel "vtfmin steps=100,800; angstat make" ## Minimize all selected structures using the macro vtfmin with the given ## number of steps and include the resulting structures into the angle ## statistics. var echo name i j n m n0 params structure ok erract syntax $macro:** save parallel skip echo := off n=nstruct n0=nstruct parallel=parallel .and. $val('nproc','1').gt.1 .and. n.gt.1 params:= do i 1 nparam params:="$params \$p$i" end do name := d$getpid save=save .or. parallel do j 1 n $if(parallel,'parallel',' ') i=istruct(j) structure copy i 0 structure=j if (skip) erract:="ok=.false.; return" ok=.true. if (parallel) then execcmds params >{$name}$i(I3.3).log. else execcmds params structure copy 0 i end if if (skip) unset erract if (save .and. ok) write ang {$name}$i(I3.3).ang info=none end do if (save .and. (master .or. .not.parallel)) then m=0 do if (m.ge.n) break i=istruct(m+1) if (existfile('{$name}$i(I3.3).ang')) then m=m+1 read ang {$name}$i(I3.3).ang structure=1 info=none structure copy 0 i remove {$name}$i(I3.3).ang else structure select - $i info=none n=n-1 end if if (parallel) then print file={$name}$i(I3.3).log remove {$name}$i(I3.3).log end if end do if (m.ne.n0) print "*** WARNING: Only $m out of $n0 structures finished." end if