Skip to content

Commit

Permalink
fix the icepack netcdf restart, add additional restart variables, now…
Browse files Browse the repository at this point in the history
… also the restart is volume conserving. Also only write eiter .ice. or .icepack. restart files
  • Loading branch information
patrickscholz committed Oct 18, 2024
1 parent dbb76f8 commit 4a5d97d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 35 deletions.
22 changes: 11 additions & 11 deletions src/ice_oce_coupling.F90
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,17 @@ subroutine oce_fluxes(ice, dynamics, tracers, partit, mesh)
!
#if defined (__icepack)

call icepack_to_fesom (nx_in=(myDim_nod2D+eDim_nod2D), &
aice_out=a_ice, &
vice_out=m_ice, &
vsno_out=m_snow, &
fhocn_tot_out=net_heat_flux, &
fresh_tot_out=fresh_wa_flux, &
fsalt_out=real_salt_flux, &
dhs_dt_out=thdgrsn, &
dhi_dt_out=thdgr, &
evap_ocn_out=evaporation, &
evap_out=ice_sublimation )
call icepack_to_fesom (nx_in = (myDim_nod2D+eDim_nod2D), &
aice_out = a_ice, &
vice_out = m_ice, &
vsno_out = m_snow, &
fhocn_tot_out = net_heat_flux, &
fresh_tot_out = fresh_wa_flux, &
fsalt_out = real_salt_flux, &
dhs_dt_out = thdgrsn, &
dhi_dt_out = thdgr, &
evap_ocn_out = evaporation, &
evap_out = ice_sublimation )

!$OMP PARALLEL DO
do n=1, myDim_nod2d+eDim_nod2d
Expand Down
14 changes: 9 additions & 5 deletions src/icepack_drivers/icedrv_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,6 @@ module subroutine ini_icepack_io(year, partit, mesh)
#include "associate_mesh.h"

! Get the tracers information from icepack
call icepack_query_tracer_indices(nt_Tsfc_out=nt_Tsfc, nt_sice_out=nt_sice, &
nt_qice_out=nt_qice, nt_qsno_out=nt_qsno)
call icepack_query_tracer_indices( &
nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, &
nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, nt_Tsfc_out=nt_Tsfc, &
Expand Down Expand Up @@ -369,10 +367,16 @@ module subroutine ini_icepack_io(year, partit, mesh)
!-----------------------------------------------------------------
! 3D restart fields (ncat)
!-----------------------------------------------------------------
call icepack_files%def_node_var('aicen' , 'sea ice concentration' , 'none', aicen(:,:) , mesh, partit, ncat)
call icepack_files%def_node_var('vicen' , 'volum per unit area of ice' , 'm' , vicen(:,:) , mesh, partit, ncat)
call icepack_files%def_node_var('vsnon' , 'volum per unit area of snow' , 'm' , vsnon(:,:) , mesh, partit, ncat)
call icepack_files%def_node_var('aice' , 'sea ice concentration' , 'none', aice(:) , mesh, partit)
call icepack_files%def_node_var('vice' , 'volum per unit area of ice' , 'm' , vice(:) , mesh, partit)
call icepack_files%def_node_var('vsno' , 'volum per unit area of snow' , 'm' , vsno(:) , mesh, partit)

call icepack_files%def_node_var('aicen' , 'sea ice concentration per class' , 'none', aicen(:,:) , mesh, partit, ncat)
call icepack_files%def_node_var('vicen' , 'volum per unit area of ice per class' , 'm' , vicen(:,:) , mesh, partit, ncat)
call icepack_files%def_node_var('vsnon' , 'volum per unit area of snow per class' , 'm' , vsnon(:,:) , mesh, partit, ncat)
call icepack_files%def_node_var('Tsfc' , 'sea ice surf. temperature' , 'degC', trcrn(:,nt_Tsfc,:), mesh, partit, ncat)
call icepack_files%def_node_var('uvel' , 'zonal component of ice velocity' , 'm/s' , uvel(:) , mesh, partit)
call icepack_files%def_node_var('vvel' , 'meridional component of ice velocity' , 'm/s' , vvel(:) , mesh, partit)

if (tr_iage) then
call icepack_files%def_node_var('iage' , 'sea ice age' , 's' , trcrn(:,nt_iage,:), mesh, partit, ncat)
Expand Down
53 changes: 34 additions & 19 deletions src/io_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,10 @@ subroutine restart(istep, nstart, ntotal, l_read, which_readr, ice, dynamics, tr
if (.not. l_read) then
call ini_ocean_io(yearnew, dynamics, tracers, partit, mesh)
if (use_ice) then
call ini_ice_io(yearnew, ice, partit, mesh)
#if defined(__icepack)
call ini_icepack_io(yearnew, partit, mesh)
#else
call ini_ice_io(yearnew, ice, partit, mesh)
#endif
end if
#if defined(__recom)
Expand All @@ -324,9 +325,10 @@ subroutine restart(istep, nstart, ntotal, l_read, which_readr, ice, dynamics, tr
else
call ini_ocean_io(yearold, dynamics, tracers, partit, mesh)
if (use_ice) then
call ini_ice_io (yearold, ice, partit, mesh)
#if defined(__icepack)
call ini_icepack_io(yearold, partit, mesh)
#else
call ini_ice_io (yearold, ice, partit, mesh)
#endif
end if
#if defined(__recom)
Expand Down Expand Up @@ -379,26 +381,33 @@ subroutine restart(istep, nstart, ntotal, l_read, which_readr, ice, dynamics, tr
! read netcdf file restart
else
which_readr = 0
!_______________________________________________________________________
! read OCEAN restart
if (partit%mype==RAW_RESTART_METADATA_RANK) print *, achar(27)//'[1;33m'//' --> read restarts from netcdf file: ocean'//achar(27)//'[0m'
call read_restart(oce_path, oce_files, partit%MPI_COMM_FESOM, partit%mype)

!_______________________________________________________________________
! read ICE/ICEPACK restart
if (use_ice) then
if (partit%mype==RAW_RESTART_METADATA_RANK) print *, achar(27)//'[1;33m'//' --> read restarts from netcdf file: ice'//achar(27)//'[0m'
call read_restart(ice_path, ice_files, partit%MPI_COMM_FESOM, partit%mype)
#if defined(__icepack)
if (partit%mype==RAW_RESTART_METADATA_RANK) print *, achar(27)//'[1;33m'//' --> read restarts from netcdf file: icepack'//achar(27)//'[0m'
call read_restart(icepack_path, icepack_files, partit%MPI_COMM_FESOM, partit%mype)
call read_restart(icepack_path, icepack_files, partit%MPI_COMM_FESOM, partit%mype)
#else
if (partit%mype==RAW_RESTART_METADATA_RANK) print *, achar(27)//'[1;33m'//' --> read restarts from netcdf file: ice'//achar(27)//'[0m'
call read_restart(ice_path, ice_files, partit%MPI_COMM_FESOM, partit%mype)
#endif
end if

#if defined(__recom)
!RECOM restart
!read here
if (REcoM_restart) then
if (partit%mype==RAW_RESTART_METADATA_RANK) print *, achar(27)//'[1;33m'//' --> read restarts from netcdf file: bio'//achar(27)//'[0m'
call read_restart(bio_path, bio_files, partit%MPI_COMM_FESOM, partit%mype)
end if
!_______________________________________________________________________
! read RECOM restarts
if (REcoM_restart) then
if (partit%mype==RAW_RESTART_METADATA_RANK) print *, achar(27)//'[1;33m'//' --> read restarts from netcdf file: bio'//achar(27)//'[0m'
call read_restart(bio_path, bio_files, partit%MPI_COMM_FESOM, partit%mype)
end if
#endif

!_______________________________________________________________________
! immediately create a raw core dump restart
if(raw_restart_length_unit /= "off") then
call write_all_raw_restarts(istep, partit%MPI_COMM_FESOM, partit%mype)
Expand Down Expand Up @@ -448,25 +457,31 @@ subroutine restart(istep, nstart, ntotal, l_read, which_readr, ice, dynamics, tr
! finally write restart for netcdf, core dump and derived type binary
! write netcdf restart
if(is_portable_restart_write) then
!___________________________________________________________________________
! write OCEAN restart
! if(partit%mype==0) write(*,*)'Do output (netCDF, restart) ...'
if (partit%mype==RAW_RESTART_METADATA_RANK) print *, achar(27)//'[1;33m'//' --> write restarts to netcdf file: ocean'//achar(27)//'[0m'
call write_restart(oce_path, oce_files, istep)

!___________________________________________________________________________
! write ICE/ICEPACK restart
if(use_ice) then
if (partit%mype==RAW_RESTART_METADATA_RANK) print *, achar(27)//'[1;33m'//' --> write restarts to netcdf file: ice'//achar(27)//'[0m'
call write_restart(ice_path, ice_files, istep)
#if defined(__icepack)
if (partit%mype==RAW_RESTART_METADATA_RANK) print *, achar(27)//'[1;33m'//' --> write restarts to netcdf file: icepack'//achar(27)//'[0m'
call write_restart(icepack_path, icepack_files, istep)
#else
if (partit%mype==RAW_RESTART_METADATA_RANK) print *, achar(27)//'[1;33m'//' --> write restarts to netcdf file: ice'//achar(27)//'[0m'
call write_restart(ic e_path, ice_files, istep)
#endif
end if

#if defined(__recom)
!RECOM restart
!write here
if (REcoM_restart .or. use_REcoM) then
if (partit%mype==RAW_RESTART_METADATA_RANK) print *, achar(27)//'[1;33m'//' --> write restarts to netcdf file: bio'//achar(27)//'[0m'
call write_restart(bio_path, bio_files, istep)
end if
!___________________________________________________________________________
! write RECOM restart
if (REcoM_restart .or. use_REcoM) then
if (partit%mype==RAW_RESTART_METADATA_RANK) print *, achar(27)//'[1;33m'//' --> write restarts to netcdf file: bio'//achar(27)//'[0m'
call write_restart(bio_path, bio_files, istep)
end if
#endif
end if

Expand Down

0 comments on commit 4a5d97d

Please sign in to comment.