Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arch makefiles #38

Open
wants to merge 5 commits into
base: ver_7.0_alpha
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 22 additions & 29 deletions Makefile.global
Original file line number Diff line number Diff line change
Expand Up @@ -16,55 +16,48 @@ ARG_FLAGS = -DARG_INT1=$(INPUT_INT1) -DARG_INT2=$(INPUT_INT2)
OBJDIR := build

ifeq ($(strip $(FF)),)
FF = $(F95COMPILER)
FF = $(F90COMPILER)
endif

ifeq ($(NETCDFLIBS),"none")
LIB_DIR =
INC_DIR =
ORM_FLAGS += -Dno_netcdf
endif
ifeq ($(NETCDFLIBS),"automatic")
else ifeq ($(NETCDFLIBS),"automatic")
LIB_DIR = $(shell nc-config --flibs)
INC_DIR = -I$(shell nc-config --includedir)
endif
ifeq ($(NETCDFLIBS),"automatic-44")
else ifeq ($(NETCDFLIBS),"automatic-44")
INC_DIR = $(shell nf-config --cflags)
LIB_DIR = $(shell nf-config --flibs)
endif
ifeq ($(NETCDFLIBS),"macports")
LIB_DIR = -L/opt/local/lib
INC_DIR = -I/opt/local/include/
LNK_FLAGS = -lnetcdf -lnetcdff
endif
ifeq ($(NETCDFLIBS),"fink")
LIB_DIR = -L/sw/lib # -L/sw/lib/netcdf-gfortran/lib
INC_DIR = -I/sw/include #-I/sw/lib/netcdf-gfortran/include
LNK_FLAGS = -lnetcdf -lnetcdff -lsz
else
LIB_DIR = -L/usr/local/lib
INC_DIR = -I/usr/local/include/
LNK_FLAGS = -lnetcdf -lnetcdff
endif

ifeq ($(F95COMPILER),"gfortran")
FF_FLAGS = -O3 -c -x f95-cpp-input -g -fbacktrace -fbounds-check
# FF_FLAGS = -O3 -c -x f95-cpp-input -g -fbacktrace -fbounds-check -ffpe-trap=denormal -static -Wall -pedantic
#FF_FLAGS = -O3 -c -x f95-cpp-input
ifeq ($(ARCH),"macports")
F90COMPILER = gfortran-mp-8
PROD_FF_FLAGS = -O3 -c -x f95-cpp-input -g -fbacktrace -fbounds-check
DEV_FF_FLAGS = -O1 -c -x f95-cpp-input -g -fbacktrace -fbounds-check -ffpe-trap=denormal -static -Wall -pedantic
F90_FLAGS = -fno-underscoring
FF += $(LIB_DIR) $(INC_DIR) $(F90_FLAGS) $(ORM_FLAGS) -J$(OBJDIR)
endif
ifeq ($(F95COMPILER),"g95")
FF_FLAGS = -c -cpp -fendian=big
F90_FLAGS = -O3 -C -g -fno-underscoring
FF += $(LIB_DIR) $(INC_DIR) $(F90_FLAGS) $(ORM_FLAGS)
endif

ifeq ($(F95COMPILER),"ifort")
FF_FLAGS = -O3 -cpp -convert big_endian -xcore-avx512
ifeq ($(ARCH),"tetralith")
F90COMPILER = ifort
PROD_FF_FLAGS = -O3 -cpp -convert big_endian -xcore-avx512
DEV_FF_FLAGS = -O1 -cpp -convert big_endian -xcore-avx512 -g -traceback -fpe0
F90_FLAGS = -free
ARG_FLAGS += -Tf
FF += $(LIB_DIR) $(INC_DIR) $(F90_FLAGS) $(ORM_FLAGS)
TT_FLAGS = -c
endif


ifeq ($(OPT),"opt")
FF_FLAGS = $(PROD_FF_FLAGS)
else
FF_FLAGS = $(DEV_FF_FLAGS)
endif


CC = gcc -O $(INC_DIR)
Expand All @@ -75,12 +68,12 @@ VPATH = src:projects/$(PROJECT):src/active_particles

all: runfile

objects := $(addprefix $(OBJDIR)/,modules.o interp_general.o $(ACTVEL) calendar.o \
objects := $(addprefix $(OBJDIR)/,modules.o interp_general.o interp2.o $(ACTVEL) calendar.o \
laplacian.o savepsi.o savepsi_new.o loop_pos.o writetrajs.o \
sw_stat.o tracer_functions.o \
seed.o init_seed.o getfile.o \
vertvel.o coord.o cross.o init_par.o time_subs.o \
pos.o interp2.o sw_seck.o sw_pres.o sw_dens0.o \
pos.o sw_seck.o sw_pres.o sw_dens0.o \
writepsi.o writetracer.o printinfo.o loop.o main.o \
setupgrid.o readfield.o diffusion.o)

Expand Down
26 changes: 16 additions & 10 deletions Makefile_tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@ PROJECT = theoretical
CASE = theoretical
RUNFILE = runtracmass

#F95COMPILER = "g95"
F95COMPILER = "gfortran"
#F95COMPILER = "ifort"
#FF = "/sw/bin/gfortran-fsf-4.9" #Alt. compiler location
# Possible architectures:
# tetralith (Swedish HPC with intel)
# macports (MacPorts for Mac OS)
# generic (copy this to make your own arch)
ARCH = "macports"
#FF = "/sw/bin/gfortran-fsf-4.9" #Alt. compiler location

NETCDFLIBS = "none"
#NETCDFLIBS = "automatic" # set using nc-config
#NETCDFLIBS = "automatic-44" # set using nf-config
#NETCDFLIBS = "macports"
#NETCDFLIBS = "fink"
#NETCDFLIBS = "source"
# Possible netCDF settings
# automatic (set by nc-config)
# automatic-44 (set by nf-config, for netCDF version >4.4)
# generic (set by yourself in Makefile.global)
# none (no netCDF)
NETCDFLIBS = "automatic-44"

# Opt = optimise, i.e. dont use so many error checks
# Else TRACMASS will compile with lots of error check which might slowdown the code
OPT = "opt"

#================================================================

Expand Down
83 changes: 62 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,42 @@ It is still in development.
Quickstart
==========

Prerequisites to run on Mac OS X
--------------------------------
Download the code
-----------------

Download and install macports (www.macports.org)
Install the following ports:
```bash
git clone https://github.com/TRACMASS/tracmass.git
```

```sh
sudo port install openmpi +gcc45 +valgrind
sudo port install netcdf +openmpi +netcdf4
sudo port install netcdf-fortran +gcc45 +openmpi
sudo port install git-core
sudo port install git-extras
Compile
-------

Enter the tracmass directory and copy the template Makefile

```bash
cd tracmass
cp Makefile_tmpl Makefile
```

Modify the Makefile to fit your system.
You will need to set ARCH, which is the name of your system, i.e. macports, tetralith etc.
You will also need to configure how TRACMASS should find the netCDF libraries, if at all.
For most systems, we recommend the option automatic-44.
Then you can run the make command.

```bash
make
```

Running a first test case
-------------------------

We recommend testing that TRACMASS was properly compiled by letting PROJECT and CASE be "theoretical" in the Makefile (which is the default).
In this case, TRACMASS will use a simple oscillating velocity field to trace trajectories.
You can run this case by setting

```bash
./runtracmass
```

Download test data
Expand All @@ -36,26 +60,43 @@ You can find some input data for testing the code on
https://www.dropbox.com/sh/b6leim7tb99i3hm/AAA7M0mxuYTwJLKjqmLnoJuca?dl=0
```

This test data includes data from NEMO, IFS and ROMS.
Before doing any analysis we recommend to download some of the test data and make sure TRACMASS is working properly.

Compile the code
----------------

Copy Makefile_tmpl to Makefile.
Choose a change PROJECT and CASE in Makefile to your projectname.
If you are using netCDF version >4.4 you can set NETCDFLIBS to "automatic-44", in which case netCDF paths will be taken from nc-config and nf-config.
In order to set up TRACMASS to run trajectories on e.g. NEMO data, you will need to change PROJECT and CASE to NEMO, and then re-compile the code.

run:

```bash
```bash
make clean
make
./runtrm
./runtracmass
```

Run your analysis
-----------------

If you wish to run TRACMASS using fields from NEMO, ROMS, IFS or CMEMS satellite altimetry, you may use these projects as is (see projects directory).
If you wish to run another case or a very specific case of the above models, you may create your own project in the projects directory.
To run with e.g. your own NEMO data, you will need to modify the projects/nemo/nemo.in namelist to suit your needs.


Change log
==========


6.0.0 First public release
7.0.0_alpha New features for parametrising sub-grid scale motions, tracing water in the atmosphere, simplified set-up for users + code clean–up + bug-fixes.
7.0.0_alpha New features for parametrising sub-grid scale motions, tracing water in the atmosphere, simplified set-up for users + code clean–up + bug-fixes.


Prerequisites to run on Mac OS X
================================

Download and install macports (www.macports.org)
Install the following ports:

```sh
sudo port install openmpi +gcc45 +valgrind
sudo port install netcdf +openmpi +netcdf4
sudo port install netcdf-fortran +gcc45 +openmpi
sudo port install git-core
sudo port install git-extras
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ subroutine readfields
USE mod_grid
USE mod_name
USE mod_vel
! USE mod_dens
USE mod_dens
USE mod_tempsalt
USE mod_stat

IMPLICIT none
Expand Down Expand Up @@ -47,11 +48,9 @@ subroutine readfields
do i=1,IMT
im=i-1
if(im.eq.0) im=IMT
#ifdef tempsalt
tem (i,j,k,2)=20.*float(k)/float(km)
sal (i,j,k,2)=30.
rho (i,j,k,2)=(28.-20.)*float(km-k)/float(km) +20.
#endif

! time evolving oscilating field
! ------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ SUBROUTINE setupgrid
integer, dimension(2) :: dim2d
integer, dimension(3) :: dim3d
real, allocatable, dimension(:,:) :: lon, lat
real, allocatable, dimension(:) :: depth
real, allocatable, dimension(:) :: depth_1d
logical :: lwrite_nc, lread_nc

lwrite_nc = .true.
lread_nc = .true.

allocate( lon(imt,jmt), lat(imt,jmt) )
allocate( depth(km) )
allocate( depth_1d(km) )

kmt=KM ! flat bottom

Expand All @@ -74,9 +74,9 @@ SUBROUTINE setupgrid
end do
end do

depth(1) = dz(1)/2.
depth_1d(1) = dz(1)/2.
do k = 2, km
depth(k) = SUM(dz(1:k-1)) + dz(k)/2.
depth_1d(k) = SUM(dz(1:k-1)) + dz(k)/2.
end do

if (lwrite_nc) then
Expand All @@ -98,7 +98,7 @@ SUBROUTINE setupgrid

call check( nf90_put_var(ncid, idlon, lon) )
call check( nf90_put_var(ncid, idlat, lat) )
call check( nf90_put_var(ncid, iddep, depth) )
call check( nf90_put_var(ncid, iddep, depth_1d) )
call check( nf90_put_var(ncid, iddx, dxv(1:jmt,1:imt)) )
call check( nf90_put_var(ncid, iddy, dyu(1:jmt,1:imt)) )
call check( nf90_put_var(ncid, iddz, dzt(1:imt,1:jmt,1:km,2)) )
Expand All @@ -112,13 +112,16 @@ SUBROUTINE setupgrid
map3d = [2, 3, 4, 1]
lon = get2DfieldNC('mesh.nc', 'lon')
lat = get2DfieldNC('mesh.nc', 'lat')
depth = get1DfieldNC('mesh.nc', 'depth')
depth_1d = get1DfieldNC('mesh.nc', 'depth')
dxv(1:imt,1:jmt) = get2DfieldNC('mesh.nc', 'dx')
dyu(1:imt,1:jmt) = get2DfieldNC('mesh.nc', 'dy')
dzt(1:imt,1:jmt,1:km,2) = get3DfieldNC('mesh.nc', 'dz')
dzt(:,:,:,1) = dzt(:,:,:,2)
end if

depth(:,:) = depth_1d(km)



! ===

Expand Down
7 changes: 5 additions & 2 deletions projects/theoretical/theoretical.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
/
&INIT_GRID_TIME
fieldsperfile = 1,
ngcm = 1,
ngcm_step = 1,
ngcm_unit = 4,
iter = 1,
intmax = 146000,
minveljd = -1,
Expand Down Expand Up @@ -67,7 +68,7 @@
! 5 = write at chosen intervals
! 6 = write each spatial grid-crossing
kriva = 6,
outdatadir = '/proj/bolinc/users/x_sarbe/TRACMASS/projects/theoretical/',
outdatadir = 'data_out'
outdatafile = 'test_k6',
! outdatafile = 'analyt_k1',
! outdatafile = 'dt1_k1',
Expand Down Expand Up @@ -169,3 +170,5 @@
twave = 8.0,
critvel = 0.1,
/
&INIT_TRACERS
/
4 changes: 0 additions & 4 deletions src/cross.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ subroutine cross_stat(ijk,ia,ja,ka,r0,sp,sn)
if(im.eq.0) im=IMT
uu=(intrpg*uflux(ia,ja,ka,nsp)+intrpr*uflux(ia,ja,ka,nsm))!*ff
um=(intrpg*uflux(im,ja,ka,nsp)+intrpr*uflux(im,ja,ka,nsm))!*ff
frac1 = min( abs(upr(1,1)), abs(0.99*uu/upr(1,1)) )
frac2 = min( abs(upr(2,1)), abs(0.99*um/upr(2,1)) )
!print*,'cross x',uu,um,upr(1,1),upr(2,1)
#ifdef turb
if(r0.ne.dble(ii)) then
Expand All @@ -66,8 +64,6 @@ subroutine cross_stat(ijk,ia,ja,ka,r0,sp,sn)
ii=ja
uu=(intrpg*vflux(ia,ja ,ka,nsp)+intrpr*vflux(ia,ja ,ka,nsm))!*ff
um=(intrpg*vflux(ia,ja-1,ka,nsp)+intrpr*vflux(ia,ja-1,ka,nsm))!*ff
frac1 = min( abs(upr(3,1)), abs(0.99*uu/upr(3,1)) )
frac2 = min( abs(upr(4,1)), abs(0.99*um/upr(4,1)) )
!print*,'cross y',uu,um,upr(3,1),upr(4,1)
#ifdef turb
if(r0.ne.dble(ja )) then
Expand Down
2 changes: 0 additions & 2 deletions src/init_par.F90
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,12 @@ SUBROUTINE init_params
seedsubints(1) = 0
end if

#ifdef tempsalt
ALLOCATE ( tem(imt,jmt,km,nst) )
ALLOCATE ( sal(imt,jmt,km,nst) )
ALLOCATE ( rho(imt,jmt,km,nst) )
tem = 0.
sal = 0.
rho = 0.
#endif

ALLOCATE ( tracers2D(n2Dtracers), tracers3D(n3Dtracers) )
DO jt=1,n2Dtracers
Expand Down
3 changes: 1 addition & 2 deletions src/interp2.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#ifdef tempsalt
subroutine interp2(i,j,k,temp,salt,dens)

! === NO interpolation of the temperature, salinity, and density===
Expand Down Expand Up @@ -28,5 +27,5 @@ subroutine interp2(i,j,k,temp,salt,dens)

return
end subroutine interp2
#endif


Loading