Example #1
0
def compile_with_ifort(srcfiles, target, cc, objdir_temp, moddir_temp,
                       expedite, dryrun, double, debug, fflagsu, arch, srcdir,
                       srcdir2, extrafiles, makefile):
    """
    Make target on Windows OS
    
    """
    # C/C++ compiler switches
    if debug:
        cflags = ['-O0', '-g']
    else:
        cflags = ['-O3']
    syslibs = ['-lc']

    fc = 'ifort.exe'
    cc = 'cl.exe'
    cflags = ['-nologo', '-c']
    fflags = ['-heap-arrays:0', '-fpe:0', '-traceback', '-nologo']
    if debug:
        fflags += ['-debug']
        cflags += ['-Zi']
    else:
        # production version compile flags
        fflags += ['-O2']
        cflags += ['-O2']
    if double:
        fflags.append('/real_size:64')
    if fflagsu is not None:
        t = fflagsu.split()
        for fflag in t:
            fflags.append('-' + fflag)
    objext = '.obj'
    batchfile = 'compile.bat'
    if os.path.isfile(batchfile):
        try:
            os.remove(batchfile)
        except:
            pass

    # Create target
    try:
        # clean exe prior to build so that test for exe below can return a
        # non-zero error code
        if flopy_avail:
            if flopy_is_exe(target):
                os.remove(target)
        makebatch(batchfile, fc, cc, fflags, cflags, srcfiles, target, arch,
                  objdir_temp, moddir_temp)
        #subprocess.check_call([batchfile, ])
        proc = subprocess.Popen([
            batchfile,
        ],
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT)
        while True:
            line = proc.stdout.readline()
            c = line.decode('utf-8')
            if c != '':
                c = c.rstrip('\r\n')
                print('{}'.format(c))
            else:
                break
        if flopy_avail:
            if not flopy_is_exe(target):
                return 1
        else:
            return 0
    except:
        print('Could not make x64 target: ', target)
        print(traceback.print_exc())

    # create makefile
    if makefile:
        print('makefile not created for Windows with Intel Compiler.')

    # return
    return 0
Example #2
0
def compile_with_ifort(srcfiles, target, fc, cc, objdir_temp, moddir_temp,
                       expedite, dryrun, double, debug, fflagsu, cflagsu,
                       syslibs, arch, srcdir, srcdir2, extrafiles, makefile):
    """
    Make target on Windows OS
    """

    if fc == 'ifort':
        fc = 'ifort.exe'
    elif fc is not None:
        fc = '{}.exe'.format(fc)
    if cc == 'icc':
        cc = 'icc.exe'
    elif cc == 'icl':
        cc = 'icl.exe'
    else:
        cc = 'cl.exe'

    # C/C++ compiler switches
    cflags = ['/nologo', '/c']
    # if debug:
    #    cflags += ['/O0', '/g']
    # else:
    #    cflags += ['/O3']

    fflags = ['/heap-arrays:0', '/fpe:0', '/traceback', '/nologo']
    if debug:
        opt = '/debug'
    else:
        opt = '/O2'
    if fflagsu is None:
        fflagsu = []
    elif isinstance(fflagsu, str):
        fflagsu = fflagsu.split()
    if cflagsu is None:
        cflagsu = []
    elif isinstance(cflagsu, str):
        cflagsu = cflagsu.split()
    # look for optimization levels in fflags
    for fflag in fflagsu:
        if fflag[:2] in ('-O', '/O') or fflag in ('-fast', '/fast'):
            if not debug:
                opt = fflag
            fflagsu.remove(fflag)
            break  # after first optimization (O) flag
    if debug:
        fflags.append(opt)
        cflags.append('/Zi')
    else:
        # production version compile flags
        fflags.append(opt)
        cflags.append('/O2')
    if double:
        fflags.append('/real-size:64')
        fflags.append('/double-size:64')
    # Split all tokens by spaces
    for fflag in ' '.join(fflagsu).split():
        if fflag not in fflags:
            fflags.append(fflag)
    for cflag in ' '.join(cflagsu).split():
        if cflag not in cflags:
            cflags.append(cflag)
    batchfile = 'compile.bat'
    if os.path.isfile(batchfile):
        try:
            os.remove(batchfile)
        except:
            pass

    # Create target
    try:
        # clean exe prior to build so that test for exe below can return a
        # non-zero error code
        if flopy_avail:
            if flopy_is_exe(target):
                os.remove(target)
        makebatch(batchfile, fc, cc, fflags, cflags, srcfiles, target,
                  arch, objdir_temp, moddir_temp)
        proc = Popen([batchfile, ], stdout=PIPE, stderr=STDOUT)
        while True:
            line = proc.stdout.readline()
            c = line.decode('utf-8')
            if c != '':
                c = c.rstrip('\r\n')
                print('{}'.format(c))
            else:
                break
        if flopy_avail:
            if not flopy_is_exe(target):
                return 1
        else:
            return 0
    except:
        print('Could not make x64 target: ', target)
        print(traceback.print_exc())

    # create makefile
    if makefile:
        print('makefile not created for Windows with Intel Compiler.')

    # return
    return 0
Example #3
0
def compile_with_ifort(srcfiles, target, fc, cc, objdir_temp, moddir_temp,
                       expedite, dryrun, double, debug, fflagsu, cflagsu,
                       syslibs, arch, srcdir, srcdir2, extrafiles, makefile):
    """
    Make target on Windows OS
    """

    if fc == 'ifort':
        fc = 'ifort.exe'
    elif fc is not None:
        fc = '{}.exe'.format(fc)
    if cc == 'icc':
        cc = 'icc.exe'
    elif cc == 'icl':
        cc = 'icl.exe'
    else:
        cc = 'cl.exe'

    # C/C++ compiler switches
    cflags = ['/nologo', '/c']
    # if debug:
    #    cflags += ['/O0', '/g']
    # else:
    #    cflags += ['/O3']

    fflags = ['/heap-arrays:0', '/fpe:0', '/traceback', '/nologo']
    if debug:
        opt = '/debug'
    else:
        opt = '/O2'
    if fflagsu is None:
        fflagsu = []
    elif isinstance(fflagsu, str):
        fflagsu = fflagsu.split()
    if cflagsu is None:
        cflagsu = []
    elif isinstance(cflagsu, str):
        cflagsu = cflagsu.split()
    # look for optimization levels in fflags
    for fflag in fflagsu:
        if fflag[:2] in ('-O', '/O') or fflag in ('-fast', '/fast'):
            if not debug:
                opt = fflag
            fflagsu.remove(fflag)
            break  # after first optimization (O) flag
    if debug:
        fflags.append(opt)
        cflags.append('/Zi')
    else:
        # production version compile flags
        fflags.append(opt)
        cflags.append('/O2')
    if double:
        fflags.append('/real-size:64')
        fflags.append('/double-size:64')
    # Split all tokens by spaces
    for fflag in ' '.join(fflagsu).split():
        if fflag not in fflags:
            fflags.append(fflag)
    for cflag in ' '.join(cflagsu).split():
        if cflag not in cflags:
            cflags.append(cflag)
    objext = '.obj'
    batchfile = 'compile.bat'
    if os.path.isfile(batchfile):
        try:
            os.remove(batchfile)
        except:
            pass

    # Create target
    try:
        # clean exe prior to build so that test for exe below can return a
        # non-zero error code
        if flopy_avail:
            if flopy_is_exe(target):
                os.remove(target)
        makebatch(batchfile, fc, cc, fflags, cflags, srcfiles, target,
                  arch, objdir_temp, moddir_temp)
        proc = Popen([batchfile, ], stdout=PIPE, stderr=STDOUT)
        while True:
            line = proc.stdout.readline()
            c = line.decode('utf-8')
            if c != '':
                c = c.rstrip('\r\n')
                print('{}'.format(c))
            else:
                break
        if flopy_avail:
            if not flopy_is_exe(target):
                return 1
        else:
            return 0
    except:
        print('Could not make x64 target: ', target)
        print(traceback.print_exc())

    # create makefile
    if makefile:
        print('makefile not created for Windows with Intel Compiler.')

    # return
    return 0