This class takes care of the BLACS installation.
| def blacs.Blacs.check_blacs |
( |
|
self | ) |
|
Checks if BLACS libraries are good
32 def check_blacs(self):
33 """ Checks if BLACS libraries are good """
38 print(
'Checking if provided BLACS works...', end=
' ')
42 integer itmp, iam, nnodes
43 call blacs_pinfo(iam, nnodes)
45 call blacs_get( 0, 0, itmp )
46 call blacs_gridinit(itmp, 'c', 1, nnodes)
47 call blacs_gridexit(itmp)
52 fcomm = self.mpif77+
' '+self.ldflags_f77+
' -o tmpf '+
'tmpf.f '+self.blacsF77lib+
' '+self.blacslib+
' '+self.blacsClib
56 print(
'\n\nBLACS: provided BLACS cannot be used! aborting...')
57 print(
'error is:\n',
'*'*40,
'\n',error,
'\n',
'*'*40)
63 print(
'\n\nBLACS: provided BLACS cannot be used! aborting...')
64 print(
'error is:\n',
'*'*40,
'\n',error,
'\n',
'*'*40)
if(UPLO(*uplo)==INVALID) info
Definition: level3_impl.h:428
def runShellCommand(command)
Definition: utils.py:87
def killfiles(lst)
Definition: utils.py:23
def writefile(fname, fill)
Definition: utils.py:17
References blacs.Blacs.blacsClib, framework.Frame.blacsClib, blacs.Blacs.blacsF77lib, framework.Frame.blacsF77lib, blacs.Blacs.blacslib, framework.Frame.blacslib, if(), utils.killfiles(), framework.Frame.ldflags_f77, framework.Frame.mpif77, Eigen::internal.print(), utils.runShellCommand(), and utils.writefile().
Referenced by blacs.Blacs.__init__().
| def blacs.Blacs.down_install_blacs |
( |
|
self | ) |
|
Downloads and installs BLACS libraries
74 def down_install_blacs(self):
75 """ Downloads and installs BLACS libraries """
80 if(
not os.path.isdir(os.path.join(os.getcwd(),
'build'))):
81 os.mkdir(os.path.join(os.getcwd(),
'build'))
83 if(
not os.path.isdir(os.path.join(os.getcwd(),
'lib'))):
84 os.mkdir(os.path.join(os.getcwd(),
'lib'))
86 if(
not os.path.isdir(os.path.join(os.getcwd(),
'log'))):
87 os.mkdir(os.path.join(os.getcwd(),
'log'))
90 os.chdir(os.path.join(os.getcwd(),
'build'))
93 if(
not os.path.isfile(os.path.join(os.getcwd(),
getURLName(self.blacsurl)))):
94 print(
'Downloading BLACS...', end=
' ')
99 print(
'Unzip and untar BLACS...', end=
' ')
100 comm =
'gunzip -f mpiblacs.tgz'
103 print(
'\n\nBLACS: cannot unzip mpiblacs.tgz')
104 print(
'stderr:\n',
'*'*40,
'\n',error,
'\n',
'*'*40)
108 comm =
'tar xf mpiblacs.tar'
111 print(
'\n\nBLACS: cannot untar mpiblacs.tgz')
112 print(
'stderr:\n',
'*'*40,
'\n',error,
'\n',
'*'*40)
114 os.remove(
'mpiblacs.tar')
118 os.chdir(os.path.join(os.getcwd(),
'BLACS'))
126 print(
'Compiling BLACS...', end=
' ')
128 comm = self.make+
' mpi'
131 print(
'\n\nBLACS: error building BLACS')
132 print(
'stderr:\n',
'*'*40,
'\n',error,
'\n',
'*'*40)
136 fulllog = os.path.join(savecwd,
'log/blacslog')
139 print(
' (log is in ',fulllog,
')')
141 os.rename(
'LIB/blacs.a',os.path.join(savecwd,
'lib/blacs.a'))
142 os.rename(
'LIB/blacsC.a',os.path.join(savecwd,
'lib/blacsC.a'))
143 os.rename(
'LIB/blacsF77.a',os.path.join(savecwd,
'lib/blacsF77.a'))
146 self.blacslib = os.path.join(savecwd,
'lib/blacs.a ')
147 self.blacsClib = os.path.join(savecwd,
'lib/blacsC.a ')
148 self.blacsF77lib = os.path.join(savecwd,
'lib/blacsF77.a ')
149 Frame.blacslib = os.path.join(savecwd,
'lib/blacs.a ')
150 Frame.blacsClib = os.path.join(savecwd,
'lib/blacsC.a ')
151 Frame.blacsF77lib = os.path.join(savecwd,
'lib/blacsF77.a ')
def downloader(uri, cmd)
Definition: utils.py:150
def getURLName(url)
Definition: utils.py:137
References framework.Frame.blacsurl, framework.Frame.downcmd, utils.downloader(), utils.getURLName(), if(), Eigen::internal::TensorBlockDescriptor< NumDims, Index >::DestinationBuffer.make(), Eigen::internal::TensorBlockDescriptor< NumDims, IndexType >::DestinationBuffer.make(), framework.Frame.make, Eigen::internal.print(), utils.runShellCommand(), blacs.Blacs.set_transcomm(), blacs.Blacs.write_bmake(), and utils.writefile().
Referenced by blacs.Blacs.__init__().
| def blacs.Blacs.set_transcomm |
( |
|
self | ) |
|
Sets the TRANSCOMM variable in Bmake.inc
159 def set_transcomm(self):
160 """ Sets the TRANSCOMM variable in Bmake.inc """
164 print(
'Setting TRANSCOMM...', end=
' ')
176 i = Ccommcheck(MPI_COMM_WORLD, MPI_COMM_SELF)
181 call mpi_finalize(ierr)
189 int Ccommcheck(int F77World, int f77comm){
190 int Np, Iam, i, OK=1;
192 if (sizeof(int) != sizeof(MPI_Comm)) OK=0;
193 else if ((MPI_Comm) F77World != MPI_COMM_WORLD) OK=0;
195 MPI_Comm_rank(MPI_COMM_WORLD, &Iam);
196 i = MPI_Comm_size((MPI_Comm) f77comm, &Np);
197 if (i != MPI_SUCCESS) OK = 0;
198 else if (Np != 1) OK = 0;
202 int CCOMMCHECK(int *F77World, int *f77comm){ return(Ccommcheck(*F77World, *f77comm));}
203 int ccommcheck_(int *F77World, int *f77comm){return(Ccommcheck(*F77World, *f77comm));}
204 int ccommcheck(int *F77World, int *f77comm){return(Ccommcheck(*F77World, *f77comm));}\n""")
206 ccomm = self.mpicc+
' '+self.ccflags+
' -c tmpc.c -o tmpc.o'
207 fcomm = self.mpif77+
' '+self.fcflags+
' tmpf.f tmpc.o -o xtc_CsameF77'
211 print(
'\n\nBLACS: Error in transcomm setting! cannot compile')
212 print(
'stderr:\n',
'*'*40,
'\n',error,
'\n',
'*'*40)
217 print(
'\n\n1BLACS: Error in transcomm setting! cannot compile')
218 print(
'stderr:\n',
'*'*40,
'\n',error,
'\n',
'*'*40)
221 comm = os.path.join(os.getcwd(),
'xtc_CsameF77')
228 killfiles([
'tmpf.f',
'tmpc.c',
'tmpc.o',
'xtc_CsameF77'])
230 self.transcomm = output
233 if(self.transcomm ==
''):
240 extern void *MPIR_ToPointer();
241 extern int MPIR_FromPointer();
242 extern void *MPIR_RmPointer();
244 if (sizeof(int) < sizeof(int*)) {
245 fcomm = MPIR_FromPointer(MPI_COMM_WORLD);
246 ccomm = (MPI_Comm) MPIR_ToPointer(fcomm);
247 if (ccomm == MPI_COMM_WORLD)
248 fprintf(stdout,\" -DUseMpich -DPOINTER_64_BITS=1\");
253 ccomm = self.mpicc+
' '+self.ccflags+
' tmpc.c -o UseMpich'
256 print(self.transcomm)
259 comm = os.path.join(os.getcwd(),
'UseMpich')
262 print(
'\n\nBLACS: Error in transcomm setting! cannot run UseMpich')
263 print(
'stderr:\n',
'*'*40,
'\n',error,
'\n',
'*'*40)
267 self.transcomm = output
270 if(self.transcomm ==
''):
274 int main(int argc, char** argv)
276 int version, subversion;
277 MPI_Init(&argc, &argv);
278 MPI_Get_version(&version, &subversion);
279 if (version==2) fprintf(stdout,\" -DUseMpi2\");
284 ccomm = self.mpicc+
' '+self.ccflags+
' tmpc.c -o UseMPI2'
287 print(self.transcomm)
288 print(
'stderr:\n',
'*'*40,
'\n',error,
'\n',
'*'*40)
291 comm = os.path.join(os.getcwd(),
'UseMPI2')
294 print(
'\n\nBLACS: Error in transcomm setting! cannot run UseMPI2')
295 print(
'stderr:\n',
'*'*40,
'\n',error,
'\n',
'*'*40)
299 self.transcomm = output
301 print(self.transcomm)
References framework.Frame.ccflags, framework.Frame.fcflags, if(), utils.killfiles(), framework.Frame.mpicc, framework.Frame.mpif77, Eigen::internal.print(), utils.runShellCommand(), and utils.writefile().
Referenced by blacs.Blacs.down_install_blacs().
| def blacs.Blacs.write_bmake |
( |
|
self | ) |
|
Writes the Bmake.inc file for BLACS installation
307 def write_bmake(self):
308 """ Writes the Bmake.inc file for BLACS installation """
309 print(
'Writing Bmake.inc...', end=
' ')
313 BTOPdir = """+os.getcwd()+
"""
316 BLACSdir = $(BTOPdir)/LIB
318 BLACSFINIT = $(BLACSdir)/blacsF77.a
319 BLACSCINIT = $(BLACSdir)/blacsC.a
320 BLACSLIB = $(BLACSdir)/blacs.a
322 MPIINCdir = """+self.mpiincdir+
"""
325 BTLIBS = $(BLACSFINIT) $(BLACSLIB) $(BLACSFINIT) $(MPILIB)
326 INSTdir = $(BTOPdir)/INSTALL/EXE
327 TESTdir = $(BTOPdir)/TESTING/EXE
328 FTESTexe = $(TESTdir)/xFbtest_$(COMMLIB)-$(PLAT)-$(BLACSDBGLVL)
329 CTESTexe = $(TESTdir)/xCbtest_$(COMMLIB)-$(PLAT)-$(BLACSDBGLVL)
330 SYSINC = -I$(MPIINCdir)
331 INTFACE = """+self.mangling+
"""
334 TRANSCOMM = """+self.transcomm+
"""
337 DEBUGLVL = -DBlacsDebugLvl=$(BLACSDBGLVL)
338 DEFS1 = -DSYSINC $(SYSINC) $(INTFACE) $(DEFBSTOP) $(DEFCOMBTOP) $(DEBUGLVL)
339 BLACSDEFS = $(DEFS1) $(SENDIS) $(BUFF) $(TRANSCOMM) $(WHATMPI) $(SYSERRORS)
341 F77 = """+self.mpif77+
"""
342 F77NO_OPTFLAGS = """+self.noopt+
"""
343 F77FLAGS = $(F77NO_OPTFLAGS) """+self.fcflags+
"""
345 F77LOADFLAGS = """+self.ldflags_f77+
"""
346 CC = """+self.mpicc+
"""
347 CCFLAGS = """+self.ccflags+
"""
349 CCLOADFLAGS = """+self.ldflags_c+
"""
352 RANLIB = """+self.ranlib+
"""
References framework.Frame.ccflags, framework.Frame.fcflags, framework.Frame.ldflags_c, framework.Frame.ldflags_f77, framework.Frame.mangling, framework.Frame.mpicc, framework.Frame.mpif77, framework.Frame.mpiincdir, framework.Frame.noopt, Eigen::internal.print(), framework.Frame.ranlib, blacs.Blacs.transcomm, and utils.writefile().
Referenced by blacs.Blacs.down_install_blacs().