@@ -352,6 +352,34 @@ def update_versions_file(meta_dirs: list[Path], upgrade_name: str) -> None:
352352 add_new_import (versions_file , upgrade_name )
353353
354354
355+ def update_versions_mod (repo : str , filepath : Path , version : str ) -> None :
356+ """
357+ Update the versions numbers in lfric versions mod files
358+ """
359+
360+ print (f"[INFO] Updating lfric_{ repo } _versions_mod.F90" )
361+
362+ version = version .removeprefix ("vn" ).split ("." )
363+ updates = {
364+ "major" : version [0 ],
365+ "minor" : version [1 ],
366+ "patch" : "0" ,
367+ "release" : ".true." ,
368+ }
369+
370+ lines = filepath .read_text ().split ("\n " )
371+ for i , line in enumerate (lines ):
372+ if len (updates ) == 0 :
373+ break
374+ for item , val in updates .items ():
375+ if re .match (rf".*::\s*lfric_{ repo } _{ item } _version\s*=" , line ):
376+ lines [i ] = f"{ line .split ('=' )[0 ]} = { val } "
377+ del updates [item ]
378+ break
379+
380+ filepath .write_text ("\n " .join (lines ))
381+
382+
355383def ticket_number (opt : str ) -> str :
356384 """
357385 Check that the command line supplied ticket number is of a suitable format
@@ -396,9 +424,8 @@ def parse_args() -> argparse.Namespace:
396424 "--apps" ,
397425 default = Path ("." ).absolute (),
398426 type = Path ,
399- help = "The path to the LFRic Apps working copy being used. Defaults to "
400- "the location the script is being run from - this assumes you are in a "
401- "working copy." ,
427+ help = "The path to the LFRic Apps working copy being used. Defaults to the "
428+ "location the script is being run from - this assumes you are in an Apps clone" ,
402429 )
403430 parser .add_argument (
404431 "-c" ,
@@ -481,6 +508,26 @@ def main() -> None:
481508
482509 update_versions_file (meta_dirs , upgrade_file_name )
483510
511+ update_versions_mod (
512+ "apps" ,
513+ args .apps
514+ / "science"
515+ / "shared"
516+ / "source"
517+ / "utilities"
518+ / "lfric_apps_version_mod.f90" ,
519+ args .version ,
520+ )
521+ update_versions_mod (
522+ "core" ,
523+ args .core
524+ / "infrastructure"
525+ / "source"
526+ / "utilities"
527+ / "lfric_core_version_mod.f90" ,
528+ args .version ,
529+ )
530+
484531
485532if __name__ == "__main__" :
486533 main ()
0 commit comments