Index: src/ecmwf_mod.f90
===================================================================
--- src/ecmwf_mod.f90	(revision adf46aef78fd55bafe1d788207a46de7fc428d1d)
+++ src/ecmwf_mod.f90	(revision adf46aef78fd55bafe1d788207a46de7fc428d1d)
@@ -0,0 +1,54 @@
+!**********************************************************************
+! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010         *
+! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa,             *
+! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann   *
+!                                                                     *
+! This file is part of FLEXPART.                                      *
+!                                                                     *
+! FLEXPART is free software: you can redistribute it and/or modify    *
+! it under the terms of the GNU General Public License as published by*
+! the Free Software Foundation, either version 3 of the License, or   *
+! (at your option) any later version.                                 *
+!                                                                     *
+! FLEXPART is distributed in the hope that it will be useful,         *
+! but WITHOUT ANY WARRANTY; without even the implied warranty of      *
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
+! GNU General Public License for more details.                        *
+!                                                                     *
+! You should have received a copy of the GNU General Public License   *
+! along with FLEXPART.  If not, see <http://www.gnu.org/licenses/>.   *
+!**********************************************************************
+
+!*******************************************************************************
+!   Include file for calculation of particle trajectories (Program FLEXPART)   *
+!        This file contains ECMWF specific parameters used in FLEXPART         *
+!        Note that module name differs from file name.                         *
+!        The makefile selects either this file, or gfs_mod.f90, depending      *
+!        on target.                                                            *
+!                                                                              *
+!        Author: ESO                                                           *
+!                                                                              *
+!        2015                                                                  *
+!                                                                              *
+!*******************************************************************************
+
+module wind_mod
+
+  implicit none
+
+  !*********************************************
+  ! Maximum dimensions of the input mother grids
+  !*********************************************
+
+  integer,parameter :: nxmax=361,nymax=181,nuvzmax=152,nwzmax=152,nzmax=152 !ECMWF new 
+  integer,parameter :: nxshift=359
+
+! 
+  !*********************************************
+  ! Maximum dimensions of the nested input grids
+  !*********************************************
+
+!  integer,parameter :: maxnests=0,nxmaxn=351,nymaxn=351 !ECMWF
+
+
+end module wind_mod
Index: src/gfs_mod.f90
===================================================================
--- src/gfs_mod.f90	(revision adf46aef78fd55bafe1d788207a46de7fc428d1d)
+++ src/gfs_mod.f90	(revision adf46aef78fd55bafe1d788207a46de7fc428d1d)
@@ -0,0 +1,46 @@
+!**********************************************************************
+! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010         *
+! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa,             *
+! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann   *
+!                                                                     *
+! This file is part of FLEXPART.                                      *
+!                                                                     *
+! FLEXPART is free software: you can redistribute it and/or modify    *
+! it under the terms of the GNU General Public License as published by*
+! the Free Software Foundation, either version 3 of the License, or   *
+! (at your option) any later version.                                 *
+!                                                                     *
+! FLEXPART is distributed in the hope that it will be useful,         *
+! but WITHOUT ANY WARRANTY; without even the implied warranty of      *
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
+! GNU General Public License for more details.                        *
+!                                                                     *
+! You should have received a copy of the GNU General Public License   *
+! along with FLEXPART.  If not, see <http://www.gnu.org/licenses/>.   *
+!**********************************************************************
+
+!*******************************************************************************
+!   Include file for calculation of particle trajectories (Program FLEXPART)   *
+!        This file contains GFS specific parameters used in FLEXPART           *
+!        Note that module name differs from file name.                         *
+!        The makefile selects either this file, or ecmwf_mod.f90, depending    *
+!        on target.                                                            *
+!                                                                              *
+!        Author: ESO                                                           *
+!                                                                              *
+!        2015                                                                  *
+!                                                                              *
+!*******************************************************************************
+
+module wind_mod
+
+  implicit none
+
+  !*********************************************
+  ! Maximum dimensions of the input mother grids
+  !*********************************************
+
+  integer,parameter :: nxmax=721,nymax=361,nuvzmax=64,nwzmax=64,nzmax=64
+  integer,parameter :: nxshift=0     ! for GFS or FNL
+
+end module wind_mod
Index: src/makefile
===================================================================
--- src/makefile	(revision 5f42c27a3ad632d81e1e6ecd2f81d821b0c11373)
+++ src/makefile	(revision adf46aef78fd55bafe1d788207a46de7fc428d1d)
@@ -6,4 +6,10 @@
 #    Dependencies are resolved in this makefile, so parallel make is
 #    possible ("make -j")
+#
+#    At NILU we have installed gcc-4.9.1 and libraries under user /homevip/flexpart
+#    ("ROOT_DIR")
+#    To use gfortran version 4.9, add "gcc=4.9" to the make command, e.g.
+#       'make -j ecmwf gcc=4.9',
+#    also set environment variable LD_LIBRARY_FLAGS=
 # 
 #  USAGE
@@ -24,6 +30,4 @@
 #
 ################################################################################
-
-
 
 ## PROGRAMS
@@ -34,12 +38,28 @@
 FLEXPART-GFS-MPI 	= FP_gfs_MPI
 
-
-## COMPILERS
-F90       = /usr/bin/gfortran
-#F90	  = ${HOME}/gcc-4.9.1/bin/gfortran
-#MPIF90    = ${HOME}/opt/bin/mpifort
-#MPIF90    = mpif90.mpich
-MPIF90    = mpif90.openmpi
-#MPIF90    = mpifort
+ifeq ($(gcc), 4.9)
+# Compiled libraries under user user ~flexpart, gfortran v4.9
+	ROOT_DIR = /homevip/flexpart/
+#	ROOT_DIR = /homevip/espen/
+
+	F90	  = ${ROOT_DIR}/gcc-4.9.1/bin/gfortran
+	MPIF90    = ${ROOT_DIR}/bin/mpifort
+
+	INCPATH1  = ${ROOT_DIR}/gcc-4.9.1/include	
+	INCPATH2  = ${ROOT_DIR}/include
+	LIBPATH1 = ${ROOT_DIR}/lib
+#	LIBPATH2 = ${ROOT_DIR}/gcc-4.9.1/lib
+#	LIBPATH2 = /lib
+else
+# Default: System libraries at NILU, gfortran v4.6
+	F90       = /usr/bin/gfortran
+	MPIF90    = /usr/bin/mpif90.openmpi
+
+	INCPATH1 = /xnilu_wrk/flex_wrk/bin64/grib_api/include
+	INCPATH2 = /usr/include
+	LIBPATH1 = /xnilu_wrk/flex_wrk/bin64/grib_api/lib
+#	LIBPATH2 = /usr/lib/x86_64-linux-gnu
+endif
+
 
 ## OPTIMIZATION LEVEL
@@ -48,24 +68,12 @@
 
 ## LIBRARIES
-LIBS = -lgrib_api_f90 -lgrib_api -lm -ljasper -lnetcdff   # -fopenmp # -llapack -lnetcdf
-
-## 1) System libraries at NILU
-INCPATH1 = /usr/include
-#INCPATH1 = /xnilu_wrk/flex_wrk/bin64/grib_api/include
-LIBPATH1 = /xnilu_wrk/flex_wrk/bin64/grib_api/lib
-#LIBPATH2 = /usr/lib/x86_64-linux-gnu
-
-## 2) Home-made libraries
-# INCPATH1  = ${HOME}/include
-INCPATH2  = /homevip/flexpart/include/
-LIBPATH2 = /homevip/flexpart/lib/
-# LIBPATH1 = ${HOME}/lib
-
-FFLAGS   = -I$(INCPATH1) -I$(INCPATH2) -O$(O_LEV) -g -m64 -mcmodel=medium -fconvert=little-endian -frecord-marker=4 -fmessage-length=0 -flto=jobserver -O$(O_LEV) -mtune=native -fuse-linker-plugin $(FUSER) # -march=native
+LIBS = -lgrib_api_f90 -lgrib_api -lm -ljasper -lnetcdff -llapack  # -fopenmp # -llapack
+
+FFLAGS   = -I$(INCPATH1) -I$(INCPATH2) -O$(O_LEV) -g -m64 -mcmodel=medium -fconvert=little-endian -frecord-marker=4 -fmessage-length=0 -flto=jobserver -O$(O_LEV) -mtune=native $(FUSER) # -march=native
 
 DBGFLAGS = -I$(INCPATH1) -I$(INCPATH2) -O$(O_LEV_DBG) -g3 -ggdb3 -m64 -mcmodel=medium -fconvert=little-endian -frecord-marker=4 -fmessage-length=0 -flto=jobserver -O$(O_LEV_DBG) -fbacktrace -Warray-bounds  -Wall -fcheck=all $(FUSER)  #  -ffpe-trap=invalid,overflow,denormal,underflow,zero -fdump-core
 
-LDFLAGS  = $(FFLAGS) -L$(LIBPATH1) -L$(LIBPATH2) $(LIBS)
-LDDEBUG  = $(DBGFLAGS) -L$(LIBPATH1) -L$(LIBPATH2) $(LIBS)
+LDFLAGS  = $(FFLAGS) -L$(LIBPATH1) $(LIBS) #-L$(LIBPATH2)
+LDDEBUG  = $(DBGFLAGS) -L$(LIBPATH1) $(LIBS) #-L$(LIBPATH2)
 
 MODOBJS = \
@@ -114,5 +122,6 @@
 	richardson.o       verttransform.o \
 	obukhov.o          gridcheck.o  \
-	convmix.o          calcmatrix.o
+	convmix.o          calcmatrix.o \
+	ecmwf_mod.o
 
 
@@ -123,5 +132,6 @@
 	richardson.o       verttransform.o \
 	obukhov.o          \
-	convmix.o      calcmatrix.o
+	convmix.o	   calcmatrix.o \
+	ecmwf_mod.o
 
 ## For GFS (serial) version:
@@ -130,5 +140,6 @@
 	richardson_gfs.o       verttransform_gfs.o \
 	obukhov_gfs.o          gridcheck_gfs.o  \
-	convmix_gfs.o          calcmatrix_gfs.o
+	convmix_gfs.o          calcmatrix_gfs.o \
+	gfs_mod.o
 
 OBJECTS = \
@@ -203,4 +214,5 @@
 gfs: $(FLEXPART-GFS)
 gfs: FC := $(F90)
+
 gfs-mpi: $(FLEXPART-GFS-MPI)
 gfs-mpi: FC := $(MPIF90)
@@ -208,4 +220,23 @@
 #all: $(FLEXPART-ECMWF)
 #all: $(FLEXPART-ECMWF-MPI)
+
+## This allows for switching between ECMWF/GFS without editing source code.
+wind_mod = ecmwf_mod.o # default wind
+# ifeq ($(MAKECMDGOALS),ecmwf)
+# wind_mod = ecmwf_mod.o
+# endif
+# ifeq ($(MAKECMDGOALS),ecmwf-mpi)
+# wind_mod = ecmwf_mod.o
+# endif
+# ifeq ($(MAKECMDGOALS),ecmwf-mpi-dbg)
+# wind_mod = ecmwf_mod.o
+# endif
+
+ifeq ($(MAKECMDGOALS),gfs)
+wind_mod = gfs_mod.o
+endif
+ifeq ($(MAKECMDGOALS),gfs-mpi)
+wind_mod = gfs_mod.o
+endif
 
 $(FLEXPART-ECMWF): $(MODOBJS) $(OBJECTS) $(OBJECTS_SERIAL) $(OBJECTS_ECMWF)
@@ -339,4 +370,5 @@
 outgrid_init.o: com_mod.o flux_mod.o oh_mod.o outg_mod.o par_mod.o unc_mod.o
 outgrid_init_nest.o: com_mod.o outg_mod.o par_mod.o unc_mod.o
+par_mod.o : $(wind_mod)
 part0.o: par_mod.o
 partdep.o: par_mod.o
Index: src/par_mod.f90
===================================================================
--- src/par_mod.f90	(revision 5f9d14aa526df192efa539f87fc409fdeeeee06c)
+++ src/par_mod.f90	(revision adf46aef78fd55bafe1d788207a46de7fc428d1d)
@@ -33,4 +33,8 @@
 
 module par_mod
+
+! wind_mod: is gfs_mod.f90 for target gfs, ecmwf_mod.f90 for target ecmwf
+!************************************************************************
+  use wind_mod 
 
   implicit none
@@ -122,6 +126,10 @@
   !*********************************************
   
+  ! nxmax,nymax,nuvzmax,nwzmax,nzmax:
+  ! Moved to ecmwf.f90 (for ECMWF) / gfs.f90 (GFS)
+  
+
   !integer,parameter :: nxmax=361,nymax=181,nuvzmax=92,nwzmax=92,nzmax=92 !FNL XF
-  integer,parameter :: nxmax=361,nymax=181,nuvzmax=152,nwzmax=152,nzmax=152 !ECMWF new 
+  !integer,parameter :: nxmax=361,nymax=181,nuvzmax=152,nwzmax=152,nzmax=152 !ECMWF new 
   !integer,parameter :: nxmax=361,nymax=181,nuvzmax=92,nwzmax=92,nzmax=92 !ECMWF
   !integer,parameter :: nxmax=361,nymax=181,nuvzmax=26,nwzmax=26,nzmax=26
@@ -129,5 +137,5 @@
   !integer,parameter :: nxmax=1201,nymax=235,nuvzmax=58,nwzmax=58,nzmax=58
 
-  integer,parameter :: nxshift=359 ! for ECMWF
+!  integer,parameter :: nxshift=359 ! for ECMWF
   !integer,parameter :: nxshift=0     ! for GFS or FNL
 
@@ -135,5 +143,6 @@
   integer,parameter :: na = nconvlevmax+1
 
-
+  ! moved to gfs_mod.f90 / ecmwf_mod.f90
+  !
   ! nxmax,nymax        maximum dimension of wind fields in x and y
   !                    direction, respectively
@@ -146,4 +155,5 @@
   !                    grids, and output grids overlapping the domain "boundary"
   !                    nxshift must not be negative; "normal" setting would be 0
+
   ! ntracermax         maximum number of tracer species in convection
   ! nconvlevmax        maximum number of levels for convection
@@ -156,5 +166,5 @@
 
   !integer,parameter :: maxnests=0, nxmaxn=0, nymaxn=0
-  integer,parameter :: maxnests=1,nxmaxn=351,nymaxn=351 !ECMWF
+  integer,parameter :: maxnests=0,nxmaxn=351,nymaxn=351 !ECMWF
 
   !integer,parameter :: maxnests=1, nxmaxn=201, nymaxn=161 ! FNL XF
@@ -200,8 +210,8 @@
   !**************************************************
 
-  integer,parameter :: maxpart=50000000
+  integer,parameter :: maxpart=60000000
 !  integer,parameter :: maxpart=60000000
 !  integer,parameter :: maxpart=120000000
-  integer,parameter :: maxspec=1
+  integer,parameter :: maxspec=6
 
   ! maxpart                 Maximum number of particles
@@ -271,4 +281,5 @@
   integer,parameter :: unitdates=94, unitheader=90,unitheader_txt=100, unitshortpart=95
   integer,parameter :: unitboundcond=89
+  integer,parameter :: unittmp=101
 
 !******************************************************
