Skip to content

Commit

Permalink
Cleanup initialization (#240)
Browse files Browse the repository at this point in the history
* move write stmts, cleanup unused vars

* replace sil_data_type and nit_data_type with bgc_data_type

* documentation

* use ocn_data_type for SSS
  • Loading branch information
eclare108213 authored and apcraig committed Nov 17, 2018
1 parent f67dab7 commit 2946264
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 2,098 deletions.
1 change: 1 addition & 0 deletions cice.setup
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ echo ""
echo "Descriptors:"
echo " PASS - successful completion"
echo " COPY - previously compiled code was copied for new test"
echo " MISS - comparison data is missing"
echo " PEND - run has been submitted to queue and is waiting or failed submission"
echo " FAIL - test is still executing, did not complete, or completed and failed"
echo ""
Expand Down
1,772 changes: 0 additions & 1,772 deletions cicecore/cicedynB/general/#ice_init.F90#

This file was deleted.

41 changes: 11 additions & 30 deletions cicecore/cicedynB/general/ice_forcing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module ice_forcing
ocn_data_format, & ! 'bin'=binary or 'nc'=netcdf
atm_data_type, & ! 'default', 'monthly', 'ncar',
! 'LYq' or 'hadgem' or 'oned'
bgc_data_type, & ! 'default', 'clim', 'ncar', 'oned'
bgc_data_type, & ! 'default', 'clim'
ocn_data_type, & ! 'default', 'clim', 'ncar', 'oned',
! 'hadgem_sst' or 'hadgem_sst_uvocn'
precip_units ! 'mm_per_month', 'mm_per_sec', 'mks','m_per_sec'
Expand Down Expand Up @@ -324,7 +324,7 @@ subroutine init_forcing_ocn(dt)
! initialize to annual climatology created from monthly data
!-------------------------------------------------------------------

if (trim(bgc_data_type) == 'clim') then
if (trim(ocn_data_type) == 'clim') then

sss_file = trim(ocn_data_dir)//'/sss.mm.100x116.da' ! gx3 only

Expand Down Expand Up @@ -368,15 +368,11 @@ subroutine init_forcing_ocn(dt)

if (my_task == master_task) close(nu_forcing)

endif ! bgc_data_type

!-------------------------------------------------------------------
! Sea surface temperature (SST)
! initialize to data for current month
!-------------------------------------------------------------------

if (trim(ocn_data_type) == 'clim') then

if (nx_global == 320) then ! gx1
sst_file = trim(ocn_data_dir)//'/sst_clim_hurrell.dat'
else ! gx3
Expand Down Expand Up @@ -444,14 +440,12 @@ subroutine init_forcing_ocn(dt)

endif ! ocn_data_type

if (trim(ocn_data_type) == 'ncar' .or. &
trim(bgc_data_type) == 'ncar') then
if (trim(ocn_data_type) == 'ncar') then
! call ocn_data_ncar_init
call ocn_data_ncar_init_3D
endif

if (trim(ocn_data_type) == 'hycom' .or. &
trim(bgc_data_type) == 'hycom') then
if (trim(ocn_data_type) == 'hycom') then
call ocn_data_hycom_init
endif

Expand Down Expand Up @@ -623,22 +617,17 @@ subroutine get_forcing_ocn (dt)

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

if (trim(ocn_data_type) == 'clim' .or. &
trim(bgc_data_type) == 'clim') then
if (trim(ocn_data_type) == 'clim') then
call ocn_data_clim(dt)
elseif (trim(ocn_data_type) == 'ncar' .or. &
trim(bgc_data_type) == 'ncar'.or. &
trim(ocn_data_type) == 'ISPOL' .or. &
trim(bgc_data_type) == 'ISPOL') then
trim(ocn_data_type) == 'ISPOL') then
call ocn_data_ncar(dt)
elseif (trim(ocn_data_type) == 'hadgem_sst' .or. &
trim(ocn_data_type) == 'hadgem_sst_uvocn') then
call ocn_data_hadgem(dt)
elseif (trim(ocn_data_type) == 'oned' .or. &
trim(bgc_data_type) == 'oned') then
elseif (trim(ocn_data_type) == 'oned') then
call ocn_data_oned
elseif (trim(ocn_data_type) == 'hycom' .or. &
trim(bgc_data_type) == 'hycom') then
elseif (trim(ocn_data_type) == 'hycom') then
! call ocn_data_hycom(dt)
!MHRI: NOT IMPLEMENTED YET
endif
Expand Down Expand Up @@ -3190,12 +3179,10 @@ subroutine ocn_data_clim (dt)
character(len=*), parameter :: subname = '(ocn_data_clim)'

if (my_task == master_task .and. istep == 1) then
if (trim(bgc_data_type)=='clim') then
if (trim(ocn_data_type)=='clim') then
write (nu_diag,*) ' '
write (nu_diag,*) 'SSS data interpolated to timestep:'
write (nu_diag,*) trim(sss_file)
endif
if (trim(ocn_data_type)=='clim') then
write (nu_diag,*) ' '
write (nu_diag,*) 'SST data interpolated to timestep:'
write (nu_diag,*) trim(sst_file)
Expand All @@ -3211,8 +3198,7 @@ subroutine ocn_data_clim (dt)
! month.
!-------------------------------------------------------------------

if (trim(bgc_data_type)=='clim' .or. &
trim(ocn_data_type)=='clim') then
if (trim(ocn_data_type)=='clim') then

midmonth = 15 ! data is given on 15th of every month
!!! midmonth = fix(p5 * real(daymo(month))) ! exact middle
Expand All @@ -3238,14 +3224,11 @@ subroutine ocn_data_clim (dt)
readm = .false.
if (istep==1 .or. (mday==midmonth .and. sec==0)) readm = .true.

endif ! bgc/ocn_data_type

!-------------------------------------------------------------------
! Read two monthly SSS values and interpolate.
! Note: SSS is restored instantaneously to data.
!-------------------------------------------------------------------

if (trim(bgc_data_type)=='clim') then
call read_clim_data (readm, 0, ixm, month, ixp, &
sss_file, sss_data, &
field_loc_center, field_type_scalar)
Expand Down Expand Up @@ -4008,7 +3991,7 @@ subroutine ocn_data_hycom_init
character (char_len) :: &
fieldname ! field name in netcdf file

if (trim(bgc_data_type) == 'hycom') then
if (trim(ocn_data_type) == 'hycom') then
sss_file = trim(ocn_data_dir)//'ice.restart.surf.nc'

if (my_task == master_task) then
Expand All @@ -4023,9 +4006,7 @@ subroutine ocn_data_hycom_init
call ice_close_nc(fid)

call ocn_freezing_temperature
endif

if (trim(ocn_data_type) == 'hycom') then
sst_file = trim(ocn_data_dir)//'ice.restart.surf.nc'

if (my_task == master_task) then
Expand Down
105 changes: 51 additions & 54 deletions cicecore/cicedynB/general/ice_forcing_bgc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ module ice_forcing_bgc
use ice_calendar, only: dt, istep, sec, mday, month
use ice_fileunits, only: nu_diag
use ice_arrays_column, only: restore_bgc, &
bgc_data_dir, sil_data_type, nit_data_type, fe_data_type
bgc_data_dir, fe_data_type
use ice_constants, only: c0, p1
use ice_constants, only: field_loc_center, field_type_scalar
use ice_exit, only: abort_ice
use ice_forcing, only: bgc_data_type
use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
use icepack_intfc, only: icepack_nspint, icepack_max_aero, &
icepack_max_algae, icepack_max_doc, icepack_max_dic
Expand Down Expand Up @@ -84,18 +85,18 @@ subroutine get_forcing_bgc
read_data_nc_point, c1intp, c2intp

integer (kind=int_kind) :: &
i, j, iblk, & ! horizontal indices
ilo,ihi,jlo,jhi, & ! beginning and end of physical domain
ixm,ixp, ixx, & ! record numbers for neighboring months
maxrec , & ! maximum record number
recslot , & ! spline slot for current record
midmonth , & ! middle day of month
recnum , & ! record number
dataloc , & ! = 1 for data located in middle of time interval
! = 2 for date located at end of time interval
ks ! bgc tracer index (bio_index_o)

character (char_len_long) :: &
i, j, iblk , & ! horizontal indices
ilo,ihi,jlo,jhi, & ! beginning and end of physical domain
ixm,ixp, ixx , & ! record numbers for neighboring months
maxrec , & ! maximum record number
recslot , & ! spline slot for current record
midmonth , & ! middle day of month
recnum , & ! record number
dataloc , & ! = 1 for data located in middle of time interval
! = 2 for date located at end of time interval
ks ! bgc tracer index (bio_index_o)

character (char_len_long) :: &
met_file, & ! netcdf filename
fieldname ! field name in netcdf file

Expand Down Expand Up @@ -125,10 +126,7 @@ subroutine get_forcing_bgc
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)

if (.not. trim(nit_data_type)=='ISPOL' .AND. &
.not. trim(sil_data_type)=='ISPOL') then
if (trim(nit_data_type) == 'clim'.or. &
trim(sil_data_type) == 'clim') then
if (trim(bgc_data_type) == 'clim') then

nit_file = 'nitrate_climatologyWOA_gx1v6f_20150107.nc'
!'nitrate_WOA2005_surface_monthly' ! gx1 only
Expand All @@ -139,12 +137,12 @@ subroutine get_forcing_bgc
sil_file = trim(bgc_data_dir)//'/'//trim(sil_file)

if (my_task == master_task .and. istep == 1) then
if (trim(sil_data_type)=='clim' .AND. tr_bgc_Sil) then
if (tr_bgc_Sil) then
write (nu_diag,*) ' '
write (nu_diag,*) 'silicate data interpolated to timestep:'
write (nu_diag,*) trim(sil_file)
endif
if (trim(nit_data_type)=='clim' .AND. tr_bgc_Nit) then
if (tr_bgc_Nit) then
write (nu_diag,*) ' '
write (nu_diag,*) 'nitrate data interpolated to timestep:'
write (nu_diag,*) trim(nit_file)
Expand Down Expand Up @@ -184,14 +182,14 @@ subroutine get_forcing_bgc
readm = .false.
if (istep==1 .or. (mday==midmonth .and. sec==0)) readm = .true.

endif ! 'clim prep' sil/nit_data_type
endif ! 'clim prep'

!-------------------------------------------------------------------
! Read two monthly silicate values and interpolate.
! Restore toward interpolated value.
!-------------------------------------------------------------------

if (trim(sil_data_type)=='clim' .AND. tr_bgc_Sil) then
if (trim(bgc_data_type)=='clim' .AND. tr_bgc_Sil) then
! call read_clim_data (readm, 0, ixm, month, ixp, &
! sil_file, sil_data, &
! field_loc_center, field_type_scalar)
Expand Down Expand Up @@ -246,7 +244,7 @@ subroutine get_forcing_bgc
enddo
!$OMP END PARALLEL DO
endif !restore
elseif (tr_bgc_Sil) then
elseif (tr_bgc_Sil) then ! bgc_data_type /= 'clim'
!$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks

Expand All @@ -273,7 +271,7 @@ subroutine get_forcing_bgc
! Restore toward interpolated value.
!-------------------------------------------------------------------

if (trim(nit_data_type)=='clim' .AND. tr_bgc_Nit) then
if (trim(bgc_data_type)=='clim' .AND. tr_bgc_Nit) then
! call read_clim_data (readm, 0, ixm, month, ixp, &
! nit_file, nit_data, &
! field_loc_center, field_type_scalar)
Expand Down Expand Up @@ -330,30 +328,30 @@ subroutine get_forcing_bgc
!$OMP END PARALLEL DO
endif !restore_bgc

elseif (trim(nit_data_type) == 'sss' .AND. tr_bgc_Nit) then
!$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks

this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi

do j = jlo, jhi
do i = ilo, ihi

nit(i,j,iblk) = sss(i,j,iblk)
ks = icepack_max_algae + 1
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !nit
ks = 2*icepack_max_algae + icepack_max_doc + 7 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !PON
enddo
enddo
enddo
!$OMP END PARALLEL DO

elseif (tr_bgc_Nit) then
! elseif (trim(nit_data_type) == 'sss' .AND. tr_bgc_Nit) then
! !$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
! do iblk = 1, nblocks

! this_block = get_block(blocks_ice(iblk),iblk)
! ilo = this_block%ilo
! ihi = this_block%ihi
! jlo = this_block%jlo
! jhi = this_block%jhi

! do j = jlo, jhi
! do i = ilo, ihi

! nit(i,j,iblk) = sss(i,j,iblk)
! ks = icepack_max_algae + 1
! ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !nit
! ks = 2*icepack_max_algae + icepack_max_doc + 7 + icepack_max_dic
! ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !PON
! enddo
! enddo
! enddo
! !$OMP END PARALLEL DO

elseif (tr_bgc_Nit) then ! bgc_data_type /= 'clim'
!$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks

Expand Down Expand Up @@ -384,7 +382,7 @@ subroutine get_forcing_bgc
! daily data located at the end of the 24-hour period.
!-------------------------------------------------------------------

elseif (trim(nit_data_type) == 'ISPOL' .or. trim(sil_data_type) == 'ISPOL') then
if (trim(bgc_data_type) == 'ISPOL') then

nit_file = trim(bgc_data_dir)//'nutrients_daily_ISPOL_WOA_field3.nc'
sil_file = trim(bgc_data_dir)//'nutrients_daily_ISPOL_WOA_field3.nc'
Expand Down Expand Up @@ -426,24 +424,23 @@ subroutine get_forcing_bgc
if (tr_bgc_Sil) then
met_file = sil_file
fieldname= 'silicate'

call read_data_nc_point(read1, 0, fyear, ixm, ixx, ixp, &
maxrec, met_file, fieldname, sil_data_p, &
field_loc_center, field_type_scalar)

sil(:,:,:) = c1intp * sil_data_p(1) &
+ c2intp * sil_data_p(2)
sil(:,:,:) = c1intp * sil_data_p(1) &
+ c2intp * sil_data_p(2)
endif

if (tr_bgc_Nit) then
met_file = nit_file
fieldname= 'nitrate'

call read_data_nc_point(read1, 0, fyear, ixm, ixx, ixp, &
maxrec, met_file, fieldname, nit_data_p, &
field_loc_center, field_type_scalar)

nit(:,:,:) = c1intp * nit_data_p(1) &
+ c2intp * nit_data_p(2)
nit(:,:,:) = c1intp * nit_data_p(1) &
+ c2intp * nit_data_p(2)
endif

!$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
Expand Down
14 changes: 2 additions & 12 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ subroutine input_data
bgc_data_type, &
ocn_data_type, ocn_data_dir, &
oceanmixed_file, restore_ocn, trestore
use ice_arrays_column, only: bgc_data_dir, &
sil_data_type, nit_data_type, fe_data_type
use ice_arrays_column, only: bgc_data_dir, fe_data_type
use ice_grid, only: grid_file, gridcpl_file, kmt_file, &
bathymetry_file, use_bathymetry, &
grid_type, grid_format, &
Expand Down Expand Up @@ -189,8 +188,7 @@ subroutine input_data
fbot_xfer_type, update_ocn_f, l_mpond_fresh, tfrz_option, &
oceanmixed_ice, restore_ice, restore_ocn, trestore, &
precip_units, default_season, &
atm_data_type, ocn_data_type, bgc_data_type, &
sil_data_type, nit_data_type, fe_data_type, &
atm_data_type, ocn_data_type, bgc_data_type, fe_data_type, &
fyear_init, ycycle, &
atm_data_dir, ocn_data_dir, bgc_data_dir, &
atm_data_format, ocn_data_format, &
Expand Down Expand Up @@ -344,8 +342,6 @@ subroutine input_data
oceanmixed_ice = .false. ! if true, use internal ocean mixed layer
ocn_data_format = 'bin' ! file format ('bin'=binary or 'nc'=netcdf)
bgc_data_type = 'default'
sil_data_type = 'default'
nit_data_type = 'default'
fe_data_type = 'default'
bgc_data_dir = 'unknown_bgc_data_dir'
ocn_data_type = 'default'
Expand Down Expand Up @@ -599,8 +595,6 @@ subroutine input_data
call broadcast_scalar(tfrz_option, master_task)
call broadcast_scalar(ocn_data_format, master_task)
call broadcast_scalar(bgc_data_type, master_task)
call broadcast_scalar(sil_data_type, master_task)
call broadcast_scalar(nit_data_type, master_task)
call broadcast_scalar(fe_data_type, master_task)
call broadcast_scalar(bgc_data_dir, master_task)
call broadcast_scalar(ocn_data_type, master_task)
Expand Down Expand Up @@ -1087,10 +1081,6 @@ subroutine input_data
endif
write(nu_diag,*) ' bgc_data_type = ', &
trim(bgc_data_type)
write(nu_diag,*) ' sil_data_type = ', &
trim(sil_data_type)
write(nu_diag,*) ' nit_data_type = ', &
trim(nit_data_type)
write(nu_diag,*) ' fe_data_type = ', &
trim(fe_data_type)
write(nu_diag,*) ' bgc_data_dir = ', &
Expand Down
Loading

0 comments on commit 2946264

Please sign in to comment.