Conversation
|
Thanks @anton-seaice - do you think this is ready for the next 25km IAF test run? |
|
Ready from my perspective.
|
There was a problem hiding this comment.
There isn't much flexibility in the mediator io. I modified this so that it can read 3d variable (x,y,time) from a netcdf . For whatever reason, 3d information in restart files is saved in separate 2d variables so the functionality didn't exisit.
|
I did some cleanup, but have finished that for now |
dougiesquire
left a comment
There was a problem hiding this comment.
Nice work @anton-seaice. Sorry for taking so long to get to this.
My main worry is the lack of time interpolation and the resulting step changes in the pattern between months. But, as we've discussed, we probably can't address that here.
| !------------------------------------------------------------------------------- | ||
| #endif | ||
|
|
||
| rc = ESMF_SUCCESS |
There was a problem hiding this comment.
Why is this needed? Is this just convention (e.g. in case someone adds an early return path or something)?
| runoff_flux => rof2ocn_spread(:,month) | ||
| ! calculate sum of spreading | ||
| local_sum = 0.0_r8 | ||
| do i = 1, size(runoff_flux) | ||
| if (lats(i) < 0.0_r8) then | ||
| local_sum(1) = local_sum(1) + areas(i) * runoff_flux(i) | ||
| else | ||
| local_sum(2) = local_sum(2) + areas(i) * runoff_flux(i) | ||
| end if | ||
| end do | ||
|
|
||
| call ESMF_VMAllreduce(vm, senddata=local_sum, recvdata=global_sum, count=2, & | ||
| reduceflag=ESMF_REDUCE_SUM, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
|
|
||
| ! adjust correction so that it's sums to 1 in each hemisphere | ||
| do i = 1, size(runoff_flux) | ||
| if (lats(i) < 0.0_r8) then | ||
| runoff_flux(i) = runoff_flux(i) / global_sum(1) | ||
| else | ||
| runoff_flux(i) = runoff_flux(i) / global_sum(2) | ||
| end if | ||
| end do | ||
|
|
||
| rof2ocn_spread(:,month) = runoff_flux |
There was a problem hiding this comment.
runoff_flux is a pointer, so the final assignment here is not necessary.
Personal preference, but I think the use of a pointer here just adds indirection.
| runoff_flux => rof2ocn_spread(:,month) | |
| ! calculate sum of spreading | |
| local_sum = 0.0_r8 | |
| do i = 1, size(runoff_flux) | |
| if (lats(i) < 0.0_r8) then | |
| local_sum(1) = local_sum(1) + areas(i) * runoff_flux(i) | |
| else | |
| local_sum(2) = local_sum(2) + areas(i) * runoff_flux(i) | |
| end if | |
| end do | |
| call ESMF_VMAllreduce(vm, senddata=local_sum, recvdata=global_sum, count=2, & | |
| reduceflag=ESMF_REDUCE_SUM, rc=rc) | |
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | |
| ! adjust correction so that it's sums to 1 in each hemisphere | |
| do i = 1, size(runoff_flux) | |
| if (lats(i) < 0.0_r8) then | |
| runoff_flux(i) = runoff_flux(i) / global_sum(1) | |
| else | |
| runoff_flux(i) = runoff_flux(i) / global_sum(2) | |
| end if | |
| end do | |
| rof2ocn_spread(:,month) = runoff_flux | |
| ! calculate sum of spreading | |
| local_sum = 0.0_r8 | |
| do i = 1, size(areas) | |
| if (lats(i) < 0.0_r8) then | |
| local_sum(1) = local_sum(1) + areas(i) * rof2ocn_spread(i,month) | |
| else | |
| local_sum(2) = local_sum(2) + areas(i) * rof2ocn_spread(i,month) | |
| end if | |
| end do | |
| call ESMF_VMAllreduce(vm, senddata=local_sum, recvdata=global_sum, count=2, & | |
| reduceflag=ESMF_REDUCE_SUM, rc=rc) | |
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | |
| ! adjust correction so that it's sums to 1 in each hemisphere | |
| do i = 1, size(areas) | |
| if (lats(i) < 0.0_r8) then | |
| rof2ocn_spread(i,month) = rof2ocn_spread(i,month) / global_sum(1) | |
| else | |
| rof2ocn_spread(i,month) = rof2ocn_spread(i,month) / global_sum(2) | |
| end if | |
| end do |
| if (maintask .and. dbug_flag > dbug_threshold) then | ||
|
|
||
| ! calculate the new global sum (after correction), should be equal to 0 | ||
| local_sum = 0.0_r8 | ||
| do n = 1, size(runoff_flux) | ||
| if (lats(n) < 0.0_r8) then | ||
| local_sum(1) = local_sum(1) + areas(n) * runoff_flux(n) | ||
| else | ||
| local_sum(2) = local_sum(2) + areas(n) * runoff_flux(n) | ||
| end if | ||
| end do | ||
|
|
||
| call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call ESMF_VMReduce(vm, senddata=local_sum, recvdata=global_sum, count=2, & | ||
| reduceflag=ESMF_REDUCE_SUM, rootPet = 0, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| write(logunit,'(a)') subname//' Before correction: '//trim(field_name) | ||
| write(logunit,'(a,e27.17)') subname//' global_sh = ', global_sum(1) | ||
| write(logunit,'(a,e27.17)') subname//' global_nh = ', global_sum(2) | ||
| end if |
There was a problem hiding this comment.
Should this really all be inside if (maintask)??
Also, is maintask is always PE 0? If it isn't, you may need to use ESMF_VMAllreduce. If it is, you could do:
| if (maintask .and. dbug_flag > dbug_threshold) then | |
| ! calculate the new global sum (after correction), should be equal to 0 | |
| local_sum = 0.0_r8 | |
| do n = 1, size(runoff_flux) | |
| if (lats(n) < 0.0_r8) then | |
| local_sum(1) = local_sum(1) + areas(n) * runoff_flux(n) | |
| else | |
| local_sum(2) = local_sum(2) + areas(n) * runoff_flux(n) | |
| end if | |
| end do | |
| call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) | |
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | |
| call ESMF_VMReduce(vm, senddata=local_sum, recvdata=global_sum, count=2, & | |
| reduceflag=ESMF_REDUCE_SUM, rootPet = 0, rc=rc) | |
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | |
| write(logunit,'(a)') subname//' Before correction: '//trim(field_name) | |
| write(logunit,'(a,e27.17)') subname//' global_sh = ', global_sum(1) | |
| write(logunit,'(a,e27.17)') subname//' global_nh = ', global_sum(2) | |
| end if | |
| if (dbug_flag > dbug_threshold) then | |
| ! calculate the new global sum (after correction), difference should be equal to 0 | |
| local_sum = 0.0_r8 | |
| do n = 1, size(runoff_flux) | |
| if (lats(n) < 0.0_r8) then | |
| local_sum(1) = local_sum(1) + areas(n) * runoff_flux(n) | |
| else | |
| local_sum(2) = local_sum(2) + areas(n) * runoff_flux(n) | |
| end if | |
| end do | |
| call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) | |
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | |
| call ESMF_VMReduce(vm, senddata=local_sum, recvdata=global_sum, count=2, & | |
| reduceflag=ESMF_REDUCE_SUM, rootPet=0, rc=rc) | |
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | |
| if (maintask) then | |
| write(logunit,'(a)') subname//' After correction: '//trim(field_name) | |
| write(logunit,'(a,e27.17)') subname//' global_sh = ', global_sum(1) | |
| write(logunit,'(a,e27.17)') subname//' global_nh = ', global_sum(2) | |
| end if | |
| end if |
| call ESMF_VMReduce(vm, senddata=local_sum, recvdata=global_sum, count=2, & | ||
| reduceflag=ESMF_REDUCE_SUM, rootPet = 0, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| write(logunit,'(a)') subname//' Before correction: '//trim(field_name) |
There was a problem hiding this comment.
| write(logunit,'(a)') subname//' Before correction: '//trim(field_name) | |
| write(logunit,'(a)') subname//' After correction: '//trim(field_name) |
|
|
||
| if (maintask .and. dbug_flag > dbug_threshold) then | ||
|
|
||
| ! calculate the new global sum (after correction), should be equal to 0 |
There was a problem hiding this comment.
| ! calculate the new global sum (after correction), should be equal to 0 | |
| ! calculate the new global sum (after correction), difference should be equal to 0 |
| rcode = pio_inq_dimlen(pioid, dimid(1), lnx) | ||
| if (rcode /= pio_noerr) then | ||
| ierr = pio_strerror(rcode, tmpstr) | ||
| call shr_sys_abort(trim(subname)//' ERROR: '//trim(tmpstr), rc=rc) |
There was a problem hiding this comment.
How come you call shr_sys_abort here, but shr_log_error for lny and lni below?
| subroutine med_io_read_init_iodesc(field, name1, pioid, iodesc, ungridded_nc, rc) | ||
|
|
||
| use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_SUCCESS | ||
| use ESMF , only : ESMF_FieldBundleIsCreated, ESMF_FieldBundle, ESMF_Mesh, ESMF_DistGrid |
There was a problem hiding this comment.
ESMF_FieldBundle is no longer used (same for a number of other imports, but this one you removed)
| use ESMF , only : ESMF_FieldBundleIsCreated, ESMF_FieldBundle, ESMF_Mesh, ESMF_DistGrid | |
| use ESMF , only : ESMF_FieldBundleIsCreated, ESMF_Mesh, ESMF_DistGrid |
| integer :: rcode, ierr | ||
| integer :: nf | ||
| integer :: k,n,l | ||
| integer :: k,n,l,m |
There was a problem hiding this comment.
Unused variable
| integer :: k,n,l,m | |
| integer :: k,n,l |
| character(len=*) ,optional ,intent(in) :: pre ! prefix to variable name | ||
| logical ,optional ,intent(in) :: ungridded_nc | ||
| ! if true : ungridded dim in fields is dimension in netcdf file, | ||
| ! if false: ungridded_dim is provided in seperate variables with the index appended |
There was a problem hiding this comment.
| ! if false: ungridded_dim is provided in seperate variables with the index appended | |
| ! if false: ungridded_dim is provided in separate variables with the index appended |
| call ESMF_LogWrite(trim(subname)//trim(tmpstr), ESMF_LOGMSG_INFO, rc=rc) | ||
| fldptr2 = 0.0_r8 |

This change allows for spreading of the iceberg melt field according to a climatological pattern.
A new configuration parameter is added,
rof2ocn_ice_spread- which is the filename for a netcdf file with a 12-monthly climatological spreading pattern. If this parameter is not set - there is no change to existing behaviour (see repro test)When a file is provided, the incoming
Forr_rofifield is spread according to the pattern supplied in the climatology of spreading.e.g., for January:
and for June:
Water volume is maintained between that coming from drof and ficeberg in MOM:
See example OM3 100km configuration:
ACCESS-NRI/access-om3-configs@3169a38