Skip to content

Commit

Permalink
Merge pull request #523 from FESOM/bugfixes_wdeconinck
Browse files Browse the repository at this point in the history
Bugfixes to parms,  widely compatable FindNETCDF, and new envs for atos and lumi
  • Loading branch information
dsidoren authored Oct 26, 2023
2 parents 849b732 + ae6958e commit 449c57a
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 59 deletions.
33 changes: 29 additions & 4 deletions cmake/FindNETCDF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ if(CMAKE_Fortran_COMPILER_LOADED)
if(HAVE_Fortran_NETCDF)
set(NETCDF_Fortran_INCLUDE_DIRECTORIES "")
set(NETCDF_Fortran_LIBRARIES "")
set(NETCDF_Fortran_FOUND 1)
else()
find_path(NETCDF_Fortran_INCLUDE_DIRECTORIES netcdf.inc HINTS $ENV{NETCDF_DIR}/include ENV NETCDF_Fortran_INCLUDE_DIRECTORIES)
find_path(NETCDF_Fortran_INCLUDE_DIRECTORIES netcdf.inc HINTS $ENV{NETCDF_ROOT}/include $ENV{NETCDF_DIR}/include $ENV{NETCDF4_DIR}/include ENV NETCDF_Fortran_INCLUDE_DIRECTORIES)
find_library(NETCDF_Fortran_LIBRARIES netcdff HINTS ${NETCDF_Fortran_INCLUDE_DIRECTORIES}/../lib)
if( NETCDF_Fortran_INCLUDE_DIRECTORIES AND NETCDF_Fortran_LIBRARIES )
set(NETCDF_Fortran_FOUND 1)
endif()
endif()
endif()

Expand All @@ -27,14 +31,18 @@ if(CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)
if(HAVE_C_NETCDF)
set(NETCDF_C_INCLUDE_DIRECTORIES "")
set(NETCDF_C_LIBRARIES "")
set(NETCDF_C_FOUND 1)
else()
find_path(NETCDF_C_INCLUDE_DIRECTORIES netcdf.h HINTS $ENV{NETCDF_DIR}/include ENV NETCDF_C_INCLUDE_DIRECTORIES)
find_path(NETCDF_C_INCLUDE_DIRECTORIES netcdf.h HINTS $ENV{NETCDF_ROOT}/include $ENV{NETCDF_DIR}/include $ENV{NETCDF4_DIR}/include ENV NETCDF_C_INCLUDE_DIRECTORIES)
find_library(NETCDF_C_LIBRARIES netcdf HINTS ${NETCDF_C_INCLUDE_DIRECTORIES}/../lib)
if( NETCDF_C_INCLUDE_DIRECTORIES AND NETCDF_C_LIBRARIES )
set(NETCDF_C_FOUND 1)
endif()
endif()
endif()

if(CMAKE_CXX_COMPILER_LOADED)
find_path(NETCDF_CXX_INCLUDE_DIRECTORIES netcdf HINTS $ENV{NETCDF_DIR}/include ENV NETCDF_CXX_INCLUDE_DIRECTORIES)
find_path(NETCDF_CXX_INCLUDE_DIRECTORIES netcdf HINTS $ENV{NETCDF_ROOT}/include $ENV{NETCDF_DIR}/include $ENV{NETCDF4_DIR} ENV NETCDF_CXX_INCLUDE_DIRECTORIES)
# the cray toolchain (e.g. hlrn) disables dynamic linking by default. to enable it at build time do e.g. "CRAYPE_LINK_TYPE=dynamic make".
find_library(NETCDF_CXX_LIBRARIES NAMES netcdf_c++4 netcdf-cxx4 HINTS ${NETCDF_CXX_INCLUDE_DIRECTORIES}/../lib)
if(NETCDF_CXX_INCLUDE_DIRECTORIES AND NETCDF_C_INCLUDE_DIRECTORIES)
Expand All @@ -43,4 +51,21 @@ if(CMAKE_CXX_COMPILER_LOADED)
if(NETCDF_CXX_LIBRARIES AND NETCDF_C_LIBRARIES)
list(APPEND NETCDF_CXX_LIBRARIES ${NETCDF_C_LIBRARIES})
endif()
endif()
if( NETCDF_CXX_INCLUDE_DIRECTORIES AND NETCDF_CXX_LIBRARIES )
set(NETCDF_CXX_FOUND 1)
endif()
endif()

if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS C)
endif()

unset({CMAKE_FIND_PACKAGE_NAME}_REQUIRED_VARS)
foreach(COMP C CXX Fortran)
if("${COMP}" IN_LIST ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
list(APPEND ${CMAKE_FIND_PACKAGE_NAME}_REQUIRED_VARS NETCDF_${COMP}_FOUND)
endif()
endforeach()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(${CMAKE_FIND_PACKAGE_NAME} HANDLE_COMPONENTS REQUIRED_VARS ${CMAKE_FIND_PACKAGE_NAME}_REQUIRED_VARS)

4 changes: 1 addition & 3 deletions env/atosecmwf/shell
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,5 @@ module load cmake/3.20.2
module load ninja/1.10.0
module load fcm/2019.05.0

export NETCDF_DIR=$NETCDF4_DIR
export FC=ifort CC=icc CXX=icpc

export FC=mpif90 CC=mpicc CXX=mpicxx # MPI wrappers for Fortran, cc and CC similarly
#export FC=mpif90 CC=gcc CXX=mpicxx # MPI wrappers for Fortran, cc and CC similarly
8 changes: 4 additions & 4 deletions env/lumi/shell
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ module load cray-netcdf/4.8.1.5
export FC=ftn
export CC=cc
export CXX=cc
export NETCDF_Fortran_INCLUDE_DIRECTORIES=$CRAY_NETCDF_DIR/include
export NETCDF_C_INCLUDE_DIRECTORIES=$CRAY_NETCDF_DIR/include
export NETCDF_C_LIBRARIES=$CRAY_NETCDF_DIR/lib
export NETCDF_Fortran_LIBRARIES=$CRAY_NETCDF_DIR/lib
#export NETCDF_Fortran_INCLUDE_DIRECTORIES=$CRAY_NETCDF_DIR/include
#export NETCDF_C_INCLUDE_DIRECTORIES=$CRAY_NETCDF_DIR/include
#export NETCDF_C_LIBRARIES=$CRAY_NETCDF_DIR/lib
#export NETCDF_Fortran_LIBRARIES=$CRAY_NETCDF_DIR/lib
$CC -v
$FC -V
$CXX -v
17 changes: 9 additions & 8 deletions lib/parms/src/DDPQ/arms2.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,15 @@ static int parms_arms_getssize_vcsr(parms_Operator self)
}

static struct parms_Operator_ops parms_arms_sol_vptr = {
parms_arms_sol_vcsr,
parms_arms_lsol_vcsr,
parms_arms_invs_vcsr,
parms_arms_ascend_vcsr,
parms_arms_getssize_vcsr,
parms_arms_nnz,
arms_free_vcsr,
arms_view_vcsr
parms_arms_sol_vcsr, /* apply */
parms_arms_lsol_vcsr, /* lsol */
parms_arms_invs_vcsr, /* invs */
NULL, /* getu !!! WARNING, UNASSIGNED !!! */
parms_arms_ascend_vcsr, /* ascend */
parms_arms_getssize_vcsr, /* getssize */
parms_arms_nnz, /* getnnz */
arms_free_vcsr, /* operator_free */
arms_view_vcsr /* operator_view */
};


Expand Down
4 changes: 2 additions & 2 deletions lib/parms/src/DDPQ/sets.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
void parms_errexit( char *f_str, ... )
{
va_list argp;
char out1[256], out2[256];
char out1[256], out2[512];

va_start(argp, f_str);
vsprintf(out1, f_str, argp);
va_end(argp);

sprintf(out2, "Error! %s\n", out1);

fprintf(stdout, out2);
fprintf(stdout, "%s", out2);
fflush(stdout);

exit( -1 );
Expand Down
17 changes: 9 additions & 8 deletions lib/parms/src/parms_ilu_vcsr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1683,14 +1683,15 @@ int parms_ilu_update(parms_Mat self, parms_FactParam param, void *mat,
if(ABS_VALUE(t1) < DBL_EPSILON) continue;

if( ii+start < schur_start ){
for(jj = 1; jj < nnz; jj++) {
iw = jw[rowjj[jj]];
if(iw != -1)
if(iw < ii+start)
rowm[iw] -= t1*rowmm[jj];
else
data->U->pa[ii+start][iw-ii-start] -= t1*rowmm[jj];
}
for(jj = 1; jj < nnz; jj++) {
iw = jw[rowjj[jj]];
if(iw != -1) {
if(iw < ii+start)
rowm[iw] -= t1*rowmm[jj];
else
data->U->pa[ii+start][iw-ii-start] -= t1*rowmm[jj];
}
}
}
else {
for(jj = 1; jj < nnz; jj++){
Expand Down
5 changes: 5 additions & 0 deletions lib/parms/src/parms_pc_schurras.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#endif
#endif

/* Forward declarations */
int parms_OperatorGetU(parms_Operator self, void **mat);
int parms_MatGetOffDiag(parms_Mat self, void **mat);
int parms_CommGetOdvlist(parms_Comm self, int **odvlist);

typedef struct schurras_data {

parms_Operator op_out,op_in;
Expand Down
15 changes: 10 additions & 5 deletions src/gen_modules_partitioning.F90
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ subroutine par_ex(COMM, mype, abort) ! finalizes MPI
#else
!For ECHAM coupled runs we use the old OASIS nameing scheme (prism / prism_proto)
use mod_prism
#endif ! oifs/echam
#endif ! oasis
#endif
! oifs/echam
#endif
! oasis

implicit none
integer, intent(in) :: COMM
Expand All @@ -112,7 +114,8 @@ subroutine par_ex(COMM, mype, abort) ! finalizes MPI
call MPI_Barrier(COMM, error)
call MPI_Finalize(error)
endif
#else ! standalone
#else
! standalone

! From here on the two coupled options
!-------------------------------------
Expand All @@ -136,8 +139,10 @@ subroutine par_ex(COMM, mype, abort) ! finalizes MPI

if (mype==0) print *, 'FESOM calls MPI_Finalize'
call MPI_Finalize(error)
#endif ! oifs/echam
#endif ! oasis
#endif
! oifs/echam
#endif
! oasis

! Regardless of standalone, OpenIFS oder ECHAM coupling, if we reach to this point
! we should be fine shutting the whole model down
Expand Down
Loading

0 comments on commit 449c57a

Please sign in to comment.