Problem with redistributing an averaged variable to different surface types
In the current implementation there is a problem, if a variable sent by the atmosphere should be redistribute on different surface types of the bottom model. The problem originates when registering the incoming atmospheric field as input variable in the main module:
!main: myname = name_atmos_var_t(j) !... CALL allocate_localvar(myname, grid_size(1), local_field(0,1)) ! index 0 means "all surface types" !... ! no constant value is given, so we will need to receive this field from the coupler ! we call a subroutine that sets a pointer to the correct local_field in the input_field list CALL add_input_field(myname, 'A', 0, 1, local_field(0,1), num_input_fields, input_field) ENDIF ! since we need this variable for calculations in each surface_type, set pointers CALL distribute_input_field(myname, 1, 0, 0, num_surface_types, local_field) !... !allocate_localvar: !... ALLOCATE(local_field%var(i)%field(length)) !... !add_input_field: !... input_field(num_input_fields)%field => local_field%var(i)%field !... !distribute_input_field: !... DO j=1,num_surface_types IF ((j == to_surface_type) .OR. ((j /= from_surface_type) .AND. (to_surface_type == 0))) THEN local_field(j,which_grid)%var(i)%field => local_field(from_surface_type,which_grid)%var(i)%field ENDIF ENDDO !...
With the given arguments the
distribute_input_field routine yields that
local_field(1,which_grid)%var(i)%field => local_field(0,which_grid)%var(i)%field local_field(2,which_grid)%var(i)%field => local_field(0,which_grid)%var(i)%field !... local_field(6,which_grid)%var(i)%field => local_field(0,which_grid)%var(i)%field
Thus all surface-type-dependent fields point to the same averaged field and cannot be set individually.
The concept of the
distribute_input_field routine should be reconsidered!
There are at least two possible ways to solve the issue. One way is to implement new variables as done in the workaround. The more elegant solution would be to introduce a namelist option
redistribution_atmos_var_t(i) which is "auto" by default, and could e.g. be set to "radi" for radiation. This option could later be checked, and the call to
distribute_input_field would only be done if the value is actually "auto". Otherwise,
allocate_localvar would be called for all surface types.
This namelist option could be used a second time: For all those fields where
redistribution_atmos_var_t(i) is set to "radi", the subroutine
distribute_radiation_flux would be called.
This allows to add other specific redistribution schemes later, in addition to "auto" and "radi".
Deleting a branch is permanent. It CANNOT be undone. Continue?