﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
950	VERY IMPORTANT: Refactoring of output fields into NetCDF files	arango		"The **ROMS** output fields continue growing, and managing the various NetCDF files is becoming daunting. Therefore, we have separated into specific modules for **BBL**, **!SeaIce**, **Sediment**, and **WEC** models, which are sub-directories of **ROMS/Nonlinear**:

 * **ROMS/Nonlinear/BBL/bbl_out.F**: It processes the Bottom Boundary Layer and Waves variables into history, quicksave, averages, and stations NetCDF files.

 * **ROMS/Nonlinear/SeaIce/ice_output.F**: It processes sea-ice model variables into history, quicksave, and averages NetCDF files.

 * **ROMS/Nonlinear/Sediment/sediment_out.F**: It processes sediment variables into history, quicksave, averages, and stations NetCDF files.

 * **ROMS/Nonlinear/WEC/wec_out.F**: It processes the Waves Effect on Currents variables into history, quicksave, averages, and stations NetCDF files.

It facilitates further field expansion and modifications for each separated model.

For example, in **def_his.F**, we call routines from the above modules to define the associated **history** variables:

{{{
#if (defined BBL_MODEL || defined WAVES_OUTPUT) && defined SOLVE3D
!
!-----------------------------------------------------------------------
! Define the bottom boundary layer model or wave variables.
!-----------------------------------------------------------------------
!
        CALL bbl_def_nf90 (ng, model, ldef, Hout, HIS,                  &
     &                     t2dgrd, u2dgrd, v2dgrd)
        IF (FoundError(exit_flag, NoError, __LINE__, MyFile)) RETURN
#endif

#if defined ICE_MODEL && defined SOLVE3D
!
!-----------------------------------------------------------------------
! Define sea-ice model variables.
!-----------------------------------------------------------------------
!
        CALL ice_def_nf90 (ng, model, ldef, Hout, HIS,                  &
     &                     t2dgrd, u2dgrd, v2dgrd)
        IF (FoundError(exit_flag, NoError, __LINE__, MyFile)) RETURN
#endif

#if defined SEDIMENT && defined SOLVE3D
!
!-----------------------------------------------------------------------
! Define sediment model variables.
!-----------------------------------------------------------------------
!
        CALL sediment_def_nf90 (ng, model, ldef, Hout, HIS,             &
     &                          t2dgrd, u2dgrd, v2dgrd,                 &
     &                          b3dgrd)
        IF (FoundError(exit_flag, NoError, __LINE__, MyFile)) RETURN
#endif

#if defined WEC_VF && defined SOLVE3D
!
!-----------------------------------------------------------------------
! Define Waves Effect on Currents variables.
!-----------------------------------------------------------------------
!
        CALL wec_def_nf90 (ng, model, ldef, Hout, HIS,                  &
     &                     t2dgrd, u2dgrd, v2dgrd,                      &
     &                     t3dgrd, u3dgrd, v3dgrd, w3dgrd)
        IF (FoundError(exit_flag, NoError, __LINE__, MyFile)) RETURN
#endif
}}}
Similarly, the actual writing of the variables in **wrt_his.F** can be accomplished by calling the respective routines:

{{{
#if (defined BBL_MODEL || defined WAVES_OUTPUT) && defined SOLVE3D
!
!-----------------------------------------------------------------------
! Write out the bottom boundary layer model or wave variables.
!-----------------------------------------------------------------------
!
        CALL bbl_wrt_nf90 (ng, model, tile,                             &
     &                     LBi, UBi, LBj, UBj,                          &
     &                     Hout, HIS)
        IF (FoundError(exit_flag, NoError, __LINE__, MyFile)) RETURN
#endif

#if defined ICE_MODEL && defined SOLVE3D
!
!-----------------------------------------------------------------------
! Write out sea-ice model variables.
!-----------------------------------------------------------------------
!
        CALL ice_wrt_nf90 (ng, model, tile,                             &
     &                     LBi, UBi, LBj, UBj,                          &
     &                     Hout, HIS)
        IF (FoundError(exit_flag, NoError, __LINE__, MyFile)) RETURN
#endif

#if defined SEDIMENT && defined SOLVE3D
!
!-----------------------------------------------------------------------
! Write out sediment model variables.
!-----------------------------------------------------------------------
!
        CALL sediment_wrt_nf90 (ng, model, tile,                        &
     &                          LBi, UBi, LBj, UBj,                     &
     &                          Hout, HIS)
        IF (FoundError(exit_flag, NoError, __LINE__, MyFile)) RETURN
#endif

#if defined WEC_VF && defined SOLVE3D
!
!-----------------------------------------------------------------------
! Write out the Waves Effect on Currents variables.
!-----------------------------------------------------------------------
!
      CALL wec_wrt_nf90 (ng, model, tile,                               &
    &                    LBi, UBi, LBj, UBj,                            &
    &                    Hout, HIS)
      IF (FoundError(exit_flag, NoError, __LINE__, MyFile)) RETURN
#endif
}}}

The above subroutines are generic and can be called for the **quicksave** and **averages** files by replacing the **Hout** and **HIS** arguments. There are also subroutines for processing the **stations** variables. For example, in module **sediment_output_mod**, we have the following public routines:

{{{
      PUBLIC :: sediment_def_nf90
# if defined PIO_LIB && defined DISTRIBUTE
      PUBLIC :: sediment_def_pio
# endif
# ifdef STATIONS
      PUBLIC :: sediment_def_station_nf90
#  if defined PIO_LIB && defined DISTRIBUTE
      PUBLIC :: sediment_def_station_pio
#  endif
# endif
      PUBLIC :: sediment_wrt_nf90
# if defined PIO_LIB && defined DISTRIBUTE
      PUBLIC :: sediment_wrt_pio
# endif
# ifdef STATIONS
      PUBLIC :: sediment_wrt_station_nf90
#  if defined PIO_LIB && defined DISTRIBUTE
      PUBLIC :: sediment_wrt_station_pio
#  endif
# endif
}}}
Thus, the output variables code is more compact and categorized."	upgrade	closed	major	Release ROMS/TOMS 4.2	Nonlinear	4.1	Done		
