Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling ISCA on Mac laptop #252

Closed
bcamilletc opened this issue Jun 19, 2023 · 4 comments
Closed

Compiling ISCA on Mac laptop #252

bcamilletc opened this issue Jun 19, 2023 · 4 comments

Comments

@bcamilletc
Copy link

Hi all!

I am an undergrad attempting to run ISCA for a senior project and am running into some errors when compiling.

Has anyone been able to run ISCA on a Mac laptop or non HPC?

   What, if any, modifications were done to the emps-gv file to run ISCA on a non HPC? 

Below is my bashrc:

directory of the Isca source code

export GFDL_BASE=/Users/physics.astronomy/Isca

"environment" configuration for emps-gv4

export GFDL_ENV=emps-gv

temporary working directory used in running the model

export GFDL_WORK=/Users/physics.astronomy/gfdl_work

directory for storing model output

export GFDL_DATA=/Users/physics.astronomy/gfdl_data

These are the errors I am running into when attempting the held_suarez_test_case:

(isca_env) ROS-0232-02-19:held_suarez physics.astronomy$ python held_suarez_test_case.py
2023-06-19 12:52:14,582 - isca - WARNING - Environment variable GFDL_SOC not set, but this is only required if using SocratesCodebase. Setting to None
2023-06-19 12:52:14,796 - isca - INFO - RRTM compilation disabled.
2023-06-19 12:52:14,797 - isca - INFO - SOCRATES compilation disabled.
2023-06-19 12:52:14,811 - isca - INFO - Writing path_names to '/Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/build/held_suarez/path_names'
2023-06-19 12:52:14,817 - isca - INFO - Running compiler
2023-06-19 12:52:14,838 - isca - INFO - loadmodules for emps-gv machines
2023-06-19 12:52:14,845 - isca - INFO - /Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/build/held_suarez/compile.sh: line 21: nf-config: command not found
2023-06-19 12:52:14,846 - isca - INFO - /Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/build/held_suarez/compile.sh: line 23: ulimit: stack size: cannot modify limit: Operation not permitted
2023-06-19 12:52:14,846 - isca - INFO - Compiling postprocessing tools
2023-06-19 12:52:14,861 - isca - INFO - loadmodules for emps-gv machines
2023-06-19 12:52:15,078 - isca - WARNING - clang: warning: -lnetcdf: 'linker' input unused [-Wunused-command-line-argument]
2023-06-19 12:52:15,140 - isca - WARNING - clang: warning: argument unused during compilation: '-L/usr/local/netcdf-4.9.2/lib' [-Wunused-command-line-argument]
2023-06-19 12:52:17,420 - isca - WARNING - mppnccombine.c:162:24: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
2023-06-19 12:52:17,421 - isca - INFO - sprintf(outfilename,argv[outputarg]); outlen=strlen(outfilename);
2023-06-19 12:52:17,421 - isca - INFO - ^~~~~~~~~~~~~~~
2023-06-19 12:52:17,421 - isca - INFO - /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
2023-06-19 12:52:17,422 - isca - INFO - __builtin___sprintf_chk (str, 0, __darwin_obsz(str), VA_ARGS)
2023-06-19 12:52:17,422 - isca - INFO - ^~~~~~~~~~~
2023-06-19 12:52:17,423 - isca - INFO - mppnccombine.c:162:24: note: treat the string as an argument to avoid this
2023-06-19 12:52:17,423 - isca - INFO - sprintf(outfilename,argv[outputarg]); outlen=strlen(outfilename);
2023-06-19 12:52:17,423 - isca - INFO - ^
2023-06-19 12:52:17,423 - isca - INFO - "%s",
2023-06-19 12:52:17,423 - isca - INFO - /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
2023-06-19 12:52:17,423 - isca - INFO - __builtin___sprintf_chk (str, 0, __darwin_obsz(str), VA_ARGS)
2023-06-19 12:52:17,423 - isca - INFO - ^
2023-06-19 12:52:17,889 - isca - WARNING - 1 warning generated.
2023-06-19 12:52:18,703 - isca - INFO - ln: /Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/build/held_suarez/mppnccombine.x: File exists
2023-06-19 12:52:18,707 - isca - INFO - ln: /Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/build/held_suarez/mppnccombine_run.sh: File exists
2023-06-19 12:52:18,707 - isca - INFO - /Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/build/held_suarez/path_names
2023-06-19 12:52:19,922 - isca - INFO - ........................................................................................................................... Makefile is ready.
2023-06-19 12:52:19,956 - isca - INFO - gfortran -Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DINTERNAL_FILE_NML -DOVERLOAD_C8 -DRRTM_NO_COMPILE -DSOC_NO_COMPILE -I/usr/local/include -I/usr/local/include -fpp -stack_temps -safe_cray_ptr -ftz -assume byterecl -shared-intel -i4 -r8 -g -O2 -diag-disable 6843 -mcmodel large -c -I/Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/code/src/shared/include /Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/code/src/shared/mpp/mpp_parameter.F90
2023-06-19 12:52:20,056 - isca - INFO - gfortran: error: unrecognized command-line option '-fpp'; did you mean '-cpp'?
2023-06-19 12:52:20,061 - isca - INFO - gfortran: error: unrecognized command-line option '-stack_temps'
2023-06-19 12:52:20,071 - isca - INFO - gfortran: error: unrecognized command-line option '-safe_cray_ptr'
2023-06-19 12:52:20,071 - isca - INFO - gfortran: error: unrecognized command-line option '-ftz'
2023-06-19 12:52:20,073 - isca - INFO - gfortran: error: unrecognized command-line option '-assume'
2023-06-19 12:52:20,080 - isca - INFO - gfortran: error: unrecognized command-line option '-shared-intel'
2023-06-19 12:52:20,080 - isca - INFO - gfortran: error: unrecognized command-line option '-i4'
2023-06-19 12:52:20,080 - isca - INFO - gfortran: error: unrecognized command-line option '-r8'; did you mean '-k8'?
2023-06-19 12:52:20,082 - isca - INFO - gfortran: error: unrecognized command-line option '-mcmodel'; did you mean '-mcmodel='?
2023-06-19 12:52:20,083 - isca - INFO - make: *** [mpp_parameter.o] Error 1
2023-06-19 12:52:20,084 - isca - INFO - ERROR: mkmf failed for held_suarez.x
Exception in thread background thread for pid 96649:
Traceback (most recent call last):
File "/Users/physics.astronomy/anaconda3/envs/isca_env/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/Users/physics.astronomy/anaconda3/envs/isca_env/lib/python3.11/threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "/Users/physics.astronomy/anaconda3/envs/isca_env/lib/python3.11/site-packages/sh.py", line 1655, in wrap
fn(*rgs, **kwargs)
File "/Users/physics.astronomy/anaconda3/envs/isca_env/lib/python3.11/site-packages/sh.py", line 2657, in background_thread
handle_exit_code(exit_code)
File "/Users/physics.astronomy/anaconda3/envs/isca_env/lib/python3.11/site-packages/sh.py", line 2348, in fn
return self.command.handle_command_exit_code(exit_code)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/physics.astronomy/anaconda3/envs/isca_env/lib/python3.11/site-packages/sh.py", line 839, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:

RAN: /bin/bash /Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/build/held_suarez/compile.sh

STDOUT:
loadmodules for emps-gv machines
/Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/build/held_suarez/compile.sh: line 21: nf-config: command not found
/Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/build/held_suarez/compile.sh: line 23: ulimit: stack size: cannot modify limit: Operation not permitted
Compiling postprocessing tools
loadmodules for emps-gv machines
clang: warning: -lnetcdf: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L/usr/local/netcdf-4.9.2/lib' [-Wunused-command-line-argument]
mppnccombine.c:162:24: warning: format string is not a string litera... (3152 more, please see e.stdout)

STDERR:

Traceback (most recent call last):
File "/Users/physics.astronomy/isca/exp/test_cases/held_suarez/held_suarez_test_case.py", line 21, in
cb.compile() # compile the source code to working directory $GFDL_WORK/codebase
^^^^^^^^^^^^
File "/Users/physics.astronomy/isca/src/extra/python/isca/helpers.py", line 38, in _useworkdir
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/physics.astronomy/isca/src/extra/python/isca/helpers.py", line 22, in _destructive
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/physics.astronomy/isca/src/extra/python/isca/codebase.py", line 279, in compile
for line in sh.bash(P(self.builddir, 'compile.sh'), _iter=True, _err_to_out=True):
File "/Users/physics.astronomy/anaconda3/envs/isca_env/lib/python3.11/site-packages/sh.py", line 895, in next
self.wait()
File "/Users/physics.astronomy/anaconda3/envs/isca_env/lib/python3.11/site-packages/sh.py", line 812, in wait
self.handle_command_exit_code(exit_code)
File "/Users/physics.astronomy/anaconda3/envs/isca_env/lib/python3.11/site-packages/sh.py", line 839, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:

RAN: /bin/bash /Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/build/held_suarez/compile.sh

STDOUT:
loadmodules for emps-gv machines
/Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/build/held_suarez/compile.sh: line 21: nf-config: command not found
/Users/physics.astronomy/gfdl_work/codebase/_Users_physics.astronomy_Isca/build/held_suarez/compile.sh: line 23: ulimit: stack size: cannot modify limit: Operation not permitted
Compiling postprocessing tools
loadmodules for emps-gv machines
clang: warning: -lnetcdf: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L/usr/local/netcdf-4.9.2/lib' [-Wunused-command-line-argument]
mppnccombine.c:162:24: warning: format string is not a string litera... (3152 more, please see e.stdout)

STDERR:

If anyone has any ideas on where I'm going wrong, I would greatly appreciate the input!

@ntlewis
Copy link
Contributor

ntlewis commented Jun 27, 2023

Hi there :) Sorry it's taken a while to reply.

First, make sure you've got conda, and that you've used it to install the isca python environment.

To compile Isca on a Mac, you'll also need to make some changes to the code. See this list of differences: master...sit23:Isca:mac_clean.

I don't think you need all of these changes. Instead, just:

  1. Create a file called src/extra/env/mac_conda and copy the contents from the link above.
  2. Copy across the changes to src/extra/python/isca/templates/compile.sh
  3. Create a file called src/extra/python/isca/templates/mkmf.template.mac_conda and copy the contents from the link above. On L20-22 of the new mkmf file, add '-fallow-invalid-boz -fallow-argument-mismatch' to the list FFLAGS.
  4. Copy across the changes to src/shared/mpp/affinity.c

Finally, in your bashrc, set GFDL_ENV with: export GFDL_ENV=mac_conda

NB: I haven't actually tested this, but it should get you going in the right direction.

@sit23, when you have a spare second, could you check the above just to see if I've missed anything?

@claralarson
Copy link

Hi,

I am also trying to compile and run ISCA on macOS. I made the changes suggested above, and I also had to define the isHeadNode function (as suggested here: 4956c4a), and I was able to run ISCA once. When I tried to run a second time, I got the following error (pasted below - I put in bold what I think is triggering the error). The pull request that defines the isHeadNode function also adds the "-fallow-invalid-boz" to FFLAGS in src/extra/python/isca/templates/mkmf.template.gfort. I tried doing this, but it didn't resolve the issue. Is this a common issue? Thanks!

2024-03-02 17:08:21,435 - isca - WARNING - Environment variable GFDL_SOC not set, but this is only required if using SocratesCodebase. Setting to None
2024-03-02 17:08:21,820 - isca - INFO - USING SINGLE COLUMN MODEL
2024-03-02 17:08:21,821 - isca - INFO - SOCRATES compilations diabled.
2024-03-02 17:08:21,834 - isca - INFO - Writing path_names to '/Users/cml99/Desktop/ISCA/isca_work/codebase/_Users_cml99_Desktop_ISCA_isca/build/column_isca/path_names'
2024-03-02 17:08:21,842 - isca - INFO - Running compiler
2024-03-02 17:08:21,863 - isca - INFO - Loading basic ubuntu-conda environment (mac version)
2024-03-02 17:08:21,875 - isca - INFO - /Users/cml99/Desktop/ISCA/isca_work/codebase/_Users_cml99_Desktop_ISCA_isca/build/column_isca/path_names
2024-03-02 17:08:23,080 - isca - INFO - ........................................................................................................................................................................................ Makefile is ready.
2024-03-02 17:08:23,117 - isca - INFO - mpifort -Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DINTERNAL_FILE_NML -DOVERLOAD_C8 -DMACOS -DCOLUMN_MODEL -DSOC_NO_COMPILE nc-config --cflags nc-config --cflags nc-config --flibs -cpp -fcray-pointer -O2 -ffree-line-length-none -fno-range-check -fdefault-real-8 -fdefault-double-8 -Wno-argument-mismatch -c -I/Users/cml99/Desktop/ISCA/isca_work/codebase/_Users_cml99_Desktop_ISCA_isca/code/src/shared/include /Users/cml99/Desktop/ISCA/isca_work/codebase/_Users_cml99_Desktop_ISCA_isca/code/src/shared/mpp/mpp_parameter.F90
2024-03-02 17:08:23,370 - isca - INFO - /Users/cml99/Desktop/ISCA/isca_work/codebase/_Users_cml99_Desktop_ISCA_isca/code/src/shared/mpp/mpp_parameter.F90:115:42:
2024-03-02 17:08:23,371 - isca - INFO - 115 | integer(LONG_KIND), parameter :: DOMAIN_ID_BASE=Z'0000000100000000' ! Workaround for 64bit init problem
2024-03-02 17:08:23,371 - isca - INFO - | 1
2024-03-02 17:08:23,371 - isca - INFO - Error: BOZ literal constant at (1) is neither a data-stmt-constant nor an actual argument to INT, REAL, DBLE, or CMPLX intrinsic function [see ‘-fno-allow-invalid-boz’]
2024-03-02 17:08:23,372 - isca - INFO - /Users/cml99/Desktop/ISCA/isca_work/codebase/_Users_cml99_Desktop_ISCA_isca/code/src/shared/mpp/mpp_parameter.F90:55:49:
2024-03-02 17:08:23,372 - isca - INFO - 55 | public :: AGRID, GLOBAL, CYCLIC, DOMAIN_ID_BASE, CENTER, CORNER
2024-03-02 17:08:23,372 - isca - INFO - | 1
2024-03-02 17:08:23,372 - isca - INFO - Error: Symbol ‘domain_id_base’ at (1) has no IMPLICIT type
2024-03-02 17:08:23,378 - isca - INFO - make: *** [mpp_parameter.o] Error 1
2024-03-02 17:08:23,378 - isca - INFO - ERROR: mkmf failed for column_isca.x

Exception in thread background thread for pid 18902:
Traceback (most recent call last):
File "/Users/cml99/anaconda3/envs/isca_env/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/Users/cml99/anaconda3/envs/isca_env/lib/python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "/Users/cml99/anaconda3/envs/isca_env/lib/python3.12/site-packages/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/Users/cml99/anaconda3/envs/isca_env/lib/python3.12/site-packages/sh.py", line 2641, in background_thread
handle_exit_code(exit_code)
File "/Users/cml99/anaconda3/envs/isca_env/lib/python3.12/site-packages/sh.py", line 2332, in fn
return self.command.handle_command_exit_code(exit_code)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cml99/anaconda3/envs/isca_env/lib/python3.12/site-packages/sh.py", line 826, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:

RAN: /bin/bash /Users/cml99/Desktop/ISCA/isca_work/codebase/_Users_cml99_Desktop_ISCA_isca/build/column_isca/compile.sh

STDOUT:
Loading basic ubuntu-conda environment (mac version)
/Users/cml99/Desktop/ISCA/isca_work/codebase/_Users_cml99_Desktop_ISCA_isca/build/column_isca/path_names
........................................................................................................................................................................................ Makefile is ready.
mpifort -Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DINTERNAL_FILE_NML -DOVERLOAD_C8 -DMACOS -DCOLUMN_MODEL -DSOC_NO_COMPILE nc-config --cflags nc-config --cflags nc-config --flibs -cpp -fcray-pointer -O2 -ffree-line-length-none -fno-range-check -fdefault-real-8 -fdefault-double-8 -Wno-argument-mismatch -c -I/Users/cml99/Desktop/ISCA/isca_work/codebase/_Users_cml99_Desktop_ISC... (1154 more, please see e.stdout)

STDERR:

Traceback (most recent call last):
File "/Users/cml99/Desktop/ISCA/isca_new_test/Isca/exp/test_cases/column_test_case/column_test_one_day.py", line 57, in
cb.compile()
File "/Users/cml99/Desktop/ISCA/isca/src/extra/python/isca/helpers.py", line 38, in _useworkdir
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/cml99/Desktop/ISCA/isca/src/extra/python/isca/helpers.py", line 22, in _destructive
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/cml99/Desktop/ISCA/isca/src/extra/python/isca/codebase.py", line 280, in compile
for line in sh.bash(P(self.builddir, 'compile.sh'), _iter=True, _err_to_out=True):
File "/Users/cml99/anaconda3/envs/isca_env/lib/python3.12/site-packages/sh.py", line 882, in next
self.wait()
File "/Users/cml99/anaconda3/envs/isca_env/lib/python3.12/site-packages/sh.py", line 799, in wait
self.handle_command_exit_code(exit_code)
File "/Users/cml99/anaconda3/envs/isca_env/lib/python3.12/site-packages/sh.py", line 826, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:

RAN: /bin/bash /Users/cml99/Desktop/ISCA/isca_work/codebase/_Users_cml99_Desktop_ISCA_isca/build/column_isca/compile.sh

STDOUT:
Loading basic ubuntu-conda environment (mac version)
/Users/cml99/Desktop/ISCA/isca_work/codebase/_Users_cml99_Desktop_ISCA_isca/build/column_isca/path_names
........................................................................................................................................................................................ Makefile is ready.
mpifort -Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DINTERNAL_FILE_NML -DOVERLOAD_C8 -DMACOS -DCOLUMN_MODEL -DSOC_NO_COMPILE nc-config --cflags nc-config --cflags nc-config --flibs -cpp -fcray-pointer -O2 -ffree-line-length-none -fno-range-check -fdefault-real-8 -fdefault-double-8 -Wno-argument-mismatch -c -I/Users/cml99/Desktop/ISCA/isca_work/codebase/_Users_cml99_Desktop_ISC... (1154 more, please see e.stdout)

STDERR:

@ntlewis
Copy link
Contributor

ntlewis commented Mar 5, 2024

Hi @claralarson, could you type echo $GFDL_ENV into your terminal and see what the output is?

It should correspond to the name of a file in the directory Isca/src/extra/env. Inside that file, could you take a look and see what GFDL_MKMF_TEMPLATE is set to?

It should correspond to a file in the directory Isca/src/extra/python/isca/templates. For example, export GFDL_MKMF_TEMPLATE=gfort points to mkmf.template.gfort.

Could you take a look inside the mkmf template your environment file is pointing to, and confirm that it includes the -fallow-invalid-boz flag you've described above? The reason I'm asking is that this compiler flag doesn't seem to be present in the STDOUT stuff you've pasted above.

If it is not present, then add the flag. Before recompiling, navigate to the directory Isca uses to compile the code with cd $GFDL_WORK. Then, delete the directory called column_isca, which should be located inside $GFDL_WORK/codebase/_Users_cml99_Desktop_ISCA_isca/build. Then, try to recompile, and see what happens! Hopefully it will work.

Let me know if you had already added the compiler flag to the correct environment file, and we'll try to figure out what else could be causing your issue.

@claralarson
Copy link

claralarson commented Mar 5, 2024

Thanks @ntlewis , now it works!

@ntlewis ntlewis closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants