Skip to content

Commit

Permalink
Update scripts, code, tests to fix handful of issues including parse …
Browse files Browse the repository at this point in the history
…namelist checking (#215)

* scripts/code improvements for more robust and correct testing

* update tests and scripts

* update test suite to allow for longer runs for some tests
  • Loading branch information
apcraig authored Oct 19, 2018
1 parent 2c1379e commit 4671a1c
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 43 deletions.
17 changes: 14 additions & 3 deletions cice.setup
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,13 @@ foreach compiler ( $ncompilers )
set casescr = "${casedir}/casescripts"
if !( -d ${casescr}) mkdir ${casescr}
# set default test output as failure
if (${docase} == 0) then
echo "#---" >! test_output
echo "FAIL ${testname_noid} build" >> test_output
echo "FAIL ${testname_noid} run" >> test_output
endif
# from basic script dir to case
foreach file (cice.build cice.settings Makefile ice_in makdep.c setup_run_dirs.csh)
if !(-e ${ICE_SCRIPTS}/$file) then
Expand Down Expand Up @@ -759,6 +766,10 @@ EOF2
${casescr}/parse_settings.sh cice.settings ${fsmods}
${casescr}/parse_namelist.sh ice_in ${fimods}
if ($status != 0) then
echo "${0}: ERROR, parse_namelist.sh aborted"
exit -1
endif
source ./cice.settings
source ./env.${machcomp} -nomodules || exit 2
${casescr}/parse_namelist_from_env.sh ice_in
Expand Down Expand Up @@ -786,9 +797,9 @@ EOF2
exit -1
endif
# Initial test_output file
echo "#---" >! test_output
echo "PEND ${testname_noid} " >> test_output
# # Initial test_output file
# echo "#---" >! test_output
# echo "PEND ${testname_noid} " >> test_output
endif
#------------------------------------------------------------
Expand Down
43 changes: 32 additions & 11 deletions cicecore/cicedynB/dynamics/ice_dyn_eap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module ice_dyn_eap

use ice_kinds_mod
use ice_blocks, only: nx_block, ny_block
use ice_communicate, only: my_task, master_task
use ice_domain_size, only: max_blocks, ncat
use ice_constants, only: c0, c1, c2, c3, c12, p1, p2, p5, &
p001, p027, p055, p111, p166, p222, p25, p333
Expand Down Expand Up @@ -416,7 +417,7 @@ subroutine eap (dt)
! stress tensor equation, total surface stress
!-----------------------------------------------------------------

!$OMP PARALLEL DO PRIVATE(iblk,strtmp)
!$TCXOMP PARALLEL DO PRIVATE(iblk,strtmp)
do iblk = 1, nblocks

! call ice_timer_start(timer_tmp1) ! dynamics
Expand Down Expand Up @@ -502,7 +503,7 @@ subroutine eap (dt)
endif
! call ice_timer_stop(timer_tmp3) ! dynamics
enddo
!$OMP END PARALLEL DO
!$TCXOMP END PARALLEL DO

call ice_timer_start(timer_bound)
if (maskhalo_dyn) then
Expand Down Expand Up @@ -1624,15 +1625,15 @@ subroutine update_stress_rdg (ksub, ndte, divu, tension, &
gamma, alpha, x, y, dx, dy, da, &
invdx, invdy, invda, invsin, &
invleng, dtemp1, dtemp2, atempprime, &
puny, pi, pi2, piq
puny, pi, pi2, piq, pih

real (kind=dbl_kind), parameter :: &
kfriction = 0.45_dbl_kind

character(len=*), parameter :: subname = '(update_stress_rdg)'

call icepack_query_parameters(puny_out=puny, &
pi_out=pi, pi2_out=pi2, piq_out=piq)
pi_out=pi, pi2_out=pi2, piq_out=piq, pih_out=pih)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
Expand All @@ -1649,8 +1650,12 @@ subroutine update_stress_rdg (ksub, ndte, divu, tension, &

a22 = c1-a11

! gamma: angle between general coordiantes and principal axis
gamma = p5*atan2((c2*a12),(a11 - a22))
! gamma: angle between general coordiantes and principal axis
if ((a11-a22) == c0) then
gamma = p5*(pih)
else
gamma = p5*atan2((c2*a12),(a11 - a22))
endif

! rotational tensor from general coordinates into principal axis
Q11 = cos(gamma)
Expand All @@ -1673,7 +1678,11 @@ subroutine update_stress_rdg (ksub, ndte, divu, tension, &
dtemp22 = p5*(divu - tension)

! alpha: angle between general coordiantes and principal axis
alpha = p5*atan2((c2*dtemp12),(dtemp11 - dtemp22))
if ((dtemp11-dtemp22) == c0) then
alpha = p5*(pih)
else
alpha = p5*atan2((c2*dtemp12),(dtemp11 - dtemp22))
endif

! y: angle between major principal axis of strain rate and structure tensor
! to make sure y between 0 and pi/2
Expand All @@ -1699,7 +1708,11 @@ subroutine update_stress_rdg (ksub, ndte, divu, tension, &
invleng = c1/sqrt(dtemp1*dtemp1 + dtemp2*dtemp2)
dtemp1 = dtemp1*invleng
dtemp2 = dtemp2*invleng
x = atan2(dtemp2,dtemp1)
if ((dtemp1) == c0) then
x = (pih)
else
x = atan2(dtemp2,dtemp1)
endif
endif

!echmod to ensure the angle lies between pi/4 and 9 pi/4
Expand Down Expand Up @@ -1928,7 +1941,7 @@ subroutine calc_ffrac (blockno, stressp, stressm, &

real (kind=dbl_kind) :: &
sigma11, sigma12, sigma22, &
gamma, sigma_1, sigma_2, &
gamma, sigma_1, sigma_2, pih, &
Q11, Q12, Q11Q11, Q11Q12, Q12Q12

real (kind=dbl_kind), parameter :: &
Expand All @@ -1937,11 +1950,20 @@ subroutine calc_ffrac (blockno, stressp, stressm, &

character(len=*), parameter :: subname = '(calc_ffrac)'

call icepack_query_parameters(pih_out=pih)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)

sigma11 = p5*(stressp+stressm)
sigma12 = stress12
sigma22 = p5*(stressp-stressm)

gamma = p5*atan2((c2*sigma12),(sigma11-sigma22))
if ((sigma11-sigma22) == c0) then
gamma = p5*(pih)
else
gamma = p5*atan2((c2*sigma12),(sigma11-sigma22))
endif

! rotate tensor to get into sigma principal axis

Expand Down Expand Up @@ -2023,7 +2045,6 @@ subroutine read_restart_eap()

use ice_blocks, only: nghost
use ice_boundary, only: ice_HaloUpdate_stress
use ice_communicate, only: my_task, master_task
use ice_constants, only: &
field_loc_center, field_type_scalar
use ice_domain, only: nblocks, halo_info
Expand Down
4 changes: 2 additions & 2 deletions cicecore/cicedynB/dynamics/ice_dyn_evp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ subroutine evp (dt)
! stress tensor equation, total surface stress
!-----------------------------------------------------------------

!$OMP PARALLEL DO PRIVATE(iblk,strtmp)
!$TCXOMP PARALLEL DO PRIVATE(iblk,strtmp)
do iblk = 1, nblocks

! if (trim(yield_curve) == 'ellipse') then
Expand Down Expand Up @@ -403,7 +403,7 @@ subroutine evp (dt)
fld2(:,:,1,iblk) = uvel(:,:,iblk)
fld2(:,:,2,iblk) = vvel(:,:,iblk)
enddo
!$OMP END PARALLEL DO
!$TCXOMP END PARALLEL DO

call ice_timer_start(timer_bound)
if (maskhalo_dyn) then
Expand Down
2 changes: 1 addition & 1 deletion cicecore/cicedynB/infrastructure/ice_restart_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ subroutine restartfile (ice_ic)
! compute aggregate ice state and open water area
!-----------------------------------------------------------------

!$OMP PARALLEL DO PRIVATE(iblk)
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks

do j = 1, ny_block
Expand Down
8 changes: 8 additions & 0 deletions cicecore/shared/ice_distribution.F90
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,14 @@ function create_distrb_cart(nprocs, workPerBlock) result(newDistrb)
end do
end do

else
allocate (newDistrb%blockGlobalID(newDistrb%numLocalBlocks), &
stat=istat)
if (istat > 0) then
call abort_ice( &
'create_distrb_cart: error allocating blockGlobalID')
return
endif
endif

!----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion configuration/scripts/cice.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set ciceexe = "UnDEFineD"
if ($#argv == 1) then
set ciceexe = $1
echo "${0}: tcx ciceexe = ${ciceexe}"
echo "${0}: ciceexe = ${ciceexe}"
if (-e ${ciceexe}) then

source ./cice.settings
Expand Down
6 changes: 3 additions & 3 deletions configuration/scripts/ice_in
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@
fe_data_type = 'default'
fyear_init = 1997
ycycle = 1
atm_data_dir = '/glade/u/home/tcraig/cice_data/'
ocn_data_dir = '/unknown_ocn_data_dir'
bgc_data_dir = '/uknown_bgc_data_dir'
atm_data_format = 'bin'
atm_data_dir = '/glade/u/home/tcraig/cice_data/'
bgc_data_dir = 'unknown_bgc_data_dir'
ocn_data_format = 'bin'
ocn_data_dir = '/unknown_ocn_data_dir'
oceanmixed_file = 'unknown_oceanmixed_file'
/

Expand Down
1 change: 1 addition & 0 deletions configuration/scripts/machines/env.hobart_intel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ setenv ICE_MACHINE_WKDIR /scratch/cluster/$user/CICE_RUNS
setenv ICE_MACHINE_INPUTDATA /fs/cgd/csm/inputdata
setenv ICE_MACHINE_BASELINE /scratch/cluster/$user/CICE_BASELINE
setenv ICE_MACHINE_SUBMIT "qsub"
setenv ICE_MACHINE_QSTAT "qstat "
setenv ICE_MACHINE_QUEUE "short"
setenv ICE_MACHINE_ACCT P00000000
setenv ICE_MACHINE_TPNODE 24
Expand Down
1 change: 1 addition & 0 deletions configuration/scripts/machines/env.hobart_nag
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ setenv ICE_MACHINE_WKDIR /scratch/cluster/$user/CICE_RUNS
setenv ICE_MACHINE_INPUTDATA /fs/cgd/csm/inputdata
setenv ICE_MACHINE_BASELINE /scratch/cluster/$user/CICE_BASELINE
setenv ICE_MACHINE_SUBMIT "qsub"
setenv ICE_MACHINE_QSTAT "qstat "
setenv ICE_MACHINE_QUEUE "short"
setenv ICE_MACHINE_ACCT P00000000
setenv ICE_MACHINE_TPNODE 24
Expand Down
2 changes: 1 addition & 1 deletion configuration/scripts/options/set_nml.alt01
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ basalstress = .true.
shortwave = 'ccsm3'
albedo_type = 'constant'
formdrag = .true.
calc_tsfc = .true.
calc_Tsfc = .true.
atm_data_type = 'default'
highfreq = .true.
fbot_xfer_type = 'Cdn_ocn'
Expand Down
2 changes: 1 addition & 1 deletion configuration/scripts/options/set_nml.alt02
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ krdg_partic = 0
krdg_redist = 0
shortwave = 'ccsm3'
albedo_type = 'ccsm3'
calc_tsfc = .true.
calc_Tsfc = .true.


7 changes: 3 additions & 4 deletions configuration/scripts/options/set_nml.gx1
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ ycycle = 1
atm_data_format = 'bin'
atm_data_type = 'LYq'
atm_data_dir = 'ICE_MACHINE_INPUTDATA/CICE_data/forcing/gx1/COREII'
precip_unit = 'mm_per_sec'
ocn_data_format = 'nc'
ocn_data_type = 'ncar'
ocn_data_dir = 'oceanmixed_ice_depth.nc'
precip_units = 'mm_per_sec'
ocn_data_dir = 'ICE_MACHINE_INPUTDATA/CICE_data/forcing/gx1/COREII'
bgc_data_dir = 'ICE_MACHINE_INPUTDATA/CICE_data/forcing/gx1/WOA/MONTHLY'

17 changes: 14 additions & 3 deletions configuration/scripts/parse_namelist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ filemods=$2

#echo "$0 $1 $2"
echo "running parse_namelist.sh"
foundstring="FoundSTRING"

while read -r line
do
Expand All @@ -24,10 +25,20 @@ do
# echo "$line $vname $value"

#sed -i 's|\(^\s*'"$vname"'\s*\=\s*\)\(.*$\)|\1'"$value"'|g' $filename
sed -i.sedbak -e 's|\(^[[:space:]]*'"$vname"'[[:space:]]*=[[:space:]]*\)\(.*$\)|\1'"$value"'|g' $filename
if [[ -e "${filename}.sedbak" ]]; then
rm ${filename}.sedbak
cp ${filename} ${filename}.check
sed -i -e 's|\(^[[:space:]]*'"$vname"'[[:space:]]*=[[:space:]]*\)\(.*$\)|\1'"$foundstring"'|g' ${filename}.check
grep -q ${foundstring} ${filename}.check
if [ $? -eq 0 ]; then
sed -i.sedbak -e 's|\(^[[:space:]]*'"$vname"'[[:space:]]*=[[:space:]]*\)\(.*$\)|\1'"$value"'|g' ${filename}
if [[ -e "${filename}.sedbak" ]]; then
rm ${filename}.sedbak
fi
else
echo "$0 ERROR: parsing error for ${vname}"
exit -99
fi
rm ${filename}.check

fi

done < "$filemods"
Expand Down
6 changes: 3 additions & 3 deletions configuration/scripts/tests/base_suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ smoke gx3 8x2 diag24,run1year,medium
decomp gx3 4x2x25x29x5
smoke gx3 4x2 diag1,run5day smoke_gx3_8x2_diag1_run5day
smoke gx3 4x1 diag1,run5day,thread smoke_gx3_8x2_diag1_run5day
restart gx1 40x4 droundrobin,short
restart tx1 40x4 dsectrobin,short
restart gx1 40x4 droundrobin,medium
restart tx1 40x4 dsectrobin,medium
restart gx3 4x4 none
restart gx3 4x4 iobinary
restart gx3 6x2 alt01
Expand All @@ -19,5 +19,5 @@ restart gx3 4x4 alt04
restart gx3 4x4 alt05
restart gbox128 4x2 none
restart gbox128 4x2 boxdyn
restart gbox128 2x2 boxadv
restart gbox128 2x2 boxadv,short
restart gbox128 4x4 boxrestore
2 changes: 1 addition & 1 deletion configuration/scripts/tests/decomp_suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ restart gx3 6x2x4x29x18 dspacecurve restart_gx3_4x2x25x29x4_
restart gx3 8x2x8x10x20 droundrobin restart_gx3_4x2x25x29x4_dslenderX2
restart gx3 6x2x50x58x1 droundrobin restart_gx3_4x2x25x29x4_dslenderX2
restart gx3 4x2x19x19x10 droundrobin restart_gx3_4x2x25x29x4_dslenderX2
restart gx3 1x20x5x29x80 dsectrobin restart_gx3_4x2x25x29x4_dslenderX2
restart gx3 1x20x5x29x80 dsectrobin,short restart_gx3_4x2x25x29x4_dslenderX2
restart gx3 16x2x5x10x20 drakeX2 restart_gx3_4x2x25x29x4_dslenderX2
restart gx3 8x2x8x10x20 droundrobin,maskhalo restart_gx3_4x2x25x29x4_dslenderX2
restart gx3 1x4x25x29x16 droundrobin restart_gx3_4x2x25x29x4_dslenderX2
Expand Down
3 changes: 3 additions & 0 deletions configuration/scripts/tests/poll_queue.csh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ foreach line ( "`cat suite.log`" )
if ( "$line" =~ *'COMPILE SUCCESSFUL'* ) then
set job_id = 1
endif
if ( "$line" =~ *'ciceexe'* ) then
set job_id = 1
endif
endif
end

Expand Down
Loading

0 comments on commit 4671a1c

Please sign in to comment.