Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

How to Fix: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)

William.Hatheway

Active member
The recent releases of Ubuntu 22 and Ubuntu 23 by Canonical introduced several changes to their base operating system, including significant updates to the GNU Compiler Collection (GCC). Specifically, these versions have been upgraded to GCC 11 and GCC 12, respectively.

A noteworthy aspect of this update is its impact on legacy Fortran code compatibility. GCC versions greater than 9 have deprecated certain antiquated Fortran commands, resulting in compatibility issues during the installation of the Weather Research and Forecasting (WRF) model. This is due to the default disabling of older code syntaxes in these newer GCC versions, which leads to errors.

To address this and ensure compatibility with legacy Fortran code while compiling libraries for WRF, WPS, and other related software, it is necessary to set specific environment variables before the compilation process. These variables enable the older Fortran code syntaxes. The required environment variables and their values are as follows:


Bash:
export fallow_argument=-fallow-argument-mismatch
export boz_argument=-fallow-invalid-boz

export FFLAGS="$fallow_argument $boz_argument -m64"
export FCFLAGS="$fallow_argument $boz_argument -m64"


These commands enable the compiler to accept argument mismatches and invalid BOZ literal constants, which are common in older Fortran codes. Detailed documentation and explanations of these compiler options can be found in the GCC online documentation, particularly in the section dedicated to Fortran Dialect Options: Fortran Dialect Options (The GNU Fortran Compiler)

It is important to note that while the
Bash:
-std=legacy
flag in GCC can also be used to enable legacy Fortran code compatibility, its usage might lead to additional complications. This flag sets the compiler to accept all legacy Fortran code, but it might inadvertently allow code practices that are incompatible with modern Fortran standards, potentially leading to unforeseen issues.

By following these guidelines and carefully setting the environment variables, developers and researchers can ensure smooth compilation and execution of WRF and other Fortran-based applications on the latest Ubuntu releases. This approach maintains compatibility with legacy codes while leveraging the advancements of the newer GCC versions.
 
The recent releases of Ubuntu 22 and Ubuntu 23 by Canonical introduced several changes to their base operating system, including significant updates to the GNU Compiler Collection (GCC). Specifically, these versions have been upgraded to GCC 11 and GCC 12, respectively.

A noteworthy aspect of this update is its impact on legacy Fortran code compatibility. GCC versions greater than 9 have deprecated certain antiquated Fortran commands, resulting in compatibility issues during the installation of the Weather Research and Forecasting (WRF) model. This is due to the default disabling of older code syntaxes in these newer GCC versions, which leads to errors.

To address this and ensure compatibility with legacy Fortran code while compiling libraries for WRF, WPS, and other related software, it is necessary to set specific environment variables before the compilation process. These variables enable the older Fortran code syntaxes. The required environment variables and their values are as follows:


Bash:
export fallow_argument=-fallow-argument-mismatch
export boz_argument=-fallow-invalid-boz

export FFLAGS="$fallow_argument $boz_argument -m64"
export FCFLAGS="$fallow_argument $boz_argument -m64"


These commands enable the compiler to accept argument mismatches and invalid BOZ literal constants, which are common in older Fortran codes. Detailed documentation and explanations of these compiler options can be found in the GCC online documentation, particularly in the section dedicated to Fortran Dialect Options: Fortran Dialect Options (The GNU Fortran Compiler)

It is important to note that while the
Bash:
-std=legacy
flag in GCC can also be used to enable legacy Fortran code compatibility, its usage might lead to additional complications. This flag sets the compiler to accept all legacy Fortran code, but it might inadvertently allow code practices that are incompatible with modern Fortran standards, potentially leading to unforeseen issues.

By following these guidelines and carefully setting the environment variables, developers and researchers can ensure smooth compilation and execution of WRF and other Fortran-based applications on the latest Ubuntu releases. This approach maintains compatibility with legacy codes while leveraging the advancements of the newer GCC versions.
Hello William,
I have a similar error. However, I am unsure how to fix the following errors (the first block of the following). In the Makefile in megan_bio_emiss, I tried several FFLAGS options (the second block of the following) but still had the same error message. I would appreciate your comment.
Thank you,
GR

********************************<Error Message>**********************************************
megan_bio_emiss> make
ftn -g -c -I/opt/cray/pe/netcdf/4.9.0.3/gnu/9.1/include misc_definitions_module.f90
ftn -g -c -I/opt/cray/pe/netcdf/4.9.0.3/gnu/9.1/include constants_module.f90
ftn -g -c -I/opt/cray/pe/netcdf/4.9.0.3/gnu/9.1/include bio_types.f90
ftn -g -c -I/opt/cray/pe/netcdf/4.9.0.3/gnu/9.1/include area_mapper.f90
ftn -g -c -I/opt/cray/pe/netcdf/4.9.0.3/gnu/9.1/include bio_emiss.f90

bio_emiss.f90:1112:78:
1112 | call handle_ncerr( nf_put_att_int( ncid, varid, 'FieldType', nf_int, 1, ii ), message )
| 1
......

1241 | call handle_ncerr( nf_put_att_int( ncid, nf_global, attr_name:)slen), attr_xtype, attr_len, attrs(m)%attr_int ), &
| 2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)

bio_emiss.f90:305:67:
305 | call handle_ncerr( nf_get_att_int( ncid, nf_global, 'MAP_PROJ', map_proj ), message )
| 1
......
1184 | call handle_ncerr( nf_get_att_int( ncid, nf_global, trim(attr_name), attrs(m)%attr_int ), message )
| 2

Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)

bio_emiss.f90:334:69:
334 | call handle_ncerr( nf_get_att_real( ncid, nf_global, 'CEN_LON', cen_lon ), message )
| 1
......
1191 | call handle_ncerr( nf_get_att_real( ncid, nf_global, trim(attr_name), attrs(m)%attr_real ), message )

| 2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)

bio_emiss.f90:337:69:
337 | call handle_ncerr( nf_get_att_real( ncid, nf_global, 'CEN_LAT', cen_lat ), message )
| 1
......
1191 | call handle_ncerr( nf_get_att_real( ncid, nf_global, trim(attr_name), attrs(m)%attr_real ), message )
| 2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)

bio_emiss.f90:340:71:
340 | call handle_ncerr( nf_get_att_real( ncid, nf_global, 'STAND_LON', stand_lon ), message )
| 1
......
1191 | call handle_ncerr( nf_get_att_real( ncid, nf_global, trim(attr_name), attrs(m)%attr_real ), message )
| 2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)

bio_emiss.f90:343:70:
343 | call handle_ncerr( nf_get_att_real( ncid, nf_global, 'TRUELAT1', truelat1 ), message )
| 1
......
1191 | call handle_ncerr( nf_get_att_real( ncid, nf_global, trim(attr_name), attrs(m)%attr_real ), message )
| 2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)

bio_emiss.f90:346:70:
346 | call handle_ncerr( nf_get_att_real( ncid, nf_global, 'TRUELAT2', truelat2 ), message )
| 1
......
1191 | call handle_ncerr( nf_get_att_real( ncid, nf_global, trim(attr_name), attrs(m)%attr_real ), message )
| 2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)

bio_emiss.f90:349:64:
349 | call handle_ncerr( nf_get_att_real( ncid, nf_global, 'DX', dx ), message )
| 1
......
1191 | call handle_ncerr( nf_get_att_real( ncid, nf_global, trim(attr_name), attrs(m)%attr_real ), message )
| 2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)

make: *** [Makefile:48: bio_emiss.o] Error 1
***********************************************************************************************************************


***Makefile *********************************************************************************************************
ifeq ($(FC),gfortran)
FFLAGS += -ffree-line-length-none
# FFLAGS += -ffree-line-length-none -std=legacy
# FFLAGS = --g -std=legacy
# FFLAGS += -ffree-line-length-none -fallow-argument-mismatch

#fallow_argument=-fallow-argument-mismatch
#boz_argument=-fallow-invalid-boz
#FFLAGS="$(fallow_argument) $(boz_argument) -m64"
#FCFLAGS="$(fallow_argument) $(boz_argument) -m64"
endif
***********************************************************************************************************************
 
From my WRF-Chem tool install kit I see that you need to modify some of the files with these commands below.

Bash:
    cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/megan_bio_emiss
    chmod +x make_util
    export DIR=$WRFCHEM_FOLDER/WRF_CHEM_Tools/Libs
    export FC=gfortran
    export NETCDF_DIR=$DIR/NETCDF
    sed -i 's/"${ar_libs} -lnetcdff"/"-lnetcdff ${ar_libs}"/' make_util
    sed -i '8s/FFLAGS = --g/FFLAGS = --g ${fallow_argument}/' Makefile
    sed -i '10s/FFLAGS = -g/FFLAGS = -g ${fallow_argument}/' Makefile
    ./make_util megan_bio_emiss 2>&1 | tee make.bio.log
    ./make_util megan_xform 2>&1 | tee make.xform.log
    ./make_util surfdata_xform 2>&1 | tee make.surfdata.log
 
The recent releases of Ubuntu 22 and Ubuntu 23 by Canonical introduced several changes to their base operating system, including significant updates to the GNU Compiler Collection (GCC). Specifically, these versions have been upgraded to GCC 11 and GCC 12, respectively.

A noteworthy aspect of this update is its impact on legacy Fortran code compatibility. GCC versions greater than 9 have deprecated certain antiquated Fortran commands, resulting in compatibility issues during the installation of the Weather Research and Forecasting (WRF) model. This is due to the default disabling of older code syntaxes in these newer GCC versions, which leads to errors.

To address this and ensure compatibility with legacy Fortran code while compiling libraries for WRF, WPS, and other related software, it is necessary to set specific environment variables before the compilation process. These variables enable the older Fortran code syntaxes. The required environment variables and their values are as follows:


Bash:
export fallow_argument=-fallow-argument-mismatch
export boz_argument=-fallow-invalid-boz

export FFLAGS="$fallow_argument $boz_argument -m64"
export FCFLAGS="$fallow_argument $boz_argument -m64"


These commands enable the compiler to accept argument mismatches and invalid BOZ literal constants, which are common in older Fortran codes. Detailed documentation and explanations of these compiler options can be found in the GCC online documentation, particularly in the section dedicated to Fortran Dialect Options: Fortran Dialect Options (The GNU Fortran Compiler)

It is important to note that while the
Bash:
-std=legacy
flag in GCC can also be used to enable legacy Fortran code compatibility, its usage might lead to additional complications. This flag sets the compiler to accept all legacy Fortran code, but it might inadvertently allow code practices that are incompatible with modern Fortran standards, potentially leading to unforeseen issues.

By following these guidelines and carefully setting the environment variables, developers and researchers can ensure smooth compilation and execution of WRF and other Fortran-based applications on the latest Ubuntu releases. This approach maintains compatibility with legacy codes while leveraging the advancements of the newer GCC versions.
Hello,

I am encountering this issue while installing ARPACK and ASWING as a first time Ubuntu user. Your help would be much appreciated.

/usr/local/ARPACK$ make lib
Making lib in /usr/local/ARPACK/BLAS

... (runs normally here for a while)

f77 -O -c znaitr.f
znaitr.f:666:35:

383 | call dvout (logfil, 1, rnorm, ndigit,
| 2
......
666 | call dvout (logfil, 2, rtemp, ndigit,
| 1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)
znaitr.f:737:39:

383 | call dvout (logfil, 1, rnorm, ndigit,
| 2
......
737 | call dvout (logfil, 2, rtemp, ndigit,
| 1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)
make[1]: *** [Makefile:50: znaitr.o] Error 1
make[1]: Leaving directory '/usr/local/ARPACK/SRC'
 
Hello,

I am encountering this issue while installing ARPACK and ASWING as a first time Ubuntu user. Your help would be much appreciated.

/usr/local/ARPACK$ make lib
Making lib in /usr/local/ARPACK/BLAS

... (runs normally here for a while)

f77 -O -c znaitr.f
znaitr.f:666:35:

383 | call dvout (logfil, 1, rnorm, ndigit,
| 2
......
666 | call dvout (logfil, 2, rtemp, ndigit,
| 1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)
znaitr.f:737:39:

383 | call dvout (logfil, 1, rnorm, ndigit,
| 2
......
737 | call dvout (logfil, 2, rtemp, ndigit,
| 1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)
make[1]: *** [Makefile:50: znaitr.o] Error 1
make[1]: Leaving directory '/usr/local/ARPACK/SRC'
I am not familar with those packages, but I would assume the setup is similar to the fix for WRF.


Code:
export fallow_argument=-fallow-argument-mismatch
export boz_argument=-fallow-invalid-boz

export FFLAGS="$fallow_argument $boz_argument -m64"
export FCFLAGS="$fallow_argument $boz_argument -m64"

make sure to put these arguments into the FFLAGS and FCFLAGS
 
I am not familar with those packages, but I would assume the setup is similar to the fix for WRF.


Code:
export fallow_argument=-fallow-argument-mismatch
export boz_argument=-fallow-invalid-boz

export FFLAGS="$fallow_argument $boz_argument -m64"
export FCFLAGS="$fallow_argument $boz_argument -m64"

make sure to put these arguments into the FFLAGS and FCFLAGS
Mr. Hatheway,

Thanks for the response. I'm still a bit confused, how do I actually access the FFLAGS and FCFLAGS from the /cd/usr/local/ARPACK file? What commands do I put in to the Ubuntu terminal?
 
Mr. Hatheway,

Thanks for the response. I'm still a bit confused, how do I actually access the FFLAGS and FCFLAGS from the /cd/usr/local/ARPACK file? What commands do I put in to the Ubuntu terminal?
that i do not know, since I have never used those systems before. You would have to talk to their systems developers.
 
From my WRF-Chem tool install kit I see that you need to modify some of the files with these commands below.

Bash:
    cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/megan_bio_emiss
    chmod +x make_util
    export DIR=$WRFCHEM_FOLDER/WRF_CHEM_Tools/Libs
    export FC=gfortran
    export NETCDF_DIR=$DIR/NETCDF
    sed -i 's/"${ar_libs} -lnetcdff"/"-lnetcdff ${ar_libs}"/' make_util
    sed -i '8s/FFLAGS = --g/FFLAGS = --g ${fallow_argument}/' Makefile
    sed -i '10s/FFLAGS = -g/FFLAGS = -g ${fallow_argument}/' Makefile
    ./make_util megan_bio_emiss 2>&1 | tee make.bio.log
    ./make_util megan_xform 2>&1 | tee make.xform.log
    ./make_util surfdata_xform 2>&1 | tee make.surfdata.log
Dear William,
Thank you for your comment. I am using WRF-v4.4. and I do not have $WRFCHEM_FOLDER/WRF_CHEM_Tools. Then, which files do I need to modify?
I appreciate your help.
GR
 
Top