Different lengths of CHARACTER (3/4) in array constructor, how to trim lines - fortran

In accordance with the answer to a similar question, I declared characters, as indicated here gfortran does not allow arrays of characters with different component lengths . However, I would like to use the trim function because I need to add spaces for manually entering names, and these variables will then be used in another part of the code. Can I crop at the same time as creating the array?

Error: different lengths of CHARACTER (3/4) in the array constructor in (1)

If I add random characters to make them the same length, it works, but I can't do it for obvious reasons. I compiled both gfortran and mpif90 with the same results

use mod_maxdims , only : maxstr
integer, parameter :: nvars_ncep = 12

character(len=maxstr), parameter, dimension(nvars_ncep) :: vars_ncep =                  &
                           (/ 'air'              & ! Air temperature                  [      K]
                            , 'pres'             & ! Pressure                         [     Pa]
                            , 'rhum'             & ! Relative humidity                [      %]
                            , 'uwnd'             & ! Zonal wind                       [    m/s]
                            , 'vwnd'             & ! Zonal wind                       [    m/s]
                            , 'pres'             & ! Pressure                         [     Pa]
                            , 'dlwrf'            & ! Downward long wave radiation     [   W/m2]
                            , 'nbdsf'            & ! Near-IR beam radiation           [   W/m2]
                            , 'nddsf'            & ! Near-IR diffuse radiation        [   W/m2]
                            , 'vbdsf'            & ! Visible beam radiation           [   W/m2]
                            , 'vddsf'            & ! Visible beam radiation           [   W/m2]
                            , 'prate'           /) ! Precipitation rate               [kg/m2/s]
+4
1

gfortran ; , , .

, , . , .

. - vars_ncep(1) = 'air', , . , , , parameter.

+4

All Articles