You are here: CLASSE Wiki>ACC/ACL Web>WindowsBuilds (20 Jun 2006, ValeriuSmiricinschi)Edit Attach
Tags

Building and Running with CESR Codes on Windows Computers at LEPP

Requirements

On windows site the following must be installed:

1. Cygwin GNU bash, version 2.05b.0(1)-release (i686-pc-cygwin). Make sure that you have makedepend, perl and win32fe utility.

2. MS Visual Studio C++ (the only thing we really use here is cl.exe compiler Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86).

3. Intel Fortran compiler version 9.0 .

4. MPIPro version 1.7.0 .

General

building -- cygwin.

running executables -- windows

Cygwin is used in order to utilize all unix script functionalities like make, perl, bash etc... The process of building is going under control of Cygwin but all outputs like *.exe *.obj files are generated as windows programs and *.exe must be run in windows command prompt.

Building CESR Codes on Windows at LEPP.

  • 1. Map network drive. Open Windows Explorer / Tools / Map NetWork drive. Select drive W: . Type in Select folder the following: \\lnx209\libs and click Finish. Now you have W: drive as \\lnx209\libs.

  • 2. Copy content of W:\CYGWIN_NT_i686\bin in z:\users\user\bin. Create file z:\users\user\.bashrc and Make sure the file contains the following lines

alias gmake=make

export PATH=${PATH}:${HOME}/bin:.

CESRLIB=devel; . cesrdefs

  • 3. Open Windows console command prompt "Build Environment for IA-32 application". Type C:\cygwin\cygwin press enter. Now you have cygwin bash console that looks like linux bash console and you are ready to use it in the same way like on linux. You can verify that all environments are set up correctly by command

printenv| grep CESR .

  • 4. Go to your application directory and type gmake.

Note : I recommend that your application is located on windows local drive not a network drive. Network drive can cause a compiler error due to delays in read/write operations.

How to run executables.

If you have built successfully your executables you can not run it in cygwin environment if it uses environment variable, for example, such as BMAD_LAT and BMAD_LAYOUT. That is because the *.exe you have generated is windows program and not cygwin program. So you have to run it in windows command prompt:

  • 1. Open Windows console command prompt "Build Environment for IA-32 application".

  • 2. Go to the z:\users\user\bin and edit the following line in cesr_init.bat:
set LIBREL=bmad_dist_yyyy_mmdd_d to LIBREL=devel

  • 3. Run cesr_init.bat

  • 4. Run your application.

Stand alone Bmad distribution build

(in the following examples it is assumed that c:\my_work\ is your working directory)

  • 2. Under cygwin untar distribution do
tar xvfz bmad_dist_yyyy_mmdd_d.tar.gz

  • 3. Go to the directory bmad_dist_yyyy_mmdd_d/bin and edit the file bmad_defs as follows:

line

BMAD_=${BMAD_-/home/cesrulib/cesr_libs/bmad_dist}

replace with

BMAD_=${BMAD_-/cygdrive/c/my_work/bmad_dist_yyyy_mmdd_d}

line

export BMAD_PD=w

change to

export BMAD_PD=c

If you are working out of d: local disk drive then you must have two lines corrected

export BMAD_PD=d export LOCAL_PD=d

  • 4. Source bmad_defs so all bmad environment variables are setup

. bmade_defs

  • 5. Finally build the distribution

make -f $BMAD_GMAKE/M.distribution

How to run executables built by M.tail against stand alone bmad distribution.

  • 1. Open Windows console command prompt "Build Environment for IA-32 application".

  • 2. go to the bmad_dist_yyyy_mmdd_d\util and edit the following two lines
in bmad_init.bat:

set LIBREL=bmad_dist change to set LIBREL=bmad_dist_yyyy_mmdd_d

set BMAD_DRIVE=W: change to set BMAD_DRIVE=c:\mywork

  • 3. Run bmad_init.bat

  • 4. Run your application.

Specifics

The main script M.tail is running under cygwin, but it calls intel ifort and MS c++ cl.exe compilers using win32fe.exe utility. The utility parses and converts all unix type paths and flaggs into windows format. But it cannot convert created simbol links so there is no simbol links, instead on windows site we have hard copies of the files and directories.

Directory paths and disks.

Under cygwin the correct path to windows directory c:\my_work\dir looks like /cygdrive/c/my_work/dir, which means that all absolute path names in Makefile must be in cygwin format not windows.

Two cygwin environment variables CESR_PD and LOCAL_PD tell M.tail script what physical drive disks are in use.

For example:

export CESR_PD=d

means CESR/BMAD libraries are located on d: disk , and

export LOCAL_PD=c

means local user build is on c: disk.

new in M.tail

Importante difference in M.tail between version 1.65 and 1.66 (last one contains windows porting changes) are:

Line 302:

New variables LINK_FILE and OBJ are introduced.

LINK_FILE:=ln -s this is default value LINK_FILE:=cp this is value for CYGWIN_NT_i686 so we enforce hard copy of the files instead of simbol linking.

Variable OBJ defines the extensions for the compiled object files.

Line 406:

Three variables F90_OBJECT_FLAG, OBJ_FILE_CFLAG and OBJ_FILE_CPPFLAG define the object output flag.

Line 459:

Variable LIBRARY_LIB defines the name of the windows style archive library.

Line 646:

There are about 70 lines of new code starting from line 646 begining with ifeq "$(PLARFORM_TAG)" "CYGWIN_NT_i686 " ...

here we have all tuning of flaggs and parameters needed for CYGWIN_NT_i686 . The important feature is that win32fe.exe utility is used with compilers. The utility accepts all standard unix type flags for compilers except flags for output of compiled fortran modules. That is why we have MOD_DIR_FLAG = -module: it is a windows style flag. Utility win32fe.exe also ignores everething that follows flag -modules: so the exact implementation of that flag in the command line will be

$(MOD_DIR_FLAG)$(patsubst /cygdrive/$(LOCAL_PD)%,$(LOCAL_PD)\:%,$(patsubst /cygdrive/$(CESR_PD)%,$(CESR_PD)\:%,$(MOD_OUT_DIR))) see for example Line 1600.

Line 913:

WIN_LIB_REQD -- variable is set to the name of windows archive library.

Line 1257:

starting with: $(LIBRARY_LIB):$(LIBRARY) ...

This is a new rule to build windows style archive library from already created unix style archive library.

Important things that have been not cleaned up yet:

-TP option (for cl.exe)

C-files from c_utils must be compiled with “–TP” option for cl.exe. This is only need to get around of absence of _Boolen in standard MS c. Do not use it anywhere else for c-files.

-MW option (for ifort)

Fortran main program files and subroutines that uses PGPLOT directly must be compiled (and linked) with “-MW” options (Multi Document Windows interface) .

No FORTRAN calls c++

The calling of c++ (MS compiled) function from FORTRAN (ifort compiled) is not possible yet. Only c-routine can be used.

c/c++ include paths

Each time you reinstall MS visual c/c++ make sure to correct include path in M.tail. There is no standard location for the MS cl.exe compiler on windows.

-- ValeriuSmiricinschi - 15 Mar 2006
Topic revision: r7 - 20 Jun 2006, ValeriuSmiricinschi



  • ACC/ACL Web

  • CLASSE Computing Info
  • CLASSE

Create personal sidebar

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding CLASSE Wiki? Send feedback