New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
#1831 (Adding the ability to read character attributes using iom_getatt) – NEMO

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#1831 closed Enhancement (fixed)

Adding the ability to read character attributes using iom_getatt

Reported by: acc Owned by: acc
Priority: low Milestone:
Component: OCE Version: trunk
Severity: Keywords:
Cc:

Description

Context

iom_getatt is a generic routine that currently (in dev_merge_2016 branch) accepts integer and real arguments. The interface for this is done correctly in iom.F90 but at the next level (iom_nf90.F90) one routine satisfies both uses with optional arguments and complicated logic. This is not easily extended for the additional case of character attributes.

Changes

The best solution is to introduce a proper generic routine into iom_nf90.F90. At the same time the option to read either file or variable attributes can be added for all types (currently it is only available for real attributes). The user will see only one routine: iom_getatt( fid, attr_name, retvar, var_name) where varname is optional (if omitted a file attribute is looked for), and retvar can be either integer, real or a character string. Inside iom.F90, iom_getatt is an interface to three routines: iom_g0d_iatt, iom_g0d_ratt and iom_g0d_catt. Each of these calls a generic routine: iom_nf90_getatt which is, in turn, an interface to three routines: iom_nf90_iatt, iom_nf90_ratt and iom_nf90_catt which are defined in iom_nf90.F90.

Commit History (2)

ChangesetAuthorTimeChangeLog
7584acc2017-01-20T15:42:50+01:00

Branch dev_merge_2016. Added iom_putatt routine to enable writing of netcdf attributes to domain configuration files. See ticket #1831

7577acc2017-01-18T18:32:11+01:00

Branch dev_merge_2016. Tidy iom_getatt routine and add ability to read character attributes. See #1831 for details

Change History (3)

comment:1 Changed 7 years ago by acc

  • Resolution set to fixed
  • Status changed from new to closed

Changes made and tested at Changeset [7577]

comment:2 Changed 7 years ago by acc

  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopened ticket in order to add iom_putatt routine which will enable the writing of attributes to netcdf output files. Primarily this is to allow cfg_write (domain.F90) to write ancillary information such as cn_cfg and nn_cfg to the domain configuration output file but the generic routines exist for the three scalar type and for general use. For clarity, the iom_getatt component routines have been renamed. The generic routines and their internal components within each of the iom.F90 and iom_nf90.F90 modules now look like this:

          iom.F90                      |            iom_nf90.F90
                                       |
              ____ iom_g0d_iatt ___    |                     ____ iom_nf90_giatt 
             /                      \  |                    /
iom_getatt-------  iom_g0d_ratt ----------- iom_nf90_getatt ----- iom_nf90_gratt
             \                      /  |                    \
              ---- iom_g0d_catt ----   |                     ---- iom_nf90_gcatt 


              ____ iom_p0d_iatt ___    |                     ____ iom_nf90_piatt
             /                      \  |                    /
iom_putatt-------  iom_p0d_ratt ----------- iom_nf90_putatt ----- iom_nf90_pratt
             \                      /  |                    \
              ---- iom_p0d_catt ----   |                     ---- iom_nf90_pcatt

but users and most developers should not need to look beyond the top-end iom_getatt and iom_putatt routines:

SUBROUTINE iom_getatt( INTEGER kiomid, CHARACTER cdatt, INTEGER || REAL(wp) || CHARACTER(*) pvar, (optional) CHARACTER(*) cdvar )

and

SUBROUTINE iom_putatt( INTEGER kiomid, CHARACTER cdatt, INTEGER || REAL(wp) || CHARACTER(*) pvar, (optional) CHARACTER(*) cdvar )

where:
kiomid is the file identifier
cdatt  is the name of the attribute
pvar   is the variable to receive the attribute value (iom_getatt) or the value to be written (iom_putatt)
cdvar  is the (optional) name of the variable to be associated with the attribute. If omitted the attribute is assumed to be a file attribute.
Last edited 7 years ago by acc (previous) (diff)

comment:3 Changed 7 years ago by acc

  • Resolution set to fixed
  • Status changed from reopened to closed

Changes made and tested at Changeset [7584]

Note: See TracTickets for help on using tickets.