Coder Social home page Coder Social logo

noaa-emc / cmeps Goto Github PK

View Code? Open in Web Editor NEW

This project forked from escomp/cmeps

0.0 0.0 17.0 8.78 MB

NUOPC Community Mediator for Earth Prediction Systems

Home Page: https://escomp.github.io/CMEPS/

Python 3.04% Fortran 95.39% C 0.03% Shell 0.02% Makefile 0.28% CMake 1.24%

cmeps's People

Contributors

aarondonahue avatar agsalin avatar alperaltuntas avatar amametjanov avatar apcraig avatar billsacks avatar binli2337 avatar binliu-noaa avatar cacraigucar avatar danrosen25 avatar deniseworthen avatar ekluzek avatar fischer-ncar avatar fvitt avatar jackreeveseyre avatar jayeshkrishna avatar jedwards4b avatar jgfouca avatar jonbob avatar mfdeakin-sandia avatar minxu74 avatar mt5555 avatar mvertens avatar ndkeen avatar rljacob avatar rsdunlapiv avatar singhbalwinder avatar uturuncoglu avatar whannah1 avatar worleyph avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cmeps's Issues

update to escomp/master

We need to update to the current ESCOMP/master of CMEPS. This is not expected to change any baselines.

update to ESCOMP/master

  1. The Xgrid implementation for calculating A-O fluxes only has been added for CESM at ESCOMP/master (ESCOMP PR #216). This capability should be brought to NOAA-EMC to allow development of the Xgrid for ufs-weather.

  2. Accumulation field bundles have been refactored (ESCOMP PR #226). The import and export accumulation FBs are no longer arrays (carried for multiple components). The import accumulation FBs (not used in UFS) are now module specific (runoff and glacial ice). The ocean export accumulation FBs (used for the ocean export in UFS) is now carried in a specific FBExpAccumOcn

  3. Clean up of med.F90. When setting up the mediator mesh and related import/export fields from components on both grids and meshes, Med.F90 utilizes an IPDv03p4 phase to modify the the decomp/distribution of the transferred Grid/Mesh. In the refactored code, the process by which an incoming grid or mesh is modified (redistributed) to the mediator PEs is much more clear: a new grid/mesh is created on the mediator PEs and upon leaving the phase, the coordinates and geom base of the old grid or mesh is automatically transferred to the new grid/mesh.

    The transfer of fields from the incoming grid/mesh is completed in the subsequent IPDv03p5 phase. For a transferred grid, the IPDv03p5 creates the mesh and then transfers all fields in the State to the mesh in a NUOPC_realize call. This call acts to kick out the old Grid-based field from the state, and replace it with a Mesh-based one.

    It should be noted that the cleanup of med.F90 resolves an issue where the call to ESMF_FieldEmptyComplete resulted in a non-fatal error. Currently, an error message in the PET logs indicates an attempt to complete a field(s) that is already destroyed:

ESMF_Field.F90:314 ESMF_FieldValidate Invalid object  - Uninitialized or already destroyed Field: fieldstatus not ready

This error did not cause the code to abort because the complete call was also missing a subsequent ChkErr call. The error was produced because for a transferred Grid, the call to NUOPC_realize had already replaced the grid fields with
the mesh fields. Thus the incoming grid field had already been destroyed (replaced by the mesh field).

  1. Mediator history refactor. Currently to obtain a coupler history file (e.g. debugging the coupled model), a special med_phase_history_write needs to be added within the run sequence. The coupler history file is also not produced at the right frequency when there are different slow and fast coupling frequency in the run sequence. The refactor of the coupler history writing will allow each component to produce a coupler history file separately; the frequency of the coupler history files will be a configurable option at run time, and can be set differently for each coupled component where a history file is requested.

This update requires ESMF8.2.0bs14 or higher. Additional settings will also need to be added to the nems.configure.

This update will also change baselines because the mediator restart file will not contain the same fields due to the changes noted in item 2 above. Testing has shown that all common fields between the two mediator restarts and all other component model restart files are b4b with existing baselines.

Coupled tests are not reproducible when compiled with Gnu

During ufs-weather PR 561 (the global RT update), it was found that the cpld_control and cpld_controlfrac tests compiled with GNU did not reproduce. The variables ImpAccumCnt and ExpAccumCnt in the mediator restart file were different between the baseline and the verify run. They also contained valid values only for the ocean component. All other component values were un-realistic (and different between baseline and verify).

The issue is that the AccumCnt is initialized to zero only for active components, but is dimensioned to all components. A fix is required to initialize the AccumCnt for all components. The fix has been tested in ufs-weather compiled with gnu and the mediator restart files are now reproducible for both the cpld_controlfrac and cpld_debugfrac tests.

Update CMEPS for HAFS-MOM6 coupling

In the HAFS-MOM6 system, the regional FV3ATM atmosphere domain and MOM6 ocean domain do not overlap completely. The FV3ATM atmosphere domain and WW3 wave domain do not overlap completely either.

The CMEPS will be updated to add the following features:

  1. Capable of coupling both FV3ATM and CDEPS datm to MOM6 at the same time. In the overlapped regions, the MOM6 model receives flux fields from FV3ATM. In the non-overlapped regions, the MOM6 model receives flux fields from GFS forcing through CDEPS datm.
  2. Capable of coupling both FV3ATM and CDEPS datm to WW3 at the same time. In the overlapped regions, the WW3 model receives 10m wind fields from FV3ATM. In the non-overlapped regions, the WW3 model receives the 10m wind fields from GFS forcing through CDEPS datm.

Update CMEPS from ESCOMP

Changes made in CMEPS by EMC have been merged at ESCOMP. These changes need to be brought back to emc/develop. Initial testing has shown these changes will change the mediator restart file because the number of components is now 9 due to the addition of another glacier component (in CESM, this allows for both a northern and southern glacier component) but all other fields in the mediator restart file should be B4B.

This update will also remove the ESMF version >8 ifdefs.

Confusing ESMF_LOGFILE_KIND definition in the namelist

The esmf_logging option in nuopc.runconfig is not working since the esmf logging is controlled by drv_in using create_esmf_pet_files namelist option (in CMEPS driver code). So, I am not sure but maybe there is no need to expose ESMF_LOGFILE_KIND in the cmeps/cime_config/namelist_definition_drv.xml file. I think CMEPS driver is not looking to it instead of it is looking to the drv_in and this information only meaningful to the driver.

Implement ocean albedo calculation for UFS

Currently the SWnet calculated for the ocean assumes a constant albedo of 0.06 for both direct and diffuse SW radiation. This albedo does not vary with sun angle. This results in an excess of SW radiation to the ocean. See Issue ufs-community/ufs-weather-model#1768 for more details.

The ocean albedo calculation can be implemented by adding the needed run phase and having UFS call the ocean albedo calculation in med_phases_prep_ocn. Currently this calculation happens only for CESM, but can be generalized for non-cesm use without duplication of code.

update to latest escomp/main

PRs merged at ESCOMP are needed to update NOAA-EMC

  • updates multiple cime and cesm related files
  • adds optional check for NaN in export FBs. This requires additional share modules, which are available in the CDEPS repo. Changes are made in the CMakeList.txt in the CMEPS-interface to access these modules. The check for NaNs in off by default. It can be enabled by adding a configuration variable in the MED attributes check_for_nans = true

coupling mode definitions are poorly defined

The original coupling modes were defined at the time of the update from the NEMS mediator. The values of coupling_mode are poorly named for the current uses in UFS. They should be changed to be more representative of the what each mode represents.

nems_orig : this is the original, non-fractional grid with an active ATM.
nems_orig_data : the original, non-fraction grid with DATM
nems_frac : the fractional grid with active ATM
nems_frac_aoflux and nems_frac_aoflux_sbs : the fractional grid using the mediator aoflux calculations.

Better names for these modes are:

nems_orig --> ufs.nfrac
nems_orig_data --> ufs.nfrac.aoflux
nems_frac --> ufs.frac
nems_frac_aoflux and nems_frac_aoflux_sbs --> ufs.frac.aoflux

single normalization type is not enforced

CMEPS uses packed fields at mapping time, meaning all fields from component n1 to n2 using a given mapping maptype are packed into the unlimited dimension of a single field. As a consequence, all packed fields for n1:n2:maptype must have the same normalization applied. This restriction is noted in code comments but not otherwise enforced in the CMEPS code, so that a user could set a 2nd normalization type without triggering an error.

A trigger needs to be implemented which will cause the application to abort if a second normalization type is specified for a given n1:n2:maptype specification.

allow coupler history files to be written to a different directory than the restart files

Currently both the coupler and history files are written using the configuration variable case_name. For consistency w/ ufs-weather and the repo-unification, the coupler history files should be written to the RESTART directory. That can be done using case_name=./RESTART/ufs.s2s. However, this forces the coupler history files to also be written to the RESTART directory instead of the run directory.

We need to add a new optional config variable to specify the restart directory. The history files would then be written by default to the run directory.

update cmeps for performance improvements

Testing in CESM revealed that the mapping and merging of fields in CMEPS was inefficient. Significant performance improvement can be achieved by packing fields into an undistributed dimension of a single field, performing the required mapping and merging on the single field and then unpacking the fields for export to the relevant component. If a field has an undistributed dimension, the packed field accordions out to accommodate the field's undistributed dimension.

Additional performance enhancements can also be achieved through ESMF itself (currently in development). These ESMF related changes are not required to implement the field packing.

The field packing performance improvement is expected to be b4b with previous answers.

crash when running GFS PBL/sfclay and clm lake in RRFS ensemble

A couple of RRFS ensemble members crashed with GFS PBL (TKE-EDMF)/sfclay and clm lake combined. This happened when lake water was frozen to lake ice in clm lake.

The reason for the crash is because clm lake is called between surface layer scheme and PBL scheme. If there is a state change in clm lake, particularly water turning into ice, stability related variables over ice will be missing and cause the crash.

Allow waves and ice to exchange fields when coupled

For resolution of issues required for moving the mesh cap from the dev/ufs-weather-model branch of WW3 to the develop branch, testing of the ww3 mesh cap with ice-wave coupling enabled is required. This testing will be carried out in collaboration w/ NCAR.

For wave-ice coupling, the wave model needs to export the wave elevation spectrum and the ice model needs to export both the sea ice thickness and floe diameter. These fields can be added to esmFieldsExchange_nems even when ice-wave coupling is not active.

compile esmf8.1.0 in s2s

The CMEPS run failed in s2s when compile with esmf8.1.0bs20. The issue is fixed by updating CMEPS/mediator/makefile.

update to latest escomp/master for PIO initialization changes

The update to the lastest ESCOMP master will bring in component level PIO initialization to the HAFS application (or UFS Weather Model) without using shr_pio_mod.F90. The shr_pio_mod.F90 is also removed from the util/ directory.

Included in the update to escomp/master is a bugfix for cart3d in med_map_mod.F90. This mapping method is not currently implemented in ufs-weather.

mediator fails w/o error message when reading restart file which does not contain a field from component

When attempting to read a mediator restart file, the mediator fails if it cannot find a field in the restart file which matches the first field in the component field bundle. This can occur when a user attempts to use a mediator restart file (start_type=continue) after adding a component when the component was not active when the restart file was written. In fact, the correct setting in this case is to use start_type=startup. However, an error message should be reported by the mediator in order to help the user diagnose what they are doing wrong in this case.

remove ifrac_nstod from med_fraction_set

The current implementation of med_fraction_set for nems is setting the ifrac using a two-step procedure where first the ifrac is mapped with nearest neighbor (ifrac_nstod) and then conservative (ifrac). A conditional is used to determine the final ifrac value.

This procedure results in the isolated coastal anomalies seen in the v0.6 milestone runs. See ufs-s2s-model issue 116 for complete details.

The use of ifrac_nstod is unnecessary; the ifrac can be mapped directly with mapnstod_consf.

The following is a section of tile3 from phyf000:07:30.tile3.nc, showing the locations of two of the coastal anomalies (stars). On the left is the sea ice concentration, on the right the land-sea-ice mask. Locations of suspicious coast points are marked with stars.
v06

This is the same comparison when ifrac_nstod is removed and the ifrac is mapped directly with mapnstod_consf in med_fraction_set:

v06_ifrac_nstod

CMEPS is forced to use custom merges because sign of field imported from ATM is wrong or unit conversion is required

CMEPS has the capability to define generic merges between components. However, these generic merges are not available when the sign of the field needs to change, or the field needs to be converted to one of different units (ie, latent->evap).

Because of this issue, multiple "custom" merges are required in med_phases_prep_ocn. For example, the sensible heat flux from the ATM has the wrong sign, requiring a custom merge:

       customwgt(:) = -ofrac(:)
       call med_merge_field(is_local%wrap%FBExp(compocn),      'Faxa_sen',  &
            FBinA=is_local%wrap%FBImp(compatm,compocn), fnameA='Faxa_sen', wgtA=customwgt, rc=rc)
       if (ChkErr(rc,__LINE__,u_FILE_u)) return

The ATM exports the latent heat flux, but the ocean requires the evaporative flux, which requires a custom merge to change the sign and units of the field:

       customwgt(:) = -ofrac(:) / const_lhvap
       call med_merge_field(is_local%wrap%FBExp(compocn),      'Faxa_evap', &
            FBinA=is_local%wrap%FBImp(compatm,compocn), fnameA='Faxa_lat' , wgtA=customwgt, rc=rc)
       if (ChkErr(rc,__LINE__,u_FILE_u)) return

The momemtum fluxes from the ATM also require a custom merge to change the sign.

This adds needless complexity to maintain these custom merges when a better solution is to have the ATM export the coupling field with the right sign or unit. This also makes it possible to leverage the existing diagnostic capabilities with CMEPS to examine global budgets for UFS applications.

mapping ATM state fields bilinearly

Changes are required in esmFldsExchange_nems and med_map_mod to implement two changes: unity normalization and bilinear mapping of ATM state fields. These are changes from the current implementation in which the criteria used was validating the NEMS mediator functionality.

  1. CMEPS has the ability to apply a "unity" normalization when mapping from source to destination grid. This ensures that the mapping weights on the destination side add to one. The normalization is a static field which needs to be calculated only once (in med_map_mod) by mapping a field value 1.0 from each source component to each destination component for each defined mapping type between those two components. The reciprocal of the mapped value 1.0 is added to the mediator internal state and used when specifying that the normalization type for mapping is "one"; e.g.
call addmap(fldListFr(source_component)%flds, 'field_name', destination_component, mapconsf, "one", 'unset')

Note that an equivalent process happens when normalizing using a time-varying ice fraction. In that case, the the normalization in the above call would be set to ifrac. When normalizing by ifrac, the mapped destination field (= mapped source_field*ifrac) is normalized by the factor 1.0/(mapped ifrac).

The ability to apply unity normalization when not normalizing by ifrac was not available in NEMS and so was set to none in the mapping calls used by UFS. Since it is a static field that is calculated only once, there is no penalty to applying the unity normalization and it ensures that the mapping weights always add to one regardless of the mapping type.

  1. For CMEPS in UFS, ATM states (T,P,Q,U,V) are being mapped conservatively when mapped to the ICE (when coupled) or to the mediator (when using the mediator aoflux calculation). (The DATM application also maps the 2m and 10m state fields conservatively for use in the bulk flux option).

For the typical case in UFS, this means mapping from a coarse ATM to a fine OCN (relatively). This creates very un-smooth destination fields. For example, the following shows the mapped Tbot (from ATM) exported to the ICE in the C96-mx100 case in the Ross Sea (Antarctic) region. The left shows the conservatively mapped field and the right shows the bilinearly mapped field.

Screen Shot 2021-03-13 at 10 42 10 AM

The following shows the value at the x=130 line:

Screen Shot 2021-03-13 at 10 42 36 AM

Since ATM T,P,Q,U,V are global, unmasked states and not fluxes, the mapping should be switched to bilinear in order to provide smooth fields to the ICE model (coupled) and for the aoflux calculation (DATM). Changes are required to both esmFieldsExchange_nems (where the mapping is defined) as well as to the srcMaskValue used for a bilinear routehandle creation from ATM->OCN,ICE.

For the datm applications (either cdeps or nemsdatm), the ATM is much finer than the OCN. This results in smooth states being passed to the ICE and aofluxes even though they are being mapped conservatively.

resolve prep_ocn redundancies

Currently the custom merges in med_phases_prep_ocn_mod.F90 are separate for the modes nems_orig/frac and nems_orig_data. With the change to the bulk formulas (as implemented in the NEMS mediator PR #69), the comparable code in CMEPS can be simplified.

This will result in a single med_phases_prep_ocn_mod.F90 which is applicable for all nems modes (orig,frac and orig_data).

back out performance version of med_io_mod.F90

Further testing in CESM revealed that one test case did not pass the restart test due to changes in med_io_mod.F90. Reverting to the previous version passed all CESM tests so the performance changes in this module have been reverted until further testing determines the issue.

The reverted code has been tested in the ufs coupled model. All RTs run to completion and are b4b with previous answers.

Update ccpp-physics used in CMEPS

The ccpp-physics component is updated to include a new option to consider sea surface current in the computation of air-sea fluxes. The ccpp-physics code used in CMEPS will need to be updated to be consistent with those changes in ccpp-physics.

mediator files have incorrect lat/lon units when component utilizes radians

When the component lat/lon values are written by the mediator to either history files or the restart files, the units are currently set as degrees by default. This is inconsistent with the units sent by fv3atm, which are in radians.

For user clarity, the coordSys used by the component should be used to set the units.

using history files with ungridded dimensions fail

Turning on mediator history files when the field contains an ungridded dimension causes a seg fault. Mediator history files are used only for diagnostic/debugging. For UFS, the only application affected would be when wave-ice coupling is enabled.

nems datm requires modifications to aoflux calculation

For use in the NEMS DATM application, the 10m U,V winds, the 2m temperature and the 2m specific humidity need to be added to the fields passed to the aoflux calculation.

The aoflux calculation itself then needs to be modified to implement Hyun-Chul's preferred bulk formulation.

character string needs padding for white space

The added character strings for the variables for the bulk method variables in esmFldsExchange_nems_mod.F90 need to be padded to the same length. This is required for using the gnu compilers.

Write ATM history files as cubed-sphere tiles instead of Mesh

When mediator history files are enabled for CMEPS, the ATM component is written on the ATM mesh. This limits the usefulness of the history files because an additional processing step is required to place the fields on the ATM tiled grid for visualization.

Allowing the ATM history files to be optionally written on the cubed sphere tiles would allow developers to make quick checks of coupling fields during development. It could also be useful when implementing a set of graphical outputs that could be generated along with the RTs, as suggested in

.

remove conditional ifdefs for ESMF>8

There are currently conditional statements in CMEPS checking the ESMF version:

#if ESMF_VERSION_MAJOR >= 8
#if ESMF_VERSION_MINOR >  0

These should be removed if they are no longer required. @mvertens and @uturuncoglu Is this safe for CESM and HAFS?

incorrect mapping type for ifrac

The field Si_ifrac being exported by CMEPS to the ATM is currently being mapped with maptype mapnstod_consf (non-frac) and mapconsf (frac_mode). This is inconsistent with the value expected by FV3 (which assumes that the ifrac imported is weighted by the whole atm grid cell). The fix is to map by mapnstod_consd for nems_orig and mapconsd for nems_frac in med_fraction_mod.F90. This fix will change all current baselines.

This fix will be implemented as through CMEPS PR #10. This PR implements other changes which are required for CESM budget calculations but do not affect the NEMS implementation.

Update CMEPS

The CMEPS mediator needs to be updated to bring support for external land component under UFS weather model.

allow ungridded dimensions for partitioned stokes drift; update CMEPS for latest ESCOMP/master

Updates the partitioned stokes drift beween MOM6 and WW3 to use ungridded dimensions.

Includes an update made at ESCOMP/master to make the med_fldList fields a linked list instead of an array. This avoids a lot of small allocations and memory fragmentation (ESCOMP#322). Changes in UFS to modify wave coupling and add optional wave-ice coupling have also been merged at ESCOMP. An update to NOAA-EMC should be made to reconcile these changes.

NOTE: The changes related to CMEPS PR#322 were tested independently at the time of commit to ESCOMP. All baselines were B4B.

Refactor esmFldsExchange_nems

The CMEPS routine which defines the field exchanges for NEMS does not have the same structure as the routines used for HAFS and CESM. Specifically, in those cases the routine is called separately for the advertise and initialize phases. The NEMS routine should be refactored to be consistent with how CESM or HAFS coupling is implemented.

Refactor Fields exchange module for UFS

In UFS, fields exchanges are defined primarily by coupling_mode instead of by field. This is less extensible than to consider each field which goes to a component and allowing the coupling mode to be intrinsically set by defining source component.

For example, a given field to compocn comes from the mediator in the case of using the atm-ocean flux calculation (either on a-grid, o-grid or x-grid) or from an ATM (either active or data).

This will make UFS coupling easier to extend and maintain, especially as we move to extend both X-grid and diagnostic capabilities within UFS.

This work is related to #93, since it will depend on minimizing the custom merges that need to be done.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.