Index: trunk/LMDZ.COMMON/ioipsl/README
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/README	(revision 2256)
+++ trunk/LMDZ.COMMON/ioipsl/README	(revision 2412)
@@ -1,16 +1,18 @@
 Scripts in this directory are illustrative examples of how to
-obtain and install IOIPSL:
-1) install_ioipsl_gnome.bash: everything is set for Gnome, just run:
-./install_ioipsl_gnome.bash
-And output modules and library will be in subdirectory 'modipsl/lib'
+download and install IOIPSL, e.g.:
+1) install_ioipsl_occigen.bash: everything is set for Occigen, just run:
+./install_ioipsl_occigen.bash
+And output modules and library will be in ../../IOIPSL
+(with links in 'modipsl/lib' and 'modipsl/bin' for backward compatibility)
 
-2) install_ioipsl_gfortran.bash and install_ioipsl_pgf90.bash are more
-general examples for installing IOIPSL on a machine with either compiler.
-Note that the paths to the NetCDF library hard coded in the scripts 
-will surely need to be adapted to your local settings.
-Then simply execute the script; output modules
-and library will be in subdirectory 'modipsl/lib'
+2) install_ioipsl_gfortran.bash, and install_ioipsl_pgf90.bash and
+install_ioipsl_ifort.bash are more general examples
+for installing IOIPSL on a machine with these compilers.
+For these you might need to ajust the location of the NetCDF library
+(see the NETCDF_HOME variable in the script)
+And you will need to set up arch files (which should match those
+of the GCM) to adequately compile the library
 
-Note that it is a good idea to install IOIPSL outside of the LMDZ tree
+Note that it is a good idea to install IOIPSL alongside LMDZ
 so that its version can be tracked (and potentialy updated), as it is
 downloaded from a different svn repository.
@@ -18,2 +20,3 @@
 
 
+
Index: trunk/LMDZ.COMMON/ioipsl/install_ioipsl_centos-ifort.bash
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/install_ioipsl_centos-ifort.bash	(revision 2256)
+++ trunk/LMDZ.COMMON/ioipsl/install_ioipsl_centos-ifort.bash	(revision 2412)
@@ -4,57 +4,62 @@
 
 #0. Preliminary stuff 
-# source the environment from the GCM arch files
-source ../arch/arch-centos-ifort-para.env
-source ../arch/arch-centos-ifort-para.path
+if (( $# == 0 ))
+then
+  # default behavior: get latest version of IOIPSL
+  rev="HEAD"
+else
+  # but otherwise the first argument of the script can be the version to use
+  if (( $# == 1 ))
+  then
+    rev=$1
+  else
+    echo "Error, invalid script arguments"
+    echo "Usage:"
+    echo "$0 rev"
+    echo " where optional rev is the IOIPSL revision number"
+    exit
+  fi
+fi
 
-whereami=`pwd -P`
+# cleanup possible previous attempt:
+\rm -rf ../../IOIPSL modipsl 
 
-# 1. Get IOIPSL (via modipsl)
-svn co http://forge.ipsl.jussieu.fr/igcmg/svn/modipsl/trunk modipsl
-cd modipsl/util
+# 1. Get IOIPSL 
+# move up at same level as LMDZ.COMMON , etc.
+cd ../..
+svn co --revision $rev http://forge.ipsl.jussieu.fr/igcmg/svn/IOIPSL/trunk IOIPSL
 
-./model IOIPSL_PLUS
-
-# 2. Set correct settings:
-# add a "ciclad" configuration to AA_make.gdef
-echo "#-Q- cicladi  #- Global definitions for CentOS at LMD, ifort" >> AA_make.gdef
-echo "#-Q- cicladi  M_K = make" >> AA_make.gdef
-echo "#-Q- cicladi  P_C = cpp" >> AA_make.gdef
-echo '#-Q- cicladi  P_O = -P -C $(P_P)' >> AA_make.gdef
-echo "#-Q- cicladi  F_C = ifort -mcmodel=large -shared-intel -c" >> AA_make.gdef
-echo "#-Q- cicladi  #-D- MD    F_D = -g" >> AA_make.gdef
-echo "#-Q- cicladi  #-D- MN    F_D =" >> AA_make.gdef
-echo "#-Q- cicladi  #-P- I4R4  F_P = -integer-size 32" >> AA_make.gdef
-echo "#-Q- cicladi  #-P- I4R8  F_P = -integer-size 32 -real-size 64" >> AA_make.gdef
-echo "#-Q- cicladi  #-P- I8R8  F_P = -integer-size 64 -real-size 64" >> AA_make.gdef
-echo '#-Q- cicladi  F_O = -O $(F_D) $(F_P) -I$(MODDIR) -module $(MODDIR)' >> AA_make.gdef
-echo "#-Q- cicladi  F_L = ifort" >> AA_make.gdef
-echo "#-Q- cicladi  M_M = 0" >> AA_make.gdef
-echo "#-Q- cicladi  L_X = 0" >> AA_make.gdef
-echo "#-Q- cicladi  L_O =" >> AA_make.gdef
-echo "#-Q- cicladi  A_C = ar -r" >> AA_make.gdef
-echo "#-Q- cicladi  A_G = ar -x" >> AA_make.gdef
-echo "#-Q- cicladi  C_C = icc -c" >> AA_make.gdef
-echo "#-Q- cicladi  C_O =" >> AA_make.gdef
-echo "#-Q- cicladi  C_L = icc" >> AA_make.gdef
-echo "#-Q- cicladi  #-" >> AA_make.gdef
-echo "#-Q- cicladi  NCDF_INC = ${NETCDF_INCDIR:2}" >> AA_make.gdef
-echo "#-Q- cicladi  NCDF_LIB = ${NETCDF_LIBDIR} ${NETCDF_LIB}" >> AA_make.gdef
-echo "#-Q- cicladi  #-" >> AA_make.gdef
-
-# set default working precision for IOIPSL:
-./ins_make -t cicladi -p I4R8
+# 2. Set correct settings: copy over arch.* files
+cd IOIPSL
+cp -f ../LMDZ.COMMON/arch/arch-centos-ifort-para.env arch
+cp -f ../LMDZ.COMMON/arch/arch-centos-ifort-para.path arch
+cp -f ../LMDZ.COMMON/arch/arch-centos-ifort-para.fcm arch
 
 ## 3. build ioipsl:
-cd ../modeles/IOIPSL/src
-make
-## Compile the rebuild tool:
-cd ../tools
-make
+./makeioipsl_fcm -arch centos-ifort-para -job 8 > makeioipsl.out 2>&1
 
-if [[ -f ${whereami}/modipsl/lib/libioipsl.a ]] 
+## 4. Check if the library was indeed built:
+whereami=`pwd -P`
+if [[ -f lib/libioipsl.a ]] 
   then
-  echo "OK: ioipsl library is in ${whereami}/modipsl/lib"
+  echo "OK: ioipsl library is in ${whereami}/lib"
 else
-  echo "Something went wrong..."
+  echo "Something went wrong... check messages in ${whereami}/makeioipsl.out"
+  exit
 fi
+
+## 5. Comply with old setup and make appropriate links
+cd ../LMDZ.COMMON/ioipsl
+mkdir modipsl 
+cd modipsl
+# lib + module files
+mkdir lib
+cd lib
+ln -s ../../../../IOIPSL/lib/libioipsl.a .
+ln -s ../../../../IOIPSL/inc/* .
+cd ..
+# rebuild utility
+mkdir bin
+cd bin
+ln -s ../../../../IOIPSL/bin/* .
+
Index: trunk/LMDZ.COMMON/ioipsl/install_ioipsl_ciclad-ifort.bash
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/install_ioipsl_ciclad-ifort.bash	(revision 2412)
+++ trunk/LMDZ.COMMON/ioipsl/install_ioipsl_ciclad-ifort.bash	(revision 2412)
@@ -0,0 +1,65 @@
+#!/bin/bash
+# script to download and install the latest version of IOIPSL on Ciclad
+#
+
+#0. Preliminary stuff
+
+if (( $# == 0 ))
+then
+  # default behavior: get latest version of IOIPSL
+  rev="HEAD"
+else
+  # but otherwise the first argument of the script can be the version to use
+  if (( $# == 1 ))
+  then
+    rev=$1
+  else
+    echo "Error, invalid script arguments"
+    echo "Usage:"
+    echo "$0 rev"
+    echo " where optional rev is the IOIPSL revision number"
+    exit
+  fi
+fi
+
+# cleanup possible previous attempt:
+\rm -rf ../../IOIPSL modipsl 
+
+# 1. Get IOIPSL 
+# move up at same level as LMDZ.COMMON , etc.
+cd ../..
+svn co --revision $rev http://forge.ipsl.jussieu.fr/igcmg/svn/IOIPSL/trunk IOIPSL
+
+# 2. Set correct settings: copy over arch.* files
+cd IOIPSL
+cp -f ../LMDZ.COMMON/arch/arch-CICLADifort.env arch
+cp -f ../LMDZ.COMMON/arch/arch-CICLADifort.path arch
+cp -f ../LMDZ.COMMON/arch/arch-CICLADifort.fcm arch
+
+## 3. build ioipsl:
+./makeioipsl_fcm -arch CICLADifort -job 8 > makeioipsl.out 2>&1
+
+## 4. Check if the library was indeed built:
+whereami=`pwd -P`
+if [[ -f lib/libioipsl.a ]] 
+  then
+  echo "OK: ioipsl library is in ${whereami}/lib"
+else
+  echo "Something went wrong... check messages in ${whereami}/makeioipsl.out"
+  exit
+fi
+
+## 5. Comply with old setup and make appropriate links
+cd ../LMDZ.COMMON/ioipsl
+mkdir modipsl 
+cd modipsl
+# lib + module files
+mkdir lib
+cd lib
+ln -s ../../../../IOIPSL/lib/libioipsl.a .
+ln -s ../../../../IOIPSL/inc/* .
+cd ..
+# rebuild utility
+mkdir bin
+cd bin
+ln -s ../../../../IOIPSL/bin/* .
Index: trunk/LMDZ.COMMON/ioipsl/install_ioipsl_ciclad.bash
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/install_ioipsl_ciclad.bash	(revision 2256)
+++ 	(revision )
@@ -1,60 +1,0 @@
-#!/bin/bash
-# script to download and install the latest version of IOIPSL on Ciclad
-#
-
-#0. Preliminary stuff
-# source the environment from the GCM arch files
-source ../arch/arch-CICLADifort.env
-source ../arch/arch-CICLADifort.path
-
-whereami=`pwd -P`
-
-# 1. Get IOIPSL (via modipsl)
-svn co http://forge.ipsl.jussieu.fr/igcmg/svn/modipsl/trunk modipsl
-cd modipsl/util
-
-./model IOIPSL_PLUS
-
-# 2. Set correct settings:
-# add a "ciclad" configuration to AA_make.gdef
-echo "#-Q- cicladi  #- Global definitions for ciclad at UPMC, ifort" >> AA_make.gdef
-echo "#-Q- cicladi  M_K = make" >> AA_make.gdef
-echo "#-Q- cicladi  P_C = cpp" >> AA_make.gdef
-echo '#-Q- cicladi  P_O = -P -C $(P_P)' >> AA_make.gdef
-echo "#-Q- cicladi  F_C = ifort -mcmodel=large -shared-intel -c" >> AA_make.gdef
-echo "#-Q- cicladi  #-D- MD    F_D = -g" >> AA_make.gdef
-echo "#-Q- cicladi  #-D- MN    F_D =" >> AA_make.gdef
-echo "#-Q- cicladi  #-P- I4R4  F_P = -integer-size 32" >> AA_make.gdef
-echo "#-Q- cicladi  #-P- I4R8  F_P = -integer-size 32 -real-size 64" >> AA_make.gdef
-echo "#-Q- cicladi  #-P- I8R8  F_P = -integer-size 64 -real-size 64" >> AA_make.gdef
-echo '#-Q- cicladi  F_O = -O $(F_D) $(F_P) -I$(MODDIR) -module $(MODDIR)' >> AA_make.gdef
-echo "#-Q- cicladi  F_L = ifort" >> AA_make.gdef
-echo "#-Q- cicladi  M_M = 0" >> AA_make.gdef
-echo "#-Q- cicladi  L_X = 0" >> AA_make.gdef
-echo "#-Q- cicladi  L_O =" >> AA_make.gdef
-echo "#-Q- cicladi  A_C = ar -r" >> AA_make.gdef
-echo "#-Q- cicladi  A_G = ar -x" >> AA_make.gdef
-echo "#-Q- cicladi  C_C = icc -c" >> AA_make.gdef
-echo "#-Q- cicladi  C_O =" >> AA_make.gdef
-echo "#-Q- cicladi  C_L = icc" >> AA_make.gdef
-echo "#-Q- cicladi  #-" >> AA_make.gdef
-echo "#-Q- cicladi  NCDF_INC = ${NETCDF_INCDIR:2}" >> AA_make.gdef
-echo "#-Q- cicladi  NCDF_LIB = ${NETCDF_LIBDIR} ${NETCDF_LIB}" >> AA_make.gdef
-echo "#-Q- cicladi  #-" >> AA_make.gdef
-
-# set default working precision for IOIPSL:
-./ins_make -t cicladi -p I4R8
-
-## 3. build ioipsl:
-cd ../modeles/IOIPSL/src
-make
-## Compile the rebuild tool:
-cd ../tools
-make
-
-if [[ -f ${whereami}/modipsl/lib/libioipsl.a ]] 
-  then
-  echo "OK: ioipsl library is in ${whereami}/modipsl/lib"
-else
-  echo "Something went wrong..."
-fi
Index: trunk/LMDZ.COMMON/ioipsl/install_ioipsl_darwin.bash
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/install_ioipsl_darwin.bash	(revision 2256)
+++ 	(revision )
@@ -1,70 +1,0 @@
-#!/bin/bash -x
-# script to download and install the latest version of IOIPSL
-# using gfortran
-# You'll probably have to change paths to NetCDF library 'lib' and 'include'
-# below to adapt this script to your computer.
-
-#setfolder="/cm/shared/apps/netcdf/gcc/64/4.1.1"
-#setfolder="/donnees/emlmd/netcdf64-4.0.1_gfortran/"
-setfolder="/usr/local/netcdf-4.0.1/"
-
-#0. Preliminary stuff 
-# netcdf include and lib dirs:
-netcdf_include=$setfolder"/include"
-netcdf_lib=$setfolder"/lib"
-
-whereami=`pwd -P`
-
-# 1. Get IOIPSL (via modipsl)
-svn co http://forge.ipsl.jussieu.fr/igcmg/svn/modipsl/trunk modipsl
-export MAKE=make
-cd modipsl/util
-
-./model IOIPSL_PLUS
-
-# 2. Set correct settings:
-# Add a Darwin case in 'AA_make.gdef'
-
-echo '#-Q- Darwin  #- Global definitions for gfortran on a Mac' >> AA_make.gdef
-echo '#-Q- Darwin  M_K = make' >> AA_make.gdef
-echo '#-Q- Darwin  P_C = cpp' >> AA_make.gdef
-echo '#-Q- Darwin  P_O = -P -C -traditional $(P_P)' >> AA_make.gdef
-echo '#-Q- Darwin  F_C = gfortran -c -cpp' >> AA_make.gdef
-echo '#-Q- Darwin  #-D- MD    F_D = -g -Wall -fbounds-check -pedantic -finit-real=nan' >> AA_make.gdef
-echo '#-Q- Darwin  #-D- MN    F_D =' >> AA_make.gdef
-echo '#-Q- Darwin  #-P- I4R4  F_P =' >> AA_make.gdef
-echo '#-Q- Darwin  #-P- I4R8  F_P = -fdefault-real-8' >> AA_make.gdef
-echo '#-Q- Darwin  #-P- I8R8  F_P = -fdefault-integer-8 -fdefault-real-8' >> AA_make.gdef
-echo '#-Q- Darwin  w_w = -O3 -funroll-all-loops $(F_D) $(F_P) -I$(MODDIR)' >> AA_make.gdef
-echo '#-Q- Darwin  F_O = $(w_w) -J$(MODDIR)' >> AA_make.gdef
-echo '#-Q- Darwin  F_L = gfortran' >> AA_make.gdef
-echo '#-Q- Darwin  M_M = 0' >> AA_make.gdef
-echo '#-Q- Darwin  L_X = 0' >> AA_make.gdef
-echo '#-Q- Darwin  L_O =' >> AA_make.gdef
-echo '#-Q- Darwin  A_C = ar -rs' >> AA_make.gdef
-echo '#-Q- Darwin  A_G = ar -x' >> AA_make.gdef
-echo '#-Q- Darwin  C_C = cc -c' >> AA_make.gdef
-echo '#-Q- Darwin  C_O =' >> AA_make.gdef
-echo '#-Q- Darwin  C_L = cc' >> AA_make.gdef
-echo '#-Q- Darwin  #-' >> AA_make.gdef
-echo "#-Q- Darwin  NCDF_INC = ${netcdf_include}" >> AA_make.gdef
-echo "#-Q- Darwin  NCDF_LIB = -L${netcdf_lib} -lnetcdf -lnetcdff" >> AA_make.gdef
-echo '#-Q- Darwin  #-' >> AA_make.gdef
-
-# set default working precision for IOIPSL:
-./ins_make -t Darwin -p I4R8
-
-## 3. build ioipsl:
-cd ../modeles/IOIPSL/src
-make
-## Compile the rebuild tool:
-cd ../tools
-make
-
-if [[ -f ${whereami}/modipsl/lib/libioipsl.a ]] 
-  then
-  echo "OK: ioipsl library is in ${whereami}/modipsl/lib"
-else
-  echo "Something went wrong..."
-fi
-
Index: trunk/LMDZ.COMMON/ioipsl/install_ioipsl_gfortran-gcc.bash
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/install_ioipsl_gfortran-gcc.bash	(revision 2256)
+++ 	(revision )
@@ -1,64 +1,0 @@
-#!/bin/bash
-# script to download and install the latest version of IOIPSL
-# using gfortran
-# You'll probably have to change paths to NetCDF library 'lib' and 'include'
-# below to adapt this script to your computer.
-
-#setfolder="/cm/shared/apps/netcdf/gcc/64/4.1.1"
-#setfolder="/donnees/emlmd/netcdf64-4.0.1_gfortran/"
-
-#0. Preliminary stuff 
-# netcdf include and lib dirs:
-#netcdf_include=$setfolder"/include"
-#netcdf_lib=$setfolder"/lib"
-netcdf_include="$NETCDFINCLUDE"
-netcdf_lib="$NETCDFDIR"
-echo $netcdf_include
-echo $netcdf_lib
-
-whereami=`pwd -P`
-
-# 1. Get IOIPSL (via modipsl)
-svn co http://forge.ipsl.jussieu.fr/igcmg/svn/modipsl/trunk modipsl
-cd modipsl/util
-
-# make all refs to ksh become refs to bash
-for i in ins_m_prec model script_diff_model script_log_analyse script_recup_model
-do
-  sed -i -e s:'#!/bin/ksh':'#!/bin/bash':1 $i
-done
-./model IOIPSL_PLUS
-
-# 2. Set correct settings:
-# modify path to netcdf in 'AA_make.gdef'
-cp AA_make.gdef AA_make.gdef.old
-sed -e s:"gfortran  NCDF_INC = /usr/local/include":"gfortran  NCDF_INC = ${netcdf_include}":1 \
-    -e s:"gfortran  NCDF_LIB = -L/usr/local/lib -lnetcdf":"gfortran  NCDF_LIB = -L${netcdf_lib} -lnetcdf -lnetcdff":1 \
-    AA_make.gdef.old > AA_make.gdef
-
-# set default working precision for IOIPSL:
-./ins_make -t gfortran -p I4R8
-
-## 3. build ioipsl:
-cd ../modeles/IOIPSL/src
-# make all refs to ksh become refs to bash
-for i in AA_make.ldef Makefile
-do
-  sed -i -e s:'/bin/ksh':'/bin/bash':1 $i
-done
-make
-## Compile the rebuild tool:
-cd ../tools
-for i in AA_make.ldef Makefile rebuild
-do
-  sed -i -e s:'/bin/ksh':'/bin/bash':1 $i
-done
-make
-
-if [[ -f ${whereami}/modipsl/lib/libioipsl.a ]] 
-  then
-  echo "OK: ioipsl library is in ${whereami}/modipsl/lib"
-else
-  echo "Something went wrong..."
-fi
-
Index: trunk/LMDZ.COMMON/ioipsl/install_ioipsl_gfortran.bash
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/install_ioipsl_gfortran.bash	(revision 2256)
+++ trunk/LMDZ.COMMON/ioipsl/install_ioipsl_gfortran.bash	(revision 2412)
@@ -2,67 +2,99 @@
 # script to download and install the latest version of IOIPSL
 # using gfortran
-# You'll probably have to change paths to NetCDF library 'lib' and 'include'
+# You'll probably have to change path to NetCDF library
 # below to adapt this script to your computer.
 
-#setfolder="/planeto/emlmd/netcdf64-4.0.1_gfortran4.4.7"
-#setfolder="/donnees/emlmd/netcdf64-4.0.1_gfortran/"
-setfolder=$NETCDF
+#0. Preliminary stuff 
+if (( $# == 0 ))
+then
+  # default behavior: get latest version of IOIPSL
+  rev="HEAD"
+else
+  # but otherwise the first argument of the script can be the version to use
+  if (( $# == 1 ))
+  then
+    rev=$1
+  else
+    echo "Error, invalid script arguments"
+    echo "Usage:"
+    echo "$0 rev"
+    echo " where optional rev is the IOIPSL revision number"
+    exit
+  fi
+fi
 
-#0. Preliminary stuff 
-# netcdf include and lib dirs:
-netcdf_include=$setfolder"/include"
-netcdf_lib=$setfolder"/lib"
+# Where is the NetCDF library root located? Hopefully nf-config can tell us
+# but you might need an appropriate "module load netcdf***" beforehand
+NETCDF_HOME=$(nf-config --prefix)
 
-whereami=`pwd -P`
+# cleanup possible previous attempt:
+\rm -rf ../../IOIPSL modipsl 
 
-# 1. Get IOIPSL (via modipsl)
-svn co http://forge.ipsl.jussieu.fr/igcmg/svn/modipsl/trunk modipsl
-cd modipsl/util
+# 1. Get IOIPSL 
+# move up at same level as LMDZ.COMMON , etc.
+cd ../..
+svn co --revision $rev http://forge.ipsl.jussieu.fr/igcmg/svn/IOIPSL/trunk IOIPSL
 
-# make all refs to ksh become refs to bash
-for i in ins_m_prec model script_diff_model script_log_analyse script_recup_model
-do
-  sed -e s:'#!/bin/ksh':'#!/bin/bash':1 $i > tmp
-  mv -f tmp $i
-done
-chmod u=rwx model
-chmod u=rwx ins_m_prec
-./model IOIPSL_PLUS
-
-# 2. Set correct settings:
-# modify path to netcdf in 'AA_make.gdef'
-cp AA_make.gdef AA_make.gdef.old
-sed -e s:"gfortran  NCDF_INC = /usr/local/include":"gfortran  NCDF_INC = ${netcdf_include}":1 \
-    -e s:"gfortran  NCDF_LIB = -L/usr/local/lib":"gfortran  NCDF_LIB = -L${netcdf_lib}":1 \
-    AA_make.gdef.old > AA_make.gdef
-
-# set default working precision for IOIPSL:
-./ins_make -t gfortran -p I4R8
+# 2. Set correct settings: make some arch.* files
+# Ideally these arch files should be the same as the GCM's
+# arch.env file (add any suitable module load here)
+cd IOIPSL/arch
+echo "" > arch-gfortran.env
+echo "export NETCDF_HOME=$NETCDF_HOME" >> arch-gfortran.env
+# arch.fcm file 
+echo '%COMPILER            gfortran' > arch-gfortran.fcm
+echo '%LINK                gfortran' >> arch-gfortran.fcm
+echo '%AR                  ar' >> arch-gfortran.fcm
+echo '%MAKE                make' >> arch-gfortran.fcm
+echo '%FPP_FLAGS           -P -traditional' >> arch-gfortran.fcm
+echo '%BASE_FFLAGS         -c -fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -fno-align-commons -fcray-pointer' >> arch-gfortran.fcm
+echo '%PROD_FFLAGS         -O3' >> arch-gfortran.fcm
+echo '%DEV_FFLAGS          -O -Wall -fbounds-check' >> arch-gfortran.fcm
+echo '%DEBUG_FFLAGS        -ffpe-trap=invalid,zero,overflow -fbounds-check -g3 -O0 -fstack-protector-all -finit-real=snan -fbacktrace' >> arch-gfortran.fcm
+echo '%MPI_FFLAGS          ' >> arch-gfortran.fcm
+echo '%OMP_FFLAGS          ' >> arch-gfortran.fcm
+echo '%BASE_LD             ' >> arch-gfortran.fcm
+echo '%MPI_LD              ' >> arch-gfortran.fcm
+echo '%OMP_LD              ' >> arch-gfortran.fcm
+# arch.path file
+echo "NETCDF_INCDIR=\"-I$NETCDF_HOME/include\"" > arch-gfortran.path
+echo "NETCDF_LIBDIR=\"-L$NETCDF_HOME/lib\"" >> arch-gfortran.path
+echo 'NETCDF_LIB="-lnetcdff"' >> arch-gfortran.path
+echo '' >> arch-gfortran.path
+echo 'HDF5_INCDIR=""' >> arch-gfortran.path
+echo 'HDF5_LIBDIR=""' >> arch-gfortran.path
+echo 'HDF5_LIB=""' >> arch-gfortran.path
+echo '' >> arch-gfortran.path
+echo 'MPI_INCDIR=""' >> arch-gfortran.path
+echo 'MPI_LIBDIR=""' >> arch-gfortran.path
+echo 'MPI_LIB=""' >> arch-gfortran.path
 
 ## 3. build ioipsl:
-cd ../modeles/IOIPSL/src
-# make all refs to ksh become refs to bash
-for i in AA_make.ldef Makefile
-do
-  sed -e s:'/bin/ksh':'/bin/bash':1 $i > tmp
-  mv -f tmp $i
-done
-make
-## Compile the rebuild tool:
-cd ../tools
-# make all refs to ksh become refs to bash
-for i in AA_make.ldef Makefile rebuild
-do
-  sed -e s:'/bin/ksh':'/bin/bash':1 $i > tmp
-  mv -f tmp $i
-done
-chmod u=rwx rebuild
-make
+cd ..
+./makeioipsl_fcm -arch gfortran -job 8 > makeioipsl.out 2>&1
 
-if [[ -f ${whereami}/modipsl/lib/libioipsl.a ]] 
+## 4. Check if the library was indeed built:
+whereami=`pwd -P`
+if [[ -f lib/libioipsl.a ]] 
   then
-  echo "OK: ioipsl library is in ${whereami}/modipsl/lib"
+  echo "OK: ioipsl library is in ${whereami}/lib"
 else
-  echo "Something went wrong..."
+  echo "Something went wrong... check messages in ${whereami}/makeioipsl.out"
+  exit
 fi
 
+## 5. Comply with old setup and make appropriate links
+cd ../LMDZ.COMMON/ioipsl
+mkdir modipsl 
+cd modipsl
+# lib + module files
+mkdir lib
+cd lib
+ln -s ../../../../IOIPSL/lib/libioipsl.a .
+ln -s ../../../../IOIPSL/inc/* .
+cd ..
+# rebuild utility
+mkdir bin
+cd bin
+ln -s ../../../../IOIPSL/bin/* .
+
Index: trunk/LMDZ.COMMON/ioipsl/install_ioipsl_gnome.bash
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/install_ioipsl_gnome.bash	(revision 2256)
+++ 	(revision )
@@ -1,57 +1,0 @@
-#!/bin/bash
-# script to download and install the latest version of IOIPSL on Gnome
-#
-
-#0. Preliminary stuff 
-
-whereami=`pwd -P`
-
-# 1. Get IOIPSL (via modipsl)
-svn co http://forge.ipsl.jussieu.fr/igcmg/svn/modipsl/trunk modipsl
-cd modipsl/util
-
-./model IOIPSL_PLUS
-
-# 2. Set correct settings:
-# add a "gnome" configuration to AA_make.gdef
-echo "#-Q- gnome  #- Global definitions for Idataplex (gnome) at UPMC, ifort" >> AA_make.gdef
-echo "#-Q- gnome  M_K = make" >> AA_make.gdef
-echo "#-Q- gnome  P_C = cpp" >> AA_make.gdef
-echo '#-Q- gnome  P_O = -P -C $(P_P)' >> AA_make.gdef
-echo "#-Q- gnome  F_C = ifort -mcmodel=large -shared-intel -c" >> AA_make.gdef
-echo "#-Q- gnome  #-D- MD    F_D = -g" >> AA_make.gdef
-echo "#-Q- gnome  #-D- MN    F_D =" >> AA_make.gdef
-echo "#-Q- gnome  #-P- I4R4  F_P = -integer-size 32" >> AA_make.gdef
-echo "#-Q- gnome  #-P- I4R8  F_P = -integer-size 32 -real-size 64" >> AA_make.gdef
-echo "#-Q- gnome  #-P- I8R8  F_P = -integer-size 64 -real-size 64" >> AA_make.gdef
-echo '#-Q- gnome  F_O = -O $(F_D) $(F_P) -I$(MODDIR) -module $(MODDIR)' >> AA_make.gdef
-echo "#-Q- gnome  F_L = ifort" >> AA_make.gdef
-echo "#-Q- gnome  M_M = 0" >> AA_make.gdef
-echo "#-Q- gnome  L_X = 0" >> AA_make.gdef
-echo "#-Q- gnome  L_O =" >> AA_make.gdef
-echo "#-Q- gnome  A_C = ar -r" >> AA_make.gdef
-echo "#-Q- gnome  A_G = ar -x" >> AA_make.gdef
-echo "#-Q- gnome  C_C = icc -c" >> AA_make.gdef
-echo "#-Q- gnome  C_O =" >> AA_make.gdef
-echo "#-Q- gnome  C_L = icc" >> AA_make.gdef
-echo "#-Q- gnome  #-" >> AA_make.gdef
-echo "#-Q- gnome  NCDF_INC = /usr/local/include" >> AA_make.gdef
-echo "#-Q- gnome  NCDF_LIB = -L/usr/local/lib -lnetcdf" >> AA_make.gdef
-echo "#-Q- gnome  #-" >> AA_make.gdef
-
-# set default working precision for IOIPSL:
-./ins_make -t gnome -p I4R8
-
-## 3. build ioipsl:
-cd ../modeles/IOIPSL/src
-make
-## Compile the rebuild tool:
-cd ../tools
-make
-
-if [[ -f ${whereami}/modipsl/lib/libioipsl.a ]] 
-  then
-  echo "OK: ioipsl library is in ${whereami}/modipsl/lib"
-else
-  echo "Something went wrong..."
-fi
Index: trunk/LMDZ.COMMON/ioipsl/install_ioipsl_ifort.bash
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/install_ioipsl_ifort.bash	(revision 2256)
+++ trunk/LMDZ.COMMON/ioipsl/install_ioipsl_ifort.bash	(revision 2412)
@@ -1,62 +1,100 @@
 #!/bin/bash
-# script to download and install the latest version of IOIPSL on Gnome
-#
+# script to download and install the latest version of IOIPSL
+# using ifort
+# You'll probably have to change path to NetCDF library
+# below to adapt this script to your computer.
 
 #0. Preliminary stuff 
-NETCDF="/opt/netcdf3/ifort"
-netcdf_include="$NETCDF/include"
-netcdf_lib="$NETCDF/lib"
-echo $netcdf_include
-echo $netcdf_lib
+if (( $# == 0 ))
+then
+  # default behavior: get latest version of IOIPSL
+  rev="HEAD"
+else
+  # but otherwise the first argument of the script can be the version to use
+  if (( $# == 1 ))
+  then
+    rev=$1
+  else
+    echo "Error, invalid script arguments"
+    echo "Usage:"
+    echo "$0 rev"
+    echo " where optional rev is the IOIPSL revision number"
+    exit
+  fi
+fi
 
-whereami=`pwd -P`
+# Where is the NetCDF library root located? Hopefully nf-config can tell us
+# but you might need an appropriate "module load netcdf***" beforehand
+NETCDF_HOME=$(nf-config --prefix)
 
-# 1. Get IOIPSL (via modipsl)
-svn co http://forge.ipsl.jussieu.fr/igcmg/svn/modipsl/trunk modipsl
-cd modipsl/util
+# cleanup possible previous attempt:
+\rm -rf ../../IOIPSL modipsl 
 
-./model IOIPSL_PLUS
+# 1. Get IOIPSL 
+# move up at same level as LMDZ.COMMON , etc.
+cd ../..
+svn co --revision $rev http://forge.ipsl.jussieu.fr/igcmg/svn/IOIPSL/trunk IOIPSL
 
-# 2. Set correct settings:
-# add a "ciclad" configuration to AA_make.gdef
-echo "#-Q- cicladi  #- Global definitions for ciclad at UPMC, ifort" >> AA_make.gdef
-echo "#-Q- cicladi  M_K = make" >> AA_make.gdef
-echo "#-Q- cicladi  P_C = cpp" >> AA_make.gdef
-echo '#-Q- cicladi  P_O = -P -C $(P_P)' >> AA_make.gdef
-echo "#-Q- cicladi  F_C = ifort -mcmodel=large -shared-intel -c" >> AA_make.gdef
-echo "#-Q- cicladi  #-D- MD    F_D = -g" >> AA_make.gdef
-echo "#-Q- cicladi  #-D- MN    F_D =" >> AA_make.gdef
-echo "#-Q- cicladi  #-P- I4R4  F_P = -integer-size 32" >> AA_make.gdef
-echo "#-Q- cicladi  #-P- I4R8  F_P = -integer-size 32 -real-size 64" >> AA_make.gdef
-echo "#-Q- cicladi  #-P- I8R8  F_P = -integer-size 64 -real-size 64" >> AA_make.gdef
-echo '#-Q- cicladi  F_O = -O $(F_D) $(F_P) -I$(MODDIR) -module $(MODDIR)' >> AA_make.gdef
-echo "#-Q- cicladi  F_L = ifort" >> AA_make.gdef
-echo "#-Q- cicladi  M_M = 0" >> AA_make.gdef
-echo "#-Q- cicladi  L_X = 0" >> AA_make.gdef
-echo "#-Q- cicladi  L_O =" >> AA_make.gdef
-echo "#-Q- cicladi  A_C = ar -r" >> AA_make.gdef
-echo "#-Q- cicladi  A_G = ar -x" >> AA_make.gdef
-echo "#-Q- cicladi  C_C = icc -c" >> AA_make.gdef
-echo "#-Q- cicladi  C_O =" >> AA_make.gdef
-echo "#-Q- cicladi  C_L = icc" >> AA_make.gdef
-echo "#-Q- cicladi  #-" >> AA_make.gdef
-echo "#-Q- cicladi  NCDF_INC = ${netcdf_include}" >> AA_make.gdef
-echo "#-Q- cicladi  NCDF_LIB = -L${netcdf_lib} -lnetcdf" >> AA_make.gdef
-echo "#-Q- cicladi  #-" >> AA_make.gdef
-
-# set default working precision for IOIPSL:
-./ins_make -t cicladi -p I4R8
+# 2. Set correct settings: make some arch.* files
+# Ideally these arch files should be the same as the GCM's
+# arch.env file (add any suitable module load here)
+cd IOIPSL/arch
+echo "" > arch-ifort.env
+echo "export NETCDF_HOME=$NETCDF_HOME" >> arch-ifort.env
+# arch.fcm file 
+echo '%COMPILER            ifort' > arch-ifort.fcm
+echo '%LINK                ifort' >> arch-ifort.fcm
+echo '%AR                  ar' >> arch-ifort.fcm
+echo '%MAKE                make' >> arch-ifort.fcm
+echo '%FPP_FLAGS           -P -traditional' >> arch-ifort.fcm
+echo '%BASE_FFLAGS         -real-size 64 -ip -mkl=parallel -fp-model precise -align common' >> arch-ifort.fcm
+echo '%PROD_FFLAGS         -O3' >> arch-ifort.fcm
+echo '%DEV_FFLAGS          -O2' >> arch-ifort.fcm
+echo '%DEBUG_FFLAGS        -fpe0 -g -no-ftz -check -traceback -ftrapuv -fp-stack-check -O0' >> arch-ifort.fcm
+echo '%MPI_FFLAGS          ' >> arch-ifort.fcm
+echo '%OMP_FFLAGS          ' >> arch-ifort.fcm
+echo '%BASE_LD             ' >> arch-ifort.fcm
+echo '%MPI_LD              ' >> arch-ifort.fcm
+echo '%OMP_LD              ' >> arch-ifort.fcm
+# arch.path file
+echo "NETCDF_INCDIR=\"-I$NETCDF_HOME/include\"" > arch-ifort.path
+echo "NETCDF_LIBDIR=\"-L$NETCDF_HOME/lib\"" >> arch-ifort.path
+echo 'NETCDF_LIB="-lnetcdff"' >> arch-ifort.path
+echo '' >> arch-ifort.path
+echo 'HDF5_INCDIR=""' >> arch-ifort.path
+echo 'HDF5_LIBDIR=""' >> arch-ifort.path
+echo 'HDF5_LIB=""' >> arch-ifort.path
+echo '' >> arch-ifort.path
+echo 'MPI_INCDIR=""' >> arch-ifort.path
+echo 'MPI_LIBDIR=""' >> arch-ifort.path
+echo 'MPI_LIB=""' >> arch-ifort.path
 
 ## 3. build ioipsl:
-cd ../modeles/IOIPSL/src
-make
-## Compile the rebuild tool:
-cd ../tools
-make
+cd ..
+./makeioipsl_fcm -arch ifort -job 8 > makeioipsl.out 2>&1
 
-if [[ -f ${whereami}/modipsl/lib/libioipsl.a ]] 
+## 4. Check if the library was indeed built:
+whereami=`pwd -P`
+if [[ -f lib/libioipsl.a ]] 
   then
-  echo "OK: ioipsl library is in ${whereami}/modipsl/lib"
+  echo "OK: ioipsl library is in ${whereami}/lib"
 else
-  echo "Something went wrong..."
+  echo "Something went wrong... check messages in ${whereami}/makeioipsl.out"
+  exit
 fi
+
+## 5. Comply with old setup and make appropriate links
+cd ../LMDZ.COMMON/ioipsl
+mkdir modipsl 
+cd modipsl
+# lib + module files
+mkdir lib
+cd lib
+ln -s ../../../../IOIPSL/lib/libioipsl.a .
+ln -s ../../../../IOIPSL/inc/* .
+cd ..
+# rebuild utility
+mkdir bin
+cd bin
+ln -s ../../../../IOIPSL/bin/* .
+
Index: trunk/LMDZ.COMMON/ioipsl/install_ioipsl_jeanzay.bash
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/install_ioipsl_jeanzay.bash	(revision 2256)
+++ trunk/LMDZ.COMMON/ioipsl/install_ioipsl_jeanzay.bash	(revision 2412)
@@ -1,34 +1,67 @@
 #!/bin/bash
-# script to download and install the latest version of IOIPSL on occigen
+# script to download and install the latest version of IOIPSL on Jean Zay
 #
 
 #0. Preliminary stuff 
-source ../arch/arch-X64_JEANZAY.env
 module load subversion
 
+if (( $# == 0 ))
+then
+  # default behavior: get latest version of IOIPSL
+  rev="HEAD"
+else
+  # but otherwise the first argument of the script can be the version to use
+  if (( $# == 1 ))
+  then
+    rev=$1
+  else
+    echo "Error, invalid script arguments"
+    echo "Usage:"
+    echo "$0 rev"
+    echo " where optional rev is the IOIPSL revision number"
+    exit
+  fi
+fi
 
-whereami=`pwd -P`
+# cleanup possible previous attempt:
+\rm -rf ../../IOIPSL modipsl 
 
-# 1. Get IOIPSL (via modipsl)
-svn co http://forge.ipsl.jussieu.fr/igcmg/svn/modipsl/trunk modipsl
-cd modipsl/util
+# 1. Get IOIPSL 
+# move up at same level as LMDZ.COMMON , etc.
+cd ../..
+svn co --revision $rev http://forge.ipsl.jussieu.fr/igcmg/svn/IOIPSL/trunk IOIPSL
 
-./model IOIPSL_PLUS
-
-# 2. Set correct settings:
-# set default working precision for IOIPSL:
-./ins_make -t jeanzay -p I4R8
+# 2. Set correct settings: copy over arch.* files
+cd IOIPSL
+cp -f ../LMDZ.COMMON/arch/arch-X64_JEANZAY.env arch
+cp -f ../LMDZ.COMMON/arch/arch-X64_JEANZAY.path arch
+cp -f ../LMDZ.COMMON/arch/arch-X64_JEANZAY.fcm arch
 
 ## 3. build ioipsl:
-cd ../modeles/IOIPSL/src
-gmake
-## Compile the rebuild tool:
-cd ../tools
-gmake
+./makeioipsl_fcm -arch X64_JEANZAY -job 8 > makeioipsl.out 2>&1
 
-if [[ -f ${whereami}/modipsl/lib/libioipsl.a ]] 
+## 4. Check if the library was indeed built:
+whereami=`pwd -P`
+if [[ -f lib/libioipsl.a ]] 
   then
-  echo "OK: ioipsl library is in ${whereami}/modipsl/lib"
+  echo "OK: ioipsl library is in ${whereami}/lib"
 else
-  echo "Something went wrong..."
+  echo "Something went wrong... check messages in ${whereami}/makeioipsl.out"
+  exit
 fi
+
+## 5. Comply with old setup and make appropriate links
+cd ../LMDZ.COMMON/ioipsl
+mkdir modipsl 
+cd modipsl
+# lib + module files
+mkdir lib
+cd lib
+ln -s ../../../../IOIPSL/lib/libioipsl.a .
+ln -s ../../../../IOIPSL/inc/* .
+cd ..
+# rebuild utility
+mkdir bin
+cd bin
+ln -s ../../../../IOIPSL/bin/* .
+
Index: trunk/LMDZ.COMMON/ioipsl/install_ioipsl_jeanzay_pgi.bash
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/install_ioipsl_jeanzay_pgi.bash	(revision 2256)
+++ trunk/LMDZ.COMMON/ioipsl/install_ioipsl_jeanzay_pgi.bash	(revision 2412)
@@ -1,40 +1,67 @@
 #!/bin/bash
-# script to download and install the latest version of IOIPSL on occigen
+# script to download and install the latest version of IOIPSL on Jean Zay
 #
 
 #0. Preliminary stuff 
-source ../arch/arch-X64_JEANZAY-pgi.env
 module load subversion
 
+if (( $# == 0 ))
+then
+  # default behavior: get latest version of IOIPSL
+  rev="HEAD"
+else
+  # but otherwise the first argument of the script can be the version to use
+  if (( $# == 1 ))
+  then
+    rev=$1
+  else
+    echo "Error, invalid script arguments"
+    echo "Usage:"
+    echo "$0 rev"
+    echo " where optional rev is the IOIPSL revision number"
+    exit
+  fi
+fi
 
-whereami=`pwd -P`
+# cleanup possible previous attempt:
+\rm -rf ../../IOIPSL modipsl 
 
-# 1. Get IOIPSL (via modipsl)
-svn co http://forge.ipsl.jussieu.fr/igcmg/svn/modipsl/trunk modipsl
-cd modipsl/util
+# 1. Get IOIPSL 
+# move up at same level as LMDZ.COMMON , etc.
+cd ../..
+svn co --revision $rev http://forge.ipsl.jussieu.fr/igcmg/svn/IOIPSL/trunk IOIPSL
 
-./model IOIPSL_PLUS
-
-# 2. Set correct settings:
-# set default working precision for IOIPSL:
-sed -i -e s:"jeanzay  F_C = mpiifort -c -cpp":"jeanzay  F_C = mpif90 -c -Mpreprocess":1 \
--e s/'jeanzay  F_O = -DCPP_PARA -O3 $(F_D) $(F_P) -I$(MODDIR) -module $(MODDIR) -fp-model precise'/'jeanzay  F_O = -DCPP_PARA -fast -O3 -Munroll=c:4 $(F_D) $(F_P) -I$(MODDIR) -module $(MODDIR)'/1 \
--e s:'jeanzay  NCDF_INC = ./':"jeanzay  NCDF_INC = $(nf-config --includedir)":1 \
--e s:'jeanzay  NCDF_LIB = -lnetcdff':"jeanzay  NCDF_LIB = $(nf-config --flibs)":1 \
--e s:"jeanzay  F_L = mpiifort":"jeanzay  F_L = mpif90":1 AA_make.gdef
-
-./ins_make -t jeanzay -p I4R8
+# 2. Set correct settings: copy over arch.* files
+cd IOIPSL
+cp -f ../LMDZ.COMMON/arch/arch-X64_JEANZAY-pgi.env arch
+cp -f ../LMDZ.COMMON/arch/arch-X64_JEANZAY-pgi.path arch
+cp -f ../LMDZ.COMMON/arch/arch-X64_JEANZAY-pgi.fcm arch
 
 ## 3. build ioipsl:
-cd ../modeles/IOIPSL/src
-gmake
-## Compile the rebuild tool:
-cd ../tools
-gmake
+./makeioipsl_fcm -arch X64_JEANZAY-pgi -job 8 > makeioipsl.out 2>&1
 
-if [[ -f ${whereami}/modipsl/lib/libioipsl.a ]] 
+## 4. Check if the library was indeed built:
+whereami=`pwd -P`
+if [[ -f lib/libioipsl.a ]] 
   then
-  echo "OK: ioipsl library is in ${whereami}/modipsl/lib"
+  echo "OK: ioipsl library is in ${whereami}/lib"
 else
-  echo "Something went wrong..."
+  echo "Something went wrong... check messages in ${whereami}/makeioipsl.out"
+  exit
 fi
+
+## 5. Comply with old setup and make appropriate links
+cd ../LMDZ.COMMON/ioipsl
+mkdir modipsl 
+cd modipsl
+# lib + module files
+mkdir lib
+cd lib
+ln -s ../../../../IOIPSL/lib/libioipsl.a .
+ln -s ../../../../IOIPSL/inc/* .
+cd ..
+# rebuild utility
+mkdir bin
+cd bin
+ln -s ../../../../IOIPSL/bin/* .
+
Index: trunk/LMDZ.COMMON/ioipsl/install_ioipsl_occigen.bash
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/install_ioipsl_occigen.bash	(revision 2256)
+++ trunk/LMDZ.COMMON/ioipsl/install_ioipsl_occigen.bash	(revision 2412)
@@ -1,66 +1,67 @@
 #!/bin/bash
-# script to download and install the latest version of IOIPSL on occigen
+# script to download and install the latest version of IOIPSL on Occigen
 #
 
-#0. Preliminary stuff 
-module purge
-#module load intel/15.6.233
-#module load intelmpi/5.1.3.258
-#module load hdf5/1.8.14
-#module load netcdf/4.3.3-rc2_fortran-4.4.1
-module load intel/17.0
-module load intelmpi/2017.0.098
-module load hdf5/1.8.17
-module load netcdf/4.4.0_fortran-4.4.2
+#0. Preliminary stuff
 
-whereami=`pwd -P`
+if (( $# == 0 ))
+then
+  # default behavior: get latest version of IOIPSL
+  rev="HEAD"
+else
+  # but otherwise the first argument of the script can be the version to use
+  if (( $# == 1 ))
+  then
+    rev=$1
+  else
+    echo "Error, invalid script arguments"
+    echo "Usage:"
+    echo "$0 rev"
+    echo " where optional rev is the IOIPSL revision number"
+    exit
+  fi
+fi
 
-# 1. Get IOIPSL (via modipsl)
-svn co http://forge.ipsl.jussieu.fr/igcmg/svn/modipsl/trunk modipsl
-cd modipsl/util
+# cleanup possible previous attempt:
+\rm -rf ../../IOIPSL modipsl 
 
-./model IOIPSL_PLUS
+# 1. Get IOIPSL 
+# move up at same level as LMDZ.COMMON , etc.
+cd ../..
+svn co --revision $rev http://forge.ipsl.jussieu.fr/igcmg/svn/IOIPSL/trunk IOIPSL
 
-# 2. Set correct settings:
-# add a "occigen" configuration to AA_make.gdef
-echo "#-Q- occigen  #- Global definitions for Occigen at CINES, ifort" >> AA_make.gdef
-echo "#-Q- occigen  M_K = make" >> AA_make.gdef
-echo "#-Q- occigen  P_C = cpp" >> AA_make.gdef
-echo '#-Q- occigen  P_O = -P -C $(P_P)' >> AA_make.gdef
-echo "#-Q- occigen  F_C = ifort -mcmodel=medium -shared-intel -c" >> AA_make.gdef
-echo "#-Q- occigen  #-D- MD    F_D = -g" >> AA_make.gdef
-echo "#-Q- occigen  #-D- MN    F_D =" >> AA_make.gdef
-echo "#-Q- occigen  #-P- I4R4  F_P = -integer-size 32" >> AA_make.gdef
-echo "#-Q- occigen  #-P- I4R8  F_P = -integer-size 32 -real-size 64" >> AA_make.gdef
-echo "#-Q- occigen  #-P- I8R8  F_P = -integer-size 64 -real-size 64" >> AA_make.gdef
-echo '#-Q- occigen  F_O = -O $(F_D) $(F_P) -I$(MODDIR) -module $(MODDIR)' >> AA_make.gdef
-echo "#-Q- occigen  F_L = ifort" >> AA_make.gdef
-echo "#-Q- occigen  M_M = 0" >> AA_make.gdef
-echo "#-Q- occigen  L_X = 0" >> AA_make.gdef
-echo "#-Q- occigen  L_O =" >> AA_make.gdef
-echo "#-Q- occigen  A_C = ar -r" >> AA_make.gdef
-echo "#-Q- occigen  A_G = ar -x" >> AA_make.gdef
-echo "#-Q- occigen  C_C = icc -c" >> AA_make.gdef
-echo "#-Q- occigen  C_O =" >> AA_make.gdef
-echo "#-Q- occigen  C_L = icc" >> AA_make.gdef
-echo "#-Q- occigen  #-" >> AA_make.gdef
-echo "#-Q- occigen  NCDF_INC = ${NETCDFF_INCDIR}" >> AA_make.gdef
-echo "#-Q- occigen  NCDF_LIB = -L${NETCDFF_LIBDIR} -lnetcdff" >> AA_make.gdef
-echo "#-Q- occigen  #-" >> AA_make.gdef
-
-# set default working precision for IOIPSL:
-./ins_make -t occigen -p I4R8
+# 2. Set correct settings: copy over arch.* files
+cd IOIPSL
+cp -f ../LMDZ.COMMON/arch/arch-X64_OCCIGEN.env arch
+cp -f ../LMDZ.COMMON/arch/arch-X64_OCCIGEN.path arch
+cp -f ../LMDZ.COMMON/arch/arch-X64_OCCIGEN.fcm arch
 
 ## 3. build ioipsl:
-cd ../modeles/IOIPSL/src
-make
-## Compile the rebuild tool:
-cd ../tools
-make
+# but first make a small correction to makeioipsl_fcm
+sed -i -e s:'$HDF5_LIBDIR $HDF5_LIB':'':1 makeioipsl_fcm
+./makeioipsl_fcm -arch X64_OCCIGEN -job 8 > makeioipsl.out 2>&1
 
-if [[ -f ${whereami}/modipsl/lib/libioipsl.a ]] 
+## 4. Check if the library was indeed built:
+whereami=`pwd -P`
+if [[ -f lib/libioipsl.a ]] 
   then
-  echo "OK: ioipsl library is in ${whereami}/modipsl/lib"
+  echo "OK: ioipsl library is in ${whereami}/lib"
 else
-  echo "Something went wrong..."
+  echo "Something went wrong... check messages in ${whereami}/makeioipsl.out"
+  exit
 fi
+
+## 5. Comply with old setup and make appropriate links
+cd ../LMDZ.COMMON/ioipsl
+mkdir modipsl 
+cd modipsl
+# lib + module files
+mkdir lib
+cd lib
+ln -s ../../../../IOIPSL/lib/libioipsl.a .
+ln -s ../../../../IOIPSL/inc/* .
+cd ..
+# rebuild utility
+mkdir bin
+cd bin
+ln -s ../../../../IOIPSL/bin/* .
Index: trunk/LMDZ.COMMON/ioipsl/install_ioipsl_pgf90.bash
===================================================================
--- trunk/LMDZ.COMMON/ioipsl/install_ioipsl_pgf90.bash	(revision 2256)
+++ trunk/LMDZ.COMMON/ioipsl/install_ioipsl_pgf90.bash	(revision 2412)
@@ -2,42 +2,99 @@
 # script to download and install the latest version of IOIPSL
 # using pgf90
-# You'll probably have to change paths to NetCDF library 'lib' and 'include'
+# You'll probably have to change path to NetCDF library
 # below to adapt this script to your computer.
 
 #0. Preliminary stuff 
-# netcdf include and lib dirs:
-netcdf_include="/donnees/emlmd/netcdf64-4.0.1_pgi/include"
-netcdf_lib="/donnees/emlmd/netcdf64-4.0.1_pgi/lib"
+if (( $# == 0 ))
+then
+  # default behavior: get latest version of IOIPSL
+  rev="HEAD"
+else
+  # but otherwise the first argument of the script can be the version to use
+  if (( $# == 1 ))
+  then
+    rev=$1
+  else
+    echo "Error, invalid script arguments"
+    echo "Usage:"
+    echo "$0 rev"
+    echo " where optional rev is the IOIPSL revision number"
+    exit
+  fi
+fi
 
-whereami=`pwd -P`
+# Where is the NetCDF library root located? Hopefully nf-config can tell us
+# but you might need an appropriate "module load netcdf***" beforehand
+NETCDF_HOME=$(nf-config --prefix)
 
-# 1. Get IOIPSL (via modipsl)
-svn co http://forge.ipsl.jussieu.fr/igcmg/svn/modipsl/trunk modipsl
-cd modipsl/util
+# cleanup possible previous attempt:
+\rm -rf ../../IOIPSL modipsl 
 
-./model IOIPSL_PLUS
+# 1. Get IOIPSL 
+# move up at same level as LMDZ.COMMON , etc.
+cd ../..
+svn co --revision $rev http://forge.ipsl.jussieu.fr/igcmg/svn/IOIPSL/trunk IOIPSL
 
-# 2. Set correct settings:
-# modify path to netcdf in 'AA_make.gdef'
-cp AA_make.gdef AA_make.gdef.old
-sed -e s:"linux    NCDF_INC = /distrib/local/netcdf/pgf/include/":"linux    NCDF_INC = ${netcdf_include}":1 \
-    -e s:"linux    NCDF_LIB = -L/distrib/local/netcdf/pgf/lib/":"linux    NCDF_LIB = -L${netcdf_lib}":1 \
-    AA_make.gdef.old > AA_make.gdef
-
-# set default working precision for IOIPSL:
-./ins_make -t linux -p I4R8
+# 2. Set correct settings: make some arch.* files
+# Ideally these arch files should be the same as the GCM's
+# arch.env file (add any suitable module load here)
+cd IOIPSL/arch
+echo "" > arch-pgf90.env
+echo "export NETCDF_HOME=$NETCDF_HOME" >> arch-pgf90.env
+# arch.fcm file 
+echo '%COMPILER            pgf90' > arch-pgf90.fcm
+echo '%LINK                pgf90' >> arch-pgf90.fcm
+echo '%AR                  ar' >> arch-pgf90.fcm
+echo '%MAKE                make' >> arch-pgf90.fcm
+echo '%FPP_FLAGS           -P -traditional' >> arch-pgf90.fcm
+echo '%BASE_FFLAGS         -i4 -r8' >> arch-pgf90.fcm
+echo '%PROD_FFLAGS         -O2 -Munroll -Mnoframe -Mautoinline -Mcache_align' >> arch-pgf90.fcm
+echo '%DEV_FFLAGS          -Mbounds' >> arch-pgf90.fcm
+echo '%DEBUG_FFLAGS        -g -traceback -Mbounds -Mchkfpstk -Mchkstk -Ktrap=denorm,divz,fp,inv,ovf' >> arch-pgf90.fcm
+echo '%MPI_FFLAGS          ' >> arch-pgf90.fcm
+echo '%OMP_FFLAGS          ' >> arch-pgf90.fcm
+echo '%BASE_LD             ' >> arch-pgf90.fcm
+echo '%MPI_LD              ' >> arch-pgf90.fcm
+echo '%OMP_LD              ' >> arch-pgf90.fcm
+# arch.path file
+echo "NETCDF_INCDIR=\"-I$NETCDF_HOME/include\"" > arch-pgf90.path
+echo "NETCDF_LIBDIR=\"-L$NETCDF_HOME/lib\"" >> arch-pgf90.path
+echo 'NETCDF_LIB="-lnetcdff"' >> arch-pgf90.path
+echo '' >> arch-pgf90.path
+echo 'HDF5_INCDIR=""' >> arch-pgf90.path
+echo 'HDF5_LIBDIR=""' >> arch-pgf90.path
+echo 'HDF5_LIB=""' >> arch-pgf90.path
+echo '' >> arch-pgf90.path
+echo 'MPI_INCDIR=""' >> arch-pgf90.path
+echo 'MPI_LIBDIR=""' >> arch-pgf90.path
+echo 'MPI_LIB=""' >> arch-pgf90.path
 
 ## 3. build ioipsl:
-cd ../modeles/IOIPSL/src
-make
-## Compile the rebuild tool:
-cd ../tools
-make
+cd ..
+./makeioipsl_fcm -arch pgf90 -job 8 > makeioipsl.out 2>&1
 
-if [[ -f ${whereami}/modipsl/lib/libioipsl.a ]] 
+## 4. Check if the library was indeed built:
+whereami=`pwd -P`
+if [[ -f lib/libioipsl.a ]] 
   then
-  echo "OK: ioipsl library is in ${whereami}/modipsl/lib"
+  echo "OK: ioipsl library is in ${whereami}/lib"
 else
-  echo "Something went wrong..."
+  echo "Something went wrong... check messages in ${whereami}/makeioipsl.out"
+  exit
 fi
 
+## 5. Comply with old setup and make appropriate links
+cd ../LMDZ.COMMON/ioipsl
+mkdir modipsl 
+cd modipsl
+# lib + module files
+mkdir lib
+cd lib
+ln -s ../../../../IOIPSL/lib/libioipsl.a .
+ln -s ../../../../IOIPSL/inc/* .
+cd ..
+# rebuild utility
+mkdir bin
+cd bin
+ln -s ../../../../IOIPSL/bin/* .
+
