# # DESCRIPTION namd Molecular dynamics simulation in NAMD # # software_usage [optional] # software_parse_cmd_options [optional] set_software_environment () { NAMD_GPU=${NAMD_GPU:-if_any} NAMD_LOG=${NAMD_LOG:-namd.log} JOBNAME=mds_namd_$(date +%s) [ -n "$NAMD_CONFIG" -a -f "$NAMD_CONFIG" ] || exit_error "Cannot find NAMD configuration file. Job submission aborted" } set_software_grid_environment () { NAMD_RUNTIME=${NAMD_RUNTIME:-NAMD-2.10} NAMD_VERSION=${NAMD_RUNTIME##*-} if [ "$BUILD_RUNTIME" = "yes" ]; then next_idx_var INPUT_FILES_NAME_ INPUT_FILES_LOCATION_ \ "namd_install.sh" "${MDS_SOFT_INSTALLS_PATH%/}/NAMD/namd_install.sh" next_idx_var INPUT_FILES_NAME_ INPUT_FILES_LOCATION_ \ "NAMD_${NAMD_VERSION}_Linux-x86_64-multicore.tar.gz" "${MDS_SOFT_INSTALLS_PATH%/}/NAMD/NAMD_${NAMD_VERSION}_Linux-x86_64-multicore.tar.gz" [ "$NAMD_GPU" = "no" ] || next_idx_var INPUT_FILES_NAME_ INPUT_FILES_LOCATION_ \ "NAMD_${NAMD_VERSION}_Linux-x86_64-multicore-CUDA.tar.gz" "${MDS_SOFT_INSTALLS_PATH%/}/NAMD/NAMD_${NAMD_VERSION}_Linux-x86_64-multicore-CUDA.tar.gz" else next_idx_var RUNTIME_CONDITION_ RUNTIME_VALUE_ "=" "${NAMD_RUNTIME}" fi if [ -z "$CPUS" -a "$NODES" != "1" ]; then echo_bad "WARNING: MolDynSub NAMD submission is not designed to run in multi-node mode. Number of nodes reduced to 1." NODES=1 fi } software_gen_params () { cat </dev/null 2>&1 [ \$? -ne 0 ] && return 1 nvidia-smi -L | sed 's/^GPU\s*\([0-9]\+\):.*/\1/' | sed -e :a -e N -e 's/\n/,/' -e ta } gpus_info () { echo "INFO: Enabling GPU acceleration. Following Nvidia GPU accelerator(s) has been found on target machine:" nvidia-smi -L } # Handle GPU acceleration if [ "\$NAMD_GPU" != "no" ]; then GPUS=\$( gpus_list ) if [ "\$NAMD_GPU" = "if_any" ]; then if [ -n "\$GPUS" ]; then export ENABLE_GPU=1 gpus_info else echo "INFO: Nvidia GPU accelerator is not found on target machine. CPU-only computing will be performed." fi elif [ "\$NAMD_GPU" = "force" ]; then if [ -n "\$GPUS" ]; then export ENABLE_GPU=1 gpus_info else echo "ERROR: GPU is explicitly requested (NAMD_GPU=force) but not found on target machine. Job execution aborted." exit 1 fi fi fi # Install NAMD in runtime if requested if [ "\$BUILD_RUNTIME" = "yes" ]; then echo "INFO: Installing NAMD as a part of job lifecycle" if [ -f "namd_install.sh" ]; then source namd_install.sh else echo "ERROR: There is no NAMD install script found. Skipping." fi else echo "INFO: Relying on pre-installed NAMD software" fi # Invoke NAMD type namd2 >/dev/null 2>&1 if [ \$? -ne 0 ]; then echo "FATAL: There is no namd2 executable found. It seams NAMD installation is broken." exit 1 fi [ -n "\${ENABLE_GPU}" ] && NAMD_DEVICES="+devices \$GPUS" namd2 +p\${NAMD_CPUS} \${NAMD_DEVICES} "\${NAMD_CONFIG}" ++verbose | tee \$NAMD_LOG END } create_input_files_list () { # input files defined within parametrized NAMD_CONFIG # eval variables in NAMD_CONFIG eval $( cat $NAMD_CONFIG | sed -n '/^set/s/set\s*\([a-zA-Z]\+\)\s*\(.*\)$/\1=\2/p' ) # get input files eval $( cat $NAMD_CONFIG | sed -n '/^\(coordinates\|structure\|parameters\)/I s/^\([a-z]\+\)\s*\(.*\)$/\L\1=\E\2/pI' ) # pass files to stage-in/jobdescription [ -n "$coordinates" ] && next_idx_var INPUT_FILES_NAME_ INPUT_FILES_LOCATION_ "$coordinates" "" [ -n "$structure" ] && next_idx_var INPUT_FILES_NAME_ INPUT_FILES_LOCATION_ "$structure" "" [ -n "$parameters" ] && next_idx_var INPUT_FILES_NAME_ INPUT_FILES_LOCATION_ "$parameters" "" # pass NAMD_CONFIG itself next_idx_var INPUT_FILES_NAME_ INPUT_FILES_LOCATION_ "$NAMD_CONFIG" "" return 0 } create_output_files_list () { local stageout_uri=$1 # output files defined within parametrized NAMD_CONFIG # eval variables in NAMD_CONFIG eval $( cat $NAMD_CONFIG | sed -n '/^set/s/set\s*\([a-zA-Z]\+\)\s*\(.*\)$/\1=\2/p' ) # get output files eval $( cat $NAMD_CONFIG | sed -n '/^\(dcdfile\|xstfile\)/I s/^\([a-z]\+\)\s*\(.*\)$/\L\1=\E\2/pI' ) # pass files to jobdescription [ -n "$dcdfile" ] && next_idx_var OUTPUT_FILES_NAME_ OUTPUT_FILES_LOCATION_ "$dcdfile" "${stageout_uri:+$stageout_uri/$dcdfile}" [ -n "$xstfile" ] && next_idx_var OUTPUT_FILES_NAME_ OUTPUT_FILES_LOCATION_ "$xstfile" "${stageout_uri:+$stageout_uri/$xstfile}" # namd.log should be saved also next_idx_var OUTPUT_FILES_NAME_ OUTPUT_FILES_LOCATION_ "$NAMD_LOG" "${stageout_uri:+$stageout_uri/$NAMD_LOG}" return 0 }