File: runtests.mpi.unix.docker

package info (click to toggle)
nwchem 7.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,134,820 kB
  • sloc: fortran: 4,903,090; ansic: 67,501; f90: 19,555; python: 17,912; java: 12,311; sh: 12,023; cpp: 9,896; perl: 6,123; csh: 4,345; makefile: 1,856; sed: 246; awk: 115; exp: 111; pascal: 76
file content (406 lines) | stat: -rwxr-xr-x 10,132 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
#!/bin/csh  -f
# 
# THIS assumes ./tests/
#
# UNIX workstation parallel and sequential execution of test jobs

# Usage:
#       runtest.mpi.unix [procs nproc] testdir1 [testdir2 ...]
#
# Return 0 if all jobs complete successfully and outputs compare OK
#          with the correct output
# Return 1 otherwise.
#

# Gets executable from environment variable NWCHEM_EXECUTABLE or
# uses the daily NWChem release build
# Gets mpirun executable from environment variable MPIRUN_PATH or
# assumes it is in your path.
# Gets nwparse.pl from enironement varialle NWPARSE or looks in your 
# nwchem tree for $NWCHEM_TOP/QA/nwparse.pl

# A test is specified by the path to the directory containing
# the test inputs and outputs.  The input file is assumed to
# begin with the same name as the directory.  
#
# E.g., if the test is specified as ./small/o3grad then
# - the input file will be ./small/o3grad/o3grad.nw
# - the verified output will be ./small/o3grad/o3grad.out

# A subdirectory of the current directory named scratchdir is deleted
# and remade for each calculation, and deleted at job end.

# A subdirectory of the current directory name testoutputs is made
# if necessary and all outputs are routed there.  Existing outputs
# are overwritten.  The name of the output file is formed by replacing
# the trailing .nw with .out.  In this directory is also put the
# output of nwparse for the verified and the test outputs.
if [[ -z "${NWCHEM_TOP}" ]]; then
    DIRQA=`dirname "$0"`
    MYPWD=`pwd`
    NWCHEM_TOP=`echo ${MYPWD}/${DIRQA} | sed -e 's/\/QA.*//' `
fi


if ($#argv == 0) then
   goto USAGE
endif
@ NPROC = 0
@ argv_set_nproc = 0
@ get_nproc = 0
set args_2_use = removeme
foreach argument ($argv)  
    if ($get_nproc) then
        @ NPROC = $argument
        @ argv_set_nproc++
        @ get_nproc = 0
    else if ($argument == "procs") then
        @ get_nproc = 1       
    else
        set args_2_use = ($args_2_use $argument)
    endif
end   
#
# now remove first dummy argument from args_2_use
set args_2_use = ($args_2_use[2-])


set CURDIR = $cwd

# Figure out where the executable is.

  set NWCHEM = nwchem

# Figure out where the nwparse.pl script is.

if (! $?NWPARSE) then
  if (-f nwparse.pl) then
    set NWPARSE = $CURDIR/nwparse.pl
  else
    echo failed: Cannot find nwparse.pl.  Set NWPARSE or NWCHEM_TOP appropriately.
    exit 1
  endif
endif

if ($NPROC) then
      set MPIRUN = "/usr/bin/mpirun"
endif
# find the -np option ??
if ($NPROC) then
      set NPOPT = "-np"
endif
# Run the tests one at a time

set SCRATCHDIR  = $CURDIR/scratchdir
set TESTOUTPUTS = $CURDIR/testoutputs

if (! -d $TESTOUTPUTS) then
  mkdir $TESTOUTPUTS
  if ($status) then
    echo failed: cannot make directory $TESTOUTPUTS
    exit 1
  endif
endif
set overall_status = 0

foreach TEST_in ($args_2_use)

  cd $CURDIR
  set TEST = tests/$TEST_in
  set TESTDIR = $CURDIR/$TEST
  set STUB    = `basename $TEST`
#
# if $TEST is not a directory try use as root of filenames
#
  if(! -d $TEST) then
    set TESTDIR = `echo $TEST | sed 's+/[^/]*$++'`
  endif
#
# if $TESTDIR not directory skip
#
  if(! -d $TESTDIR) then
    echo failed: could not find job in $TEST
    echo ignoring this failure
    continue
  endif

  echo " "
  echo " Running $TESTDIR/$STUB "
  echo " "

# Clean the scratch directory and copy the input and verified output
# files to the scratch and test output directories

  echo "     cleaning scratch"

  /bin/rm -rf $SCRATCHDIR
  if (! -d $SCRATCHDIR) then
    mkdir $SCRATCHDIR
    if ($status) then
      echo failed: cannot make $SCRATCHDIR
      exit 1
    endif
  endif

  echo "     copying input and verified output files"

  set OUTPUTFILE   = $STUB.out
  set INPUTFILE    = $STUB.nw

#
# MD input files
#
  set TESTFILE     = $STUB.tst
  set RESTARTFILE  = $STUB.rst
  set RDFINPUTFILE = $STUB.rdi
  set MRINPUTFILE  = $STUB.mri
  set TOPOLOGYFILE = (`echo $STUB.top | sed 's/_.*\././'`)
  set PDBFILE      = (`echo $STUB.pdb | sed 's/_.*\././'`)
#
# ESP file
#
  set ESPFILE      = $STUB.q
#
  set md_test_run = 0
  if( -f $TESTDIR/$TOPOLOGYFILE) then
    set md_test_run = 1
  endif
  if( -f $TESTDIR/$PDBFILE) then
    set md_test_run = 1
  endif
  if( -f $TESTDIR/$TESTFILE) then
    set md_test_run = 1
  endif
#
  set esp_test_run = 0
  if( -f $TESTDIR/$ESPFILE) then
    set esp_test_run = 1
  endif
#
#MV
# qmmm will be signified by the presence of
# empty file named "qmmm"
  set qmmm_test_run = 0
  if( -f $TESTDIR/qmmm) then
    set qmmm_test_run = 1
#   if qmmm run md is off
    set md_test_run = 0
  endif
#MV

  if (! -f $TESTDIR/$INPUTFILE) then
    echo failed: cannot access $TESTDIR/$INPUTFILE
    set overall_status = 1
    continue
  endif
# set INPUTFILE=$TESTDIR/$INPUTFILE 
  if(! $md_test_run) then
    if (! -f $TESTDIR/$OUTPUTFILE) then
      echo failed: Could not find verified output file $TESTDIR/$OUTPUTFILE
      set overall_status  = 1
      continue
    endif
  endif

#  cp $TESTDIR/$INPUTFILE $SCRATCHDIR
  if (-f $TESTDIR/$STUB.xyz) cp $TESTDIR/$STUB.xyz $SCRATCHDIR
  if (-f $TESTDIR/EMBPOT) cp $TESTDIR/EMBPOT $SCRATCHDIR
  if (-f $TESTOUTPUTS/$STUB.ok.out) /bin/rm -f $TESTOUTPUTS/$STUB.ok.out
  if($md_test_run) then
  if(-f $TESTDIR/$OUTPUTFILE) cp $TESTDIR/$OUTPUTFILE $TESTOUTPUTS/$STUB.ok.out
  else
  cp $TESTDIR/$OUTPUTFILE $TESTOUTPUTS/$STUB.ok.out
  endif

#
# copy the MD files
#
  if($md_test_run) then
    if (-f $TESTDIR/amber.par) cp $TESTDIR/amber.par $SCRATCHDIR
    cp $TESTDIR/$TESTFILE $TESTOUTPUTS/$STUB.ok.tst
    if(-f $TESTDIR/$TOPOLOGYFILE) cp $TESTDIR/$TOPOLOGYFILE $SCRATCHDIR
    if(-f $TESTDIR/$RESTARTFILE) cp $TESTDIR/$RESTARTFILE $SCRATCHDIR
    if(-f $TESTDIR/$RDFINPUTFILE) cp $TESTDIR/$RDFINPUTFILE $SCRATCHDIR
    if(-f $TESTDIR/$PDBFILE) cp $TESTDIR/$PDBFILE $SCRATCHDIR
    if(-f $TESTDIR/$MRINPUTFILE) cp $TESTDIR/$MRINPUTFILE $SCRATCHDIR
  endif
  if($qmmm_test_run) then
     cp $TESTDIR/*rst $SCRATCHDIR
     cp $TESTDIR/*top $SCRATCHDIR
  endif
#
# copy the ESP file
#
  if($esp_test_run) then
    cp $TESTDIR/$ESPFILE $TESTOUTPUTS/$STUB.ok.q
  endif

#

# Run the calculation in the scratch directory

  cd $SCRATCHDIR

  if (-f $TESTOUTPUTS/$STUB.out) /bin/rm -f $TESTOUTPUTS/$STUB.out

  echo "     running nwchem ($NWCHEM)"

  set x="%Uu %Ss %E %P (%Xt+%Dds+%Kavg+%Mmax)k %Ii+%Oo %Fpf %Wswaps"
  set time=(1 "$x")

  echo " "

#
# MD creates it own $STUB.out
#
sync
  if($md_test_run) then
    if ($NPROC) then
        $MPIRUN $NPOPT $NPROC $NWCHEM $INPUTFILE >& $OUTPUTFILE
        @ runstatus = $status
    else
       $NWCHEM $INPUTFILE >& $OUTPUTFILE
       @ runstatus = $status
    endif
    if(-f $OUTPUTFILE) cp $OUTPUTFILE $TESTOUTPUTS/$OUTPUTFILE
    if(-f $TESTFILE) then 
      cp $TESTFILE $TESTOUTPUTS/$TESTFILE
    endif 
    if(-f $TOPOLOGYFILE) then 
      cp $TOPOLOGYFILE $TESTOUTPUTS/$TOPOLOGYFILE
    endif
  else
#
    if ($NPROC) then
#echo "launching"
#echo "mpirun is" $MPIRUN
#echo "-np otp equal to " $NPOPT
#echo "nwchem exex is" $NWCHEM
#if($NONSTD_MPI) then
#echo " command is"     $MPIRUN $NWCHEM $INPUTFILE  $TESTOUTPUTS/$OUTPUTFILE
#else
#echo " command is"     $MPIRUN $NPOPT $NPROC $NWCHEM $INPUTFILE  $TESTOUTPUTS/$OUTPUTFIL
#endif
#       In the case of standard MPI we construct the appropriate command here.
#        $MPIRUN $NPOPT $NPROC $NWCHEM $INPUTFILE >& $TESTOUTPUTS/$OUTPUTFILE
echo docker run  -v  "$TESTDIR":/data --entrypoint='/usr/bin/mpirun'  edoapra/nwchem-dev $NPOPT $NPROC $NWCHEM $INPUTFILE 
docker run --rm=true  -v  "$TESTDIR":/data --entrypoint='/usr/bin/mpirun'  edoapra/nwchem-dev $NPOPT $NPROC $NWCHEM $INPUTFILE >& $TESTOUTPUTS/$OUTPUTFILE
        @ runstatus = $status
    else
echo executing2
      $NWCHEM $INPUTFILE >& $TESTOUTPUTS/$OUTPUTFILE
       @ runstatus = $status
    endif
#
  endif
#
  if ($runstatus) then
    echo "     NWChem execution failed"
    set overall_status = 1
    tail -50 $TESTOUTPUTS/$OUTPUTFILE
    continue
  endif

  set time=(60 "$x")

  cd $TESTOUTPUTS

#
  if($md_test_run) then
    echo -n "     verifying nwout ...... "
# verify $STUB.nwout here for QMD & QM/MM
    echo "skipped"
    set diff1status=0
  else

# Now verify the output

    echo -n "     verifying output ... "

    perl $NWPARSE $STUB.out >& /dev/null
    if ($status) then
      echo nwparse.pl failed on test output $STUB.out
      set overall_status = 1
      continue
    endif 
    perl $NWPARSE $STUB.ok.out >& /dev/null
    if ($status) then
      echo nwparse.pl failed on verified output $STUB.ok.out
      set overall_status = 1
      continue
    endif

    diff -w $STUB.ok.out.nwparse $STUB.out.nwparse >& /dev/null
    @ diff1status = $status
#
  endif
#

  if ($diff1status) then
    echo "failed"
    set overall_status = 1
    continue 
  else
#
# diff MD test files
#
    if(!($md_test_run)&& !($esp_test_run)) then   # Now verify the output
      echo "OK" 
    else if($esp_test_run) then

    cp $SCRATCHDIR/$ESPFILE $TESTOUTPUTS/.
#    echo "doing ls -l " $STUB.ok.q $STUB.q
#    echo `ls -l $STUB.ok.q $STUB.q`
       diff -w $STUB.ok.q $STUB.q >& /dev/null
       if($status) then
         echo "ESP comparison failed"
         set overall_status = 1
         continue 
       else
         echo "ESP charges match"
       endif
    else
      echo -n "     verifying test ....... "
#
      if(-f $STUB.tst) then
       diff -w $STUB.ok.tst $STUB.tst >& /dev/null
       if($status) then
         echo "failed"
         set overall_status = 1
         continue 
       else
         echo "completed"
       endif
      else
       echo "skipped"
       echo -n "     verifying topology ... "
       set ttt = (`diff -w $STUB.ok.tst $TOPOLOGYFILE | wc -l`)
       if($ttt == 4) then
        echo "completed "
       else
        echo "failed"
        set overall_status = 1
        continue 
       endif
      endif
    endif
  endif
end

cd $CURDIR
/bin/rm -rf $SCRATCHDIR
  
echo " "
if ($overall_status) then
  echo Failed
else
  echo OK
endif

exit $overall_status


USAGE:
  echo "runtest.unix [-procs nproc] testdir1 [testdir2 ...]"
  echo " -procs nproc sets the number of processors to use"
  exit 0