diff --git a/diag_manager/diag_data.F90 b/diag_manager/diag_data.F90 index 6e29583146..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 @@ -183,7 +179,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 +406,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 +439,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..7de428ea5f 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)) 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