Skip to content

Commit

Permalink
Merge pull request #199 from duvivier/vectors
Browse files Browse the repository at this point in the history
Vectors
  • Loading branch information
duvivier committed Oct 9, 2018
2 parents df1b09d + 101a155 commit 4f2adf3
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 14 deletions.
94 changes: 86 additions & 8 deletions cicecore/cicedynB/analysis/ice_history.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
module ice_history

use ice_kinds_mod
use ice_constants, only: c0, c1, c2, c100, p001, p25, p5, &
mps_to_cmpdy, kg_to_g, spval
use ice_constants, only: c0, c1, c2, c100, c360, c180, &
p001, p25, p5, mps_to_cmpdy, kg_to_g, spval
use ice_fileunits, only: nu_nml, nml_filename, nu_diag, &
get_fileunit, release_fileunit
use ice_exit, only: abort_ice
Expand Down Expand Up @@ -81,7 +81,7 @@ subroutine init_hist (dt)

! local variables

real (kind=dbl_kind) :: rhofresh, Tffresh, secday
real (kind=dbl_kind) :: rhofresh, Tffresh, secday, rad_to_deg
logical (kind=log_kind) :: formdrag
logical (kind=log_kind) :: tr_iage, tr_FY, tr_lvl, tr_pond, tr_aero, tr_brine
logical (kind=log_kind) :: skl_bgc, solve_zsal, solve_zbgc, z_tracers
Expand All @@ -96,7 +96,7 @@ subroutine init_hist (dt)
!-----------------------------------------------------------------

call icepack_query_parameters(rhofresh_out=rhofresh, Tffresh_out=Tffresh, &
secday_out=secday)
secday_out=secday, rad_to_deg_out=rad_to_deg)
call icepack_query_parameters(formdrag_out=formdrag, skl_bgc_out=skl_bgc, &
solve_zsal_out=solve_zsal, solve_zbgc_out=solve_zbgc, z_tracers_out=z_tracers)
call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, &
Expand Down Expand Up @@ -302,6 +302,8 @@ subroutine init_hist (dt)
call broadcast_scalar (f_vvel, master_task)
call broadcast_scalar (f_uatm, master_task)
call broadcast_scalar (f_vatm, master_task)
call broadcast_scalar (f_atmspd, master_task)
call broadcast_scalar (f_atmdir, master_task)
call broadcast_scalar (f_sice, master_task)
call broadcast_scalar (f_fswup, master_task)
call broadcast_scalar (f_fswdn, master_task)
Expand All @@ -314,6 +316,8 @@ subroutine init_hist (dt)
call broadcast_scalar (f_sss, master_task)
call broadcast_scalar (f_uocn, master_task)
call broadcast_scalar (f_vocn, master_task)
call broadcast_scalar (f_ocnspd, master_task)
call broadcast_scalar (f_ocndir, master_task)
call broadcast_scalar (f_frzmlt, master_task)
call broadcast_scalar (f_fswfac, master_task)
call broadcast_scalar (f_fswint_ai, master_task)
Expand Down Expand Up @@ -404,6 +408,7 @@ subroutine init_hist (dt)
call broadcast_scalar (f_sistryubot, master_task)
call broadcast_scalar (f_sicompstren, master_task)
call broadcast_scalar (f_sispeed, master_task)
call broadcast_scalar (f_sidir, master_task)
call broadcast_scalar (f_sialb, master_task)
call broadcast_scalar (f_sihc, master_task)
call broadcast_scalar (f_sisnhc, master_task)
Expand Down Expand Up @@ -540,6 +545,16 @@ subroutine init_hist (dt)
"atm velocity (y)", &
"positive is y direction on U grid", c1, c0, &
ns1, f_vatm)

call define_hist_field(n_atmspd,"atmspd","m/s",ustr2D, ucstr, &
"atmosphere wind speed", &
"vector magnitude", c1, c0, &
ns1, f_atmspd)

call define_hist_field(n_atmdir,"atmdir","deg",ustr2D, ucstr, &
"atmosphere wind direction", &
"vector direction - coming from", c1, c0, &
ns1, f_atmdir)

call define_hist_field(n_sice,"sice","ppt",tstr2D, tcstr, &
"bulk ice salinity", &
Expand Down Expand Up @@ -600,6 +615,16 @@ subroutine init_hist (dt)
"ocean current (y)", &
"positive is y direction on U grid", c1, c0, &
ns1, f_vocn)

call define_hist_field(n_ocnspd,"ocnspd","m/s",ustr2D, ucstr, &
"ocean current speed", &
"vector magnitude", c1, c0, &
ns1, f_ocnspd)

call define_hist_field(n_ocndir,"ocndir","deg",ustr2D, ucstr, &
"ocean current direction", &
"vector direction - going to", c1, c0, &
ns1, f_ocndir)

call define_hist_field(n_frzmlt,"frzmlt","W/m^2",tstr2D, tcstr, &
"freeze/melt potential", &
Expand Down Expand Up @@ -1148,6 +1173,11 @@ subroutine init_hist (dt)
"ice speed", &
"none", c1, c0, &
ns1, f_sispeed)

call define_hist_field(n_sidir,"sidir","deg",ustr2D, ucstr, &
"ice direction", &
"vector direction - going to", c1, c0, &
ns1, f_sidir)

call define_hist_field(n_sialb,"sialb","1",tstr2D, tcstr, &
"sea ice albedo", &
Expand Down Expand Up @@ -1692,7 +1722,7 @@ subroutine accum_hist (dt)
real (kind=dbl_kind), dimension (nx_block,ny_block,ncat_hist) :: &
ravgipn, worka3

real (kind=dbl_kind) :: awtvdr, awtidr, awtvdf, awtidf, puny, secday
real (kind=dbl_kind) :: awtvdr, awtidr, awtvdf, awtidf, puny, secday, rad_to_deg
real (kind=dbl_kind) :: Tffresh, rhoi, rhos, rhow, ice_ref_salinity
real (kind=dbl_kind) :: rho_ice, rho_ocn, Tice, Sbr, phi, rhob, dfresh, dfsalt
logical (kind=log_kind) :: formdrag, skl_bgc
Expand All @@ -1706,7 +1736,8 @@ subroutine accum_hist (dt)
character(len=*), parameter :: subname = '(accum_hist)'

call icepack_query_parameters(awtvdr_out=awtvdr, awtidr_out=awtidr, &
awtvdf_out=awtvdf, awtidf_out=awtidf, puny_out=puny, secday_out=secday)
awtvdf_out=awtvdf, awtidf_out=awtidf, puny_out=puny, secday_out=secday, &
rad_to_deg_out=rad_to_deg)
call icepack_query_parameters(Tffresh_out=Tffresh, rhoi_out=rhoi, rhos_out=rhos, &
rhow_out=rhow, ice_ref_salinity_out=ice_ref_salinity)
call icepack_query_parameters(formdrag_out=formdrag, skl_bgc_out=skl_bgc, ktherm_out=ktherm)
Expand Down Expand Up @@ -1814,7 +1845,21 @@ subroutine accum_hist (dt)
call accum_hist_field(n_uatm, iblk, uatm(:,:,iblk), a2D)
if (f_vatm (1:1) /= 'x') &
call accum_hist_field(n_vatm, iblk, vatm(:,:,iblk), a2D)

if (f_atmspd (1:1) /= 'x') &
call accum_hist_field(n_atmspd, iblk, sqrt( &
(uatm(:,:,iblk)*uatm(:,:,iblk)) + &
(vatm(:,:,iblk)*vatm(:,:,iblk))), a2D)
if (f_atmdir(1:1) /= 'x') then
worka(:,:) = c0
do j = jlo, jhi
do i = ilo, ihi
if (abs(uatm(i,j,iblk)) > puny .or. abs(vatm(i,j,iblk)) > puny) &
worka(i,j) = atan2(uatm(i,j,iblk),vatm(i,j,iblk))*rad_to_deg
worka(i,j) = worka(i,j) + c180
enddo
enddo
call accum_hist_field(n_atmdir, iblk, worka(:,:), a2D)
endif
if (f_sice (1:1) /= 'x') then
do j = jlo, jhi
do i = ilo, ihi
Expand Down Expand Up @@ -1852,6 +1897,25 @@ subroutine accum_hist (dt)
call accum_hist_field(n_uocn, iblk, uocn(:,:,iblk), a2D)
if (f_vocn (1:1) /= 'x') &
call accum_hist_field(n_vocn, iblk, vocn(:,:,iblk), a2D)
if (f_ocnspd (1:1) /= 'x') &
call accum_hist_field(n_ocnspd, iblk, sqrt( &
(uocn(:,:,iblk)*uocn(:,:,iblk)) + &
(vocn(:,:,iblk)*vocn(:,:,iblk))), a2D)
if (f_ocndir(1:1) /= 'x') then
worka(:,:) = c0
do j = jlo, jhi
do i = ilo, ihi
if (abs(uocn(i,j,iblk)) > puny .or. abs(vocn(i,j,iblk)) > puny) &
worka(i,j) = atan2(uocn(i,j,iblk),vocn(i,j,iblk))*rad_to_deg
if (worka(i,j) < 0.0 ) then
worka(i,j) = worka(i,j) + c360
else
worka(i,j) = worka(i,j) * c1
endif
enddo
enddo
call accum_hist_field(n_ocndir, iblk, worka(:,:), a2D)
endif
if (f_frzmlt (1:1) /= 'x') &
call accum_hist_field(n_frzmlt, iblk, frzmlt_init(:,:,iblk), a2D)

Expand Down Expand Up @@ -2128,7 +2192,21 @@ subroutine accum_hist (dt)
enddo
call accum_hist_field(n_sispeed, iblk, worka(:,:), a2D)
endif

if (f_sidir(1:1) /= 'x') then
worka(:,:) = c0
do j = jlo, jhi
do i = ilo, ihi
if (abs(uvel(i,j,iblk)) > puny .or. abs(vvel(i,j,iblk)) > puny) &
worka(i,j) = atan2(uvel(i,j,iblk),vvel(i,j,iblk))*rad_to_deg
if (worka(i,j) < 0.0 ) then
worka(i,j) = worka(i,j) + c360
else
worka(i,j) = worka(i,j) * c1
endif
enddo
enddo
call accum_hist_field(n_sidir, iblk, worka(:,:), a2D)
endif
if (f_sidmasstranx(1:1) /= 'x') then
worka(:,:) = c0
do j = jlo, jhi
Expand Down
21 changes: 15 additions & 6 deletions cicecore/cicedynB/analysis/ice_history_shared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module ice_history_shared
! (1) Add to frequency flags (f_<field>)
! (2) Add to namelist (here and also in ice_in)
! (3) Add to index list
! In init_hist:
! In init_hist (in ice_history.F90):
! (4) Add define_hist_field call with vname, vdesc, vunit,
! and vcomment, vcellmeas, and conversion factor if necessary.
! (5) Add flag to broadcast list
Expand Down Expand Up @@ -188,12 +188,14 @@ module ice_history_shared
f_Tsfc = 'm', f_aice = 'm', &
f_uvel = 'm', f_vvel = 'm', &
f_uatm = 'm', f_vatm = 'm', &
f_atmspd = 'm', f_atmdir = 'm', &
f_fswup = 'm', &
f_fswdn = 'm', f_flwdn = 'm', &
f_snow = 'm', f_snow_ai = 'm', &
f_rain = 'm', f_rain_ai = 'm', &
f_sst = 'm', f_sss = 'm', &
f_uocn = 'm', f_vocn = 'm', &
f_ocnspd = 'm', f_ocndir = 'm', &
f_sice = 'm', f_frzmlt = 'm', &
f_fswfac = 'm', f_fswint_ai = 'x', &
f_fswabs = 'm', f_fswabs_ai = 'm', &
Expand Down Expand Up @@ -235,11 +237,12 @@ module ice_history_shared
f_mlt_onset = 'm', f_frz_onset = 'm', &
f_iage = 'm', f_FY = 'm', &
f_hisnap = 'm', f_aisnap = 'm', &
f_CMIP = 'x', &
f_CMIP = 'x' , &
f_sithick = 'x', f_sisnthick = 'x', &
f_siage = 'x', &
f_siage = 'x', &
f_sitemptop = 'x', f_sitempsnic = 'x', &
f_sitempbot = 'x', f_sispeed = 'x', &
f_sitempbot = 'x', &
f_sispeed = 'x', f_sidir = 'x', &
f_siu = 'x', f_siv = 'x', &
f_sidmasstranx = 'x', f_sidmasstrany = 'x', &
f_sistrxdtop = 'x', f_sistrydtop = 'x', &
Expand Down Expand Up @@ -328,12 +331,14 @@ module ice_history_shared
f_Tsfc, f_aice , &
f_uvel, f_vvel , &
f_uatm, f_vatm , &
f_atmspd, f_atmdir , &
f_fswup, &
f_fswdn, f_flwdn , &
f_snow, f_snow_ai , &
f_rain, f_rain_ai , &
f_sst, f_sss , &
f_uocn, f_vocn , &
f_ocnspd, f_ocndir , &
f_sice, f_frzmlt , &
f_fswfac, f_fswint_ai, &
f_fswabs, f_fswabs_ai, &
Expand Down Expand Up @@ -379,7 +384,8 @@ module ice_history_shared
f_sithick, f_sisnthick, &
f_siage, &
f_sitemptop, f_sitempsnic,&
f_sitempbot, f_sispeed, &
f_sitempbot, &
f_sispeed, f_sidir, &
f_siu, f_siv, &
f_sidmasstranx, f_sidmasstrany, &
f_sistrxdtop, f_sistrydtop, &
Expand Down Expand Up @@ -484,13 +490,15 @@ module ice_history_shared
n_Tsfc , n_aice , &
n_uvel , n_vvel , &
n_uatm , n_vatm , &
n_atmspd , n_atmdir , &
n_sice , &
n_fswup , &
n_fswdn , n_flwdn , &
n_snow , n_snow_ai , &
n_rain , n_rain_ai , &
n_sst , n_sss , &
n_uocn , n_vocn , &
n_ocnspd , n_ocndir , &
n_frzmlt , n_fswfac , &
n_fswint_ai , &
n_fswabs , n_fswabs_ai , &
Expand Down Expand Up @@ -535,7 +543,8 @@ module ice_history_shared
n_sithick , n_sisnthick , &
n_siage, &
n_sitemptop , n_sitempsnic , &
n_sitempbot , n_sispeed, &
n_sitempbot , &
n_sispeed , n_sidir , &
n_siu, n_siv, &
n_sidmasstranx, n_sidmasstrany, &
n_sistrxdtop, n_sistrydtop, &
Expand Down

0 comments on commit 4f2adf3

Please sign in to comment.