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

Added DMI/nuopc driver #377

Merged
merged 13 commits into from
Nov 22, 2019
Merged
6 changes: 4 additions & 2 deletions cicecore/cicedynB/infrastructure/ice_domain.F90
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ subroutine init_domain_blocks
call broadcast_scalar(maskhalo_bound, master_task)
if (my_task == master_task) then
if (max_blocks < 1) then
max_blocks=( ((nx_global-1)/block_size_x + 1) * &
((ny_global-1)/block_size_y + 1) ) / nprocs
max_blocks=int( &
( (dble(nx_global-1)/dble(block_size_x + 1)) * &
(dble(ny_global-1)/dble(block_size_y + 1)) ) &
/ dble(nprocs))
write(nu_diag,'(/,a52,i6,/)') &
'(ice_domain): max_block < 1: max_block estimated to ',max_blocks
endif
Expand Down
40 changes: 24 additions & 16 deletions cicecore/cicedynB/infrastructure/ice_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ subroutine init_grid2
real (kind=dbl_kind) :: &
angle_0, angle_w, angle_s, angle_sw, &
pi, pi2, puny

! real (kind=dbl_kind) :: ANGLET_dum
logical (kind=log_kind), dimension(nx_block,ny_block,max_blocks):: &
out_of_range

Expand Down Expand Up @@ -491,24 +491,32 @@ subroutine init_grid2
angle_w = ANGLE(i-1,j ,iblk) ! | |
angle_s = ANGLE(i, j-1,iblk) ! | |
angle_sw = ANGLE(i-1,j-1,iblk) ! sw---s

if ( angle_0 < c0 ) then
if ( abs(angle_w - angle_0) > pi) &
angle_w = angle_w - pi2
if ( abs(angle_s - angle_0) > pi) &
angle_s = angle_s - pi2
if ( abs(angle_sw - angle_0) > pi) &
angle_sw = angle_sw - pi2
endif

ANGLET(i,j,iblk) = angle_0 * p25 + angle_w * p25 &
+ angle_s * p25 + angle_sw* p25
enddo
enddo
ANGLET(i,j,iblk) = atan2(p25*(sin(angle_0)+ &
sin(angle_w)+ &
sin(angle_s)+ &
sin(angle_sw)),&
p25*(cos(angle_0)+ &
cos(angle_w)+ &
cos(angle_s)+ &
cos(angle_sw)))
! if ( angle_0 < c0 ) then
! if ( abs(angle_w - angle_0) > pi) &
! angle_w = angle_w - pi2
! if ( abs(angle_s - angle_0) > pi) &
! angle_s = angle_s - pi2
! if ( abs(angle_sw - angle_0) > pi) &
! angle_sw = angle_sw - pi2
! endif

! ANGLET_dum = angle_0 * p25 + angle_w * p25 &
! + angle_s * p25 + angle_sw* p25
! write(my_task+700,*) ANGLET_dum, ANGLET(i,j,iblk)
enddo
enddo
! call flush(my_task+700)
enddo
!$OMP END PARALLEL DO
endif ! cpom_grid

if (trim(grid_type) == 'regional') then
! for W boundary extrapolate from interior
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block)
Expand Down
97 changes: 97 additions & 0 deletions cicecore/drivers/nuopc/dmi/CICE.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
!=======================================================================
! Copyright (c) 2019, Triad National Security, LLC
! All rights reserved.
!
! Copyright 2019. Triad National Security, LLC. This software was
! produced under U.S. Government contract DE-AC52-06NA25396 for Los
! Alamos National Laboratory (LANL), which is operated by Triad
! National Security, LLC for the U.S. Department of Energy. The U.S.
! Government has rights to use, reproduce, and distribute this software.
! NEITHER THE GOVERNMENT NOR TRIAD NATIONAL SECURITY, LLC MAKES ANY
! WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF
! THIS SOFTWARE. If software is modified to produce derivative works,
! such modified software should be clearly marked, so as not to confuse
! it with the version available from LANL.
!
! The full license and distribution policy are available from
! https://github.com/CICE-Consortium
!
!=======================================================================
#ifndef popcice
!
! Main driver routine for CICE. Initializes and steps through the model.
! This program should be compiled if CICE is run as a separate executable,
! but not if CICE subroutines are called from another program (e.g., CAM).
!
! authors Elizabeth C. Hunke and William H. Lipscomb, LANL
!
! 2006: Converted to free form source (F90) by Elizabeth Hunke
! 2008: E. Hunke moved ESMF code to its own driver
!
program icemodel

use CICE_InitMod
use CICE_RunMod
use CICE_FinalMod

implicit none
character(len=*), parameter :: subname='(icemodel)'

!-----------------------------------------------------------------
! Initialize CICE
!-----------------------------------------------------------------

call CICE_Initialize

!-----------------------------------------------------------------
! Run CICE
!-----------------------------------------------------------------

call CICE_Run

!-----------------------------------------------------------------
! Finalize CICE
!-----------------------------------------------------------------

call CICE_Finalize

end program icemodel

#endif
!=======================================================================
!
! Wrapper for the print_state debugging routine.
! Useful for debugging in the main driver (see ice.F_debug)
! ip, jp, mtask are set in ice_diagnostics.F
!
! author Elizabeth C. Hunke, LANL
!
subroutine debug_ice(iblk, plabeld)

use ice_kinds_mod
use ice_calendar, only: istep1
use ice_communicate, only: my_task
use ice_diagnostics, only: check_step, iblkp, ip, jp, mtask, print_state
use ice_blocks, only: nx_block, ny_block

character (char_len), intent(in) :: plabeld
integer (kind=int_kind), intent(in) :: iblk

! local
integer (kind=int_kind) :: i, j
character(len=*), parameter :: subname='(debug_ice)'

if (istep1 >= check_step .and. &
iblk==iblkp .and. my_task==mtask) then

do j = 1, ny_block
do i = 1, nx_block
if (i==ip .and. j==jp) call print_state(plabeld,i,j,iblk)
enddo
enddo

endif

end subroutine debug_ice

!=======================================================================
104 changes: 104 additions & 0 deletions cicecore/drivers/nuopc/dmi/CICE_FinalMod.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
!=======================================================================
!
! This module contains routines for the final exit of the CICE model,
! including final output and clean exit from any message passing
! environments and frameworks.
!
! authors: Philip W. Jones, LANL
! 2006: Converted to free source form (F90) by Elizabeth Hunke
! 2008: E. Hunke moved ESMF code to its own driver

module CICE_FinalMod

use ice_kinds_mod
use ice_communicate, only: my_task, master_task
use ice_exit, only: end_run, abort_ice
use ice_fileunits, only: nu_diag, release_all_fileunits
use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted

implicit none
private
public :: CICE_Finalize

!=======================================================================

contains

!=======================================================================
!
! This routine shuts down CICE by exiting all relevent environments.

subroutine CICE_Finalize

use ice_restart_shared, only: runid
use ice_timers, only: ice_timer_stop, ice_timer_print_all, timer_total

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

!-------------------------------------------------------------------
! stop timers and print timer info
!-------------------------------------------------------------------

call ice_timer_stop(timer_total) ! stop timing entire run
call ice_timer_print_all(stats=.false.) ! print timing information

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

if (my_task == master_task) then
write(nu_diag, *) " "
write(nu_diag, *) "CICE COMPLETED SUCCESSFULLY "
write(nu_diag, *) " "
endif

!echmod if (nu_diag /= 6) close (nu_diag) ! diagnostic output
call release_all_fileunits

!-------------------------------------------------------------------
! write 'finished' file if needed
!-------------------------------------------------------------------

if (runid == 'bering') call writeout_finished_file()

!-------------------------------------------------------------------
! quit MPI
!-------------------------------------------------------------------

#ifndef coupled
#ifndef CICE_DMI
call end_run ! quit MPI
#endif
#endif
end subroutine CICE_Finalize

!=======================================================================
!
! Write a file indicating that this run finished cleanly. This is
! needed only for runs on machine 'bering' (set using runid = 'bering').
!
! author: Adrian Turner, LANL

subroutine writeout_finished_file()

use ice_restart_shared, only: restart_dir

character(len=char_len_long) :: filename
character(len=*), parameter :: subname = '(writeout_finished_file)'

if (my_task == master_task) then

filename = trim(restart_dir)//"finished"
open(11,file=filename)
write(11,*) "finished"
close(11)

endif

end subroutine writeout_finished_file

!=======================================================================

end module CICE_FinalMod

!=======================================================================
Loading