diff --git a/source/f90/Makefile b/source/f90/Makefile index 70f44d156dabdddcf54eb906a1e4a22a4dbdafb1..bc645ae458c376d62e5fc080c98ea93ec04365ab 100644 --- a/source/f90/Makefile +++ b/source/f90/Makefile @@ -4,7 +4,7 @@ FC = gfortran # fortran compiler options -FFLAGS = -g -gdwarf-2 -fbounds-check -fcheck=all -ffpe-trap=invalid -O0 -Wall +FFLAGS = -g -gdwarf-2 -fbounds-check -fcheck=all -ffpe-trap=invalid -O1 -Wall -Jbuild # -Wextra -Werror -Wpedantic # gfortran version 4.8 does not know -fdiagnostics-color # safeguard for major version >= 5 @@ -13,6 +13,8 @@ ifeq "$(GFORTAN_VERSION_GE_5)" "1" FFLAGS += -fdiagnostics-color=auto endif +YAMLLIBS = -L/opt/local/lib -lyaml + # python3 interpreter PYTHON3 = python3 @@ -20,65 +22,63 @@ PYTHON3 = python3 OS := $(shell echo `uname -s`) # implicit rules for compiling fortran files -%.o: %.f90 ; $(FC) $(FFLAGS) -c $< -%_mod.mod: %.f90 ; $(FC) $(FFLAGS) -c $< +build/%.o: %.f90 ; $(FC) $(FFLAGS) -c -o $@ $< +build/%_mod.mod: %.f90 ; $(FC) $(FFLAGS) -c -o build/$*.o $< + +all: eels-boson -all: boson eels eels-boson +bosonmods = build/sicot_mod.mod build/sintr_mod.mod build/rcffi_mod.mod +build/doboson.o: doboson.f90 $(bosonmods) -bosonmods = sicot_mod.mod sintr_mod.mod rcffi_mod.mod -doboson.o: doboson.f90 $(bosonmods) +build/sicot_mod.mod: build/sintr_mod.mod -sicot_mod.mod: sintr_mod.mod +bosonsubs = build/doboson.o build/respon.o build/sicot.o build/sintr.o build/rcffi.o build/o.o -bosonsubs = doboson.o respon.o sicot.o sintr.o rcffi.o o.o -boson: boson.f90 change_working_dir.o $(bosonsubs) $(bosonmods) - $(FC) $(FFLAGS) -o bosonf90 boson.f90 change_working_dir.o $(bosonsubs) +eelsmods = build/quanc8_mod.mod build/queels_mod.mod build/seteps_mod.mod build/param_mod.mod build/oscillatorType_mod.mod +build/doeels.o: doeels.f90 $(eelsmods) -eelsmods = quanc8_mod.mod queels_mod.mod seteps_mod.mod param_mod.mod oscillatorType_mod.mod -doeels.o: doeels.f90 $(eelsmods) +build/queels_mod.mod: build/quanc8_mod.mod build/fint1_mod.mod build/fint2_mod.mod build/fint3_mod.mod +build/quanc8_mod.mod: build/fun_mod.mod +build/fint1_mod.mod: build/surlos_mod.mod build/param_mod.mod +build/fint2_mod.mod: build/surlos_mod.mod build/param_mod.mod +build/fint3_mod.mod: build/surlos_mod.mod build/param_mod.mod +build/fun_mod.mod: build/param_mod.mod +build/seteps_mod.mod: build/oscillatorType_mod.mod -queels_mod.mod: quanc8_mod.mod fint1_mod.mod fint2_mod.mod fint3_mod.mod -quanc8_mod.mod: fun_mod.mod -fint1_mod.mod: surlos_mod.mod param_mod.mod -fint2_mod.mod: surlos_mod.mod param_mod.mod -fint3_mod.mod: surlos_mod.mod param_mod.mod -fun_mod.mod: param_mod.mod -seteps_mod.mod: oscillatorType_mod.mod +yamlsubs = build/libyaml_interface.o build/fortran_yaml_c_interface.o build/fortran_yaml_c_types.o build/fortran_yaml_c.o -getoptsubs = getopt.o text.o system.o constants.o date_and_time.o kinds.o dummy_variables.o +getoptsubs = build/getopt.o build/text.o build/system.o build/constants.o build/date_and_time.o build/kinds.o build/dummy_variables.o -getoptmods = sufr_getopt.mod sufr_text.mod sufr_system.mod sufr_constants.mod sufr_date_and_time.mod sufr_kinds.mod sufr_dummy.mod +getoptmods = build/sufr_getopt.mod build/sufr_text.mod build/sufr_system.mod build/sufr_constants.mod build/sufr_date_and_time.mod build/sufr_kinds.mod build/sufr_dummy.mod -sufr_getopt.mod: sufr_text.mod - $(FC) $(FFLAGS) -ffree-line-length-180 -c -o getopt.o ../getopt-libs/libsufr-0.7.7/src/getopt.f90 +build/sufr_getopt.mod: build/sufr_text.mod + $(FC) $(FFLAGS) -ffree-line-length-180 -c -o build/getopt.o ../getopt-libs/libsufr-0.7.7/src/getopt.f90 -sufr_text.mod: sufr_system.mod - $(FC) $(FFLAGS) -ffree-line-length-160 -c -o text.o ../getopt-libs/libsufr-0.7.7/src/text.f90 +build/sufr_text.mod: build/sufr_system.mod + $(FC) $(FFLAGS) -ffree-line-length-160 -c -o build/text.o ../getopt-libs/libsufr-0.7.7/src/text.f90 -sufr_system.mod: sufr_constants.mod sufr_dummy.mod - $(FC) $(FFLAGS) -c -o system.o ../getopt-libs/libsufr-0.7.7/src/system.f90 +build/sufr_system.mod: build/sufr_constants.mod build/sufr_dummy.mod + $(FC) $(FFLAGS) -c -o build/system.o ../getopt-libs/libsufr-0.7.7/src/system.f90 -sufr_constants.mod: sufr_date_and_time.mod - $(FC) $(FFLAGS) -ffree-line-length-256 -c -o constants.o ../getopt-libs/libsufr-0.7.7/src/constants.f90 +build/sufr_constants.mod: build/sufr_date_and_time.mod + $(FC) $(FFLAGS) -ffree-line-length-256 -c -o build/constants.o ../getopt-libs/libsufr-0.7.7/src/constants.f90 -sufr_date_and_time.mod: sufr_kinds.mod - $(FC) $(FFLAGS) -ffree-line-length-150 -c -o date_and_time.o ../getopt-libs/libsufr-0.7.7/src/date_and_time.f90 +build/sufr_date_and_time.mod: build/sufr_kinds.mod + $(FC) $(FFLAGS) -ffree-line-length-150 -c -o build/date_and_time.o ../getopt-libs/libsufr-0.7.7/src/date_and_time.f90 -sufr_kinds.mod: - $(FC) $(FFLAGS) -c -o kinds.o ../getopt-libs/libsufr-0.7.7/src/kinds.f90 +build/sufr_kinds.mod: + $(FC) $(FFLAGS) -c -o build/kinds.o ../getopt-libs/libsufr-0.7.7/src/kinds.f90 -sufr_dummy.mod: - $(FC) $(FFLAGS) -c -o dummy_variables.o ../getopt-libs/libsufr-0.7.7/src/dummy_variables.f90 +build/sufr_dummy.mod: + $(FC) $(FFLAGS) -c -o build/dummy_variables.o ../getopt-libs/libsufr-0.7.7/src/dummy_variables.f90 -eelssubs = doeels.o usurlo.o quanc8.o fun.o queels.o fint1.o fint2.o fint3.o surlos.o seteps.o phint.o qrat.o param.o oscillatorType.o -eels: eels.f90 change_working_dir.o $(eelssubs) $(eelsmods) - $(FC) $(FFLAGS) -o eelsf90 eels.f90 change_working_dir.o $(eelssubs) +build/get_commandline_options.o: get_commandline_options.f90 $(getoptmods) $(getoptsubs) + $(FC) $(FFLAGS) -c -o $@ get_commandline_options.f90 -get_commandline_options.o: get_commandline_options.f90 $(getoptmods) $(getoptsubs) - $(FC) $(FFLAGS) -c -o get_commandline_options.o get_commandline_options.f90 +eelssubs = build/doeels.o build/usurlo.o build/quanc8.o build/fun.o build/queels.o build/fint1.o build/fint2.o build/fint3.o build/surlos.o build/seteps.o build/phint.o build/qrat.o build/param.o build/oscillatorType.o -eels-boson: eels-boson.f90 get_commandline_options.o $(getoptsubs) $(getoptmods) $(eelssubs) $(eelsmods) $(bosonsubs) $(bosonmods) - $(FC) $(FFLAGS) -o eels-boson eels-boson.f90 get_commandline_options.o $(getoptsubs) $(eelssubs) $(bosonsubs) +eels-boson: eels-boson.f90 build/get_commandline_options.o $(getoptsubs) $(getoptmods) $(eelssubs) $(eelsmods) $(bosonsubs) $(bosonmods) + $(FC) $(FFLAGS) $(YAMLLIBS) -o build/$@ eels-boson.f90 build/get_commandline_options.o $(yamlsubs) $(getoptsubs) $(eelssubs) $(bosonsubs) pylibs: doeels-py doboson-py @@ -105,13 +105,9 @@ ifeq ( $(OS), Darwin ) endif clean: - rm -f *.o - rm -rf *.dSYM - rm -f *.mod - rm -f *.so - rm -f eelsou bosou - rm -f bosonf90 bosonf90.exe - rm -f eelsf90 eelsf90.exe - rm -f eels-boson eels-boson.exe + rm -f build/*.o + rm -rf build/*.dSYM + rm -f build/*.mod + rm -f build/eels-boson build/eels-boson.exe .PHONY: all clean coverage diff --git a/source/f90/eels-boson.f90 b/source/f90/eels-boson.f90 index 778aa7db9cff9692582d2f4cf2b8098e6cb6243e..bc3265de3b1b68bac199c8d64037012d8f208a08 100644 --- a/source/f90/eels-boson.f90 +++ b/source/f90/eels-boson.f90 @@ -11,11 +11,17 @@ program eels_boson use get_commandline_options_mod use doeels_mod use oscillator_mod + use fortran_yaml_c implicit none include 'version.inc' + type(YamlFile), target :: file + character(:), allocatable :: err + + class(type_node), pointer :: root + double precision :: e0, theta, phia, phib, wmin, wmax, dw integer :: i, j, jos, k, l, layers, neps, nper, nw logical :: user @@ -36,18 +42,23 @@ program eels_boson logical :: debug integer :: ioStatus - character (len = :), allocatable :: eelsin_name, eelsou_name - character (len = :), allocatable :: bosin_name, bosou_name - - ! the historic default names - eelsin_name = 'eelsin' - eelsou_name = ' ' ! eelsou is not needed - bosin_name = 'bosin' - bosou_name = 'bosou' + character (len = :), allocatable :: eelsin_name, bosonout_name + + ! the default names + eelsin_name = 'eelsin.yaml' + bosonout_name = 'bosonout.txt' - call get_commandline_options(eelsin_name, eelsou_name, bosin_name, bosou_name) + call get_commandline_options(eelsin_name, bosonout_name) + + call file%parse(eelsin_name, err) + if (allocated(err)) then + print*,err + stop 1 + endif + + root => file%root - ! *** read spectrometer parameters +! *** read spectrometer parameters open(unit = 11, file = eelsin_name) ! impact energy (ev) read(11, *) e0 @@ -167,7 +178,7 @@ program eels_boson layers, neps, nper, name, size(name), thick, epsinf, nos, oscType, osc, size(osc, 2),& contrl, wn_array, debug, f, size(wn_array)) - open(unit = 13, file = bosin_name) + open(unit = 13, file = eelsin_name) ! target temperature (Kelvin) read(13, *) t ! width of the instrumental response (cm**-1) @@ -200,7 +211,7 @@ program eels_boson wmin, wmax, nw, f, debug, xout, yout, nout) comment(2) = comment(1) - open(unit = 14, file = bosou_name) + open(unit = 14, file = bosonout_name) write(14, '(a, f6.2, a, f5.1, a, f5.2, a, f5.2, a, f6.1, a, f5.2)') & 'e0 =', e0, ' theta =', theta, ' phia =', phia, ' phib =', phib, ' T =', t, ' GAUSS =', gauss write(14, *) comment(2) diff --git a/source/f90/get_commandline_options.f90 b/source/f90/get_commandline_options.f90 index e9977be96a19336c3dbf6636d20485f8b56650ce..ee59f1f51aba5608ebec7d58a94ea6249731e7ee 100644 --- a/source/f90/get_commandline_options.f90 +++ b/source/f90/get_commandline_options.f90 @@ -1,6 +1,6 @@ module get_commandline_options_mod contains -subroutine get_commandline_options(eelsin_name, eelsou_name, bosin_name, bosou_name) +subroutine get_commandline_options(eelsin_name, bosonout_name) ! This routine defines the commandline options, parses the commandline and sets the ! filenames of I/O files. @@ -13,8 +13,7 @@ subroutine get_commandline_options(eelsin_name, eelsou_name, bosin_name, bosou_n implicit none - character (len = :), allocatable, intent(in out) :: eelsin_name, eelsou_name - character (len = :), allocatable, intent(in out) :: bosin_name, bosou_name + character (len = :), allocatable, intent(in out) :: eelsin_name, bosonout_name include 'version.inc' @@ -23,16 +22,14 @@ subroutine get_commandline_options(eelsin_name, eelsou_name, bosin_name, bosou_n ! Set up the longOpts struct to define the valid options: ! short option, long option, argument (no = 0 / yes = 1), short description - type(getopt_t) :: longOpts(8) = & - [ & - getopt_t('v', 'version', 0, 'Print version'), & - getopt_t('V', 'version', 0, 'Print version'), & - getopt_t('h', 'help', 0, 'Print options'), & - getopt_t('d', 'dir', 1, 'Change I/O directory'), & - getopt_t('e', 'eelsin', 1, 'Name of EELS input file (eelsin)'), & - getopt_t('f', 'eelsou', 1, 'Name of EELS output file (optional)'), & - getopt_t('b', 'bosin', 1, 'Name of BOSON input file (bosin)'), & - getopt_t('c', 'bosou', 1, 'Name of BOSON output file (bosou)') & + type(getopt_t) :: longOpts(6) = & + [ & + getopt_t('v', 'version', 0, 'Print version'), & + getopt_t('V', 'version', 0, 'Print version'), & + getopt_t('h', 'help', 0, 'Print options'), & + getopt_t('d', 'dir', 1, 'Change I/O directory'), & + getopt_t('e', 'eelsin', 1, 'Name of EELS input file (eelsin.yaml)'), & + getopt_t('b', 'bosonout', 1, 'Name of BOSON output file (bosonout.txt)') & ] do ! scan all the command-line parameters @@ -56,12 +53,8 @@ subroutine get_commandline_options(eelsin_name, eelsou_name, bosin_name, bosou_n end if case('e') eelsin_name = optArg - case('f') - eelsou_name = optArg case('b') - bosin_name = optArg - case('c') - bosou_name = optArg + bosonout_name = optArg case('v') write (*,*) 'eels-boson version: ' // version stop