Skip to content

Commit e8f2999

Browse files
Merge pull request #2 from gustavo-marques/temp_salt_z_init_file
Adds option to read initial temp and salt from separate files
2 parents 269f630 + 86936ba commit e8f2999

3 files changed

Lines changed: 195 additions & 17 deletions

File tree

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
module ocn_comp_mct
2+
3+
!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
4+
!BOP
5+
! !MODULE: ocn_comp_mct
6+
! !INTERFACE:
7+
8+
! !DESCRIPTION:
9+
! This is the main driver for the MOM6 in CIME
10+
!
11+
! !REVISION HISTORY:
12+
!
13+
! !USES:
14+
use esmf
15+
use seq_cdata_mod
16+
use mct_mod
17+
18+
! From MOM6
19+
use ocean_model_mod, only: ocean_state_type, ocean_public_type
20+
use ocean_model_mod, only: ocean_model_init
21+
use MOM_time_manager, only: time_type, set_date, set_calendar_type, NOLEAP
22+
use MOM_domains, only: MOM_infra_init, num_pes, root_pe, pe_here
23+
24+
!
25+
! !PUBLIC MEMBER FUNCTIONS:
26+
implicit none
27+
public :: ocn_init_mct
28+
public :: ocn_run_mct
29+
public :: ocn_final_mct
30+
private ! By default make data private
31+
32+
!
33+
! ! PUBLIC DATA:
34+
!
35+
! !REVISION HISTORY:
36+
! Author: Mariana Vertenstein
37+
!
38+
!EOP
39+
! !PRIVATE MODULE FUNCTIONS:
40+
41+
!
42+
! !PRIVATE MODULE VARIABLES
43+
type(ocean_state_type), pointer :: ocn_state => NULL() ! Private state of ocean
44+
type(ocean_public_type), pointer :: ocn_surface => NULL() ! Public surface state of ocean
45+
46+
!=======================================================================
47+
48+
contains
49+
50+
!***********************************************************************
51+
!BOP
52+
!
53+
! !IROUTINE: ocn_init_mct
54+
!
55+
! !INTERFACE:
56+
subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
57+
!
58+
! !DESCRIPTION:
59+
! Initialize POP
60+
!
61+
! !INPUT/OUTPUT PARAMETERS:
62+
63+
type(ESMF_Clock) , intent(inout) :: EClock
64+
type(seq_cdata) , intent(inout) :: cdata_o
65+
type(mct_aVect) , intent(inout) :: x2o_o, o2x_o
66+
character(len=*), optional , intent(in) :: NLFilename ! Namelist filename
67+
!
68+
! !REVISION HISTORY:
69+
! Author: Mariana Vertenstein
70+
!EOP
71+
!-----------------------------------------------------------------------
72+
!
73+
! local variables
74+
!
75+
!-----------------------------------------------------------------------
76+
type(time_type) :: time_init ! Start time of coupled model's calendar
77+
type(time_type) :: time_in ! Start time for ocean model at initialization
78+
type(ESMF_time) :: current_time
79+
integer :: year, month, day, hour, minute, seconds, rc
80+
character(len=128) :: errMsg
81+
integer :: mpicom
82+
integer :: npes, pe0
83+
integer :: i
84+
85+
mpicom = cdata_o%mpicom
86+
87+
call MOM_infra_init(mpicom)
88+
call ESMF_ClockGet(EClock, currTime=current_time, rc=rc)
89+
call ESMF_TimeGet(current_time, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
90+
! we need to confirm this:
91+
call set_calendar_type(NOLEAP)
92+
93+
time_init = set_date(year, month, day, hour, minute, seconds, err_msg=errMsg)
94+
time_in = set_date(year, month, day, hour, minute, seconds, err_msg=errMsg)
95+
96+
npes = num_pes()
97+
pe0 = root_pe()
98+
99+
allocate(ocn_surface)
100+
ocn_surface%is_ocean_PE = .true.
101+
allocate(ocn_surface%pelist(npes))
102+
ocn_surface%pelist(:) = (/(i,i=pe0,pe0+npes)/)
103+
104+
call ocean_model_init(ocn_surface, ocn_state, time_init, time_in)
105+
106+
!-----------------------------------------------------------------------
107+
!EOC
108+
109+
end subroutine ocn_init_mct
110+
111+
!***********************************************************************
112+
!BOP
113+
!
114+
! !IROUTINE: ocn_run_mct
115+
!
116+
! !INTERFACE:
117+
subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)
118+
!
119+
! !DESCRIPTION:
120+
! Run POP for a coupling interval
121+
!
122+
! !INPUT/OUTPUT PARAMETERS:
123+
type(ESMF_Clock) , intent(inout) :: EClock
124+
type(seq_cdata) , intent(inout) :: cdata_o
125+
type(mct_aVect) , intent(inout) :: x2o_o
126+
type(mct_aVect) , intent(inout) :: o2x_o
127+
128+
!
129+
! !REVISION HISTORY:
130+
! Author: Mariana Vertenstein
131+
!EOP
132+
!-----------------------------------------------------------------------
133+
!
134+
! local variables
135+
!
136+
!-----------------------------------------------------------------------
137+
138+
!-----------------------------------------------------------------------
139+
!EOC
140+
141+
end subroutine ocn_run_mct
142+
143+
!***********************************************************************
144+
!BOP
145+
!
146+
! !IROUTINE: ocn_final_mct
147+
!
148+
! !INTERFACE:
149+
subroutine ocn_final_mct( EClock, cdata_o, x2o_o, o2x_o)
150+
!
151+
! !DESCRIPTION:
152+
! Finalize POP
153+
!
154+
! !USES:
155+
! !ARGUMENTS:
156+
type(ESMF_Clock) , intent(inout) :: EClock
157+
type(seq_cdata) , intent(inout) :: cdata_o
158+
type(mct_aVect) , intent(inout) :: x2o_o
159+
type(mct_aVect) , intent(inout) :: o2x_o
160+
!
161+
! !REVISION HISTORY:
162+
! Author: Fei Liu
163+
!EOP
164+
!BOC
165+
!-----------------------------------------------------------------------
166+
!
167+
! local variables
168+
!
169+
!-----------------------------------------------------------------------
170+
171+
end subroutine ocn_final_mct
172+
173+
174+
end module ocn_comp_mct
175+
176+
!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

src/ice_shelf/MOM_ice_shelf.F90

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,17 +1053,6 @@ subroutine add_shelf_flux(G, CS, state, fluxes)
10531053
endif
10541054

10551055

1056-
! Add frazil formation diagnosed by the ocean model (J m-2) in the
1057-
! form of surface layer evaporation (kg m-2 s-1). Update lprec in the
1058-
! control structure for diagnostic purposes.
1059-
1060-
if (associated(state%frazil)) then
1061-
fraz = state%frazil(i,j) / CS%time_step / CS%Lat_fusion
1062-
if (associated(fluxes%evap)) fluxes%evap(i,j) = fluxes%evap(i,j) - fraz
1063-
CS%lprec(i,j)=CS%lprec(i,j) - fraz
1064-
state%frazil(i,j) = 0.0
1065-
endif
1066-
10671056
if (associated(fluxes%sens)) fluxes%sens(i,j) = -frac_area*CS%t_flux(i,j)*CS%flux_factor
10681057
if (associated(fluxes%salt_flux)) fluxes%salt_flux(i,j) = frac_area * CS%salt_flux(i,j)*CS%flux_factor
10691058
if (associated(fluxes%p_surf)) fluxes%p_surf(i,j) = frac_area * CS%g_Earth * CS%mass_shelf(i,j)

src/initialization/MOM_state_initialization.F90

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,10 @@ subroutine MOM_temp_salt_initialize_from_Z(h, tv, G, GV, PF, dirs)
16481648

16491649
character(len=200) :: filename ! The name of an input file containing temperature
16501650
! and salinity in z-space; also used for ice shelf area.
1651+
character(len=200) :: tfilename ! The name of an input file containing only temperature
1652+
! in z-space.
1653+
character(len=200) :: sfilename ! The name of an input file containing only salinity
1654+
! in z-space.
16511655
character(len=200) :: inputdir ! The directory where NetCDF input files are.
16521656
character(len=200) :: mesg, area_varname, ice_shelf_file
16531657

@@ -1745,15 +1749,24 @@ subroutine MOM_temp_salt_initialize_from_Z(h, tv, G, GV, PF, dirs)
17451749

17461750
call get_param(PF, mod, "TEMP_SALT_Z_INIT_FILE",filename, &
17471751
"The name of the z-space input file used to initialize \n"//&
1748-
"the layer thicknesses, temperatures and salinities.", &
1749-
default="temp_salt_z.nc")
1752+
"temperatures (T) and salinities (S). If T and S are not \n" //&
1753+
"in the same file, TEMP_Z_INIT_FILE and SALT_Z_INIT_FILE \n" //&
1754+
"must be set.",default="temp_salt_z.nc")
1755+
call get_param(PF, mod, "TEMP_Z_INIT_FILE",tfilename, &
1756+
"The name of the z-space input file used to initialize \n"//&
1757+
"temperatures, only.", default=trim(filename))
1758+
call get_param(PF, mod, "SALT_Z_INIT_FILE",sfilename, &
1759+
"The name of the z-space input file used to initialize \n"//&
1760+
"temperatures, only.", default=trim(filename))
17501761
filename = trim(inputdir)//trim(filename)
1762+
tfilename = trim(inputdir)//trim(tfilename)
1763+
sfilename = trim(inputdir)//trim(sfilename)
17511764
call get_param(PF, mod, "Z_INIT_FILE_PTEMP_VAR", potemp_var, &
17521765
"The name of the potential temperature variable in \n"//&
1753-
"TEMP_SALT_Z_INIT_FILE.", default="ptemp")
1766+
"TEMP_Z_INIT_FILE.", default="ptemp")
17541767
call get_param(PF, mod, "Z_INIT_FILE_SALT_VAR", salin_var, &
17551768
"The name of the salinity variable in \n"//&
1756-
"TEMP_SALT_Z_INIT_FILE.", default="salt")
1769+
"SALT_Z_INIT_FILE.", default="salt")
17571770
call get_param(PF, mod, "Z_INIT_HOMOGENIZE", homogenize, &
17581771
"If True, then horizontally homogenize the interpolated \n"//&
17591772
"initial conditions.", default=.false.)
@@ -1792,10 +1805,10 @@ subroutine MOM_temp_salt_initialize_from_Z(h, tv, G, GV, PF, dirs)
17921805
! value at the northernmost/southernmost latitude.
17931806

17941807

1795-
call horiz_interp_and_extrap_tracer(filename, potemp_var,1.0,1, &
1808+
call horiz_interp_and_extrap_tracer(tfilename, potemp_var,1.0,1, &
17961809
G, temp_z, mask_z, z_in, z_edges_in, missing_value_temp, reentrant_x, tripolar_n, homogenize)
17971810

1798-
call horiz_interp_and_extrap_tracer(filename, salin_var,1.0,1, &
1811+
call horiz_interp_and_extrap_tracer(sfilename, salin_var,1.0,1, &
17991812
G, salt_z, mask_z, z_in, z_edges_in, missing_value_salt, reentrant_x, tripolar_n, homogenize)
18001813

18011814
kd = size(z_in,1)

0 commit comments

Comments
 (0)