@@ -123,6 +123,13 @@ def build_env(is_test, recreate, compiler, mpi, conda_mpi, version,
123123 mpi_prefix = f'mpi_{ conda_mpi } '
124124
125125 nco_spec = config .get ('spack_specs' , 'nco' )
126+
127+ # whether to remove esmpy and xesmf, becasue they will be installed
128+ # manually with pip
129+ remove_esmf_esmpy_xesmf = (
130+ config .get ('e3sm_unified' , 'esmpy' ) != 'None' and
131+ config .get ('e3sm_unified' , 'xesmf' ) != 'None' )
132+
126133 if is_test :
127134
128135 nco_dev = ('alpha' in nco_spec or 'beta' in nco_spec )
@@ -139,16 +146,17 @@ def build_env(is_test, recreate, compiler, mpi, conda_mpi, version,
139146 channels = f'{ channels } -c conda-forge/label/{ package } _dev'
140147
141148 # edit if not using a release candidate for a given package
142- dev_labels = ['e3sm_diags' , 'mpas_analysis' , 'zppy' ]
149+ dev_labels = ['e3sm_unified' , 'chemdyg' , 'e3sm_diags' ,
150+ 'mpas_analysis' , 'zppy' , 'zstash' ]
143151 for package in dev_labels :
144152 channels = f'{ channels } -c conda-forge/label/{ package } _dev'
145153 channels = f'{ channels } ' \
146- f'-c conda-forge ' \
147- f'-c e3sm/label/e3sm_dev'
154+ f'-c conda-forge '
148155 else :
149- channels = '--override-channels -c conda-forge -c defaults -c e3sm '
156+ channels = '--override-channels -c conda-forge'
150157
151- packages = f'python={ python } pip'
158+ packages = f'python={ python } pip "setuptools>=41.2" setuptools_scm ' \
159+ f'setuptools-git-versioning'
152160
153161 source_activation_scripts = \
154162 f'source { conda_base } /etc/profile.d/conda.sh'
@@ -163,9 +171,13 @@ def build_env(is_test, recreate, compiler, mpi, conda_mpi, version,
163171 check_call (commands )
164172
165173 if conda_mpi == 'hpc' :
166- remove_packages = 'tempest-remap esmf esmpy '
167- if nco_spec != '' :
174+ remove_packages = 'tempest-remap'
175+ if nco_spec != 'None ' :
168176 remove_packages = f'nco { remove_packages } '
177+
178+ if remove_esmf_esmpy_xesmf :
179+ remove_packages = f'{ remove_packages } esmf esmpy xesmf'
180+
169181 # remove conda-forge versions so we're sure to use Spack versions
170182 commands = f'{ activate_base } && conda remove -y --force ' \
171183 f'-n { env_name } { remove_packages } '
@@ -180,8 +192,8 @@ def build_env(is_test, recreate, compiler, mpi, conda_mpi, version,
180192def install_mache_from_branch (activate_env , fork , branch ):
181193 print ('Clone and install local mache\n ' )
182194 commands = f'{ activate_env } && ' \
183- f'cd build_mache/mache && ' \
184- f'python -m pip install --no-deps .'
195+ f'cd build_mache/mache && ' \
196+ f'python -m pip install --no-deps .'
185197
186198 check_call (commands )
187199
@@ -191,17 +203,20 @@ def build_sys_ilamb_esmpy(config, machine, compiler, mpi, template_path,
191203
192204 mpi4py_version = config .get ('e3sm_unified' , 'mpi4py' )
193205 ilamb_version = config .get ('e3sm_unified' , 'ilamb' )
194- build_mpi4py = str ( mpi4py_version != 'None' )
195- build_ilamb = str ( ilamb_version != 'None' )
206+ build_mpi4py = mpi4py_version != 'None'
207+ build_ilamb = ilamb_version != 'None'
196208
197209 esmpy_version = config .get ('e3sm_unified' , 'esmpy' )
198- build_esmpy = str (esmpy_version != 'None' )
210+ build_esmpy = esmpy_version != 'None'
211+
212+ xesmf_version = config .get ('e3sm_unified' , 'xesmf' )
213+ build_xesmf = xesmf_version != 'None'
199214
200215 mpicc , _ , _ , modules = \
201216 get_modules_env_vars_and_mpi_compilers (machine , compiler , mpi ,
202217 shell = 'sh' )
203218
204- script_filename = 'build_ilamb_esmpy .bash'
219+ script_filename = 'build_ilamb_esmpy_xesmf .bash'
205220
206221 with open (f'{ template_path } /build.template' , 'r' ) as f :
207222 template = Template (f .read ())
@@ -211,33 +226,41 @@ def build_sys_ilamb_esmpy(config, machine, compiler, mpi, template_path,
211226 activate_env_lines = activate_env .replace (' && ' , '\n ' )
212227 modules = f'{ activate_env_lines } \n { modules } '
213228
214- spack_branch_base = f'{ spack_base } /{ spack_env } '
215- spack_view = f'{ spack_branch_base } /var/spack/environments/' \
229+ spack_view = f'{ spack_base } /var/spack/environments/' \
216230 f'{ spack_env } /.spack-env/view'
217231 script = template .render (
218232 mpicc = mpicc , modules = modules , template_path = template_path ,
219- mpi4py_version = mpi4py_version , build_mpi4py = build_mpi4py ,
220- ilamb_version = ilamb_version , build_ilamb = build_ilamb ,
233+ mpi4py_version = mpi4py_version , build_mpi4py = str ( build_mpi4py ) ,
234+ ilamb_version = ilamb_version , build_ilamb = str ( build_ilamb ) ,
221235 ilamb_channels = channels , esmpy_version = esmpy_version ,
222- build_esmpy = build_esmpy , spack_view = spack_view )
236+ build_esmpy = str (build_esmpy ), xesmf_version = xesmf_version ,
237+ build_xesmf = str (build_xesmf ), spack_view = spack_view )
223238 print (f'Writing { script_filename } ' )
224239 with open (script_filename , 'w' ) as handle :
225240 handle .write (script )
226241
227242 command = f'/bin/bash { script_filename } '
228243 check_call (command )
229244
245+ if build_esmpy :
246+ # use spack esmf
247+ esmf_mk = f'export ESMFMKFILE={ spack_view } /lib/esmf.mk'
248+ else :
249+ # use conda esmf
250+ esmf_mk = 'export ESMFMKFILE=${CONDA_PREFIX}/lib/esmf.mk'
251+ return esmf_mk
252+
230253
231254def build_spack_env (config , machine , compiler , mpi , spack_env , tmpdir ):
232255
233256 base_path = config .get ('e3sm_unified' , 'base_path' )
234257 spack_base = f'{ base_path } /spack/{ spack_env } '
235258
236- if config .has_option ('e3sm_unified' , 'use_system_hdf5_netcdf ' ):
237- use_system_hdf5_netcdf = config .getboolean ('e3sm_unified' ,
238- 'use_system_hdf5_netcdf ' )
259+ if config .has_option ('e3sm_unified' , 'use_e3sm_hdf5_netcdf ' ):
260+ use_e3sm_hdf5_netcdf = config .getboolean ('e3sm_unified' ,
261+ 'use_e3sm_hdf5_netcdf ' )
239262 else :
240- use_system_hdf5_netcdf = False
263+ use_e3sm_hdf5_netcdf = False
241264
242265 if config .has_option ('e3sm_unified' , 'spack_mirror' ):
243266 spack_mirror = config .get ('e3sm_unified' , 'spack_mirror' )
@@ -248,7 +271,7 @@ def build_spack_env(config, machine, compiler, mpi, spack_env, tmpdir):
248271 section = config ['spack_specs' ]
249272 for option in section :
250273 # skip redundant specs if using E3SM packages
251- if use_system_hdf5_netcdf and \
274+ if use_e3sm_hdf5_netcdf and \
252275 option in ['hdf5' , 'netcdf_c' , 'netcdf_fortran' ,
253276 'parallel_netcdf' ]:
254277 continue
@@ -259,7 +282,7 @@ def build_spack_env(config, machine, compiler, mpi, spack_env, tmpdir):
259282 make_spack_env (spack_path = spack_base , env_name = spack_env ,
260283 spack_specs = specs , compiler = compiler , mpi = mpi ,
261284 machine = machine , tmpdir = tmpdir , include_e3sm_lapack = True ,
262- include_system_hdf5_netcdf = use_system_hdf5_netcdf ,
285+ include_e3sm_hdf5_netcdf = use_e3sm_hdf5_netcdf ,
263286 spack_mirror = spack_mirror )
264287
265288 return spack_base
@@ -339,6 +362,7 @@ def check_env(script_filename, env_name, conda_mpi, machine):
339362 'IPython' , 'globus_cli' , 'zstash' ]
340363 if conda_mpi not in ['nompi' , 'hpc' ]:
341364 imports .append ('ILAMB' )
365+ imports .append ('esmpy' )
342366
343367 commands = [['mpas_analysis' , '-h' ],
344368 ['livv' , '--version' ],
@@ -416,10 +440,10 @@ def main():
416440
417441 nompi_compiler = None
418442 nompi_suffix = '_login'
419- # first, make environment for login nodes. We're using mpich from
420- # conda-forge for now because we haven't had any luck with esmf>8.2.0 nompi
443+ # first, make environment for login nodes. We're using no-MPI from
444+ # conda-forge for now
421445 env_path , env_nompi , activate_env , _ , _ = build_env (
422- is_test , recreate , nompi_compiler , mpi , 'mpich ' , version ,
446+ is_test , recreate , nompi_compiler , mpi , 'nompi ' , version ,
423447 python , conda_base , nompi_suffix , nompi_suffix , activate_base ,
424448 args .local_conda_build , config )
425449
@@ -444,8 +468,10 @@ def main():
444468 if compiler is not None :
445469 spack_base = build_spack_env (config , machine , compiler , mpi , spack_env ,
446470 args .tmpdir )
447- build_sys_ilamb_esmpy (config , machine , compiler , mpi , template_path ,
448- activate_env , channels , spack_base , spack_env )
471+ esmf_mk = build_sys_ilamb_esmpy (config , machine , compiler , mpi ,
472+ template_path , activate_env , channels ,
473+ spack_base , spack_env )
474+ sys_info ['env_vars' ].append (esmf_mk )
449475 else :
450476 spack_base = None
451477
0 commit comments