From 4956c4aca4c3fec841e5041c20602826a5452c6c Mon Sep 17 00:00:00 2001 From: gaelforget Date: Fri, 11 Jun 2021 03:03:09 -0400 Subject: [PATCH] working version that has worked with gfortran11 on macOS v11.2 --- src/extra/env/gfortran_mac | 9 +++++++++ src/extra/python/isca/templates/compile.sh | 8 ++++---- .../python/isca/templates/mkmf.template.gfort | 5 ++--- src/extra/python/isca/templates/run.sh | 2 +- src/shared/mosaic/create_xgrid.c | 16 ++++++++++++---- src/shared/mpp/affinity.c | 12 ++++++++++-- 6 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 src/extra/env/gfortran_mac diff --git a/src/extra/env/gfortran_mac b/src/extra/env/gfortran_mac new file mode 100644 index 000000000..13f3af634 --- /dev/null +++ b/src/extra/env/gfortran_mac @@ -0,0 +1,9 @@ +echo Loading basic gfortran environment + +# this defaults to ia64, but we will use gfortran, not ifort +export GFDL_MKMF_TEMPLATE=gfort +export F90=mpifort +export CC=mpicc +export CDEFS=" -DMACOS " +export NETCDF_LIBS=`nf-config --flibs` + diff --git a/src/extra/python/isca/templates/compile.sh b/src/extra/python/isca/templates/compile.sh index d20377492..c51a0789a 100755 --- a/src/extra/python/isca/templates/compile.sh +++ b/src/extra/python/isca/templates/compile.sh @@ -18,9 +18,9 @@ template_debug={{ template_dir }}/mkmf.template.debug execdir={{ execdir }} # where code is compiled and executable is created executable={{ executable_name }} -netcdf_flags=`nf-config --fflags --flibs` +#netcdf_flags=`nf-config --fflags --flibs` -ulimit -s unlimited # Set stack size to unlimited +#ulimit -s unlimited # Set stack size to unlimited export MALLOC_CHECK_=0 # 3. compile the mppncombine tool if it hasn't yet been done. @@ -53,13 +53,13 @@ if [ $debug == True ]; then echo "Compiling in debug mode" # execute mkmf to create makefile -cppDefs="-Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DINTERNAL_FILE_NML -DOVERLOAD_C8 {{compile_flags}}" +cppDefs="-Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DINTERNAL_FILE_NML -DOVERLOAD_C8 ${CDEFS} {{compile_flags}}" $mkmf -a $sourcedir -t $template_debug -p $executable -c "$cppDefs" $pathnames $sourcedir/shared/include $sourcedir/shared/mpp/include else # execute mkmf to create makefile -cppDefs="-Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DINTERNAL_FILE_NML -DOVERLOAD_C8 {{compile_flags}}" +cppDefs="-Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DINTERNAL_FILE_NML -DOVERLOAD_C8 ${CDEFS} {{compile_flags}}" $mkmf -a $sourcedir -t $template -p $executable -c "$cppDefs" $pathnames $sourcedir/shared/include $sourcedir/shared/mpp/include fi diff --git a/src/extra/python/isca/templates/mkmf.template.gfort b/src/extra/python/isca/templates/mkmf.template.gfort index b35336dbc..16fe2e0da 100755 --- a/src/extra/python/isca/templates/mkmf.template.gfort +++ b/src/extra/python/isca/templates/mkmf.template.gfort @@ -2,7 +2,6 @@ # typical use with mkmf # mkmf -t template.ifc -c"-Duse_libMPI -Duse_netCDF" path_names /usr/local/include CPPFLAGS = -I/usr/local/include -NETCDF_LIBS = `nf-config --fflags --flibs` # FFLAGS: # -cpp: Use the fortran preprocessor @@ -18,8 +17,8 @@ NETCDF_LIBS = `nf-config --fflags --flibs` FFLAGS = $(CPPFLAGS) $(NETCDF_LIBS) -cpp -fcray-pointer \ -O2 -ffree-line-length-none -fno-range-check \ - -fdefault-real-8 -fdefault-double-8 - + -fallow-argument-mismatch -fallow-invalid-boz \ + -fdefault-real-8 -fdefault-double-8 FC = $(F90) LD = $(F90) $(NETCDF_LIBS) diff --git a/src/extra/python/isca/templates/run.sh b/src/extra/python/isca/templates/run.sh index e4a8d606c..260edb562 100644 --- a/src/extra/python/isca/templates/run.sh +++ b/src/extra/python/isca/templates/run.sh @@ -5,7 +5,7 @@ rundir={{ rundir }} # change this if you're rerunning from the output directory source {{ env_source }} -ulimit -s unlimited +#ulimit -s unlimited debug={{ run_idb }} # logical to identify if running in debug mode or not diff --git a/src/shared/mosaic/create_xgrid.c b/src/shared/mosaic/create_xgrid.c index e539a6ac1..0abd595da 100644 --- a/src/shared/mosaic/create_xgrid.c +++ b/src/shared/mosaic/create_xgrid.c @@ -96,6 +96,14 @@ void get_grid_great_circle_area_(const int *nlon, const int *nlat, const double } #endif +int isHeadNode_b(struct Node *list, struct Node nodeIn) +{ + if(sameNode(*list, nodeIn)) + return 1; + else + return 0; +} + void get_grid_great_circle_area(const int *nlon, const int *nlat, const double *x, const double *y, const double *z, double *area) { int nx, ny, nxp, i, j, n_in; @@ -1360,7 +1368,7 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do error_handler("firstIntersect is not in the subjList"); } addNode(polyList, firstIntersect); - if( isHeadNode(intersectList, firstIntersect) ) { + if( isHeadNode_b(intersectList, firstIntersect) ) { temp = intersectList; intersectList = getNextNode(intersectList); free(temp); @@ -1431,7 +1439,7 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do else { addNode(polyList, *temp2); if(temp2IsIntersect) { /* remove temp2 from intersectList */ - if( isHeadNode(intersectList, *temp2) ) { + if( isHeadNode_b(intersectList, *temp2) ) { temp = intersectList; intersectList = getNextNode(intersectList); free(temp); @@ -1457,7 +1465,7 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do /* add curIntersect to polyList and remove it from intersectList and curList */ addNode(polyList, curIntersect); - if( isHeadNode(intersectList, curIntersect) ) { + if( isHeadNode_b(intersectList, curIntersect) ) { temp = intersectList; intersectList = getNextNode(intersectList); free(temp); @@ -1466,7 +1474,7 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do removeNode(intersectList, curIntersect); nintersect--; - if( isHeadNode(curList, curIntersect) ) { + if( isHeadNode_b(curList, curIntersect) ) { temp = curList; curList = getNextNode(curList); if( curListNum == 0 ) diff --git a/src/shared/mpp/affinity.c b/src/shared/mpp/affinity.c index f0eb78149..60a1b4d76 100644 --- a/src/shared/mpp/affinity.c +++ b/src/shared/mpp/affinity.c @@ -21,6 +21,13 @@ #define _GNU_SOURCE +#ifdef MACOS + +int get_cpu_affinity(void) { return -1; }; +void set_cpu_affinity( int cpu ) {}; + +#else + #include #include #include @@ -64,8 +71,6 @@ int get_cpu_affinity(void) return (last_cpu == -1) ? first_cpu : -1; } -int get_cpu_affinity_(void) { return get_cpu_affinity(); } /* Fortran interface */ - /* * Set CPU affinity to one core. @@ -81,4 +86,7 @@ void set_cpu_affinity( int cpu ) } } +#endif + +int get_cpu_affinity_(void) { return get_cpu_affinity(); } /* Fortran interface */ void set_cpu_affinity_(int *cpu) { set_cpu_affinity(*cpu); } /* Fortran interface */