NCAR / ccpp-scm

CCPP Single Column Model
Other
13 stars 50 forks source link

All debug runs fail with gcc+gfortran on macOS #310

Closed climbfuji closed 2 years ago

climbfuji commented 2 years ago

As of 2022/03/27, all debug runs fail on macOS with gcc+gfortran with

An error occurred in ccpp_physics_init: Detected size mismatch for variable physics%Model%input_nml_file in group physics before cires_ugwp_init, expected        0 but got        1. Exiting...

This is because Fortran thinks that the uninitialized array

    character(len=:), pointer, dimension(:) :: input_nml_file => null() !< character string containing full namelist
                                                                        !< for use with internal file reads

has length one and not length zero.

I am not sure if this is the case with other compilers/on other systems, therefore the best way to fix this is to add an active attribute in GFS_typedefs.meta (last line below):

[input_nml_file_length]
  standard_name = number_of_lines_in_internal_namelist
  long_name = lines in namelist file for internal file reads
  units = count
  dimensions = ()
  type = integer
[input_nml_file]
  standard_name = filename_of_internal_namelist
  long_name = namelist filename for internal file reads
  units = none
  dimensions = (number_of_lines_in_internal_namelist)
  type = character
  kind = len=256
  active = (number_of_lines_in_internal_namelist > 0)

This tells the debug checks in the autogenerated caps to bypass filename_of_internal_namelist if number_of_lines_in_internal_namelist == 0.

climbfuji commented 2 years ago

@grantfirl Note that the corresponding change was merged into fv3atm: https://github.com/NOAA-EMC/fv3atm/commit/bffbeeb523bba6119dd17abfc73ab9125a4f5e07