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

Changes to support NUOPC in CESM and OMP bug fixes. #478

Merged
merged 18 commits into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ subroutine input_data
ice_ic /= 'none' .and. ice_ic /= 'default') then
if (my_task == master_task) then
write(nu_diag,*) subname//' ERROR: runtype, restart, ice_ic are inconsistent:'
write(nu_diag,*) subname//' ERROR: runtype=',trim(runtype), 'restart=',restart, 'ice_ic=',trim(ice_ic)
write(nu_diag,*) subname//' ERROR: runtype=',trim(runtype), ' restart=',restart, ' ice_ic=',trim(ice_ic)
write(nu_diag,*) subname//' ERROR: Please review user guide'
endif
abort_list = trim(abort_list)//":1"
Expand Down
2 changes: 1 addition & 1 deletion cicecore/drivers/nuopc/cmeps/CICE_InitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ subroutine cice_init(mpicom_ice)
! coupler communication or forcing data initialization
!--------------------------------------------------------------------

#ifndef coupled
call init_forcing_atmo ! initialize atmospheric forcing (standalone)

#ifndef coupled
#ifndef CESMCOUPLED
if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice
call get_forcing_atmo ! atmospheric forcing from data
Expand Down
6 changes: 5 additions & 1 deletion cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
module CICE_RunMod

use ice_kinds_mod
#ifdef CESMCOUPLED
use perf_mod, only : t_startf, t_stopf, t_barrierf
#endif
use ice_fileunits, only: nu_diag
use ice_arrays_column, only: oceanmixed_ice
use ice_constants, only: c0, c1
Expand Down Expand Up @@ -207,12 +209,14 @@ subroutine ice_step
call init_history_bgc
call ice_timer_stop(timer_diags) ! diagnostics/history

#ifdef CESMCOUPLED
if (prescribed_ice) then ! read prescribed ice
call t_barrierf('cice_run_presc_BARRIER',MPI_COMM_ICE)
call t_startf ('cice_run_presc')
call ice_prescribed_run(idate, sec)
call t_stopf ('cice_run_presc')
endif
#endif

call save_init

Expand Down Expand Up @@ -374,7 +378,7 @@ subroutine coupling_prep (iblk)
fsens, flat, fswabs, flwout, evap, Tref, Qref, &
scale_fluxes, frzmlt_init, frzmlt, Uref, wind
use ice_flux_bgc, only: faero_ocn, fiso_ocn, Qref_iso, fiso_evap, &
fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai
fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai, &
fnit, fsil, famm, fdmsp, fdms, fhum, fdust, falgalN, &
fdoc, fdic, fdon, ffep, ffed, bgcflux_ice_to_ocn
use ice_grid, only: tmask
Expand Down
412 changes: 328 additions & 84 deletions cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90

Large diffs are not rendered by default.

204 changes: 143 additions & 61 deletions cicecore/drivers/nuopc/cmeps/ice_import_export.F90

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions cicecore/drivers/nuopc/cmeps/ice_prescribed_mod.F90
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
module ice_prescribed_mod

#ifdef CESMCOUPLED
#ifndef CESMCOUPLED

use ice_kinds_mod

implicit none
private ! except

logical(kind=log_kind), parameter, public :: prescribed_ice = .false. ! true if prescribed ice

#else

! !DESCRIPTION:
! The prescribed ice model reads in ice concentration data from a netCDF
Expand Down Expand Up @@ -49,7 +58,7 @@ module ice_prescribed_mod
! !PUBLIC DATA MEMBERS:
logical(kind=log_kind), public :: prescribed_ice ! true if prescribed ice

integer(SHR_KIND_IN),parameter :: nFilesMaximum = 400 ! max number of files
integer(kind=int_kind),parameter :: nFilesMaximum = 400 ! max number of files
integer(kind=int_kind) :: stream_year_first ! first year in stream to use
integer(kind=int_kind) :: stream_year_last ! last year in stream to use
integer(kind=int_kind) :: model_year_align ! align stream_year_first
Expand Down
80 changes: 43 additions & 37 deletions cicecore/drivers/nuopc/cmeps/ice_shr_methods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ module ice_shr_methods
use ESMF , only : ESMF_VM, ESMF_VMGet, ESMF_VMBroadcast, ESMF_VMGetCurrent
use NUOPC , only : NUOPC_CompAttributeGet
use NUOPC_Model , only : NUOPC_ModelGet
use shr_kind_mod , only : r8 => shr_kind_r8, cl=>shr_kind_cl, cs=>shr_kind_cs
use shr_sys_mod , only : shr_sys_abort
use ice_kinds_mod, only : r8 => dbl_kind, cl=>char_len_long, cs=>char_len
use ice_exit , only : abort_ice
#ifdef CESMCOUPLED
use shr_file_mod , only : shr_file_setlogunit, shr_file_getLogUnit
#endif

implicit none
private
Expand Down Expand Up @@ -89,9 +91,11 @@ subroutine memcheck(string, level, mastertask)
character(len=*), parameter :: subname='(memcheck)'
!-----------------------------------------------------------------------

#ifdef CESMCOUPLED
if ((mastertask .and. memdebug_level > level) .or. memdebug_level > level+1) then
ierr = GPTLprint_memusage(string)
endif
#endif

end subroutine memcheck

Expand Down Expand Up @@ -160,7 +164,9 @@ subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc)
logUnit = 6
endif

#ifdef CESMCOUPLED
call shr_file_setLogUnit (logunit)
#endif

end subroutine set_component_logging

Expand Down Expand Up @@ -710,10 +716,10 @@ subroutine alarmInit( clock, alarm, option, &

case (optDate)
if (.not. present(opt_ymd)) then
call shr_sys_abort(subname//trim(option)//' requires opt_ymd')
call abort_ice(subname//trim(option)//' requires opt_ymd')
end if
if (lymd < 0 .or. ltod < 0) then
call shr_sys_abort(subname//trim(option)//'opt_ymd, opt_tod invalid')
call abort_ice(subname//trim(option)//'opt_ymd, opt_tod invalid')
end if
call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -723,13 +729,13 @@ subroutine alarmInit( clock, alarm, option, &

case (optIfdays0)
if (.not. present(opt_ymd)) then
call shr_sys_abort(subname//trim(option)//' requires opt_ymd')
call abort_ice(subname//trim(option)//' requires opt_ymd')
end if
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -739,30 +745,30 @@ subroutine alarmInit( clock, alarm, option, &

case (optNSteps)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
AlarmInterval = AlarmInterval * opt_n
update_nextalarm = .true.

case (optNStep)
if (.not.present(opt_n)) call shr_sys_abort(subname//trim(option)//' requires opt_n')
if (opt_n <= 0) call shr_sys_abort(subname//trim(option)//' invalid opt_n')
if (.not.present(opt_n)) call abort_ice(subname//trim(option)//' requires opt_n')
if (opt_n <= 0) call abort_ice(subname//trim(option)//' invalid opt_n')
call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
AlarmInterval = AlarmInterval * opt_n
update_nextalarm = .true.

case (optNSeconds)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -771,10 +777,10 @@ subroutine alarmInit( clock, alarm, option, &

case (optNSecond)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -784,20 +790,20 @@ subroutine alarmInit( clock, alarm, option, &
case (optNMinutes)
call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
AlarmInterval = AlarmInterval * opt_n
update_nextalarm = .true.

case (optNMinute)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -806,10 +812,10 @@ subroutine alarmInit( clock, alarm, option, &

case (optNHours)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -818,10 +824,10 @@ subroutine alarmInit( clock, alarm, option, &

case (optNHour)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -830,10 +836,10 @@ subroutine alarmInit( clock, alarm, option, &

case (optNDays)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -842,10 +848,10 @@ subroutine alarmInit( clock, alarm, option, &

case (optNDay)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -854,10 +860,10 @@ subroutine alarmInit( clock, alarm, option, &

case (optNMonths)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -866,10 +872,10 @@ subroutine alarmInit( clock, alarm, option, &

case (optNMonth)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -885,10 +891,10 @@ subroutine alarmInit( clock, alarm, option, &

case (optNYears)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -897,10 +903,10 @@ subroutine alarmInit( clock, alarm, option, &

case (optNYear)
if (.not.present(opt_n)) then
call shr_sys_abort(subname//trim(option)//' requires opt_n')
call abort_ice(subname//trim(option)//' requires opt_n')
end if
if (opt_n <= 0) then
call shr_sys_abort(subname//trim(option)//' invalid opt_n')
call abort_ice(subname//trim(option)//' invalid opt_n')
end if
call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -915,7 +921,7 @@ subroutine alarmInit( clock, alarm, option, &
update_nextalarm = .true.

case default
call shr_sys_abort(subname//'unknown option '//trim(option))
call abort_ice(subname//'unknown option '//trim(option))

end select

Expand Down Expand Up @@ -964,7 +970,7 @@ subroutine timeInit( Time, ymd, cal, tod, rc)
rc = ESMF_SUCCESS

if ( (ymd < 0) .or. (tod < 0) .or. (tod > SecPerDay) )then
call shr_sys_abort( subname//'ERROR yymmdd is a negative number or time-of-day out of bounds' )
call abort_ice( subname//'ERROR yymmdd is a negative number or time-of-day out of bounds' )
end if

tdate = abs(date)
Expand Down
8 changes: 6 additions & 2 deletions cicecore/shared/ice_init_column.F90
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ subroutine init_bgc()

if (solve_zsal) then ! default values

!$OMP PARALLEL DO PRIVATE(iblk,i,j,n,ilo,ihi,jlo,jhi,this_block)
!$OMP PARALLEL DO PRIVATE(iblk,i,j,k,n,ilo,ihi,jlo,jhi,this_block,trcrn_bgc)
do iblk = 1, nblocks

this_block = get_block(blocks_ice(iblk),iblk)
Expand Down Expand Up @@ -816,6 +816,7 @@ subroutine init_bgc()
enddo ! i
enddo ! j
enddo ! iblk
!$OMP END PARALLEL DO
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
Expand Down Expand Up @@ -855,6 +856,7 @@ subroutine init_bgc()
enddo ! j

enddo ! iblk
!$OMP END PARALLEL DO

call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
Expand All @@ -865,7 +867,7 @@ subroutine init_bgc()

endif ! .not. restart

!$OMP PARALLEL DO PRIVATE(iblk,i,j,n,ilo,ihi,jlo,jhi,this_block)
!$OMP PARALLEL DO PRIVATE(iblk,i,j,k,n,ilo,ihi,jlo,jhi,this_block,sicen,trcrn_bgc)
do iblk = 1, nblocks

this_block = get_block(blocks_ice(iblk),iblk)
Expand Down Expand Up @@ -900,6 +902,7 @@ subroutine init_bgc()
enddo ! j

enddo ! iblk
!$OMP END PARALLEL DO

call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
Expand All @@ -925,6 +928,7 @@ subroutine init_bgc()
enddo ! i
enddo ! j
enddo ! iblk
!$OMP END PARALLEL DO

call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
Expand Down
Loading