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

Build script and build testing. #4

Open
wants to merge 11 commits into
base: master
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build/**.obj
build/rrtmg_sw**
build/makefile
run_examples_std_atm/rrtmg_sw*
**/log.txt
test/rrtmg**
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ The following files (in `build/makefiles` directory) can be used to compile RRTM
| `make_rrtmg_sw_aix_xlf90` | Sample makefile for AIX (XLF90 compiler)
| `make_rrtmg_sw_OS_X_g95` | Sample makefile for OS_X (G95 compiler)
| `make_rrtmg_sw_OS_X_ibm_xl` | Sample makefile for OS_X (IBM XL compiler)
| `make_rrtmg_sw_linux_mimi` | Sample makefile for running on UiO machine "mimi" with gfortran

### SAMPLE INPUT/OUTPUT
Several sample input (and output) files are included in the `run_examples_std_atm` directory. Note that user-defined profiles may be used for as many as 200 layers.
Expand Down Expand Up @@ -127,7 +128,12 @@ Several sample input (and output) files are included in the `run_examples_std_at
| `script.run_std_atm` | UNIX script for running the full suite of example cases, which will put the output into similarly named files prefixed with `output_rrtm*` |

### INSTRUCTIONS FOR COMPILING AND RUNNING THE COLUMN MODEL:
1) In the `build` directory, link one of the makefiles from the `makefile` sub-directory into `build/make.build`. To use the optional netCDF input file, switch the keyword `KGSRC` in the makefile from `dat` to `nc`. Compile the model with `make -f make.build`

0) If you are planning to use netCDF input, make sure your version of netcdf has `nc-config` utility,
you can check it by `nc-config --version` which will tell the version of your netCDF install. Since since the source code is written in Fortran, check if your netCDF distribution has fortran support: `nc-config --has-fortran`.
1) In the `build` directory, simply run `./build.sh <platform_name> <kgsrc_format>` or link one of the makefiles from the `makefiles` sub-directory into `build/makefile`. To use optional netCDF input file with the manual make build do `make KGSRC=<dat/nc>`, this will overwrite variable `KGSRC` in the makefile to `dat` to `nc`.
2) If manual make build fails, you can clean with `make clean` to restart it from scratch.
3) If you've build with `./build.sh` you can test your build by running `./test.sh`. If a tests fails but you want to see the resluts of all of the tests run `./test.sh --allow-failed`.
2) Link the executable to, for example, `rrtmg_sw` in the `run_examples_std_atm` directory
3) If the optional netCDF input file was selected when compiling, link the file `data/rrtmg_sw.nc` into the `run_examples_std_atm` directory.
4) In the `run_examples_std_atm` directory, run the UNIX script `./script.run_std_atm` to run the full suite of example cases. To run a single case, modify `INPUT_RRTM` following the instructions in `doc/rrtmg_sw_instructions.txt`, or copy one of the example `input_rrtm*` files into `INPUT_RRTM`. If clouds are selected (`ICLD` > 0), then modify `IN_CLD_RRTM` or copy one of the `in_cld_rrtm*` files into `IN_CLD_RRTM`. If aerosols are selected (`IAER` > 0), then modify `IN_AER_RRTM` or set it to the sample file `in_aer_rrtm-aer12`.
Expand Down
74 changes: 74 additions & 0 deletions build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash


#USAGE: build platform kgsrc

platform=$1
kgsrc=$2
version=v5.00
i=0
declare -a platforms=()
for file in ./makefiles/* ; do
platforms[$i]=${file#"./makefiles/make_rrtmg_sw_"}
i=$((i+1))
done
echo ${platforms[*]}
if [[ ${platform} == "" ]] ; then
echo "No platform selected."
echo "Usage: $0 <platform> <kgsrc_format>"
exit 1
fi
match=0
for p in "${platforms[@]}" ; do
if [[ $p == ${platform} ]] ; then
match=1
break
fi
done
if [[ $match == 0 ]] ; then
echo "$platform is not supported."
echo "Available platforms are:"
echo ${platforms[*]}
exit 1
fi
if [[ ${kgsrc} == "" ]]; then
echo "no kgsrc_format selected"
exit 1
elif ! [[ ${kgsrc} =~ "nc" || ${kgsrc} =~ "dat" ]] ; then
echo "KGSRC format is not supported."
echo "Available formats are:"
echo "nc dat"
exit 1
fi


if ! [[ -L "./makefile" ]] ; then
ln -s ./makefiles/make_rrtmg_sw_${platform} ./makefile
fi

if [[ ${platform} == "linux_mimi" ]] ; then
module purge
module load netCDF-Fortran/4.6.0-gompi-2022a
fi

make PLATFORM=${platform} KGSRC=${kgsrc}

if [[ -f ./rrtmg_sw_${version}_${platform} ]] ; then

cd ../test/
ln -sf ../build/rrtmg_sw_${version}_${platform} rrtmg_sw
if [[ ${kgsrc} == "nc" ]] ; then
cp -f ../data/rrtmg_sw.nc ./
fi
cd ../run_examples_std_atm/
ln -sf ../build/rrtmg_sw_${version}_${platform} rrtmg_sw
if [[ ${kgsrc} == "nc" ]] ; then
cp -f ../data/rrtmg_sw.nc ./
fi
echo "build complete"
echo "test the build by running ./test.sh"
else
echo "build was not complete"
exit 1
fi

13 changes: 13 additions & 0 deletions build/makefiles/make_rrtmg_sw_OS_X_g95
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,16 @@ conclude :
echo '================='
echo

##############################
# cleaning
##############################
clean :

echo cleaning: $(CDOTO)
rm -rf $(CDOTO)
echo "cleaning: *.mod"
rm -rf *.mod
echo "cleaning: *.o"
rm -rf *.o
echo "cleaning: $(OUTPUT)"
rm -rf $(OUTPUT)
13 changes: 13 additions & 0 deletions build/makefiles/make_rrtmg_sw_OS_X_ibm_xl
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,16 @@ conclude :
echo '================='
echo

##############################
# cleaning
##############################
clean :

echo cleaning: $(CDOTO)
rm -rf $(CDOTO)
echo "cleaning: *.mod"
rm -rf *.mod
echo "cleaning: *.o"
rm -rf *.o
echo "cleaning: $(OUTPUT)"
rm -rf $(OUTPUT)
26 changes: 23 additions & 3 deletions build/makefiles/make_rrtmg_sw_aix_xlf90
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,16 @@ $(CDOTO)/$(MK26).o : $(MPATH)/$(MK26).f90
$(CDOTO)/$(MK27).o : $(MPATH)/$(MK27).f90
$(FC) $(FCOPTS) -I$(CDOTO) -c $(MPATH)/$(MK27).f90
\mv $(MK27).o *.mod $(CDOTO)

$(CDOTO)/$(MK28).o : $(MPATH)/$(MK28).f90
$(FC) $(FCOPTS) -I$(CDOTO) -c $(MPATH)/$(MK28).f90
clean :

echo cleaning: $(CDOTO)
rm -rf $(CDOTO)
echo "cleaning: *.mod"
rm -rf *.mod
echo "cleaning: *.o"
rm -rf *.o
echo "cleaning: $(OUTPUT)"
rm -rf $(OUTPUT)
\mv $(MK28).o *.mod $(CDOTO)

$(CDOTO)/$(MK29).o : $(MPATH)/$(MK29).f90
Expand Down Expand Up @@ -438,3 +445,16 @@ conclude :
echo '================='
echo

##############################
# cleaning
##############################
clean :

echo cleaning: $(CDOTO)
rm -rf $(CDOTO)
echo "cleaning: *.mod"
rm -rf *.mod
echo "cleaning: *.o"
rm -rf *.o
echo "cleaning: $(OUTPUT)"
rm -rf $(OUTPUT)
Loading