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

Coupled #4

Merged
merged 4 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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