Skip to content

Commit

Permalink
Merge pull request #75 from PrincetonUniversity/ci
Browse files Browse the repository at this point in the history
Change version to 2.75 and begin to automatically check compilation
  • Loading branch information
Caoxiang Zhu authored Jul 8, 2020
2 parents 99fc9b0 + b097617 commit 44867a9
Show file tree
Hide file tree
Showing 11 changed files with 415 additions and 53 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build_use_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: build-test
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
container: zhucaoxiang/stellopt:compile
env:
MACHINE: docker
STELLOPT_PATH: ${{ github.workspace }}
OMPI_ALLOW_RUN_AS_ROOT: 1
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
steps:
- name: checkout sources
uses: actions/checkout@master
- name: compile
run: |
cd ${STELLOPT_PATH}
./build_all -o clean_debug -j 2
- name: test
run: |
mpiexec ./bin/xstelloptv2 test -h
48 changes: 48 additions & 0 deletions BENCHMARKS/VMEC_TEST/compare_VMEC.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Caoxiang Zhu ([email protected])
For any help, type ./compare_VMEC.py -h
"""
import numpy as np
import xarray
import argparse

# parse command line arguments
# =============================================================================
parser = argparse.ArgumentParser(description="Compare two VMEC netcdf outputs")
parser.add_argument("filename", type=str, help="file name to be compared")
parser.add_argument("reference", type=str, help="reference data")
parser.add_argument("-t", "--tol", type=float, default=1E-8, help="difference tolerance")

args = parser.parse_args()
print('Compare VMEC outputs in {:s} and {:s} with tolerance {:12.5E}'.format(args.filename, args.reference, args.tol))
data = xarray.open_dataset(args.filename)
ref = xarray.open_dataset(args.reference)

tol = args.tol
match = True
skip_list = ['version_']
loose_list = ['jcuru', 'jdotb', 'currumnc', 'currvmnc'] # j related terms must have large tol

print('======================================')
for key in ref:
if key in skip_list:
continue
if key in loose_list:
tol = max(1E-3, tol)
else:
tol = args.tol
try:
diff = np.linalg.norm(ref[key].values - data[key].values)/len(ref[key].values)
unmatch = diff > tol
if unmatch:
match = False
print('UNMATCHED: '+key+', diff={:12.5E}'.format(diff))
except TypeError:
pass
print(' comparison passed: {:} '.format(match))
print('======================================')
assert match, 'Differences in some elements are larger than the tolerence.'

exit
3 changes: 1 addition & 2 deletions BENCHMARKS/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

.PHONY: test_vmec

test_vmec:
test_vmec:
@echo "Beginning testing of VMEC2000"
@cd $(VMEC_TEST_DIR); rm -f jxbout* mercier* threed1* wout*;
@echo $(MPI_RUN) $(MPI_RUN_OPTS_SM) $(MYHOME)/xvmec2000 input.DSHAPE
Expand All @@ -45,7 +45,6 @@ test_vmec:
@cd $(VMEC_TEST_DIR); $(MPI_RUN) $(MPI_RUN_OPTS_SM) $(MYHOME)/xvmec2000 input.DIII-D
@cd $(VMEC_TEST_DIR); ./compare_DIII-D.py
@echo "Tesing of VMEC2000 complete"
@echo ""

test_diagno:
@echo "Beginning testing of DIAGNO"
Expand Down
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM zhucaoxiang/stellopt:compile
MAINTAINER Caoxiang Zhu <[email protected]> & STELLOPT developers

WORKDIR /home/STELLOPT

COPY . /home/STELLOPT
# Compile STELLOPT
ENV MACHINE="docker"
ENV STELLOPT_PATH=/home/STELLOPT
RUN echo $STELLOPT_PATH
RUN cd $STELLOPT_PATH && ./build_all -j4 2>&1 | tee log.build
RUN chmod -R 777 ${STELLOPT_PATH}/BENCHMARKS
RUN cp -RP ${STELLOPT_PATH}/bin/* /usr/local/bin/

# add user
WORKDIR /home/visitor
RUN groupadd -r visitor -g 433 && \
useradd -u 431 -r -g visitor -d /home/visitor -s /sbin/nologin -c "Docker image user" visitor && \
chown -R visitor:visitor /home/visitor
USER visitor

# Set commands
CMD ["/bin/bash"]
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,40 @@ wish to use. For example to use `SHARE/make_bobdole.inc` you would set
important to set `STELLOPT_PATH` to the path to your current directory
where you've pulled the repository.

Once a working copy is developed for your computer, you are welcome
to push it back to the main repository for other users.
Before beginning, it is recommened to create an install branch. To do
this issue the following commands from main directory:
Once you configure the environment variables, you can begin to compile the code by

git checkout -b install
./build_all

The -b option tells us to create a new branch (you could also issue
two commands). Now you'll be on your install branch feel free to
edit files as necessary for your installation. To build the code
use the build_all script which will systematically build and compile
all the files.
By default, it will compile all the codes in the folder with the option `clean_release`.
You can customize the script by providing additional commandline arguments, like `./build_all -o release -j 4 STELLOPTV2`. To check the options, type `./build_all -h`.

For more information, please view [STELLOPT compilation](https://princetonuniversity.github.io/STELLOPT/STELLOPT%20Compilation).
There is also a Docker image available for use at https://hub.docker.com/r/zhucaoxiang/stellopt.

For more information, please view [STELLOPT compilation](https://princetonuniversity.github.io/STELLOPT/STELLOPT%20Compilation).

# EDITING CODE
To edit the code please first checkout a new branch with the feature
you'd like. Then when you want your changes merged into master,
please push your branch to the remote:

git push origin <branchname>

Once a working copy is developed for your computer, you are welcome
to push it back to the main repository for other users.
You can ask for a write permission and push your changes into a remote branch.
Then submit a pull request through
[GitHub](https://github.com/PrincetonUniversity/STELLOPT/pulls).

Or you can share your changes via [git fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo), which doesn't require you have the write permission.

GitHub actions will be triggered by each push and pull-request. The code will be compiled with debug option and you can check the full log at [GitHub actions](https://github.com/PrincetonUniversity/STELLOPT/actions).

# PYTHON INTERFACE
# UTILITIES
A Python interface using CTYPES is also included but it requires a
static shared build of LIBSTELL. This is still a highly experimental
option.
option. You can find the python scripts at `./pySTEL`.

There are also some other plotting packages developed by group members.
Here are some examples.

- [matlabVMEC](https://github.com/lazersos/matlabVMEC): MATLAB packages for various codes.
- [coilpy](https://github.com/zhucaoxiang/CoilPy): Python package for toroidal Fourier surface, coils, FOCUS and STELLOPT.

If you are willing to share your code, please add your contributions here.

# REPORT BUGS
If you find any bugs or have any suggestions, please submit an issue
Expand All @@ -54,4 +56,4 @@ You can find some wiki pages at
[GitHub pages](https://princetonuniversity.github.io/STELLOPT/).
This is automatically generated from the `markdown` source files
in the [gh-pages](https://github.com/PrincetonUniversity/STELLOPT/tree/gh-pages) branch.
Everyone is welcome to contribute to the wiki pages.
You are welcome to report/fix/update the wiki pages.
139 changes: 139 additions & 0 deletions SHARE/make_docker.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#######################################################################
# Define Basic Utilities
#######################################################################
SHELL = /bin/sh
PWD1 = `pwd`
MYHOME = $(STELLOPT_PATH)/bin
PRECOMP:= /lib/cpp -traditional -DLINUX
COMPILE = $(FC)
COMPILE_FREE = $(FC) -ffree-form -ffree-line-length-none -ffixed-line-length-none
LINK = ld $(FLAGS) -o
LINK_AR = ar -ruv
LINK_C = $(CC) -shared -Wl,-z-defs

#######################################################################
# Define Compiler Flags
#######################################################################
FLAGS_R = -O2 -fexternal-blas
FLAGS_D = -g -O0 -fexternal-blas -fbacktrace -fcheck=all
LIBS = -L/usr/lib -lscalapack-openmpi -lblas -llapack

#######################################################################
# MPI Options
#######################################################################
LMPI = T
MPI_COMPILE = mpif90
MPI_COMPILE_FREE = mpif90 -ffree-form \
-ffree-line-length-none -ffixed-line-length-none
MPI_COMPILE_C = mpicc
MPI_LINK = mpif90
MPI_RUN = mpiexec
MPI_RUN_OPTS =
# MPI_RUN_OPTS_SM = -np 16
# MPI_RUN_OPTS_MD = -np 64
# MPI_RUN_OPTS_LG = -np 256

#######################################################################
# NAG Options
#######################################################################
LNAG = F
NAG_LIB = -L$(NAG_ROOT)/lib -lnag_nag

#######################################################################
# NETCDF Options
#######################################################################
LNETCDF = T
NETCDF_INC = -I/usr/include
NETCDF_LIB = -L/usr/lib -lnetcdf -lnetcdff

#######################################################################
# NTCC Options
#######################################################################
LNTCC = F
NTCC_INC = -I/usr/include
NTCC_LIB = -L/usr/lib -laladdinsub -lr8slatec -ladpak\
-lcppsub -lcomput -lpspline -lportlib -lezcdf -lmds_sub \
-lmdstransp -lvaxonly

#######################################################################
# HDF5 Options
#######################################################################
LHDF5 = T
HDF5_INC = -I/usr/include/hdf5/openmpi
HDF5_LIB = -L/usr/lib/x86_64-linux-gnu/hdf5/openmpi \
-lhdf5 -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran

#######################################################################
# PGPLOT Options
#######################################################################
LPGPLOT = F
PGPLOT_INC = -I$(PGPLOT_DIR)
PGPLOT_LIB = -L$(PGPLOT_DIR) -lpgplot -L/usr/lib/x86_64-linux-gnu -lX11

#######################################################################
# SILO Options
#######################################################################
LSILO = F
SILO_INC = -I$(SILOHOME)/include
SILO_LIB = -L$(SILOHOME)/lib/x86_64-linux-gnu -lsiloh5

#######################################################################
# DKES/NEO Options
#######################################################################
LDKES = T
LNEO = T

#######################################################################
# GENE Options
#######################################################################
LGENE = F
GENE_INC = -I$(GENE_PATH)
GENE_DIR = $(GENE_PATH)
LIB_GENE = libgene.a
GENE_LIB = $(GENE_DIR)/$(LIB_GENE) \
-L/u/slazerso/src/GENE17_2016/external/pppl_cluster/futils/src -lfutils \
-L$(FFTWHOME)/lib -lfftw3 \
-L$(SLEPC_DIR)/$(PETSC_ARCH)/lib -lslepc \
-L$(PETSC_DIR)/$(PETSC_ARCH)/lib -lpetsc -lX11

#######################################################################
# COILOPT++ Options
#######################################################################
LCOILOPT = F
COILOPT_INC = -I$(COILOPT_PATH)
COILOPTPP_DIR = $(COILOPT_PATH)
LIB_COILOPTPP = libcoilopt++.a
COILOPT_LIB = $(COILOPT_PATH)/$(LIB_COILOPTPP) \
-L$(GSLHOME)/lib/x86_64-linux-gnu -lgsl -lgslcblas -lstdc++ -lmpi_cxx

#######################################################################
# TERPSICHORE Options
#######################################################################
LTERPSICHORE= F
TERPSICHORE_INC = -I$(TERPSICHORE_PATH)
TERPSICHORE_DIR = $(TERPSICHORE_PATH)
LIB_TERPSICHORE = libterpsichore.a
TERPSICHORE_LIB = $(TERPSICHORE_DIR)/$(LIB_TERPSICHORE)

#######################################################################
# TRAVIS Options
#######################################################################
LTRAVIS= F
TRAVIS_DIR = $(TRAVIS_PATH)
LIB_TRAVIS = libtravis64_sopt.a
LIB_MCONF = libmconf64.a
TRAVIS_LIB = $(TRAVIS_DIR)/lib/$(LIB_TRAVIS) \
$(TRAVIS_DIR)/mag_conf/lib/$(LIB_MCONF) -lstdc++

#######################################################################
# REGCOIL Options
#######################################################################
LREGCOIL= F
REGCOIL_DIR = $(REGCOIL_PATH)
REGCOIL_INC = -I$(REGCOIL_DIR)
LIB_REGCOIL = libregcoil.a
REGCOIL_LIB = $(REGCOIL_DIR)/$(LIB_REGCOIL) -fopenmp

#######################################################################
# LIBSTELL Shared Options
#######################################################################
Loading

0 comments on commit 44867a9

Please sign in to comment.