6 Minimum working example for PyXMake. 8 @note: Compile the complete MCODAC library for ABAQUS remotely. 12 ---------------------------------------------------------------------------------------------- 15 - Adopt Paths.log according to your system settings. 20 @author: garb_ma [DLR-FA,STM Braunschweig] 21 ---------------------------------------------------------------------------------------------- 31 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
35 from PyXMake
import VTL
38 __user = os.getenv(
"username")
39 __mcd_cluster_dev = posixpath.join(Utility.AsDrive(
"home",posixpath.sep),__user,
"mcodac")
40 __mcd_cluster_incpath = posixpath.join(__mcd_cluster_dev,
"include")
41 __mcd_cluster_libpath = posixpath.join(__mcd_cluster_dev,
"lib")
45 from PyCODAC.Tools.Utility
import GetPyCODACPath
47 __mcd_core_path = os.path.join(GetPyCODACPath(),
"Core")
54 ErrorHandling.InputError(20)
56 def main(BuildID,user, key,
58 path2src=os.path.join(__mcd_core_path,
"src"),
59 path2feature=os.path.join(__mcd_core_path,
"solver"),
61 files=VTL.GetSourceCode(0),
63 source_file=
"mcd_astandard.f",
65 version=
"abq2019", makeopt=0,
69 dependency=posixpath.join(Utility.AsDrive(
"cluster",posixpath.sep),
"software",
"mcodac",
"stable"), verbosity=0,
71 host=
"129.247.54.37", port=22,
75 Main function to execute the script. 78 print(
'==================================')
79 print(
'Starting build process on the institute cluster')
80 print(
'==================================')
83 pyx_comp =
'-fpp -qopenmp -DCLUSTER -DDEBUG -fPIC -auto -lmkl -extend_source -O2 -fixed -parallel -fpe0 -recursive' 87 pyx_make = posixpath.join(Utility.AsDrive(
"cluster",posixpath.sep),
"software",
"abaqus",
"Commands", version)
88 pyx_post =
"function ifort() { $pyx_ifort $@ \ 89 -O2 -fpe0 -traceback -recursive -qopenmp -DDEBUG -DCLUSTER -lmcd_corex64; } && \ 90 export -f ifort; rm -f *.so; rm -f *.o; "+ pyx_make +
" make -library pyx_file" 92 pyx_make = posixpath.join(Utility.AsDrive(
"cluster",posixpath.sep),
"software",
"ansys_inc",version,
"ansys")
93 pyx_post =
"export ANS_PATH="+pyx_make+
" && \ 94 export FPATH=$FPATH:$ANS_PATH/customize/include && \ 95 export CPATH=$CPATH:$ANS_PATH/customize/include && \ 96 function fcomp() { $pyx_ifort \ 97 -w -c -fpp -openmp -fpic -O2 -ftz \ 99 -module ./ -DLINX64_SYS -DLINUXEM64T_SYS -DFORTRAN -DOPENMP\ 100 -DCADOE_SOLVER -DDEBUG -DCLUSTER $@; } && \ 101 function flink() { $pyx_ifort \ 102 -shared -Xlinker -relax -Xlinker \ 103 --whole-archive userlib.a -Xlinker --no-whole-archive \ 104 -o libansuser.so -Xlinker -soname=libansuser.so $@; } && \ 105 source $ANS_PATH/bin/anssh.ini; \ 106 rm -f *.o; rm -f *.so; \ 107 fcomp pyx_file.f && wait; \ 108 ar -qc userlib.a *.o && flink -lmcd_corex64; rm -f *.a; rm -f *.o; " 110 raise NotImplementedError
113 outpath = posixpath.join(Utility.AsDrive(
"home",posixpath.sep),user)
114 libpath = posixpath.join(dependency,
"lib"); incpath = posixpath.join(dependency,
"include")
115 includes = [outpath, [posixpath.join(incpath, x)
for x
in VTL.GetIncludeDirectory(__mcd_core_path, 0, 4,
"x64")]]
116 libs = [posixpath.join(libpath,
"libinterpx64.a"), posixpath.join(libpath,
"libmueslix64.a"),
117 posixpath.join(libpath,
"libpchipx64.a"), posixpath.join(libpath,
"libbbeamx64.a"),
118 posixpath.join(libpath,
"libdispmodulex64.a")]
121 SSHBuild = pyx.SSH(BuildID, files, scratch=scratch, verbose=verbosity)
124 print(
'==================================')
125 print(
'Establishing SSH connection.')
126 print(
'==================================')
127 SSHBuild.Settings(user, key, host, port)
128 SSH = SSHBuild.ssh_client.open_sftp()
129 SSH.put(os.path.join(path2feature,source_file),
"pyx_file.f")
133 SSHBuild.SourcePath(path2src)
134 SSHBuild.AddIncludePath(includes)
135 SSHBuild.AddDependencyPath(outpath)
136 SSHBuild.Environment(posixpath.join(Utility.AsDrive(
"cluster",posixpath.sep),
"software",
"slurm",
"etc",
"env.d"),
"ifort2016.sh")
137 SSHBuild.OutputPath(outpath)
138 SSHBuild.Preprocessing(inend=
'.for', outend=
'.f90')
139 SSHBuild.Build(pyx_comp, linkedIn=libs)
140 SSHBuild.Postprocessing(pyx_post)
145 if __name__ ==
"__main__":
149 parser = argparse.ArgumentParser(description=
"Build MCODAC's shared library remotely and its subsidiaries on the institute cluster.\ 150 Supported features are ABAQUS, ANSYS & NASTRAN")
151 parser.add_argument(
"BuildID", metavar=
"BuildID", nargs=1, help=
"Name ID for build job")
152 parser.add_argument(
"user", metavar=
"user", nargs=1, help=
"Current user for SSH connection")
153 parser.add_argument(
"key", metavar=
"key", nargs=1, help=
"Path to private SSH key")
154 parser.add_argument(
"source_path", metavar=
"source", nargs=1, help=
"Directory containing all source files")
155 parser.add_argument(
"feature_path", metavar=
"feature", nargs=1, help=
"Directory containing the feature source file \ 156 in dependence of requested feature: ABAQUS, ANSYS, NASTRAN.")
159 args, _ = parser.parse_known_args()
164 BuildID = args.BuildID[0]
167 path2src = args.source_path[0]
168 path2feature = args.feature_path[0]
172 key = os.path.join(Utility.AsDrive(
"C"),
"Users",user,
"Keys",
"Putty",
"id_rsa")
173 path2src=os.path.join(__mcd_core_path,
"src")
174 path2feature=os.path.join(__mcd_core_path,
"solver")
176 main(BuildID,user,key,path2src,path2feature)
179 print(
"==================================")
181 print(
"==================================")
def main(BuildID, user, key, path2src=os.path.join(__mcd_core_path,"src"), path2feature=os.path.join(__mcd_core_path,"solver"), files=VTL.GetSourceCode(0), source_file="mcd_astandard.f", version="abq2019", makeopt=0, scratch=VTL.Scratch, dependency=posixpath.join(Utility.AsDrive("cluster", posixpath.sep),"software","mcodac","stable"), verbosity=0, host="129.247.54.37", port=22, kwargs)
Module containing all relevant modules and scripts associated with the building process.