ufs-weather-model icon indicating copy to clipboard operation
ufs-weather-model copied to clipboard

HAFS app can not be build using GNU compiler, syntax error in HYCOM

Open DusanJovic-NOAA opened this issue 3 years ago • 2 comments

Description

HAFS app can not be build using GNU compiler, syntax error in HYCOM:

/scratch2/NCEPDEV/fv3-cam/Dusan.Jovic/ufs/multiple_output_grids/ufs-weather-model/HYCOM-interface/HYCOM/mod_archiv.F90:1194:16:

 1194 |           'ssh', &
      |                1
Error: Different CHARACTER lengths (3/4) in array constructor at (1)
/scratch2/NCEPDEV/fv3-cam/Dusan.Jovic/ufs/multiple_output_grids/ufs-weather-model/HYCOM-interface/HYCOM/mod_archiv.F90:1250:43:

 1250 |         call export_from_hycom_tiled(util2,cname_exp(k))  !can't use util1
      |                                           1
Error: Function 'cname_exp' at (1) has no IMPLICIT type
make[2]: *** [HYCOM-interface/CMakeFiles/hycom_obj.dir/HYCOM/mod_archiv.F90.o] Error 1
make[2]: *** Waiting for unfinished jobs....

To Reproduce:

What compilers/machines are you seeing this with? GNU compiler on Hera. Give explicit steps to reproduce the behavior.

  1. load ufs_hera.gnu module
  2. try to build any HAFS app configuration
  3. then, oops, look at the bug

DusanJovic-NOAA avatar Jan 28 '22 17:01 DusanJovic-NOAA

On Cheyenne, HYCOM can be built with the following changes. However the build then fails in WW3, with the "type mismatch" error on an MPI_SEND. When WW3 can be built with CMake, we can add the same "fallow-argument-mismatch" for GNU>10 which should allow the HAFS apps to be built w/ GNU.

diff --git a/HYCOM-interface/CMakeLists.txt b/HYCOM-interface/CMakeLists.txt
index 2566905b..bb3b181a 100644
--- a/HYCOM-interface/CMakeLists.txt
+++ b/HYCOM-interface/CMakeLists.txt
@@ -3,6 +3,9 @@ get_filename_component(hycom_dir "${CMAKE_CURRENT_SOURCE_DIR}/HYCOM" ABSOLUTE)
 ### HYCOM Fortran compiler flags
 if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
   set(CMAKE_Fortran_FLAGS "-g -fbacktrace")
+  if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10)
+    set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz")
+  endif()
   set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8 -fdefault-double-8")
   set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Waliasing -fcray-pointer -fconvert=big-endian -ffree-line-length-none -fno-range-check -fbacktrace")
   set(CMAKE_Fortran_FLAGS_RELEASE "-O3")
diff --git a/NUOPC/HYCOM_OceanComp.F90 b/NUOPC/HYCOM_OceanComp.F90
index 41cf915..a6d6bf1 100644
--- a/NUOPC/HYCOM_OceanComp.F90
+++ b/NUOPC/HYCOM_OceanComp.F90
@@ -136,7 +136,6 @@ module HYCOM_Mod
 ! espc_timer(6): Run Phase export
 #endif
   real(ESMF_KIND_R8),parameter :: fillValue = 9.99e20_ESMF_KIND_R8
-
 !===============================================================================
   contains
 !===============================================================================
@@ -209,14 +208,14 @@ module HYCOM_Mod
       defaultValue="0", convention="NUOPC", purpose="Instance", rc=rc)
     if (ESMF_STDERRORCHECK(rc)) return
     diagnostic = ESMF_UtilString2Int(value, &
-      specialStringList=(/"min","max","bit16","maxplus"/), &
+      specialStringList=(/"min    ","max    ","bit16  ","maxplus"/), &
       specialValueList=(/0,65535,65536,131071/), rc=rc)
     if (ESMF_STDERRORCHECK(rc)) return
     call ESMF_AttributeGet(model, name="Verbosity", value=value, &
       defaultValue="0", convention="NUOPC", purpose="Instance", rc=rc)
     if (ESMF_STDERRORCHECK(rc)) return
     verbosity = ESMF_UtilString2Int(value, &
-      specialStringList=(/"off","low","high","max","bit16","maxplus"/), &
+      specialStringList=(/"off    ","low    ","high   ","max    ","bit16  ","maxplus"/), &
       specialValueList=(/0,9985,32513,65535,65536,131071/), rc=rc)
     if (ESMF_STDERRORCHECK(rc)) return

@@ -854,14 +853,14 @@ module HYCOM_Mod
       defaultValue="0", convention="NUOPC", purpose="Instance", rc=rc)
     if (ESMF_STDERRORCHECK(rc)) return  ! bail out
     diagnostic = ESMF_UtilString2Int(value, &
-      specialStringList=(/"min","max","bit16","maxplus"/), &
+      specialStringList=(/"min    ","max    ","bit16  ","maxplus"/), &
       specialValueList=(/0,65535,65536,131071/), rc=rc)
     if (ESMF_STDERRORCHECK(rc)) return  ! bail out
     call ESMF_AttributeGet(model, name="Verbosity", value=value, &
       defaultValue="0", convention="NUOPC", purpose="Instance", rc=rc)
     if (ESMF_STDERRORCHECK(rc)) return  ! bail out
     verbosity = ESMF_UtilString2Int(value, &
-      specialStringList=(/"off","low","high","max","bit16","maxplus"/), &
+      specialStringList=(/"off    ","low    ","high   ","max    ","bit16  ","maxplus"/), &
       specialValueList=(/0,9985,32513,65535,65536,131071/), rc=rc)
     if (ESMF_STDERRORCHECK(rc)) return  ! bail out

@@ -1367,14 +1366,14 @@ module HYCOM_Mod
       defaultValue="0", convention="NUOPC", purpose="Instance", rc=rc)
     if (ESMF_STDERRORCHECK(rc)) return  ! bail out
     diagnostic = ESMF_UtilString2Int(value, &
-      specialStringList=(/"min","max","bit16","maxplus"/), &
+      specialStringList=(/"min    ","max    ","bit16  ","maxplus"/), &
       specialValueList=(/0,65535,65536,131071/), rc=rc)
     if (ESMF_STDERRORCHECK(rc)) return  ! bail out
     call ESMF_AttributeGet(model, name="Verbosity", value=value, &
       defaultValue="0", convention="NUOPC", purpose="Instance", rc=rc)
     if (ESMF_STDERRORCHECK(rc)) return  ! bail out
     verbosity = ESMF_UtilString2Int(value, &
-      specialStringList=(/"off","low","high","max","bit16","maxplus"/), &
+      specialStringList=(/"off    ","low    ","high   ","max    ","bit16  ","maxplus"/), &
       specialValueList=(/0,9985,32513,65535,65536,131071/), rc=rc)
     if (ESMF_STDERRORCHECK(rc)) return  ! bail out

diff --git a/mod_archiv.F90 b/mod_archiv.F90
index ef4b0af..0f9592e 100644
--- a/mod_archiv.F90
+++ b/mod_archiv.F90
@@ -1187,13 +1187,13 @@
       integer, parameter ::   numExpFields = 7
       character*30, dimension(numExpFields), parameter :: &
         cname_exp = (/ &
-          'sst', &
-          'sss', &
-          'ssu', &
-          'ssv', &
-          'ssh', &
+          'sst ', &
+          'sss ', &
+          'ssu ', &
+          'ssv ', &
+          'ssh ', &
           'ssfi', &
-          'mlt'     /)
+          'mlt '    /)
 !
       dtime = time
       call forday(dtime,yrflag, iyear,jday,ihour)

DeniseWorthen avatar Feb 09 '22 20:02 DeniseWorthen

A more elegant solution is provided via email from @climbfuji , posing the question to Intel regarding GNU compile failure with a line such as attrList=(/"fhzero", "ncld", "nsoil", "imp_physics", "dtp"/), rc=rc)

Comment by Steve Lionel (Ret.) (Blackbelt):

I will also note that you can use:

attrList=(/character(11)::"fhzero", "ncld", "nsoil", "imp_physics", "dtp"/), rc=rc)

This is standard-conforming and does what Intel Fortran does as an extension.

DeniseWorthen avatar Feb 25 '22 16:02 DeniseWorthen

Is there a reason to maintain this as an issue? Will HYCOM ever be built w/ GNU before it is replaced by MOM6?

DeniseWorthen avatar Jan 24 '23 19:01 DeniseWorthen

@BinLiu-NOAA checking to see if you're aware of this issue and if we should maintain it?

zach1221 avatar Mar 07 '24 20:03 zach1221

@DeniseWorthen, @zach1221 I don't think from HAFS side, we will try to support building HAFS HYCOM coupling with GNU compiler. Besides, in future HAFS upgrades, the plan to is to transition to MOM6 coupling. Meanwhile, even HAFS FV3ATM only moving-nesting configuration currently does not support GNU compiler either.

BinLiu-NOAA avatar Mar 08 '24 01:03 BinLiu-NOAA

@DeniseWorthen, @zach1221 I don't think from HAFS side, we will try to support building HAFS HYCOM coupling with GNU compiler. Besides, in future HAFS upgrades, the plan to is to transition to MOM6 coupling. Meanwhile, even HAFS FV3ATM only moving-nesting configuration currently does not support GNU compiler either.

Ok, thank you @BinLiu-NOAA. I will go ahead and close this. @DusanJovic-NOAA if you believe it should be kept open, please let me know.

zach1221 avatar Mar 15 '24 18:03 zach1221