TABLE OF CONTENTS
::pwtk::pseudo_download
SYNOPSIS
proc ::pwtk::pseudo_download {args} {
USAGE
::pwtk::pseudo::download ?-url URL? PSEUDO1 ?PSEUDO2? ...
PURPOSE
Download the pseudopotential files from the URL directory to 'pseudo_dir' if they are not present in 'pseudo_dir'.
OPTION
- -url ... list of URL addresses from where to download the pseudopotentials; default = {https://pseudopotentials.quantum-espresso.org/upf_files/ http://pseudopotentials.quantum-espresso.org/upf_files/}
ARGUMENTS
- PSEUDO1, PSEUDO2, ... list of pseudopotential files to download from URL
EXAMPLE
::pwtk::pseudo::download Fe.pz-nd-rrkjus.UPF O.pz-rrkjus.UPF
RETURN VALUE
The list of downloaded pseudopotentials.
SOURCE
# parse options & arguments set nargmin 1 set nargmax -1 set usage "-url URL PSEUDO1 ?PSEUDO2? ..." set options { {url.arg {https://pseudopotentials.quantum-espresso.org/upf_files http://pseudopotentials.quantum-espresso.org/upf_files} "URL addresses from where to download the pseudopotentials"} } ::pwtk::parseOpt_ set pseudoList $args set urls $opt(url) # get pseudo_dir # # from INPUT_PW.html: # Default: value of the $ESPRESSO_PSEUDO environment variable if set; # '$HOME/espresso/pseudo/' otherwise set pseudo_dir [::pwtk::input::namelistGetVarValue CONTROL pseudo_dir trim] ::pwtk::ifset pseudo_dir [::pwtk::pseudo_dir] ::pwtk::ifset pseudo_dir [varvalue ::env(ESPRESSO_PSEUDO)] ::pwtk::ifset pseudo_dir $::env(HOME)/espresso/pseudo try { if { ! [file exists $pseudo_dir] } { infoMsg "from [procName]: creating pseudo_dir $pseudo_dir " file mkdir $pseudo_dir } } on error err { ::pwtk::error "error creating pseudo_dir $pseudo_dir\n\n$err" 1 } # wget or curl ? set dnl [::pwtk::getExecutable wget curl] # download PPs set result {} foreach pseudo $pseudoList { set full_pseudo [file normalize [file join $pseudo_dir $pseudo]] if { ! [file exists $full_pseudo] } { switch -glob -- $dnl { *wget { set o -O } *curl { set o -o } default { ::pwtk::error "cannot download $pseudo from the internet: neither wget nor curl found" 1 } } set nl 1 foreach url $urls { ::pwtk::print "Downloading $pseudo from $url" ::pwtk::try_exec -i -- $dnl $url/$pseudo $o $full_pseudo # sometimes a download from https://* fails due to # certificate issue. Hence, check that $full_pseudo # exists and is of non-zero size if { [file exists $full_pseudo] } { if { [file size $full_pseudo] > 0 } { break } else { file delete $full_pseudo } } } if { ! [file exists $full_pseudo] || [file size $full_pseudo] == 0 } { ::pwtk::error "failed to download the $pseudo pseudopotential from [join $urls { and }]" 1 } lappend result $pseudo } } if { [info exists nl] } { puts "" } return $result }