# Build EC-EARTH on LUCIA

EC-Earth is a global coupled climate model. It is developed by a consortium of European research institutions.
The goal of this project is to adapt this model for our needs in ELIC: install, run management, etc.

## System requirements

See : [how to build **iompi** toolchain on LUCIA](../softs.md)

> !!! skip this part : for PY only !!!

## User requirements

First, load the required env modules

```bash
module load craype-x86-milan
module load PrgEnv-intel/8.3.3
module load Perl/.5.34.1-GCCcore-11.3.0
MODULEPATH=$MODULEPATH:/gpfs/projects/acad/ecearth/softs/easybuild/modules/all
module load netCDF-Fortran/4.6.0-iompi-2022.05
module load imkl/2022.1.0 OpenJPEG/2.5.0-GCCcore-11.3.0 grib_api/1.24.0-iompi-2022.05
```

Then, checkout the EC-Earth SVN repository

```bash
mkdir -p ~/models/ecearth
cd ~/models/ecearth
svn co https://svn.ec-earth.org/ecearth3/tags/3.3.3.2 ecearth_3.3.3.2
```

Final step, create & overwrite all the makefile's from this git repository (`build` folder)
```
cd $HOME
git clone https://gogs.elic.ucl.ac.be/pbarriat/ECEARTHCFG.git
cd ~/ECEARTHCFG/3.3.3.2/build
cp config-build.xml ~/models/ecearth/ecearth_3.3.3.2/sources
cp ec-conf3 ~/models/ecearth/ecearth_3.3.3.2/sources/util/ec-conf
cp lucia-cray-iompi.xml ~/models/ecearth/ecearth_3.3.3.2/sources/platform
cd ~/models/ecearth/ecearth_3.3.3.2/sources
./util/ec-conf/ec-conf3 -p lucia-cray-iompi config-build.xml
cd ~/ECEARTHCFG/3.3.3.2/build
cp ifs.makefile           ~/models/ecearth_3.3.3.2/sources/ifs-36r4/Makefile.d/Makefile.config.ecconf
cp nemo.makefile          ~/models/ecearth_3.3.3.2/sources/nemo-3.6/ARCH/arch-ecconf.fcm
cp oasis.makefile         ~/models/ecearth_3.3.3.2/sources/oasis3-mct/util/make_dir/Makefile.d/Makefile.config.ecconf
cp runoff-mapper.makefile ~/models/ecearth_3.3.3.2/sources/runoff-mapper/src/Makefile
cp xios.env               ~/models/ecearth_3.3.3.2/sources/xios-2.5/arch/arch-ecconf.env
cp xios.fcm               ~/models/ecearth_3.3.3.2/sources/xios-2.5/arch/arch-ecconf.fcm
cp xios.path              ~/models/ecearth_3.3.3.2/sources/xios-2.5/arch/arch-ecconf.path
```

## Compile

* Compile **oasis**:

```bash
cd ~/models/ecearth_3.3.3.2/sources/oasis3-mct/util/make_dir
make BUILD_ARCH=ecconf -f TopMakefileOasis3
```

* Compile **IFS**:

```bash
cd ~/models/ecearth_3.3.3.2/sources/ifs-36r4
./makeifs -j 4
```

* Compile **xios**:

```bash
cd ~/models/ecearth_3.3.3.2/sources/xios-2.5
./make_xios --prod --arch ecconf --use_oasis oasis3_mct --netcdf_lib netcdf4_par -j 4
```

* Compile **NEMO**:

```bash
cd ~/models/ecearth_3.3.3.2/sources/nemo-3.6/CONFIG
./makenemo -n ORCA1L75_LIM3 -m ecconf -j4
```

* Compile **runoff-mapper**:

```bash
cd ~/models/ecearth_3.3.3.2/sources/runoff-mapper/src
make
```

## Run

Overwrite the `ecconf.cfg` and copy the first job script

```bash
cd ~/ECEARTHCFG/3.3.3.2/run
cp EC00.sh ecconf.cfg ~/models/ecearth/ecearth_3.3.3.2/runtime/classic
```

### Data

I prepared all the input files in `/gpfs/scratch/acad/ecearth/data/bsc32/` directory.

### Very first try

|  CC   | Release | RES |  XIOS  | NEMO | IFS | #NODES |  WTIME per MONTH        |
| ----- | --- | ---- | ------ | -------------- | ------ | ------- | -------------------- |
| `EC00.sh` | iompi/2022.05 | T255L91_ORCA1L75 |  1  |   86  |   320    |     3      | **121min**       |
| `EC01.sh` | iompi/2022.05 | T255L91_ORCA1L75 |  6  |  256  |   1024   |    11       | **min**       |

- 1 year (1850), restart every year

## Contributors

- ELIC members [@pbarriat](https://gogs.elic.ucl.ac.be/pbarriat)
