Add in area correction to mizuRoute
- Dominant language
- Fortran
- Stars
- 59
- Forks
- 73
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 2
Description
With the latest version of CTSM we have area correction added into CTSM, MOSART and RTM. This is multiplying fields by the ratio of what the model things the area is divided by the area as defined by the mesh file.
Here's an example section added to the end of realize fields for RTM:
``` fortran
+ ! Determine areas for regridding
+ call ESMF_MeshGet(Emesh, numOwnedElements=numOwnedElements, rc=rc)
+ if (chkerr(rc,__LINE__,u_FILE_u)) return
+ call ESMF_StateGet(exportState, itemName=trim(fldsFrRof(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))
+ n = 0
+ do g = runoff%begr,runoff%endr
+ n = n + 1
+ model_areas(n) = runoff%area(g)*1.0e-6_r8/(re*re)
+ mod2med_areacor(n) = model_areas(n) / mesh_areas(n)
+ med2mod_areacor(n) = mesh_areas(n) / mod2med_areacor(n)
+ end do
+ deallocate(model_areas)
+ deallocate(mesh_areas)
+
+ min_mod2med_areacor = minval(mod2med_areacor)
+ max_mod2med_areacor = maxval(mod2med_areacor)
+ min_med2mod_areacor = minval(med2mod_areacor)
+ max_med2mod_areacor = maxval(med2mod_areacor)
+ call shr_mpi_max(max_mod2med_areacor, max_mod2med_areacor_glob, mpicom_rof)
+ call shr_mpi_min(min_mod2med_areacor, min_mod2med_areacor_glob, mpicom_rof)
+ call shr_mpi_max(max_med2mod_areacor, max_med2mod_areacor_glob, mpicom_rof)
+ call shr_mpi_min(min_med2mod_areacor, min_med2mod_areacor_glob, mpicom_rof)
+
+ if (masterproc) then
+ write(iulog,'(2A,2g23.15,A )') trim(subname),' : min_mod2med_areacor, max_mod2med_areacor ',&
+ min_mod2med_areacor_glob, max_mod2med_areacor_glob, 'RTM'
+ write(iulog,'(2A,2g23.15,A )') trim(subname),' : min_med2mod_areacor, max_med2mod_areacor ',&
+ min_med2mod_areacor_glob, max_med2mod_areacor_glob, 'RTM'
+ end if
+
```
Then import_fields adds an extra argument for each field...
``` fortran
allocate(temp(begr:endr,3))
- call state_getimport(importState, 'Flrl_rofsur', begr, endr, output=temp(:,1), rc=rc)
+ call state_getimport(importState, 'Flrl_rofsur', begr, endr, output=temp(:,1), do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
```
Which then does this...
``` fortran
+ ! determine output array
+ if (do_area_correction) then
+ fldptr(:) = fldptr(:) * med2mod_areacor(:)
end if
+ do g = begr,endr
+ output(g) = fldptr(g-begr+1)
+ end do
+
+ ! check for nans
+ call check_for_nans(fldptr, trim(fldname), begr)
```
Similar stuff for export state...
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.