Work @ CCT

Wednesday, April 4, 2007

Variables made parameters in Cactus

1. Remove the declaration of the variable

2. In the param.ccl from ~/Cactus/arrangements/CactusShrimp/Shrimp/ declare the variables you want to make as Cactus parameters

i.e.

PRIVATE:
( !!Access level)

INT endday "The last day of the simulation or the number of days"
(!!The parameter type and name)

{
1:365::"range for the endday"
(!! The range or the allowed values)

} 80
(!!default value)

3. In the parameter file specify the value of the variable (~/Cactus/exe/shrimp.par):

i.e. - add this line:
Shrimp::endday=12

4. In the main file ( inside the code) :

- include the following library:
#include "cctk_Parameters.h"

- in the subroutines where the variable is used, add:
DECLARE_CCTK_PARAMETERS
(that would be after the implicit none)

Tuesday, April 3, 2007

Integrating the Shrimp code into Cactus

1. Download Cactus

-download the script that is used to checkout Cactus:
wget http://www.cactuscode.org/download/GetCactus

-change the permision:
chmod 755 GetCactus

-execute:
./GetCactus

--------------------------------------------------------------------

Directory for Cactus installation [Cactus] :

Anonymous Flesh checkout? (y)es, n)o, h)elp) [yes] : yes

Checkout Flesh from
[1] Last stable release
[2] Standard development version (bug fixes/unstable)
Choose version: (1-2, h)elp, q)uit) [1] : 1


Verbose checkout (y)es, n)o, h)elp) [no] : no

--------------------------------------------------------------------

2. Create a new thorn

cd Cactus

gmake newthorn

________________________________________________________________________
Creating a new thorn
Thorn name
--> Shrimp

The following arrangements are available:
Pick one, or create a new one.
arrangement
--> CactusShrimp

Thorn Author Name
--> Elena C.

Email Address
--> elena@cct.lsu.edu

Add another author? Y/N
--> n

Creating new arrangement CactusShrimp
Creating thorn Shrimp in CactusShrimp
All done.
Please remember to fill out the README and doc/documentation.tex files.
________________________________________________________________________


- copy the shrimp files in the "src" directory and rename the file with the code from .f90 to .F90
- finally, these files should be in src:

Bolivar2003.prn fineelmtrim.txt make.code.defn
CBelevations.prn GITemps2003.txt Shrimp_02_08_07_clean_UNIX.F90
EGelevations.prn Grand Isle 2003.txt var1.i

Note:
- the difference between the extensions .f90 and .F90 is about the "no preprocessing" Fortran 90 free form
- the file has to be rename, otherwise later there will be problems

3. Prepare the F90 file for compilation

- we choose to integrate into Cactus the optmized/tuned version of the shrimp code

- here are the changes we made in order to put into Cactus:

-#include "cctk.h"
-#include "cctk_Arguments.h"
!! including the necessary libraries

!!make the main program a subroutine:
-subroutine Shrimp_main(CCTK_ARGUMENTS)
- implicit none
-
- DECLARE_CCTK_ARGUMENTS

!! and don't forget to close the subroutine instead of the program;
-end subroutine Shrimp_main-

!! change all the INCLUDE 'name' to #include "name"
i.e.
-#include "var1.i"



4. Modify make.code.defn from Cactus/arrangements/CactusShrimp/Shrimp/src/

# Main make.code.defn file for thorn Shrimp
# $Header$

# Source files in this directory
SRCS = Shrimp_02_08_07_clean_UNIX.F90

# Subdirectories containing source files
SUBDIRS =



5. Modify the schedule.ccl from Cactus/arrangements/CactusShrimp/Shrimp/

# Schedule definitions for thorn Shrimp
# $Header$

SCHEDULE Shrimp_main AT EVOL
{
LANG: FORTRAN
} "Main function of the Shrimp code"


6. Modify the interface.ccl to

# Interface definition for thorn Shrimp
# $Header$

implements: Shrimp #name of the thorn
inherits:

7. Create a file with the thorns to be used in the compilation

cd ~/Cactus/
vim file

-in our case, the file contains only CactusShrimp/Shrimp
i.e.
less file
CactusShrimp/Shrimp

8. Use an option file for compilation (i.e. the options-numrel-intel file from Enrique)

9. Compile the code

gmake shrimp_conf-config THORNLIST=file options=options-numrel-intel

10. You should have the following message returned at the end :

________________________________________________________________________
All done !
________________________________________________________________________


11. Create a parameter file in Cactus/exe

less shrimp.par
ActiveThorns="Shrimp"
Cactus::cctk_itlast = 80

12. This is important and it might be omitted.

- the external files used by the code should be inside the exe directory as well.
- therefore the following should be there:

Bolivar2003.prn checkhab.out GITemps2003.txt var1.i
cactus_shrimp_conf EGelevations.prn Grand Isle 2003.txt
CBelevations.prn fineelmtrim.txt shrimp.par


13. From inside the exe directory run the code:

- cactus_shrimp_conf should be there

mpirun -np 1 cactus_shrimp_conf shrimp.par

Enjoy!!!