From 4cec698801dbfcdd7b0854d029c9e86e8c4d771e Mon Sep 17 00:00:00 2001 From: Thomas Robinson Date: Thu, 20 May 2021 08:14:10 -0400 Subject: [PATCH 1/3] Makes MAX_FIELDS_PER_FILE a namelist variable and allocates the fields with this value. --- diag_manager/diag_data.F90 | 5 +++-- diag_manager/diag_util.F90 | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/diag_manager/diag_data.F90 b/diag_manager/diag_data.F90 index 6e29583146..007b581c45 100644 --- a/diag_manager/diag_data.F90 +++ b/diag_manager/diag_data.F90 @@ -183,7 +183,7 @@ MODULE diag_data_mod TYPE file_type CHARACTER(len=128) :: name !< Name of the output file. CHARACTER(len=128) :: long_name - INTEGER, DIMENSION(max_fields_per_file) :: fields + INTEGER, allocatable, DIMENSION(:) :: fields INTEGER :: num_fields INTEGER :: output_freq INTEGER :: output_units @@ -410,6 +410,7 @@ MODULE diag_data_mod ! Will determine which value to use when checking a regional output if the region is the full axis or a sub-axis. ! The values are defined as GLO_REG_VAL (-999) and GLO_REG_VAL_ALT (-1) in diag_data_mod. ! + !> MAX_FIELDS_PER_FILE default = 300 Maximum number of fields per file. LOGICAL :: append_pelist_name = .FALSE. LOGICAL :: mix_snapshot_average_fields =.FALSE. INTEGER :: max_files = 31 !< Maximum number of output files allowed. Increase via diag_manager_nml. @@ -442,7 +443,7 @@ MODULE diag_data_mod INTEGER :: max_axis_attributes = 4 !< Maximum number of user definable attributes per axis. LOGICAL :: prepend_date = .TRUE. !< Should the history file have the start date prepended to the file name LOGICAL :: use_mpp_io = .false. !< false is fms2_io (default); true is mpp_io - + INTEGER :: MAX_FIELDS_PER_FILE = 300 !< Maximum number of fields per file. ! ! ! Fill value used. Value will be NF90_FILL_REAL if using the diff --git a/diag_manager/diag_util.F90 b/diag_manager/diag_util.F90 index 673c98b38c..b9551ae7ee 100644 --- a/diag_manager/diag_util.F90 +++ b/diag_manager/diag_util.F90 @@ -1355,6 +1355,8 @@ SUBROUTINE init_output_field(module_name, field_name, output_name, output_file,& ! CALL error_mesg('diag_util_mod::init_output_field',& & 'MAX_FIELDS_PER_FILE = '//TRIM(error_msg)//' exceeded. Increase MAX_FIELDS_PER_FILE in diag_data.F90.', FATAL) + ELSEIF (.not. allocated(files(file_num)%fields(num_fields)) then + allocate(files(file_num)%fields(MAX_FIELDS_PER_FILE)) END IF num_fields = files(file_num)%num_fields files(file_num)%fields(num_fields) = out_num From 53500a4d0a140b1405b13c7decb708b383630759 Mon Sep 17 00:00:00 2001 From: Thomas Robinson Date: Thu, 20 May 2021 09:07:43 -0400 Subject: [PATCH 2/3] Fixes typos in diag_data.F90 diag_util.F90 --- diag_manager/diag_data.F90 | 4 ---- diag_manager/diag_util.F90 | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/diag_manager/diag_data.F90 b/diag_manager/diag_data.F90 index 007b581c45..ae6a74598f 100644 --- a/diag_manager/diag_data.F90 +++ b/diag_manager/diag_data.F90 @@ -93,9 +93,6 @@ MODULE diag_data_mod ! - ! - ! Maximum number of fields per file. - ! ! ! ! @@ -121,7 +118,6 @@ MODULE diag_data_mod ! Return value for a diag_field that isn't found in the diag_table ! ! Specify storage limits for fixed size tables used for pointers, etc. - INTEGER, PARAMETER :: MAX_FIELDS_PER_FILE = 300 !< Maximum number of fields per file. INTEGER, PARAMETER :: DIAG_OTHER = 0 INTEGER, PARAMETER :: DIAG_OCEAN = 1 INTEGER, PARAMETER :: DIAG_ALL = 2 diff --git a/diag_manager/diag_util.F90 b/diag_manager/diag_util.F90 index b9551ae7ee..9b612ea594 100644 --- a/diag_manager/diag_util.F90 +++ b/diag_manager/diag_util.F90 @@ -1355,7 +1355,7 @@ SUBROUTINE init_output_field(module_name, field_name, output_name, output_file,& ! CALL error_mesg('diag_util_mod::init_output_field',& & 'MAX_FIELDS_PER_FILE = '//TRIM(error_msg)//' exceeded. Increase MAX_FIELDS_PER_FILE in diag_data.F90.', FATAL) - ELSEIF (.not. allocated(files(file_num)%fields(num_fields)) then + ELSEIF (.not. allocated(files(file_num)%fields(num_fields))) THEN allocate(files(file_num)%fields(MAX_FIELDS_PER_FILE)) END IF num_fields = files(file_num)%num_fields From 812ed15d32edbc85581749c14fd54cc2bff9fb81 Mon Sep 17 00:00:00 2001 From: Thomas Robinson Date: Thu, 20 May 2021 09:55:56 -0400 Subject: [PATCH 3/3] Fixes issue with checking an allocatable --- diag_manager/diag_util.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diag_manager/diag_util.F90 b/diag_manager/diag_util.F90 index 9b612ea594..7de428ea5f 100644 --- a/diag_manager/diag_util.F90 +++ b/diag_manager/diag_util.F90 @@ -1355,7 +1355,7 @@ SUBROUTINE init_output_field(module_name, field_name, output_name, output_file,& ! CALL error_mesg('diag_util_mod::init_output_field',& & 'MAX_FIELDS_PER_FILE = '//TRIM(error_msg)//' exceeded. Increase MAX_FIELDS_PER_FILE in diag_data.F90.', FATAL) - ELSEIF (.not. allocated(files(file_num)%fields(num_fields))) THEN + ELSEIF (.not. allocated(files(file_num)%fields)) THEN allocate(files(file_num)%fields(MAX_FIELDS_PER_FILE)) END IF num_fields = files(file_num)%num_fields