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.
Changeset 11971 for NEMO/branches – NEMO

Changeset 11971 for NEMO/branches


Ignore:
Timestamp:
2019-11-26T18:17:21+01:00 (4 years ago)
Author:
smueller
Message:

Inclusion of average regressor values, regressor metadata, and references to the analysed fields in the intermediate-data output for multiple-linear-regression analysis (ticket #2175)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2019/dev_r11879_ENHANCE-05_SimonM-Harmonic_Analysis/src/OCE/DIA/diamlr.F90

    r11961 r11971  
    6060      TYPE(xios_fieldgroup)                       ::   slxhdl_fldgrp 
    6161      TYPE(xios_filegroup)                        ::   slxhdl_filgrp 
    62       TYPE(xios_field), ALLOCATABLE, DIMENSION(:) ::   slxhdl_regs, slxhdl_flds 
     62      TYPE(xios_field), ALLOCATABLE, DIMENSION(:) ::   slxhdl_regs,    slxhdl_flds 
    6363      TYPE(xios_field)                            ::   slxhdl_fld 
    6464      TYPE(xios_file)                             ::   slxhdl_fil 
    65       LOGICAL                                     ::   llxatt_enabled 
    66       CHARACTER(LEN=256)                          ::   clxatt_expr 
     65      LOGICAL                                     ::   llxatt_enabled, llxatt_comment 
     66      CHARACTER(LEN=256)                          ::   clxatt_expr,    clxatt_comment 
    6767      CHARACTER(LEN=32)                           ::   clxatt_name1,   clxatt_name2 
    6868      CHARACTER(LEN=32)                           ::   clxatt_gridref, clxatt_fieldref 
     
    124124            CALL xios_add_child      ( slxhdl_filgrp, slxhdl_fil, "diamlr_file_"//cl6a ) 
    125125            CALL xios_set_attr       ( slxhdl_fil, name_suffix="_diamlr_"//cl6a,   & 
    126                &                       description="Intermediary output for multiple-linear-regression analysis - "//cl6a ) 
     126               &                       description="Intermediate output for multiple-linear-regression analysis - "//cl6a ) 
    127127            CALL iom_update_file_name( "diamlr_file_"//cl6a ) 
    128128         END DO 
     
    193193                  END DO 
    194194 
    195                   ! Set name attribute (and overwrite possible pre-configured name) 
    196                   ! with field id to enable id string retrieval from stored handle 
    197                   ! below; also re-set expression with possible substitutions 
    198                   CALL xios_set_attr  ( slxhdl_regs(ireg+1), name="diamlr_r"//cl3i, expr=TRIM( clxatt_expr ) ) 
     195                  ! Set standard value for comment attribute, including possible 
     196                  ! existing comment added in parantheses 
     197                  CALL xios_is_defined_attr( slxhdl_regs(ireg+1), comment=llxatt_comment ) 
     198                  IF ( llxatt_comment ) THEN 
     199                     CALL xios_get_attr( slxhdl_regs(ireg+1), comment=clxatt_comment ) 
     200                     clxatt_comment = "Regressor "//cl3i//" ("//TRIM( clxatt_comment )//") " 
     201                  ELSE 
     202                     clxatt_comment = "Regressor "//cl3i 
     203                  END IF 
     204 
     205                  ! Set name attribute (and overwrite possible pre-configured 
     206                  ! name) with field id to enable id string retrieval from 
     207                  ! stored handle below, re-set expression with possible 
     208                  ! substitutions, and set or re-set comment attribute 
     209                  CALL xios_set_attr  ( slxhdl_regs(ireg+1), name="diamlr_r"//cl3i, expr=TRIM( clxatt_expr ),   & 
     210                     &                  comment=TRIM( clxatt_comment ) ) 
    199211 
    200212                  ireg = ireg + 1   ! Accept regressor in list of active regressors 
     
    241253            !      3-dimensional versions are simply obtained via grid 
    242254            !      transformations from the 2-dimensional version. 
    243             CALL xios_get_attr  ( slxhdl_regs( jm ), name=clxatt_name1, expr=clxatt_expr, enabled=llxatt_enabled ) 
     255            CALL xios_get_attr  ( slxhdl_regs( jm ), name=clxatt_name1, expr=clxatt_expr,              & 
     256               &                  enabled=llxatt_enabled, comment=clxatt_comment ) 
    244257            CALL xios_add_child ( slxhdl_fldgrp, slxhdl_fld, TRIM( clxatt_name1 )//"_2D" ) 
    245258            CALL xios_set_attr  ( slxhdl_fld, expr=TRIM( clxatt_expr ), grid_ref="diamlr_grid_2D",     & 
     
    251264               &                  field_ref=TRIM( clxatt_name1 )//"_2D", enabled=llxatt_enabled) 
    252265 
    253             !  ii) set up definitions for the output of scalar products with 
    254             !      itself and with other active regressors 
     266            !  ii) set up output of active regressors, including metadata 
     267            CALL xios_get_handle( "diamlr_file_scalar", slxhdl_fil ) 
     268            ! Add regressor to output file 
     269            CALL xios_add_child ( slxhdl_fil, slxhdl_fld, TRIM( clxatt_name1 ) ) 
     270            CALL xios_set_attr  ( slxhdl_fld, standard_name=TRIM( clxatt_comment ), long_name=TRIM( clxatt_expr ),   & 
     271               &                  operation="average" ) 
     272                
     273            ! iii) set up the output of scalar products with itself and with 
     274            !      other active regressors 
    255275            CALL xios_get_attr  ( slxhdl_regs(jm), name=clxatt_name1 ) 
    256             CALL xios_get_handle( "diamlr_file_scalar", slxhdl_fil) 
    257276            DO jn = 1, jm 
    258277               ! Field for product between regressors 
    259                CALL xios_get_attr  ( slxhdl_regs(jn), name=clxatt_name2, enabled=llxatt_enabled ) 
     278               CALL xios_get_attr  ( slxhdl_regs(jn), name=clxatt_name2 ) 
    260279               CALL xios_add_child ( slxhdl_fldgrp, slxhdl_fld, TRIM( clxatt_name1 )//"."//TRIM( clxatt_name2 ) ) 
    261280               ! Set appropriate name attribute to avoid the possibility of 
    262281               ! using an inappropriate inherited name attribute as the variable 
    263282               ! name in the output file 
    264                CALL xios_set_attr  ( slxhdl_fld, name=TRIM( clxatt_name1 )//"."//TRIM( clxatt_name2 ),      & 
    265                   &                  grid_ref="diamlr_grid_scalar", expr="this * "//TRIM( clxatt_name2 ),   & 
    266                   &                  field_ref=TRIM( clxatt_name1 ), enabled=llxatt_enabled, operation="accumulate") 
     283               CALL xios_set_attr  ( slxhdl_fld,                                                        & 
     284                  &                  name=TRIM( clxatt_name1 )//"."//TRIM( clxatt_name2 ),              & 
     285                  &                  grid_ref="diamlr_grid_scalar",                                     & 
     286                  &                  expr="this * "//TRIM( clxatt_name2 ),                              & 
     287                  &                  field_ref=TRIM( clxatt_name1 ),                                    & 
     288                  &                  enabled=llxatt_enabled,                                            & 
     289                  &                  long_name="Scalar product of regressor "//TRIM( clxatt_name1 )//   & 
     290                  &                     " and regressor "//TRIM( clxatt_name2 ),                        & 
     291                  &                  standard_name=TRIM( clxatt_name1 )//"."//TRIM( clxatt_name2 ),     & 
     292                  &                  operation="accumulate") 
    267293               ! Add regressor-product field to output file 
    268294               CALL xios_add_child ( slxhdl_fil, slxhdl_fld, TRIM( clxatt_name1 )//"."//TRIM( clxatt_name2 ) ) 
     
    282308               ! Set appropriate name attribute to avoid the possibility of 
    283309               ! using an inappropriate inherited name attribute as the variable 
    284                ! name in the output file 
    285                CALL xios_set_attr  ( slxhdl_fld, name=TRIM( clxatt_name2 )//"."//TRIM( clxatt_name1 ),         & 
    286                   &                  expr="this * "//TRIM( clxatt_fieldref ), grid_ref="diamlr_grid_"//clgd,   & 
    287                   &                  field_ref=TRIM( clxatt_name1 )//"_"//clgd, enabled=llxatt_enabled, operation="accumulate" ) 
     310               ! name in the output file; use metadata (standard_name and 
     311               ! long_name) to refer to the id of the analysed field 
     312               CALL xios_set_attr  ( slxhdl_fld,                                                         & 
     313                  &                  name=TRIM( clxatt_name2 )//"."//TRIM( clxatt_name1 ),               & 
     314                  &                  expr="this * "//TRIM( clxatt_fieldref ),                            & 
     315                  &                  grid_ref="diamlr_grid_"//clgd,                                      & 
     316                  &                  field_ref=TRIM( clxatt_name1 )//"_"//clgd,                          & 
     317                  &                  enabled=llxatt_enabled,                                             & 
     318                  &                  long_name="Scalar product of "//TRIM( clxatt_fieldref )//           & 
     319                  &                     " and regressor "//TRIM( clxatt_name1 ),                         & 
     320                  &                  standard_name=TRIM( clxatt_fieldref )//"."//TRIM( clxatt_name1 ),   & 
     321                  &                  operation="accumulate" ) 
    288322               CALL xios_get_handle( "diamlr_file_grid_"//clgt, slxhdl_fil ) 
    289323               CALL xios_add_child ( slxhdl_fil, slxhdl_fld, TRIM( clxatt_name2 )//"."//TRIM( clxatt_name1 ) ) 
Note: See TracChangeset for help on using the changeset viewer.