You are on page 1of 3

From Mihai Stoichitescu

Hello everyone,

I. A complete tutorial on compiling the source code of Yasso to a Windows library (dll).
II. Loading Yasso in R.
III. Clean up after compiling

###########################################################################
I. A complete tutorial on compiling the source code of Yasso to a Windows library (dll).
###########################################################################

Step 1. _____________________________________________________________________
Download an automated installer to compile with: http://sourceforge.net/projects/mingwbuilds/

Step 2. _____________________________________________________________________
Run mingw-builds-install.exe and install the build with the R architecture that you will be using.
In the installer leave everything as is, just change the architecture to x64 if you will be using R x64
and for things to be easier in the future, choose to install on folder C:\MinGW.

Step 3. _____________________________________________________________________
Insert an absolute path to the system environmental. Follow this tutorial and insert the path
corresponding to the architecture that you will be using:

 x32 bit - C:\MinGW\mingw32\bin


 x64 bit - C:\MinGW\mingw64\bin

If you want to compile for both do this step again after doing step 4 but change the path before
compiling and don't put both paths.

Step 4. _____________________________________________________________________
Compile the original yasso source code (built in fortran).
Go here and save y07_subroutine.f90 in the folder C:\Yasso\Model (if a new version is released
browse to it on the left side of the page).

Open y07_subroutine.f90 in a text editor like Notepad / Notepad++ / Sublime Text and change the
first 4 lines from this:
MODULE yasso
IMPLICIT NONE
CONTAINS
SUBROUTINE mod5c(a,t,cl,init,inf,s,z) !components separately
to this
SUBROUTINE yasso07(a,t,cl,init,inf,s,z) !components separately
and the last two lines from this:
END SUBROUTINE mod5c
END MODULE yasso
to this
END SUBROUTINE inverse
END SUBROUTINE yasso07
or get the attached f90 already edited source code from Aleksi (I think) who made some changes
regarding the
variables from REAL to DOUBLE PRECISION (the latter being more precise ) and some other
tweaks.
Press ⌘ Win+R , type cmd and enter Command Prompt.

Type: gcc --version


If everyting ok you should see something like this: gcc (rev5, Bulti by MinGW-W64 project) 4.8.1....
If not, exit the Command prompt and check system environmental path again in step 3.

Type: cd C:\Yasso\Model

Type:
gfortran -m 32 -shared -o y07_subroutine 32 .dll y07_subroutine.f90
or
gfortran -m 64 -shared -o y07_subroutine 64 .dll y07_subroutine.f90
You shouldn't see any output if everything ok, just a blank space. If you see an error check that the
path is correct and/or exit Command Prompt and redo.

You should now have one or two dll's in the C:\Yasso\Model folder (depending if you compiled for
both 32-64 bit or not)

###########################################################################
II. Loading Yasso in R.
###########################################################################

Now the really easy part.

Run the Yasso07.r attached, line by line and all should be well.

Remember to use:
y07_subroutine32.dll in the R (x32) and the C:\MinGW\mingw32\bin path
or
y07_subroutine64.dll in the R (x64) and the C:\MinGW\mingw64\bin path

###########################################################################
III. CLEAN UP after compiling
###########################################################################

In case you finished the compiling business and you won't be compiling anything anytime soon you
can delete every single folder and file in :
C:\MinGW\mingw32\ C:\MinGW\mingw64\
except except
bin\libgcc_s_dw2-1.dll bin\libgcc_s_seh-1.dll
bin\libgfortran-3.dll bin\libgfortran-3.dll
bin\libquadmath-0.dll bin\libquadmath-0.dll
bin\libwinpthread-1.dll bin\libwinpthread-1.dll

The above files are the files that are used when loading the y07_subroutineXX.dll in R.
Another alternative would be copying these files to C:\Windows\system32
If you'll do this you can even delete the line added to the path in step 3.

###########################################################################
###########################################################################

You might also like