From 6abee604fc464a58316b5ec4c89140b2ba205952 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Tue, 16 Mar 2021 13:41:44 -0600 Subject: [PATCH 01/10] Fix reading of SOM forcing file. --- cicecore/cicedynB/general/ice_forcing.F90 | 25 ++++++++------- .../infrastructure/ice_read_write.F90 | 31 ++++++++++++------- .../drivers/standalone/cice/CICE_InitMod.F90 | 2 +- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/cicecore/cicedynB/general/ice_forcing.F90 b/cicecore/cicedynB/general/ice_forcing.F90 index edbba8101..dec892fe0 100644 --- a/cicecore/cicedynB/general/ice_forcing.F90 +++ b/cicecore/cicedynB/general/ice_forcing.F90 @@ -469,8 +469,8 @@ subroutine init_forcing_ocn(dt) endif ! ocn_data_type if (trim(ocn_data_type) == 'ncar') then -! call ocn_data_ncar_init - call ocn_data_ncar_init_3D + call ocn_data_ncar_init +! call ocn_data_ncar_init_3D endif if (trim(ocn_data_type) == 'hycom') then @@ -3722,13 +3722,14 @@ subroutine ocn_data_ncar_init do m=1,12 ! Note: netCDF does single to double conversion if necessary - if (n >= 4 .and. n <= 7) then - call ice_read_nc(fid, m, vname(n), work1, dbug, & - field_loc_NEcorner, field_type_vector) - else - call ice_read_nc(fid, m, vname(n), work1, dbug, & +! if (n >= 4 .and. n <= 7) then +! call ice_read_nc(fid, m, vname(n), work1, dbug, & +! field_loc_NEcorner, field_type_vector) +! else + call ice_read_nc(fid, m, vname(n), work1, .true., & field_loc_center, field_type_scalar) - endif +! endif + ocn_frc_m(:,:,:,n,m) = work1(:,:,:) enddo ! month loop @@ -3764,8 +3765,8 @@ subroutine ocn_data_ncar_init endif !echmod - currents cause Fram outflow to be too large - ocn_frc_m(:,:,:,4,:) = c0 - ocn_frc_m(:,:,:,5,:) = c0 +! ocn_frc_m(:,:,:,4,:) = c0 +! ocn_frc_m(:,:,:,5,:) = c0 !echmod end subroutine ocn_data_ncar_init @@ -3995,8 +3996,8 @@ subroutine ocn_data_ncar(dt) ! Find interpolation coefficients call interp_coeff_monthly (recslot) + sst_data(:,:,:,:) = c0 do n = nfld, 1, -1 - !$OMP PARALLEL DO PRIVATE(iblk,i,j) do iblk = 1, nblocks ! use sst_data arrays as temporary work space until n=1 if (ixm /= -99) then ! first half of month @@ -4007,7 +4008,6 @@ subroutine ocn_data_ncar(dt) sst_data(:,:,2,iblk) = ocn_frc_m(:,:,iblk,n,ixp) endif enddo - !$OMP END PARALLEL DO call interpolate_data (sst_data,work1) ! masking by hm is necessary due to NaNs in the data file @@ -4071,6 +4071,7 @@ subroutine ocn_data_ncar(dt) !$OMP END PARALLEL DO endif + dbug = .true. if (dbug) then if (my_task == master_task) & write (nu_diag,*) 'ocn_data_ncar' diff --git a/cicecore/cicedynB/infrastructure/ice_read_write.F90 b/cicecore/cicedynB/infrastructure/ice_read_write.F90 index 87d0813cc..d902c62f8 100644 --- a/cicecore/cicedynB/infrastructure/ice_read_write.F90 +++ b/cicecore/cicedynB/infrastructure/ice_read_write.F90 @@ -1116,6 +1116,7 @@ subroutine ice_read_nc_xy(fid, nrec, varname, work, diag, & ! dimlen ! dimension size real (kind=dbl_kind) :: & + missingvalue, & amin, amax, asum ! min, max values and sum of input array ! character (char_len) :: & @@ -1141,6 +1142,8 @@ subroutine ice_read_nc_xy(fid, nrec, varname, work, diag, & nx = nx_global ny = ny_global + work = c0 ! to satisfy intent(out) attribute + if (present(restart_ext)) then if (restart_ext) then nx = nx_global + 2*nghost @@ -1181,6 +1184,7 @@ subroutine ice_read_nc_xy(fid, nrec, varname, work, diag, & count=(/nx,ny,1/) ) endif + status = nf90_get_att(fid, varid, "_FillValue", missingvalue) endif ! my_task = master_task !------------------------------------------------------------------- @@ -1188,9 +1192,9 @@ subroutine ice_read_nc_xy(fid, nrec, varname, work, diag, & !------------------------------------------------------------------- if (my_task==master_task .and. diag) then -! write(nu_diag,*) & -! 'ice_read_nc_xy, fid= ',fid, ', nrec = ',nrec, & -! ', varname = ',trim(varname) + write(nu_diag,*) & + 'ice_read_nc_xy, fid= ',fid, ', nrec = ',nrec, & + ', varname = ',trim(varname) ! status = nf90_inquire(fid, nDimensions=ndim, nVariables=nvar) ! write(nu_diag,*) 'ndim= ',ndim,', nvar= ',nvar ! do id=1,ndim @@ -1198,8 +1202,8 @@ subroutine ice_read_nc_xy(fid, nrec, varname, work, diag, & ! write(nu_diag,*) 'Dim name = ',trim(dimname),', size = ',dimlen ! enddo amin = minval(work_g1) - amax = maxval(work_g1, mask = work_g1 /= spval_dbl) - asum = sum (work_g1, mask = work_g1 /= spval_dbl) + amax = maxval(work_g1, mask = work_g1 /= missingvalue) + asum = sum (work_g1, mask = work_g1 /= missingvalue) write(nu_diag,*) ' min, max, sum =', amin, amax, asum, trim(varname) endif @@ -1223,12 +1227,15 @@ subroutine ice_read_nc_xy(fid, nrec, varname, work, diag, & endif deallocate(work_g1) + +! echmod: this should not be necessary if fill/missing are only on land + where (work > 1.0e+30_dbl_kind) work = c0 + if (orca_halogrid .and. .not. present(restart_ext)) deallocate(work_g2) #else call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined', & file=__FILE__, line=__LINE__) - work = c0 ! to satisfy intent(out) attribute #endif end subroutine ice_read_nc_xy @@ -1282,6 +1289,7 @@ subroutine ice_read_nc_xyz(fid, nrec, varname, work, diag, & ! dimlen ! size of dimension real (kind=dbl_kind) :: & + missingvalue, & ! missing value amin, amax, asum ! min, max values and sum of input array ! character (char_len) :: & @@ -1347,6 +1355,7 @@ subroutine ice_read_nc_xyz(fid, nrec, varname, work, diag, & count=(/nx,ny,ncat,1/) ) endif + status = nf90_get_att(fid, varid, "_FillValue", missingvalue) endif ! my_task = master_task !------------------------------------------------------------------- @@ -1354,9 +1363,9 @@ subroutine ice_read_nc_xyz(fid, nrec, varname, work, diag, & !------------------------------------------------------------------- if (my_task==master_task .and. diag) then -! write(nu_diag,*) & -! 'ice_read_nc_xyz, fid= ',fid, ', nrec = ',nrec, & -! ', varname = ',trim(varname) + write(nu_diag,*) & + 'ice_read_nc_xyz, fid= ',fid, ', nrec = ',nrec, & + ', varname = ',trim(varname) ! status = nf90_inquire(fid, nDimensions=ndim, nVariables=nvar) ! write(nu_diag,*) 'ndim= ',ndim,', nvar= ',nvar ! do id=1,ndim @@ -1365,8 +1374,8 @@ subroutine ice_read_nc_xyz(fid, nrec, varname, work, diag, & ! enddo do n=1,ncat amin = minval(work_g1(:,:,n)) - amax = maxval(work_g1(:,:,n), mask = work_g1(:,:,n) /= spval_dbl) - asum = sum (work_g1(:,:,n), mask = work_g1(:,:,n) /= spval_dbl) + amax = maxval(work_g1(:,:,n), mask = work_g1(:,:,n) /= missingvalue) + asum = sum (work_g1(:,:,n), mask = work_g1(:,:,n) /= missingvalue) write(nu_diag,*) ' min, max, sum =', amin, amax, asum, trim(varname) enddo endif diff --git a/cicecore/drivers/standalone/cice/CICE_InitMod.F90 b/cicecore/drivers/standalone/cice/CICE_InitMod.F90 index 8b507740d..3f362ea92 100644 --- a/cicecore/drivers/standalone/cice/CICE_InitMod.F90 +++ b/cicecore/drivers/standalone/cice/CICE_InitMod.F90 @@ -158,7 +158,6 @@ subroutine cice_init ! call calendar(time) ! determine the initial date - call init_forcing_ocn(dt) ! initialize sss and sst from data call init_state ! initialize the ice state call init_transport ! initialize horizontal transport call ice_HaloRestore_init ! restored boundary conditions @@ -201,6 +200,7 @@ subroutine cice_init !-------------------------------------------------------------------- call init_forcing_atmo ! initialize atmospheric forcing (standalone) + call init_forcing_ocn(dt) ! initialize sss and sst from data if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice call get_forcing_atmo ! atmospheric forcing from data From 5f82dde64e7157733e35ef9231e0607e2d684d9a Mon Sep 17 00:00:00 2001 From: David Bailey Date: Tue, 16 Mar 2021 13:50:50 -0600 Subject: [PATCH 02/10] Remove some debugging --- cicecore/cicedynB/general/ice_forcing.F90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cicecore/cicedynB/general/ice_forcing.F90 b/cicecore/cicedynB/general/ice_forcing.F90 index dec892fe0..115925e47 100644 --- a/cicecore/cicedynB/general/ice_forcing.F90 +++ b/cicecore/cicedynB/general/ice_forcing.F90 @@ -3726,7 +3726,7 @@ subroutine ocn_data_ncar_init ! call ice_read_nc(fid, m, vname(n), work1, dbug, & ! field_loc_NEcorner, field_type_vector) ! else - call ice_read_nc(fid, m, vname(n), work1, .true., & + call ice_read_nc(fid, m, vname(n), work1, dbug, & field_loc_center, field_type_scalar) ! endif @@ -4071,7 +4071,6 @@ subroutine ocn_data_ncar(dt) !$OMP END PARALLEL DO endif - dbug = .true. if (dbug) then if (my_task == master_task) & write (nu_diag,*) 'ocn_data_ncar' From 3d327cabb3d3c8986c060bd7f6e28ace59786149 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Tue, 16 Mar 2021 15:58:00 -0600 Subject: [PATCH 03/10] Add oceanmixed_ice test case. --- configuration/scripts/options/set_nml.ml | 7 +++++++ configuration/scripts/tests/base_suite.ts | 1 + 2 files changed, 8 insertions(+) create mode 100644 configuration/scripts/options/set_nml.ml diff --git a/configuration/scripts/options/set_nml.ml b/configuration/scripts/options/set_nml.ml new file mode 100644 index 000000000..005e7b657 --- /dev/null +++ b/configuration/scripts/options/set_nml.ml @@ -0,0 +1,7 @@ + +oceanmixed_ice = .true. +ocn_data_type = 'ncar' +ocn_data_format = 'nc' +ocn_data_dir = '/glade/p/cesm/pcwg_dev/CICE_data/forcing/gx1' +oceanmixed_file = 'pop_frc.gx1.nc' + diff --git a/configuration/scripts/tests/base_suite.ts b/configuration/scripts/tests/base_suite.ts index 1ed489730..03389359a 100755 --- a/configuration/scripts/tests/base_suite.ts +++ b/configuration/scripts/tests/base_suite.ts @@ -39,6 +39,7 @@ restart gx1 8x1 bgczclim,medium smoke gx1 24x1 medium,run90day,yi2008 smoke gx3 8x1 medium,run90day,yi2008 restart gx1 24x1 short +restart gx1 24x1 short,ml restart gx3 8x1 short smoke gx3 4x2 fsd1,diag24,run5day,debug smoke gx3 8x2 fsd12,diag24,run5day,short From fc4b9c27ad60eccb83687d9ea87a83931c482dcd Mon Sep 17 00:00:00 2001 From: David Bailey Date: Wed, 17 Mar 2021 09:32:40 -0600 Subject: [PATCH 04/10] Move alloc_forcing call --- cicecore/cicedynB/general/ice_forcing.F90 | 13 ++++++------- cicecore/drivers/standalone/cice/CICE_InitMod.F90 | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cicecore/cicedynB/general/ice_forcing.F90 b/cicecore/cicedynB/general/ice_forcing.F90 index 115925e47..5a1011687 100644 --- a/cicecore/cicedynB/general/ice_forcing.F90 +++ b/cicecore/cicedynB/general/ice_forcing.F90 @@ -223,9 +223,6 @@ subroutine init_forcing_atmo character(len=*), parameter :: subname = '(init_forcing_atmo)' - ! Allocate forcing arrays - call alloc_forcing() - fyear = fyear_init + mod(nyr-1,ycycle) ! current year fyear_final = fyear_init + ycycle - 1 ! last year in forcing cycle @@ -332,10 +329,12 @@ subroutine init_forcing_ocn(dt) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) -! sst_data(:,:,:,:) = c0 -! sss_data(:,:,:,:) = c0 -! uocn_data(:,:,:,:) = c0 -! vocn_data(:,:,:,:) = c0 + call alloc_forcing() + + sst_data(:,:,:,:) = c0 + sss_data(:,:,:,:) = c0 + uocn_data(:,:,:,:) = c0 + vocn_data(:,:,:,:) = c0 nbits = 64 ! double precision data diff --git a/cicecore/drivers/standalone/cice/CICE_InitMod.F90 b/cicecore/drivers/standalone/cice/CICE_InitMod.F90 index 3f362ea92..ac6726ca2 100644 --- a/cicecore/drivers/standalone/cice/CICE_InitMod.F90 +++ b/cicecore/drivers/standalone/cice/CICE_InitMod.F90 @@ -156,8 +156,10 @@ subroutine cice_init if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) + ! call calendar(time) ! determine the initial date + call init_forcing_ocn(dt) ! initialize sss and sst from data call init_state ! initialize the ice state call init_transport ! initialize horizontal transport call ice_HaloRestore_init ! restored boundary conditions @@ -200,7 +202,6 @@ subroutine cice_init !-------------------------------------------------------------------- call init_forcing_atmo ! initialize atmospheric forcing (standalone) - call init_forcing_ocn(dt) ! initialize sss and sst from data if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice call get_forcing_atmo ! atmospheric forcing from data From 7b6ed7e941a8c204382e78ba923db785370e6703 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Wed, 17 Mar 2021 09:35:37 -0600 Subject: [PATCH 05/10] Add ICE_MACHINE_INPUTDATA to set_nml.ml --- configuration/scripts/options/set_nml.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/scripts/options/set_nml.ml b/configuration/scripts/options/set_nml.ml index 005e7b657..316456a8f 100644 --- a/configuration/scripts/options/set_nml.ml +++ b/configuration/scripts/options/set_nml.ml @@ -2,6 +2,6 @@ oceanmixed_ice = .true. ocn_data_type = 'ncar' ocn_data_format = 'nc' -ocn_data_dir = '/glade/p/cesm/pcwg_dev/CICE_data/forcing/gx1' +ocn_data_dir = 'ICE_MACHINE_INPUTDATA/CICE_data/forcing/gx1' oceanmixed_file = 'pop_frc.gx1.nc' From a732acb8cb775b5145ef08100c8c448658a0cfaa Mon Sep 17 00:00:00 2001 From: David Bailey Date: Wed, 17 Mar 2021 09:44:36 -0600 Subject: [PATCH 06/10] Actually fix conflicts --- cicecore/cicedynB/general/ice_forcing.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cicecore/cicedynB/general/ice_forcing.F90 b/cicecore/cicedynB/general/ice_forcing.F90 index d5404869e..1981baaf9 100644 --- a/cicecore/cicedynB/general/ice_forcing.F90 +++ b/cicecore/cicedynB/general/ice_forcing.F90 @@ -232,9 +232,9 @@ subroutine init_forcing_atmo integer (kind=int_kind) :: modadj ! adjustment for mod function character(len=*), parameter :: subname = '(init_forcing_atmo)' - ! Allocate forcing arrays - call alloc_forcing() + if (forcing_debug .and. my_task == master_task) write(nu_diag,*) subname,'fdbg start' + modadj = abs((min(0,myear-fyear_init)/ycycle+1)*ycycle) fyear = fyear_init + mod(nyr-1,ycycle) ! current year fyear_final = fyear_init + ycycle - 1 ! last year in forcing cycle From c950718eeb571f04d3f1360a460113a15ce43fda Mon Sep 17 00:00:00 2001 From: David Bailey Date: Wed, 17 Mar 2021 09:45:59 -0600 Subject: [PATCH 07/10] Actually fix conflicts --- cicecore/cicedynB/general/ice_forcing.F90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cicecore/cicedynB/general/ice_forcing.F90 b/cicecore/cicedynB/general/ice_forcing.F90 index 1981baaf9..a88492810 100644 --- a/cicecore/cicedynB/general/ice_forcing.F90 +++ b/cicecore/cicedynB/general/ice_forcing.F90 @@ -235,7 +235,7 @@ subroutine init_forcing_atmo if (forcing_debug .and. my_task == master_task) write(nu_diag,*) subname,'fdbg start' modadj = abs((min(0,myear-fyear_init)/ycycle+1)*ycycle) - fyear = fyear_init + mod(nyr-1,ycycle) ! current year + fyear = fyear_init + mod(myear-fyear_init+modadj,ycycle) fyear_final = fyear_init + ycycle - 1 ! last year in forcing cycle if (forcing_debug .and. my_task == master_task) then @@ -567,7 +567,6 @@ subroutine get_forcing_atmo call ice_timer_start(timer_forcing) fyear_old = fyear - modadj = abs((min(0,myear-fyear_init)/ycycle+1)*ycycle) fyear = fyear_init + mod(myear-fyear_init+modadj,ycycle) if (trim(atm_data_type) /= 'default' .and. & (istep <= 1 .or. fyear /= fyear_old)) then From ddae42b6342051272ee16ac242fe07ab617b1b3c Mon Sep 17 00:00:00 2001 From: David Bailey Date: Wed, 17 Mar 2021 09:46:37 -0600 Subject: [PATCH 08/10] Actually fix conflicts --- cicecore/cicedynB/general/ice_forcing.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cicecore/cicedynB/general/ice_forcing.F90 b/cicecore/cicedynB/general/ice_forcing.F90 index a88492810..936ec9a14 100644 --- a/cicecore/cicedynB/general/ice_forcing.F90 +++ b/cicecore/cicedynB/general/ice_forcing.F90 @@ -235,7 +235,7 @@ subroutine init_forcing_atmo if (forcing_debug .and. my_task == master_task) write(nu_diag,*) subname,'fdbg start' modadj = abs((min(0,myear-fyear_init)/ycycle+1)*ycycle) - fyear = fyear_init + mod(myear-fyear_init+modadj,ycycle) + fyear = fyear_init + mod(myear-fyear_init+modadj,ycycle) fyear_final = fyear_init + ycycle - 1 ! last year in forcing cycle if (forcing_debug .and. my_task == master_task) then From f44f96701ebf8585454c9a2afda114be67181fb1 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Wed, 17 Mar 2021 09:48:50 -0600 Subject: [PATCH 09/10] Actually fix conflicts --- cicecore/cicedynB/general/ice_forcing.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/cicecore/cicedynB/general/ice_forcing.F90 b/cicecore/cicedynB/general/ice_forcing.F90 index 936ec9a14..9c8688763 100644 --- a/cicecore/cicedynB/general/ice_forcing.F90 +++ b/cicecore/cicedynB/general/ice_forcing.F90 @@ -567,6 +567,7 @@ subroutine get_forcing_atmo call ice_timer_start(timer_forcing) fyear_old = fyear + modadj = abs((min(0,myear-fyear_init)/ycycle+1)*ycycle) fyear = fyear_init + mod(myear-fyear_init+modadj,ycycle) if (trim(atm_data_type) /= 'default' .and. & (istep <= 1 .or. fyear /= fyear_old)) then From 643bc28f1fe8e17addfdb765730ee93e58fd15c5 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Wed, 24 Mar 2021 12:17:01 -0600 Subject: [PATCH 10/10] Update filename and location for ocean forcing --- configuration/scripts/options/set_nml.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration/scripts/options/set_nml.ml b/configuration/scripts/options/set_nml.ml index 316456a8f..57a148fd1 100644 --- a/configuration/scripts/options/set_nml.ml +++ b/configuration/scripts/options/set_nml.ml @@ -2,6 +2,6 @@ oceanmixed_ice = .true. ocn_data_type = 'ncar' ocn_data_format = 'nc' -ocn_data_dir = 'ICE_MACHINE_INPUTDATA/CICE_data/forcing/gx1' -oceanmixed_file = 'pop_frc.gx1.nc' +ocn_data_dir = 'ICE_MACHINE_INPUTDATA/CICE_data/forcing/gx1/CESM/MONTHLY' +oceanmixed_file = 'ocean_forcing_clim_2D_gx1.nc'