Skip to content
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
15 changes: 14 additions & 1 deletion src/soca/Fields/soca_fields_metadata_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module soca_fields_metadata_mod

use fckit_configuration_module, only: fckit_configuration, fckit_yamlconfiguration
use fckit_pathname_module, only : fckit_pathname
use kinds, only: kind_real

implicit none
private
Expand All @@ -24,10 +25,11 @@ module soca_fields_metadata_mod
character(len=:), allocatable :: levels !< "1", or "full_ocn"
character(len=:), allocatable :: getval_name !< variable name used by UFO
character(len=:), allocatable :: getval_name_surface ! name used by UFO for the surface (if this is a 3D field)
character(len=:), allocatable :: io_file !< the restart file domain (ocn, sfc, ice)
character(len=:), allocatable :: io_file !< the restart file domain (ocn, sfc, ice). Or if "CONSTANT" use the value in "constant_value"
character(len=:), allocatable :: io_name !< the name use in the restart IO
character(len=:), allocatable :: property !< physical property of the field, "none" or "positive_definite"
logical :: vert_interp !< true if the field can be vertically interpolated
real(kind=kind_real) :: constant_value !< An optional value to use globally for the field
end type


Expand Down Expand Up @@ -73,6 +75,7 @@ subroutine soca_fields_metadata_create(self, filename)

integer :: i, j
logical :: bool
real(kind=kind_real) :: r
character(len=:), allocatable :: str

! parse all the metadata from a yaml configuration file
Expand Down Expand Up @@ -116,6 +119,16 @@ subroutine soca_fields_metadata_create(self, filename)
end if
self%metadata(i)%vert_interp = bool

if(conf_list(i)%get("constant value", r)) then
if (.not. self%metadata(i)%io_file == "") then
str=repeat(" ", 1024)
write(str, *) "error in field metadata file for '", self%metadata(i)%name, &
"' : 'io file' cannot be set if 'constant value' is given"
call abor1_ftn(str)
end if
self%metadata(i)%constant_value = r
self%metadata(i)%io_file = "CONSTANT"
end if
end do

! check for duplicates
Expand Down
6 changes: 5 additions & 1 deletion src/soca/Fields/soca_fields_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,11 @@ subroutine soca_fields_read(self, f_conf, vdate)

! built-in variables
do i=1,size(self%fields)
if(self%fields(i)%metadata%io_name /= "") then

if(self%fields(i)%metadata%io_file == "CONSTANT") then
self%fields(i)%val(:,:,:) = self%fields(i)%metadata%constant_value

else if(self%fields(i)%metadata%io_file /= "") then
! which file are we reading from?
select case(self%fields(i)%metadata%io_file)
case ('ocn')
Expand Down
6 changes: 6 additions & 0 deletions test/Data/fields_metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# getval_name_surface: GetValues variable name for 2D surface of a 3D field (Default: <unused>)
# io_file: The restart file domain "ocn", "sfc", or "ice" (Default: <unused>)
# io_name: The variable name used in the restart IO (Default: <unused>)
# constant value: Used for "dummy" fields. Sets the entire field to the given constant globally
# This parameter cannot be used with io_file/io_name
# --------------------------------------------------------------------------------------------------


Expand Down Expand Up @@ -165,3 +167,7 @@

- name: sea_water_depth
levels: full_ocn

# --------------------------------------------------------------------------------------------------
- name: dummy_atm1
constant value: 5.0
2 changes: 1 addition & 1 deletion test/testinput/hofx_3d.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ state:
ocn_filename: MOM.res.nc
ice_filename: cice.res.nc
sfc_filename: sfc.res.nc
state variables: [cicen, hicen, hsnon, socn, tocn, ssh, hocn, uocn, vocn, sw, lhf, shf, lw, us, chl]
state variables: [cicen, hicen, hsnon, socn, tocn, ssh, hocn, uocn, vocn, sw, lhf, shf, lw, us, chl, dummy_atm1]

window begin: 2018-04-14T00:00:00Z
window length: P2D
Expand Down
1 change: 1 addition & 0 deletions test/testref/hofx_3d.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ State:
lw min=0.0000000000000000 max=88.0360870361328125 mean=31.3955290035652546
us min=0.0043958698226386 max=0.0196578730801191 mean=0.0086443089692577
chl min=0.0000100000000000 max=4.6719899196170607 mean=0.1184829680403295
dummy_atm1 min=5.0000000000000000 max=5.0000000000000000 mean=5.0000000000000000
H(x):
CoolSkin nobs= 200 Min=-4.1785594844341176, Max=25.2197343303870412, RMS=20.1355481819576383

Expand Down