Skip to content

Commit

Permalink
run.py will not build code, only run exe now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yujin Zeng committed Dec 12, 2023
1 parent cf6a9d0 commit e009390
Showing 1 changed file with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import subprocess

input_path = "/discover/nobackup/projects/gmao/bcs_shared/preprocessing_bcs_inputs/land/routing"
netcdf_path = "/usr/local/other/netcdf4/4.1.2/gcc-4.8.5"
#netcdf_path = "/usr/local/other/netcdf4/4.1.2/gcc-4.8.5"
install_path = "../../../../../../../../../../../install/bin"

This comment has been minimized.

Copy link
@gmao-rreichle

gmao-rreichle Dec 12, 2023

Contributor

@zyj8881357 : Have you tried run.py after the most recent commit? If I'm not mistaken, the new CMakeLists.txt does (intentionally) not install the programs, so after a build the *.x file are probably still in the preproc dir

This comment has been minimized.

Copy link
@zyj8881357

zyj8881357 via email Dec 12, 2023

This comment has been minimized.

Copy link
@gmao-rreichle

gmao-rreichle Dec 13, 2023

Contributor

Thanks, @zyj8881357. If the *.x files are in the install/bin dir after the build, I'm misunderstanding the "build-but-do-not-install" approach that we were going to follow for CMakeLists.txt.
@weiyuan-jiang, does it make sense to you that the *.x files from the preproc programs are in the install/bin dir?

This comment has been minimized.

Copy link
@mathomp4

mathomp4 Dec 13, 2023

Member

Chiming in here. If you want to build an executable but not install it for some reason, then you can try adding NOINSTALL as an option to ecbuild_add_executable in the CMakeLists.txt file. Then the executable should still be built (either in build/bin or in the build src tree...not sure which), but it should not be installed at install/bin.

This comment has been minimized.

Copy link
@weiyuan-jiang

weiyuan-jiang Dec 13, 2023

Contributor

Thanks, @zyj8881357. If the *.x files are in the install/bin dir after the build, I'm misunderstanding the "build-but-do-not-install" approach that we were going to follow for CMakeLists.txt. @weiyuan-jiang, does it make sense to you that the *.x files from the preproc programs are in the install/bin dir?

My bad, Those executables are still there. Thans @mathomp4 , I just fixed it

This comment has been minimized.

Copy link
@weiyuan-jiang

weiyuan-jiang Dec 13, 2023

Contributor

That is not a good practice. I will change it


# Remove files and directories
os.system("rm -rf inputs >& /dev/null")
os.system("rm -rf outputs >& /dev/null")
os.system("rm -f *.mod >& /dev/null")
os.system("rm -f *.out >& /dev/null")
#os.system("rm -f *.mod >& /dev/null")
#os.system("rm -f *.out >& /dev/null")
os.system("rm -f *.x >& /dev/null")

This comment has been minimized.

Copy link
@gmao-rreichle

gmao-rreichle Dec 12, 2023

Contributor

Why delete the *.x files from the build? This doesn't seem right.

os.system("rm -f Outlet_latlon.43200x21600 >& /dev/null")

# Create directories and symbolic links
Expand All @@ -19,7 +21,7 @@
for file in os.listdir(input_path):
os.symlink(os.path.join(input_path, file), os.path.join("inputs", file))

# Build and run Fortran programs
# Link and run Fortran programs
programs = [
"get_outlets_catchindex",
"get_outlets_land",
Expand All @@ -29,18 +31,21 @@
"Pfaf_to_2d_30s_land",
]

for program in programs:
print(f"Building {program} ...")
#for program in programs:
# print(f"Building {program} ...")
#subprocess.run(["./build", program])
subprocess.run(f"gfortran constant.f90 {program}.f90 -I{netcdf_path}/include -L{netcdf_path}/lib -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lcurl -lz -lsz -ldl -o {program}.out",shell=True)
# subprocess.run(f"gfortran constant.f90 {program}.f90 -I{netcdf_path}/include -L{netcdf_path}/lib -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lcurl -lz -lsz -ldl -o {program}.out",shell=True)
current_working_directory = os.getcwd()
for program in programs:
os.symlink(os.path.join(install_path, program+".x"), os.path.join(current_working_directory, program+".x"))

out_programs = [
"get_outlets_catchindex.out",
"get_outlets_land.out",
"get_sinkxy_land.out",
"get_outlets_land_allcat.out",
"get_landocean_Greenland_real.out",
"Pfaf_to_2d_30s_land.out",
"get_outlets_catchindex.x",
"get_outlets_land.x",
"get_sinkxy_land.x",
"get_outlets_land_allcat.x",
"get_landocean_Greenland_real.x",
"Pfaf_to_2d_30s_land.x",
]

for out_program in out_programs:
Expand All @@ -54,6 +59,7 @@
os.system("rm -rf outputs")
os.system("rm -rf inputs")
print("Removing *.out files ...")
os.system("rm -f *.out")
os.system("rm -f *.mod")
#os.system("rm -f *.out")
os.system("rm -f *.x")

This comment has been minimized.

Copy link
@gmao-rreichle

gmao-rreichle Dec 12, 2023

Contributor

Why delete the program files from the build? This doesn't seem right.

#os.system("rm -f *.mod")

0 comments on commit e009390

Please sign in to comment.