<commit_before>**Author: <NAME>** (<<EMAIL>>)

[TOC]

# Preparing Mac for ACME


1. Xcode
 - Download and install Xcode
 - Install Xcode command line developers tool by running the following command on terminal ```xcode-select --install``` and click on Install button
 - Launch Xcode and accept licence.


2. MacPorts
 - Download pkg for appropriate OS X from https://www.macports.org/install.php
 - Install the macports by double clicking on the *pkg and following on screen instructions.

3. Install softwares
  * gcc4.9:    

 ```
sudo port install gcc49
#
# Set soft links for gcc-mp-4.9/g++-mp-4.9/gfortran-mp-4.9 as
# gcc/g++/gfortran in /opt/local/bin
#
sudo ln -s /opt/local/bin/gcc-mp-4.9 /opt/local/bin/gcc
sudo ln -s /opt/local/bin/g++-mp-4.9 /opt/local/bin/g++
sudo ln -s /opt/local/bin/gfortran-mp-4.9 /opt/local/bin/gfortran
```

  * MPICH:

 ```
sudo port install mpich-gcc49
sudo port select --set mpi mpich-gcc49-fortran
 ```
  * HDF5:

 ```
sudo port install hdf5 +mpich +gcc49
 ```
  * NetCDF:    
 
 ```
 sudo port install netcdf-fortran +gcc49 +mpich
 ```
 
  * Git:       

 ```
sudo port install git
 ```

  * Mercurial: 

 ```
sudo port install mercurial
 ```

  * Perl:

 ```
sudo port install perl5
sudo port install p5.16-xml-libxml
 ```

  * CMake

 ```
sudo port install cmake
 ```

  * GMake

 ```
sudo port install gmake
 ```

<!---
  * Python:    

 ```
sudo port install python35
sudo port select --set python python35
 ```
-->

# Compiling an ACME case on Mac

- Checkout ACME

```
cd <project-directory>
git clone <EMAIL>:ACME-Climate/ACME.git

```

- Create a case for ACME

```
export RES=1x1_brazil
export COMPSET=ICLM45
export COMPILER=gnu
export MACH=mac

export CASE_NAME=${RES}.${COMPSET}.${COMPILER}

cd ACME/scripts

./create_newcase \
-case ${CASE_NAME} \
-compset ${COMPSET} \
-res ${RES} \
-compiler ${COMPILER} \
-mach ${MACH}

cd $CASE_NAME

```

- Modify env\_mach_pes.xmlodi

- Modify env\_build.xml

```
./xmlchange -file env_build.xml -id MPILIB -val mpich
./xmlchange -file env_build.xml -id OS -val Darwin
./xmlchange -file env_build.xml -id CESMSCRATCHROOT -val ${PWD}
./xmlchange -file env_build.xml -id EXEROOT -val ${PWD}/bld
```

- Modify env\_run.xml

```
./xmlchange -file env_run.xml -id DATM_CLMNCEP_YR_END -val 2000
./xmlchange -file env_run.xml -id DATM_CLMNCEP_YR_START -val 2000
./xmlchange -file env_run.xml -id DATM_CLMNCEP_YR_ALIGN -val 1
./xmlchange -file env_run.xml -id RUNDIR -val ${PWD}/run
```

- Do the setup

```
./cesm_setup
```

- Check that only a handful of files are missing.

```
>export DIN_LOC_ROOT=`./xmlquery DIN_LOC_ROOT | awk '{print $4}'`<commit_msg>Fix a typo<commit_after>**Author: <NAME>** (<<EMAIL>>)

[TOC]

# Preparing Mac for ACME


1. Xcode
 - Download and install Xcode
 - Install Xcode command line developers tool by running the following command on terminal ```xcode-select --install``` and click on Install button
 - Launch Xcode and accept licence.


2. MacPorts
 - Download pkg for appropriate OS X from https://www.macports.org/install.php
 - Install the macports by double clicking on the *pkg and following on screen instructions.

3. Install softwares
  * gcc4.9:    

 ```
sudo port install gcc49
#
# Set soft links for gcc-mp-4.9/g++-mp-4.9/gfortran-mp-4.9 as
# gcc/g++/gfortran in /opt/local/bin
#
sudo ln -s /opt/local/bin/gcc-mp-4.9 /opt/local/bin/gcc
sudo ln -s /opt/local/bin/g++-mp-4.9 /opt/local/bin/g++
sudo ln -s /opt/local/bin/gfortran-mp-4.9 /opt/local/bin/gfortran
```

  * MPICH:

 ```
sudo port install mpich-gcc49
sudo port select --set mpi mpich-gcc49-fortran
 ```
  * HDF5:

 ```
sudo port install hdf5 +mpich +gcc49
 ```
  * NetCDF:    
 
 ```
 sudo port install netcdf-fortran +gcc49 +mpich
 ```
 
  * Git:       

 ```
sudo port install git
 ```

  * Mercurial: 

 ```
sudo port install mercurial
 ```

  * Perl:

 ```
sudo port install perl5
sudo port install p5.16-xml-libxml
 ```

  * CMake

 ```
sudo port install cmake
 ```

  * GMake

 ```
sudo port install gmake
 ```

<!---
  * Python:    

 ```
sudo port install python35
sudo port select --set python python35
 ```
-->

# Compiling an ACME case on Mac

- Checkout ACME

```
cd <project-directory>
git clone git@github.com:ACME-Climate/ACME.git

```

- Create a case for ACME

```
export RES=1x1_brazil
export COMPSET=ICLM45
export COMPILER=gnu
export MACH=mac

export CASE_NAME=${RES}.${COMPSET}.${COMPILER}

cd ACME/scripts

./create_newcase \
-case ${CASE_NAME} \
-compset ${COMPSET} \
-res ${RES} \
-compiler ${COMPILER} \
-mach ${MACH}

cd $CASE_NAME

```

- Modify env\_mach_pes.xml

- Modify env\_build.xml

```
./xmlchange -file env_build.xml -id MPILIB -val mpich
./xmlchange -file env_build.xml -id OS -val Darwin
./xmlchange -file env_build.xml -id CESMSCRATCHROOT -val ${PWD}
./xmlchange -file env_build.xml -id EXEROOT -val ${PWD}/bld
```

- Modify env\_run.xml

```
./xmlchange -file env_run.xml -id DATM_CLMNCEP_YR_END -val 2000
./xmlchange -file env_run.xml -id DATM_CLMNCEP_YR_START -val 2000
./xmlchange -file env_run.xml -id DATM_CLMNCEP_YR_ALIGN -val 1
./xmlchange -file env_run.xml -id RUNDIR -val ${PWD}/run
```

- Do the setup

```
./cesm_setup
```

- Check that only a handful of files are missing.

```
>export DIN_LOC_ROOT=`./xmlquery DIN_LOC_ROOT | awk '{print $4}'`
{'fraction_non_alphanumeric': 0.14645222327341534, 'fraction_numerical': 0.019299905392620626, 'mean_word_length': 3.1426332288401255, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 16, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 44}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '339930', 'n_tokens_mistral': 2171, 'n_tokens_neox': 2018, 'n_words': 569}