﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
368	bulk fluxes and adjoint-based algorithms	arango	arango	"The bulk flux ('''BULK_FLUXES''') formulation in ROMS is complicated and highly nonlinear.  Although we have the tangent linear, representer, and adjoint versions of '''bulk_flux.F''', we have found out stability issues with the linearization in the adjoint-based algorithms.

In the past, we have run the nonlinear model first and saved the fluxes in the history file to be used as a forcing file in the adjoint-based applications. The problem that we had with this strategy is that we output the surface salinity flux as '''(E-P)*Ssur''' (variable '''ssflux''') and the model at input just needs '''E-P''' (variable '''swflux'''). In order to avoid conflicts, a new variable is introduced '''EminusP''' that allows some flexibility. So '''varinfo.dat''' has now the following entry:

{{{
'EminusP'                                          ! Input/Output
  'bulk_flux surface net freswater flux, (E-P)'
  'meter second-1'                                 ! computed by NLM ROMS
  'EminusP, scalar, series'                        ! bulk_flux.F and
  'ocean_time'                                     ! needed in adjoint-based
  'idEmPf'                                         ! applications
  'r2dvar'
  1.0d0
}}}

Also, all the input script were modified to add a new I/O variable switch:
{{{
Hout(idEmPf) == F                          ! E-P flux
}}}

A new C-preprocessing option '''NL_BULK_FLUXES''' was introduced to handle the reading of surface fluxes computed by the nonlinear model ('''bulk_flux.F''') in the representer model.  See '''rp_get_data.F''' and '''rp_set_data.F'''.

This option can be also used in the nonlinear model when '''BULK_FLUXES''' is not defined to read such surface salinity flux if needed:
{{{
#  if defined NL_BULK_FLUXES && !defined BULK_FLUXES
!
!-----------------------------------------------------------------------
!  Surface net freshwater flux (E-P) from NLM bulk flux computation.
!-----------------------------------------------------------------------
!
      CALL get_2dfld (ng, iRPM, idEmPf, ncFRCid(idEmPf,ng),             &
     &                nFfiles(ng), FRCname(1,ng), update(1),            &
     &                LBi, UBi, LBj, UBj, 2, 1,                         &
#   ifdef MASKING
     &                GRID(ng) % rmask(LBi,LBj),                        &
#   endif
     &                FORCES(ng) % stflxG(LBi,LBj,1,isalt))

#  elif !(defined ANA_SSFLUX || defined EMINUSP || defined SRELAXATION)
!
!-----------------------------------------------------------------------
!  Surface net freshwater flux: E-P.
!-----------------------------------------------------------------------
!
      CALL get_2dfld (ng, iNLM, idsfwf, ncFRCid(idsfwf,ng),             &
     &                nFfiles(ng), FRCname(1,ng), update(1),            &
     &                LBi, UBi, LBj, UBj, 2, 1,                         &
#   ifdef MASKING
     &                GRID(ng) % rmask(LBi,LBj),                        &
#   endif
     &                FORCES(ng) % stflxG(LBi,LBj,1,isalt))
#  endif
}}}

Many thanks to Andy Moore for suggesting this capability."	upgrade	closed	major	Adjoint Based Algorithms	Adjoint	3.3	Done		
