ESCOMP / CAM-SIMA

Community Atmosphere Model - System for Integrated Modeling of the Atmosphere
4 stars 12 forks source link

Add framework for reading data from file to pass to physics suites #162

Open peverwhee opened 3 years ago

peverwhee commented 3 years ago

New namelist variable format:

< stdname >_file = "< filename >" < stdname >_frequency = "init" < stdname >_file_varnames = "< varname1 >,< varname2 >" < stdname >_interpolate = .false.

  1. Add metadata file based on scheme's namelist variables (will be auto-generated)
  2. Read namelist variables (in gw namelist reader that will one day be auto-generated) & register info from namelist in hash table (declare variable as initialized)
  3. Use _frequency to check if it's time to read the data. If so, find the variable in the file using _file_varnames list.

(driving force for this framework: need orographic data for gravity waves scheme)

gold2718 commented 3 years ago

If we use a derived type to hold this information for an input variable:

! New module or physics_data.F90?
type, public :: input_data_field_t
   character(len=:), allocatable :: standard_name
   character(len=:), allocatable :: filename
   character(len=:), allocatable :: frequency
   character(len=:), allocatable :: file_varnames
   logical                       :: interpolate
end type input_data_field_t

! One of these variables for each input variable, declared and used in a scheme's namelist-reader module.
type(input_data_field_t) :: <stdname>
<stdname>%standard_name = <stdname>

then, we can use syntax that automatically sets <stdname>:

<stdname>%filename = "<filename>"
<stdname>%frequency = "init"
<stdname>%file_varnames = "<varname1>,<varname2>"
<stdname>%interpolate = .false.

After the namelist processing is complete (read, broadcast, print), add this item to the hash table (located in the same module which contains input_data_field_t and which will do the reading).

Bonus, add a print method to input_data_field_t to ease printing in each namelist-reader module.

gold2718 commented 3 years ago

We will also need a metadata file (type = module) for each namelist-reader file with one variable defined for each scheme input that needs to be read from a file.