@echo off :: :: - Assume the following files and directory structure: :: /current_directory (njoy2012) :: ... containing this batch script :: ... containing src (used by upd) :: ... containing whatever makefile is specified below :: by the User's make command :: /up# ... containing up#.txt :: /manual ... containing NJOYMan.cls :: /figs ... containing all NJOY manual pdf figure files :: :: - This batch file ... :: - checks for a new NJOY version #; :: - verifies that a "up#\up#.txt" directory and file exist, then :: copies that "up#.txt" file to the current directory and renames :: it "upn". if a "upn" file already exists it is temporarily :: renamed "old_upn"; :: - executes "upd x" to extract new *.f90 and *.tex files; :: - executes "nmake /f makef.win.ifort" to create a new njoy :: executable program; :: - rename the new executable, "xnjoy.xex", to "njoy2012.#.exe"; :: - NOTE: if "njoy2012.#.exe" already exists the rename :: command will fail but this script will continue. :: - newly created *.mod and *.obj files are deleted, but *.f90 :: files are moved to the up# directory; :: - exectues "upd l" to create new *.lst files, which are also :: moved to the up# directory; :: - delete the no longer needed "upn" file. if it had been created :: earlier we also delete the "old_upn" file; :: - the previously created *.tex files are moved to the "manual" :: directory; :: - cd into the manual directory and create a new NJOY manual :: pdf file. :: - we use the MikTeX "texify" program to accomplish :: this last step. the *.tex files are retained, although :: the appropriate command to delete them is provided as a :: comment should Users desire to implement this step. :: - "texify" runs pdfLaTeX, MakeIndex and BibTeX iteratively :: to create a new "njoy2012.pdf" file. :: - rename the newly created "njoy2012.pdf" to "njoy2012.#.pdf" :: and exit. :: - if any step fails to execute and a old upn file had been saved, :: the current upn file is deleted and the old upn file is restored. :: - NOTE: we use "nmake", a Microsoft version of the unix :: "make" program to create a new njoy executable. :: - NOTE: this script attempts to delete no longer needed :: object files after the new executable has been :: created. the extension for object files varies :: among compilers, typically .o or .obj. we specify :: .obj in this script. :: :: perform input variable test ... if "%1" equ "" GOTO blank :: check that requested update file exists ... if NOT exist up%1\up%1.txt GOTO noupn :: if present, temporarily save the current upn file ... if exist upn echo current upn saved if exist upn rename upn old_upn :: copy latest up## file to upn and execute upd ... copy up%1\up%1.txt upn upd x if ERRORLEVEL 1 goto upd_abort echo All required *.f90 and *.tex files have been created ... continue :: compile new njoy .f90 source files nmake /f makef.win.ifort if ERRORLEVEL 1 goto nmake_abort rename xnjoy.exe njoy2012.%1.exe echo The NJOY2012.%1 executable has been created del *.mod del *.obj echo Saving *.f90 files ... for %%i in (*.f90) do move *.f90 up%1\ :: if we're here a new executable has been created, lets :: also create and save *.lst files for future edits ... echo Creating and saving *.lst files ... upd l for %%i in (*.lst) do move *.lst up%1\ :: clean up old and current upn files ... del upn if exist old_upn del old_upn :: create a new manual :: latest *.tex files are moved, and will overwrite, any *.tex :: files that exist in \manual. echo working to create a new NJOY manual pdf ... for %%i in (*.tex) do move *.tex manual\ cd manual texify --pdf --quiet --clean njoy12.tex if ERRORLEVEL 1 goto tex_abort rename njoy12.pdf NJOY2012.%1.pdf :: for %%i in (*.tex) do del *.tex echo finished! cd .. echo new njoy code and manual are available ... exiting goto end :blank echo Need an NJOY version specification ... no action taken goto end :noupn echo Can't find up%1\up%1.txt ... exiting goto end :upd_abort if exist upn del upn if exist old_upn rename old_upn upn if exist upn echo previous upn file has been restored echo upd error ... processing halted goto end :nmake_abort del upn if exist old_upn rename old_upn upn if exist upn echo previous upn file has been restored echo nmake or fortran compilation error ... processing halted goto end :tex_abort if exist old_upn rename old_upn upn if exist upn echo previous upn file has been restored echo tex error, revised njoy manual was not created ... processing halted :end