55#
66# SPDX-License-Identifier: (Apache-2.0 OR MIT)
77
8- from spack .package import install , join_path , mkdirp
9- # from pprint import pprint
8+ from spack .package import *
9+
1010
1111# https://spack.readthedocs.io/en/latest/build_systems/makefilepackage.html
1212class Oasis3Mct (MakefilePackage ):
@@ -17,6 +17,11 @@ class Oasis3Mct(MakefilePackage):
1717
1818 maintainers ("harshula" , "penguian" )
1919
20+ version (
21+ "upstream" ,
22+ branch = "OASIS3-MCT_5.0" ,
23+ git = "https://gitlab.com/cerfacs/oasis3-mct.git" ,
24+ )
2025 version ("access-om2" , branch = "master" , preferred = True )
2126 version ("access-esm1.5" , branch = "access-esm1.5" )
2227
@@ -42,7 +47,7 @@ class Oasis3Mct(MakefilePackage):
4247 __pkgdir = join_path (__libdir , "pkgconfig" )
4348 __makefiledir = join_path ("util" , "make_dir" )
4449 __makeinc = join_path (__makefiledir , "make.inc" )
45- __libs = { "mct" : {} , "mpeu" : {} , "psmile.MPI1" : {} , "scrip" : {}}
50+ __libs = [ "mct" , "mpeu" , "psmile.MPI1" , "scrip" ]
4651
4752 # doc/oasis3mct_UserGuide.pdf:
4853 # If module mod_oasis is used in the models, it is enough to include
@@ -55,148 +60,36 @@ class Oasis3Mct(MakefilePackage):
5560 # use both the psmile and mct libraries $ARCHDIR/lib/libpsmile.MPI1.a
5661 # and libmct.a and libmpeu.a when linking.
5762
58- __libs ["mct" ]["incfiles" ] = [
59- "m_accumulatorcomms.mod" ,
60- "m_accumulator.mod" ,
61- "m_attrvectcomms.mod" ,
62- "m_attrvect.mod" ,
63- "m_attrvectreduce.mod" ,
64- "m_chars.mod" ,
65- "m_convertmaps.mod" ,
66- "mct_mod.mod" ,
67- "m_die.mod" ,
68- "m_dropdead.mod" ,
69- "m_errorhandler.mod" ,
70- "m_exchangemaps.mod" ,
71- "m_fccomms.mod" ,
72- "m_filename.mod" ,
73- "m_fileresolv.mod" ,
74- "m_flow.mod" ,
75- "m_generalgridcomms.mod" ,
76- "m_generalgrid.mod" ,
77- "m_globalmap.mod" ,
78- "m_globalsegmapcomms.mod" ,
79- "m_globalsegmap.mod" ,
80- "m_globaltolocal.mod" ,
81- "m_indexbin_char.mod" ,
82- "m_indexbin_integer.mod" ,
83- "m_indexbin_logical.mod" ,
84- "m_inpak90.mod" ,
85- "m_ioutil.mod" ,
86- "m_list.mod" ,
87- "m_mall.mod" ,
88- "m_matattrvectmul.mod" ,
89- "m_mctworld.mod" ,
90- "m_merge.mod" ,
91- "m_mergesorts.mod" ,
92- "m_mpif90.mod" ,
93- "m_mpif.mod" ,
94- "m_mpout.mod" ,
95- "m_navigator.mod" ,
96- "m_permuter.mod" ,
97- "m_rankmerge.mod" ,
98- "m_realkinds.mod" ,
99- "m_rearranger.mod" ,
100- "m_router.mod" ,
101- "m_sortingtools.mod" ,
102- "m_sparsematrixcomms.mod" ,
103- "m_sparsematrixdecomp.mod" ,
104- "m_sparsematrix.mod" ,
105- "m_sparsematrixplus.mod" ,
106- "m_sparsematrixtomaps.mod" ,
107- "m_spatialintegral.mod" ,
108- "m_spatialintegralv.mod" ,
109- "m_stdio.mod" ,
110- "m_string.mod" ,
111- "m_strtemplate.mod" ,
112- "m_traceback.mod" ,
113- "m_transfer.mod" ,
114- "m_zeit.mod" ,
115- ]
116-
117- __libs ["mpeu" ]["incfiles" ] = []
118-
119- __libs ["psmile.MPI1" ]["incfiles" ] = [
120- "mod_oasis_advance.mod" ,
121- "mod_oasis_coupler.mod" ,
122- "mod_oasis_data.mod" ,
123- "mod_oasis_getput_interface.mod" ,
124- "mod_oasis_grid.mod" ,
125- "mod_oasis_io.mod" ,
126- "mod_oasis_ioshr.mod" ,
127- "mod_oasis_kinds.mod" ,
128- "mod_oasis_method.mod" ,
129- "mod_oasis.mod" ,
130- "mod_oasis_mpi.mod" ,
131- "mod_oasis_namcouple.mod" ,
132- "mod_oasis_parameters.mod" ,
133- "mod_oasis_part.mod" ,
134- "mod_oasis_string.mod" ,
135- "mod_oasis_sys.mod" ,
136- "mod_oasis_timer.mod" ,
137- "mod_oasis_var.mod" ,
138- "mod_prism.mod" ,
139- ]
140-
141- __libs ["scrip" ]["incfiles" ] = [
142- "constants.mod" ,
143- "grids.mod" ,
144- "iounits.mod" ,
145- "kinds_mod.mod" ,
146- "mod_oasis_flush.mod" ,
147- "netcdf_mod.mod" ,
148- "remap_bicubic.mod" ,
149- "remap_bicubic_reduced.mod" ,
150- "remap_bilinear.mod" ,
151- "remap_bilinear_reduced.mod" ,
152- "remap_conservative.mod" ,
153- "remap_distance_weight.mod" ,
154- "remap_gaussian_weight.mod" ,
155- "remap_vars.mod" ,
156- "remap_write.mod" ,
157- "timers.mod" ,
158- ]
159-
160- def __init__ (self , args ):
161- super ().__init__ (args )
162-
163- for k in self .__libs .keys ():
164- self .__libs [k ]["filename" ] = "lib" + k + ".a"
165- self .__libs [k ]["filerelpath" ] = join_path (
166- "lib" , self .__libs [k ]["filename" ]
167- )
168- self .__libs [k ]["pcname" ] = "oasis3-" + k + ".pc"
169- self .__libs [k ]["pcrelpath" ] = join_path (
170- "lib" , "pkgconfig" , self .__libs [k ]["pcname" ]
171- )
172- self .__libs [k ]["pcpath" ] = join_path (
173- self .__pkgdir , self .__libs [k ]["pcname" ]
174- )
175-
176- # Uncomment to print package files and directories
177- # pprint(self.__libs)
178-
63+ # TODO: Remove this function when it is no longer required
17964 def url_for_version (self , version ):
65+ if self .spec .satisfies ("@upstream" ):
66+ raise ValueError ("url_for_version() called for version @upstream" )
67+
18068 return "https://github.com/ACCESS-NRI/oasis3-mct/tarball/{0}" .format (version )
18169
18270 def __create_pkgconfig (self , spec , prefix ):
18371
72+ oasis_version = "2.0"
73+ if self .spec .satisfies ("@upstream" ):
74+ oasis_version = "5"
75+
18476 mkdirp (self .__pkgdir )
185- for k in self .__libs . keys () :
77+ for k in self .__libs :
18678 text = f"""\
18779 prefix={ prefix }
18880exec_prefix=${{prefix}}
18981libdir=${{exec_prefix}}/lib
19082includedir=${{prefix}}/include
19183
19284Name: { k }
193- Description: OASIS3-MCT 2.0 { k } Library for Fortran
194- Version: 2.0
85+ Description: OASIS3-MCT { oasis_version } { k } Library for Fortran
86+ Version: { oasis_version }
19587Libs: -L${{libdir}} -l{ k }
19688Cflags: -I${{includedir}}/{ k }
19789"""
19890
199- with open (self .__libs [k ]["pcpath" ], "w" , encoding = "utf-8" ) as pc :
91+ pcpath = join_path (self .__pkgdir , "oasis3-" + k + ".pc" )
92+ with open (pcpath , "w" , encoding = "utf-8" ) as pc :
20093 nchars_written = pc .write (text )
20194
20295 if nchars_written < len (text ):
@@ -224,7 +117,7 @@ def edit(self, spec, prefix):
224117 CFLAGS = ""
225118 if "@access-esm1.5" in self .spec :
226119 NCI_OPTIM_FLAGS = "-g3 -O2 -xCORE-AVX512 -debug all -check none -traceback"
227-
120+
228121 if "+deterministic" in self .spec :
229122 NCI_OPTIM_FLAGS = "-g0 -O0 -axCORE-AVX2 -debug none -check none"
230123 CFLAGS = "-g0"
@@ -343,29 +236,13 @@ def build(self, spec, prefix):
343236
344237 def install (self , spec , prefix ):
345238
346- mkdirp (prefix .lib .pkgconfig )
347-
348- src_dst = []
349- for libname in self .__libs .keys ():
350-
351- mkdirp (join_path (prefix .include , libname ))
352-
353- for f in [
354- self .__libs [libname ]["filerelpath" ],
355- self .__libs [libname ]["pcrelpath" ],
356- ]:
357- src_dst .append (
358- (join_path (self .__builddir , f ), join_path (prefix , f ))
359- )
239+ install_tree (self .__libdir , prefix .lib )
360240
361- for f in self .__libs [ libname ][ "incfiles" ] :
362- src_dst . append (
363- (
364- join_path ( self . __incdir , libname , f ),
365- join_path ( prefix . include , libname , f ),
366- )
367- )
241+ for libname in self .__libs :
242+ srcdir = join_path ( self . __incdir , libname )
243+ dstdir = join_path ( prefix . include , libname )
244+ mkdirp ( dstdir )
245+ h = find_all_headers ( srcdir )
246+ for headerfile in h . headers :
247+ install ( headerfile , dstdir )
368248
369- # Uncomment to print source and destination tuples
370- # pprint(src_dst)
371- [install (s , d ) for (s , d ) in src_dst ]
0 commit comments