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

(PLATFORM-1077) Adding CI/CD capabilities and Unit Tests #76

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a1b8d1f
test
kbooker79 Feb 15, 2024
75c2ff8
platform-1077, adding initial CI/CD for Jenkins
kbooker79 Feb 20, 2024
a6ba2a0
Removing typo.
kbooker79 Feb 20, 2024
ac9750c
Fixing other typo
kbooker79 Feb 20, 2024
22bcb97
Adding unit tests script
kbooker79 Feb 20, 2024
5705b9b
Adding label removal
kbooker79 Feb 20, 2024
0cf35af
Adding auth token from Jenkins.
kbooker79 Feb 20, 2024
697fdba
Checking env variables
kbooker79 Feb 20, 2024
2831d28
Troubleshooting
kbooker79 Feb 20, 2024
ba0d045
More troubleshooting
kbooker79 Feb 20, 2024
fd3b29a
Updating
kbooker79 Feb 20, 2024
3d62c00
Updating
kbooker79 Feb 20, 2024
43f20e1
Updating
kbooker79 Feb 20, 2024
967efff
Updating to use CHANGE_URL rather than GIT_URL
kbooker79 Feb 20, 2024
00d1289
Updating to use token for testing repo.
kbooker79 Feb 20, 2024
da3280c
Updating
kbooker79 Feb 20, 2024
bef267e
Updating auth
kbooker79 Feb 20, 2024
4e7af4c
PLATFORM-1077, removing pendatic comment file.
kbooker79 Feb 22, 2024
2c1b31d
Merge branch 'NOAA-PSL:master' into platform-1077
kbooker79 May 17, 2024
9c95c32
Update Jenkinsfile
zach1221 May 17, 2024
35c32c0
Update stochastic_physics.F90 fix do_sppt logic
zach1221 May 17, 2024
9f235a4
Create input.nml
zach1221 May 17, 2024
0de7a90
Update run_standalone.sh input-data and account
zach1221 May 17, 2024
ebb4758
Update standalone_stochy.F90 add new spp parameters and allocation
zach1221 May 17, 2024
7160eb4
Update Jenkinsfile
zach1221 May 17, 2024
b762de9
Update Jenkinsfile
zach1221 May 17, 2024
539923f
Update Jenkinsfile
zach1221 May 17, 2024
3f328d1
Update Jenkinsfile
zach1221 May 17, 2024
72fbbd9
Merge branch 'NOAA-PSL:master' into platform-1077
zach1221 Aug 5, 2024
3d4ee1c
Update input.nml enable SPP
zach1221 Aug 5, 2024
3849844
Update input.nml
zach1221 Aug 5, 2024
3e6b455
Update input.nml update n_var_spp
zach1221 Aug 6, 2024
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
59 changes: 59 additions & 0 deletions .cicd/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
pipeline {
agent none
environment {
GITHUB_TOKEN = credentials('GithubJenkinsNew')
AWS_ACCOUNT_ID = 211527314271
}
stages {
stage('Run Unit Tests') {
agent {
label 'hera'
}
steps {
script {
cleanWs()
checkout scm
sh '''
cd unit_tests
echo "Running Unit Tests on ${NODE_NAME}"
./compile_standalone.hera_gnu
cp -r /scratch2/NAGAPE/epic/UFS-WM_RT/NEMSfv3gfs/input-data-20221101/FV3_input_data/INPUT INPUT
srun --label -A epic -n 24 standalone_stochy.x
mkdir stochy_out
mv workg* stochy_out
cd stochy_out/
ls
'''
}
}
}
}
post {
always {
node('built-in') {
sh '''
GIT_OWNER=$(echo $CHANGE_URL | cut -d '/' -f4)
GIT_REPO_NAME=$(echo $CHANGE_URL | cut -d '/' -f5 | cut -d '.' -f1)
echo "Testing successfully completed...removing label(s)"
curl --silent -X DELETE -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${GITHUB_TOKEN}" https://api.github.com/repos/${GIT_OWNER}/${GIT_REPO_NAME}/issues/${CHANGE_ID}/labels -d '{"labels":["run-unit-tests"]}'
'''
}
}
success {
node('built-in') {
echo 'This will run only if successful.'
sh '''
aws sns publish --topic-arn "arn:aws:sns:us-east-1:${AWS_ACCOUNT_ID}:Jenkins-CICD-Notifications" --region us-east-1 --message '{"version":"1.0","source":"custom","content":{"description":":sunny: Jenkins build *'"$JOB_NAME"' '"$BUILD_NUMBER"'* with *PR-'"$CHANGE_ID"'* *succeeded*"}}'
'''
}
}
failure {
node('built-in') {
echo 'This will run only if the run was marked as unstable.'
sh '''
aws sns publish --topic-arn "arn:aws:sns:us-east-1:${AWS_ACCOUNT_ID}:Jenkins-CICD-Notifications" --region us-east-1 --message '{"version":"1.0","source":"custom","content":{"description":":warning: Jenkins build *'"$JOB_NAME"' '"$BUILD_NUMBER"'* with *PR-'"$CHANGE_ID"'* *failed!*"}}'
'''
}
}
}
}
2 changes: 1 addition & 1 deletion stochastic_physics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ subroutine init_stochastic_physics(levs, blksz, dtp, sppt_amp, input_nml_file_in
endif
enddo
if (sppt_sfclimit) then
do k=1,7
do k=1,levs
vfact_sppt(k)=pbl_taper(k)
enddo
endif
Expand Down
99 changes: 99 additions & 0 deletions unit_tests/input.nml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
&amip_interp_nml
interp_oi_sst = .true.
use_ncep_sst = .true.
use_ncep_ice = .false.
no_anom_sst = .false.
data_set = 'reynolds_oi',
date_out_of_range = 'climo',
/

&atmos_model_nml
blocksize = 32
chksum_debug = .false.
dycore_only = .false.
fhout = 1
fhmax = 800
fhmaxhf = -1
ccpp_suite = 'FV3_GFS_v15p2_coupled'
/

&diag_manager_nml
prepend_date = .F.
/

&fms_io_nml
checksum_required = .false.
max_files_r = 100,
max_files_w = 100,
/

&fms_nml
clock_grain = 'ROUTINE',
domains_stack_size = 40000000,
print_memory_usage = .false.
/

&fv_grid_nml
grid_file = 'INPUT/grid_spec.nc'
/

&fv_core_nml
layout = 1,4
io_layout = 1,1
npx = 97,
npy = 97,
ntiles = 6,
grid_type = -1

/

&gfs_physics_nml
do_spp = .true.
do_sppt = .true.
do_shum = .true.
do_skeb = .true.
lndp_type = 2
n_var_lndp = 2
n_var_spp = 5
/

&nam_sppperts
Copy link
Contributor

@JeffBeck-NOAA JeffBeck-NOAA Aug 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are the options for SPP (note that these are the generally recommended settings to run SPP at 3-km in the SRW App; I've not tested it with any other UFS App or at different grid resolutions):

DO_SPP: true
N_VAR_SPP: 5
SPP_VAR_LIST: "pbl", "sfc", "mp", "rad", "gwd"
SPP_MAG_LIST: 0.2, 0.2, 0.75, 0.2, 0.2
SPP_LSCALE: 150000.0, 150000.0, 150000.0, 150000.0, 150000.0
SPP_TSCALE: 21600.0, 21600.0, 21600.0, 21600.0, 21600.0
SPP_SIGTOP1: 0.1, 0.1, 0.1, 0.1, 0.1
SPP_SIGTOP2: 0.025, 0.025, 0.025, 0.025, 0.025
SPP_STDDEV_CUTOFF: 1.5, 1.5, 2.5, 1.5, 1.5
ISEED_SPP: 4, 5, 6, 7, 8

Note that EMC implemented SPP for the Grell-Frietas scheme, which can be turned on by adding "cu_deep" to the SPP_VAR_LIST variable and adding an additional value to the other namelist entries.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, @JeffBeck-NOAA. I've added the changes to input.nml. I added "cu_deep" as an additional variable to SPP_VAR_LIST as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zach1221, did n_var_spp not work with 6?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeffBeck-NOAA yes, looks like it failed with the below. I was going to try with 5, but Hera is down for maintenance currently.

At line 182 of file compns_stochy.F90 (unit = 21, file = 'input.nml')
1: Fortran runtime error: Cannot match namelist object name spp_var_list:

SPP_VAR_LIST: "pbl", "sfc", "mp", "rad", "gwd", "cu_deep"
SPP_MAG_LIST: 0.2, 0.2, 0.75, 0.2, 0.2
SPP_LSCALE: 150000.0, 150000.0, 150000.0, 150000.0, 150000.0
SPP_TSCALE: 21600.0, 21600.0, 21600.0, 21600.0, 21600.0
SPP_SIGTOP1: 0.1, 0.1, 0.1, 0.1, 0.1
SPP_SIGTOP2: 0.025, 0.025, 0.025, 0.025, 0.025
SPP_STDDEV_CUTOFF: 1.5, 1.5, 2.5, 1.5, 1.5
ISEED_SPP: 4, 5, 6, 7, 8

/
&nam_stochy
SKEBNORM=1,
SKEB_NPASS=30,
SKEB_VDOF=5,
SKEB=0.5,
SKEB_TAU=2.16E4,
SKEB_LSCALE=1000.E3,
SHUM=0.01,
SHUM_TAU=21600,
SHUM_LSCALE=500000,
SPPT=0.8,0.4,0.1
SPPT_TAU=21600,86400,216000
SPPT_LSCALE=500000,1000000,2000000
SPPT_LOGIT=.TRUE.,
SPPT_SFCLIMIT=.TRUE.,
ISEED_SHUM=1,
ISEED_SKEB=2,
ISEED_SPPT=3,
STOCHINI=.false.
/
&nam_sfcperts
lndp_type=2
lndp_var_list='vgf','smc'
lndp_prt_list=1.0,0.5
iseed_lndp=4,5
lndp_tau= 86400,
lndp_lscale = 250000,
lndp_model_type = 1
/
6 changes: 3 additions & 3 deletions unit_tests/run_standalone.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
#SBATCH -e err
#SBATCH -o out
#SBATCH --account=gsienkf
#SBATCH --account=epic
#SBATCH --qos=debug
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=40
Expand All @@ -25,7 +25,7 @@ fi

# copy input directory
if [ ! -d INPUT ]; then
cp -r /scratch2/BMC/gsienkf/Philip.Pegion/stochastic_physics_unit_tests/input_data INPUT
cp -r /scratch2/NAGAPE/epic/UFS-WM_RT/NEMSfv3gfs/input-data-20221101/FV3_input_data/INPUT INPUT
fi
mkdir -p RESTART

Expand All @@ -40,6 +40,6 @@ sed -i -e "s/RES/$RES/g" input.nml
sed -i -e "s/_STOCHINI_/.false./g" input.nml
export OMP_NUM_THREADS=2
module list
time srun --label -n 24 standalone_stochy.x
time srun --label -n 24 standalone_stochy.x
mkdir stochy_out
mv workg* stochy_out
35 changes: 25 additions & 10 deletions unit_tests/standalone_stochy.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
program standalone_stochy

use mpi_f08
use stochastic_physics, only : init_stochastic_physics,run_stochastic_physics
use get_stochy_pattern_mod, only : write_stoch_restart_atm

Expand All @@ -16,6 +16,7 @@ program standalone_stochy
implicit none
integer, parameter :: nlevs=3
integer, parameter :: max_n_var_lndp = 6
integer, parameter :: max_n_var_spp = 6
integer :: ntasks,fid
integer :: nthreads
integer :: ncid,xt_dim_id,yt_dim_id,time_dim_id,xt_var_id,yt_var_id,time_var_id,var_id_lat,var_id_lon,var_id_tile
Expand All @@ -24,9 +25,11 @@ program standalone_stochy
integer :: zt_dim_id,zt_var_id
character*2 :: strid

character(len=3), dimension(max_n_var_lndp) :: lndp_var_list
real(kind=kind_dbl_prec), dimension(max_n_var_lndp) :: lndp_prt_list
include 'mpif.h'
character(len=3), allocatable :: lndp_var_list(:)
real(kind=kind_dbl_prec), allocatable :: lndp_prt_list(:)
character(len=10), allocatable :: spp_var_list(:)
real(kind=kind_dbl_prec), allocatable :: spp_prt_list(:)
real(kind=kind_dbl_prec), allocatable :: spp_stddev_cutoff(:)
include 'netcdf.inc'
real :: ak(nlevs+1),bk(nlevs+1)
real(kind=4) :: ts,undef
Expand All @@ -42,7 +45,7 @@ program standalone_stochy
integer :: i1,i2,j1,npts,istart,tpt
character*80 :: fname
character*1 :: ntile_out_str
integer :: comm
type(MPI_Comm) :: comm

real(kind=4),allocatable,dimension(:,:) :: workg,tile_number
real(kind=4),allocatable,dimension(:,:,:) :: workg3d
Expand All @@ -58,18 +61,19 @@ program standalone_stochy
real (kind=kind_phys),allocatable :: skebu_wts (:,:,:)
real (kind=kind_phys),allocatable :: skebv_wts (:,:,:)
real (kind=kind_phys),allocatable :: sfc_wts (:,:,:)
real (kind=kind_phys),allocatable :: spp_wts (:,:,:,:)
integer,allocatable :: blksz(:)
integer :: me !< MPI rank designator
integer :: root_pe !< MPI rank of root atmosphere processor
real(kind=kind_phys) :: dtp !< physics timestep in seconds
real(kind=kind_phys) :: fhour !< previous forecast hour
real(kind=kind_phys) :: sppt_amp !< amplitude of sppt (to go to cld scheme)
logical :: do_sppt,do_shum,do_skeb,use_zmtnblck
integer :: skeb_npass,n_var_lndp, lndp_type
logical :: do_sppt,do_shum,do_skeb,do_spp,use_zmtnblck
integer :: skeb_npass,n_var_lndp, lndp_type, n_var_spp
character(len=65) :: fn_nml !< namelist filename
character(len=256),allocatable :: input_nml_file(:) !< character string containing full namelist

namelist /gfs_physics_nml/do_sppt,do_skeb,do_shum,lndp_type,n_var_lndp
namelist /gfs_physics_nml/do_sppt,do_skeb,do_shum,do_spp,lndp_type,n_var_lndp,n_var_spp
write_this_tile=.false.
ntile_out_str='0'
nlunit=23
Expand All @@ -80,12 +84,21 @@ program standalone_stochy
read(ntile_out_str,'(I1.1)') ntile_out
open (unit=nlunit, file='input.nml', status='OLD')
n_var_lndp=0
n_var_spp =0
lndp_type=0
do_sppt=.false.
do_shum=.false.
do_skeb=.false.
do_spp =.false.
read(nlunit,gfs_physics_nml)
close(nlunit)

!allocate spp and lnp arrays
allocate(lndp_var_list(n_var_lndp))
allocate(lndp_prt_list(n_var_lndp))
allocate(spp_var_list(n_var_spp))
allocate(spp_prt_list(n_var_spp))
allocate(spp_stddev_cutoff(n_var_spp))
! define stuff
pi=3.14159265359
undef=9.99e+20
Expand Down Expand Up @@ -178,11 +191,12 @@ program standalone_stochy
root_pe=mpp_root_pe()
allocate(input_nml_file(1))
input_nml_file='input.nml'
comm=MPI_COMM_WORLD
comm=mpi_comm_world
call init_stochastic_physics(nlevs, blksz, dtp, sppt_amp, &
input_nml_file, fn_nml, nlunit, xlon, xlat, do_sppt, do_shum, &
do_skeb, lndp_type, n_var_lndp, use_zmtnblck, skeb_npass, &
lndp_var_list, lndp_prt_list, &
n_var_spp, spp_var_list, spp_prt_list, spp_stddev_cutoff, do_spp, &
ak, bk, nthreads, root_pe, comm, ierr)
if (ierr .ne. 0) print *, 'ERROR init_stochastic_physics call' ! Draper - need proper error trapping here
call get_outfile(fname)
Expand Down Expand Up @@ -292,6 +306,7 @@ program standalone_stochy
if (do_skeb)allocate(skebu_wts(nblks,blksz_1,nlevs))
if (do_skeb)allocate(skebv_wts(nblks,blksz_1,nlevs))
if (lndp_type > 0)allocate(sfc_wts(nblks,blksz_1,n_var_lndp))
if (do_spp)allocate(spp_wts(nblks,blksz_1,nlevs,n_var_spp))
if (stochini) then
istart=11
else
Expand All @@ -301,7 +316,7 @@ program standalone_stochy
do i=istart,21
ts=i/4.0
call run_stochastic_physics(nlevs, i-1, fhour, blksz, &
sppt_wts=sppt_wts, shum_wts=shum_wts, skebu_wts=skebu_wts, skebv_wts=skebv_wts, sfc_wts=sfc_wts, &
sppt_wts=sppt_wts, shum_wts=shum_wts, skebu_wts=skebu_wts, skebv_wts=skebv_wts, sfc_wts=sfc_wts, spp_wts=spp_wts, &
nthreads=nthreads)

if (me.EQ.0 .and. do_sppt) print*,'SPPT_WTS=',i,sppt_wts(1,1,2)
Expand Down