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

Simplify model compilation after modifying a single .F file #369

Open
zhl-ouc opened this issue Feb 27, 2025 · 3 comments
Open

Simplify model compilation after modifying a single .F file #369

zhl-ouc opened this issue Feb 27, 2025 · 3 comments

Comments

@zhl-ouc
Copy link

zhl-ouc commented Feb 27, 2025

Dear Professor,
I'm sorry to bother you. I modified a specific Fortran file (phys/module_sf_mynn.F) in WRF and want to recompile it incrementally without rebuilding the entire model. Is this possible?
I have already tried the following method: cd COAWST/WRF, ./compile -j 4 em_real, but the compilation failed.

@jcwarner-usgs
Copy link
Collaborator

when you say 'build it incrementally' what do you mean?

  1. just build WRF?
    if you want to just build wrf, then make your *.h file just have
    #define WRF_MODEL

  2. or just build that .F file?
    if you want to only build that file, it may be a bit harder. you could do a full wrf build and save the build process to a log file.
    script build.log
    ./build_coawst.sh
    when it is done, type exit.
    Then edit build.log and find where it is building that .F and use those steps. Here are the specific steps for my build.

sed -e "s/^!.'.//" -e "s/^ !.'.*//" module_sf_mynn.F > module_sf_mynn.G

/usr/bin/cpp -P -traditional -I/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/WRF/inc -DEM_CORE=1 -DNMM_CORE=0 -DNMM_MAX_DIM=2600 -DDA_CORE=0 -DWRFPLUS=0 -DIWORDSIZE=4 -DDWORDSIZE=8 -DRWORDSIZE=4 -DLWORD SIZE=4 -DNONSTANDARD_SYSTEM_FUNC -DWRF_USE_CLM -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT -DDM_PARALLEL -DNETCDF -DLANDREAD_STUB=1 -DUSE_ALLOCATABLES -Dwrfmodel -DGRIB1 -DINTIO -DKEEP_INT_AROUND -DLIMIT_ARGS -DBUILD_RRTMG_FAST=0 -DBUILD_RRTMK=0 -DBUILD_SBM_FAST=1 -DSHOW_ALL_VARS_USED=0 -DCONFIG_BUF_LEN=65536 -DMAX_DOMAINS_F=21 -DMAX_HISTORY=25 -DNMM_NEST=0 -I. -traditional-cpp -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT -DSANDY -D'PROJECT_HEADER="/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/Projects/Sandy/WW3/sandy.h"' -D'GLOBAL_DEFS="/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test//ROMS/Include/globaldefs.h"' -DEM_CORE=1 -DNMM_CORE=0 -DNMM_MAX_DIM=2600 -DDA_CORE=0 -DWRFPLUS=0 -DIWORDSIZE=4 -DDWORDSIZE=8 -DRWORDSIZE=4 -DLWORDSIZE=4 -DNONSTANDARD_SYSTEM_FUNC -DWRF_USE_CLM -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT -DDM_PARALLEL -DNETCDF -DLANDREAD_STUB=1 -DUSE_ALLOCATABLES -Dwrfmodel -DGRIB1 -DINTIO -DKEEP_INT_AROUND -DLIMIT_ARGS -DBUILD_RRTMG_FAST=0 -DBUILD_RRTMK=0 -DBUILD_SBM_FAST=1 -DSHOW_ALL_VARS_USED=0 -DCONFIG_BUF_LEN=65536 -DMAX_DOMAINS_F=21 -DMAX_HISTORY=25 -DNMM_NEST=0 -I. -traditional-cpp -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT module_sf_mynn.G > module_sf_mynn.bb

/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/WRF/tools/standard.exe module_sf_mynn.bb | /usr/bin/cpp sf_myraditional -traditional-cpp -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT > module_sf_mynn.f90

rm -f module_sf_mynn.G module_sf_mynn.bb
sf_mynnif90 -f90=ifort -o module_sf_mynn.o -c -O3 -ip -fp-model precise -w -ftz -align all -fno-alias -FR -convert big_endian -I../dyn_em -I/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/WRF/external/ esmf_time_f90 -I/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/WRF/main -I/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/WRF/external/io_netcdf -I/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/WRF/external/io_int -I/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/WRF/frame -I/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/WRF/share -I/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/WRF/phys -I/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/WRF/wrftladj -I/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/WRF/chem -I/proj/usgs-share/users/jcwarner/help_cases/sandy_ww3_roms_test/WRF/inc -I/vortexfs1/apps/impistack-1.0/include -I/proj/usgs-share/
users/jcwarner/help_cases/sandy_ww3_roms_test/Build_roms -I/vortexfs1/usgs/jwarner/models/MCT_stack/include -real-sizeexpr 8 \* 4 -i4 module_sf_mynn.f90

and that creates the module_sf_mynn.f90

@zhl-ouc zhl-ouc closed this as completed Feb 28, 2025
@zhl-ouc zhl-ouc reopened this Feb 28, 2025
@zhl-ouc
Copy link
Author

zhl-ouc commented Feb 28, 2025

I want to build just that .F file. Thanks for your advice! I've used the second method you suggested.
Following this method, I rebuilt module_sf_mynn.F, which created module_sf_mynn.f90, module_sf_mynn.o, and the module_sf_mynn.mod successfully. However, the modified code doesn't work when I run the experiment. For example, when I add "print *, XX" in module_sf_mynn.F, there is no print information in the running output file. When I rebuild the entire model, the print information can be seen. Are there other files that should be rebuilt after I build module_sf_mynn.F?

@jcwarner-usgs
Copy link
Collaborator

you are getting into the details of how a model compiles. these are not easy steps.
after the module_sf_mynn.o is created, at some point later that .o is added to a lib (maybe libwrf.a or something), then the libs are linked to make an executable.
If you look at the output of the build, all this happens. but it is very involved.

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

2 participants