Skip to content

Commit

Permalink
scamn bugfix for nuopc driver (#926)
Browse files Browse the repository at this point in the history
Co-authored-by: John Truesdale <[email protected]>
  • Loading branch information
dabail10 and jtruesdal committed Jan 11, 2024
1 parent 1314e17 commit a20bfdd
Showing 1 changed file with 44 additions and 34 deletions.
78 changes: 44 additions & 34 deletions cicecore/drivers/nuopc/cmeps/ice_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -363,45 +363,55 @@ subroutine ice_realize_fields(gcomp, mesh, flds_scalar_name, flds_scalar_num, rc
mesh=mesh, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
#ifdef CESMCOUPLED
! Get mesh areas from second field - using second field since the
! first field is the scalar field
if (single_column) return

! allocate area correction factors
call ESMF_MeshGet(mesh, numOwnedElements=numOwnedElements, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_StateGet(exportState, itemName=trim(fldsFrIce(2)%stdname), field=lfield, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldRegridGetArea(lfield, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldGet(lfield, farrayPtr=dataptr, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
allocate(mesh_areas(numOwnedElements))
mesh_areas(:) = dataptr(:)

! Determine flux correction factors (module variables)
allocate(model_areas(numOwnedElements))
allocate(mod2med_areacor(numOwnedElements))
allocate(med2mod_areacor(numOwnedElements))
mod2med_areacor(:) = 1._dbl_kind
med2mod_areacor(:) = 1._dbl_kind
n = 0
do iblk = 1, nblocks
this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi
do j = jlo, jhi
do i = ilo, ihi
n = n+1
model_areas(n) = tarea(i,j,iblk)/(radius*radius)
mod2med_areacor(n) = model_areas(n) / mesh_areas(n)
med2mod_areacor(n) = mesh_areas(n) / model_areas(n)
allocate (mod2med_areacor(numOwnedElements))
allocate (med2mod_areacor(numOwnedElements))

if (single_column) then

mod2med_areacor(:) = 1._dbl_kind
med2mod_areacor(:) = 1._dbl_kind

else

! Get mesh areas from second field - using second field since the
! first field is the scalar field

call ESMF_StateGet(exportState, itemName=trim(fldsFrIce(2)%stdname), field=lfield, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldRegridGetArea(lfield, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldGet(lfield, farrayPtr=dataptr, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
allocate(mesh_areas(numOwnedElements))
mesh_areas(:) = dataptr(:)

! Determine flux correction factors (module variables)
allocate(model_areas(numOwnedElements))
mod2med_areacor(:) = 1._dbl_kind
med2mod_areacor(:) = 1._dbl_kind
n = 0
do iblk = 1, nblocks
this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi
do j = jlo, jhi
do i = ilo, ihi
n = n+1
model_areas(n) = tarea(i,j,iblk)/(radius*radius)
mod2med_areacor(n) = model_areas(n) / mesh_areas(n)
med2mod_areacor(n) = mesh_areas(n) / model_areas(n)
enddo
enddo
enddo
enddo
deallocate(model_areas)
deallocate(mesh_areas)
deallocate(model_areas)
deallocate(mesh_areas)
end if

min_mod2med_areacor = minval(mod2med_areacor)
max_mod2med_areacor = maxval(mod2med_areacor)
Expand Down

0 comments on commit a20bfdd

Please sign in to comment.