###Make.ndf # www.BillHowell.ca 06Oct07 # Warning: Use Courier constant-width font and no-line-wrap to view this file! Otherwise the code doesn't line up and it's hard to read. lm IS loaddefs 'C:\Documents and Settings\William Neil Howell\My Documents\Climate\Laskar - Milankovic insolation program\Howell\Holocene Milankovic\make.ndf' % switches to control actions ; loaddef_all_mode := l ; % o or l - Whether to load all files? ; loaddef_selected_mode := o ; % o or l - Whether to load specified files? ; loaddef_display_mode := 1 ; % 0 or 1 - !! display line by line as file loads? ; autolog_mode := l ; % o or l - capture results in a log file ; symbol_mode := o ; % o or l - produce a listing of globals to help debug and track ; run_mode := o ; % o or l - run problems (l) or not (o) ; run_type := "run_insoln ; % run one only of several different types as described below ; % "run_insoln - insolation calculations ; % "run_interp - only for interpolation routine ; % loaddef all files, order shouldn't matter if externals properly declared ; make_all_list := "fm_structure "fm_interpolation "fm_interpolation_setup "fm_complete_inputs "fm_insolation ; # load fm_milankovic separately (LONGGG! time to load - don't want to include in normal "edit-compile-run" cycle) "fm_Milankovic "fm_rEarthSun % specify which files to loaddef - use solitary for single file ; make_specified_list := solitary "f_Milankovic ; #********************************* # To work with files independently set "loaddef_selected_mode = l and "make_specified_list to the list of files desired # Note: This is NOT a normal "make", it is just an extremely loose, simple implementation of some easy ideas inspired by "make". As QNial is interpretedm i don't even care about the datestamps on files (later I will, at a higher meta-level of programming). #********************************* # globals defined here, or used in this file only ; f_make := 'make.ndf' ; autolog_mode&_m := f_make ; e_strip_list&_m := f_make ; e_missing&_m := f_make ; e_missing2&_m := f_make ; e_list&_m := f_make ; e_strip_list&_m := f_make ; f_Civilization_setup&_m := f_make ; f_complete_inputs&_m := f_make ; f_interpolation&_m := f_make ; f_insolation&_m := f_make ; f_make&_m := f_make ; f_Milankovic&_m := f_make ; f_Smillie&_m := f_make ; f_Solanki_Tapping&_m := f_make ; f_list&_m := f_make ; f_list_flag&_m := f_make ; f_list_len&_m := f_make ; ff_list&_m := f_make ; fout_make&_m := f_make ; Howell_lib&_m := f_make ; i&_m := f_make ; lm&_m := f_make ; loaddef_all_mode&_m := f_make ; loaddef_selected_mode&_m := f_make ; loaddef_display_mode&_m := f_make ; Laskar_directory&_m := f_make ; make_all_list&_m := f_make ; make_specified_list&_m := f_make ; QNial_lib&_m := f_make ; old_logmode&_m := f_make ; Working_dir&_m := f_make ; results_dir&_m := f_make ; run_interpolation&_m := f_make ; run_mode&_m := f_make ; run_normal&_m := f_make ; run_test_data&_m := f_make ; run_type&_m := f_make ; string_wide&_m := f_make ; symbol_mode&_m := f_make ; % test_interpolation&_m := f_make ; test_years&_m := f_make ; v_list&_m := f_make ; v_list_flag&_m := f_make ; v_list_len&_m := f_make ; vv_list&_m := f_make ; xx&_m := f_make ; z_list&_m := f_make ; z_list_flag&_m := f_make ; # External globals calc_insolation IS EXTERNAL operation ; calc_insolation&_x := f_make ; calc_insolation_all_months IS EXTERNAL operation ; calc_insolation&_x := f_make ; check_interpolation IS EXTERNAL operation ; check_interpolation&_x := f_make ; complete_inputs IS EXTERNAL expression ; complete_inputs&_x := f_make ; # *************************** % Library directories ; QNial_lib := 'C:\Languages\QNial\niallib\' ; Stats_lib := 'C:\Documents and Settings\William Neil Howell\My Documents\Qnial\Smillie UAlberta - statistics 1987\' ; Howell_lib := 'C:\Documents and Settings\William Neil Howell\My Documents\Qnial\MY_NDFS\' ; Working_dir := 'C:\Documents and Settings\William Neil Howell\My Documents\Climate\Laskar - Milankovic insolation program\Howell\Holocene Milankovic\' ; inputs_dir := 'C:\Documents and Settings\William Neil Howell\My Documents\Climate\Laskar - Milankovic insolation program\Howell\Holocene Milankovic\' ; results_dir := 'C:\Documents and Settings\William Neil Howell\My Documents\Climate\Laskar - Milankovic insolation program\Howell\Holocene Milankovic\Results\' ; # *************************** # string_wide.ndf www.BillHowell.ca 18Feb07 # cut a string to a fixed length, or pad end with spaces to make up the length # Usage: string_wide str1 sw str1 string sw fixed string length string_wide IS Op str1 sw { sl := first shape str1 ; IF first shape str1 <= sw THEN s_pad := (sw - sl) reshape ` ; link str1 s_pad ELSE sw take str1 ENDIF } # *************************** make % Names of project files ; fm_complete_inputs := 'Complete inputs.ndf' ; fm_insolation := 'Holocene insolation.ndf' ; fm_interpolation := 'Interpolation.ndf' ; fm_interpolation_setup := 'Holocene Milankovic & barycenter interpolation setup.ndf' ; fm_Milankovic := 'Holocene Milankovic data.ndf' ; fm_rEarthSun := 'horizons_results vectors -3000 to 3000 results.txt' ; fm_structure := 'Structure.ndf' ; IF autolog_mode THEN old_logmode := set "log ; setlogname link Working_dir 'auto.nlg' ; ELSE old_logmode := set "nolog ; ENDIF ; IF not in "F_MILANKOVIC (first symbols 0) THEN loaddefs (link Working_dir (execute "fm_Milankovic)) ; loaddefs (link Working_dir (execute "fm_rEarthSun )) ; ENDIF ; IF loaddef_all_mode THEN FOR i WITH make_all_list DO loaddefs (link Working_dir (execute i)) loaddef_display_mode ; ENDFOR ; ELSEIF loaddef_selected_mode THEN FOR i WITH make_specified_list DO loaddefs (link Working_dir (execute i)) loaddef_display_mode ; ENDFOR ; ENDIF ; IF symbol_mode THEN fout_make := open (link Working_dir 'Symbol_list.txt') "w ; IF isfault fout_make THEN writescreen 'Couldnt open Symbol_list.txt' ; ELSE fout_make EACHRIGHT writefile '###Laskar insolation calculations via QNial: project symbols - files where defined & used as globals' ' ' ; xx:= EACH string EACH first (symbols 0) ; e_list := (OR ( ('&_O$' EACHRIGHT regexp_match xx) ('&_V$' EACHRIGHT regexp_match xx) ('&_E$' EACHRIGHT regexp_match xx) ('&_M$' EACHRIGHT regexp_match xx) ('&_X$' EACHRIGHT regexp_match xx) ) ) sublist xx ; v_list := EACH string e_list ; v_list_len := 3 + max EACH shape v_list ; vv_list := v_list EACHLEFT string_wide (first v_list_len) ; f_list := EACH string EACH execute e_list ; f_list_len := 1 + max EACH shape f_list ; ff_list := f_list EACHLEFT string_wide (first f_list_len) ; z_list := EACH link pack vv_list ff_list ; e_strip_list := EACH regexp_substitute ('&_.$' '' EACHRIGHT append e_list) ; e_missing := NOT (EACH OR (xx EACHLEFT EACHRIGHT = e_strip_list)) sublist xx ; e_missing2 := NOT ('&_.$' EACHRIGHT regexp_match e_missing) sublist e_missing ; fout_make EACHRIGHT writefile ' ' '#*******************' 'Global symbols not in GlobSymb - could be trouble' ' ' ' ' ; fout_make EACHRIGHT writefile e_missing2 ; fout_make EACHRIGHT writefile ' ' '#*******************' 'GlobSymb listings that are not in Complete list - probably junk (do this by hand?)' ' ' ' ' ; fout_make EACHRIGHT writefile ' ' '#*******************' 'GlobSymb - Global project symbols that have been labelled as such in files' ' ' ; fout_make EACHRIGHT writefile z_list ; fout_make EACHRIGHT writefile ' ' '#*******************' 'Complete list of global symbols' ' ' ; fout_make EACHRIGHT writefile xx ; close fout_make ; ENDIF ; ENDIF ; #********************************* debugging tricks (!!! OUT OF DATE !!!) # 'Make' error location 1. open 'make.ndf' in the QNial environment (as a separate window) a. in make.ndf set loaddef_mode := l ; autolog_mode := l ; symbol_mode := l ; b. clearws % ; 2. type 'make "all' in the QNial interpreter window a. from the interpreter window: Menu Interpreter -> view log file b. Menu Search -> Find '?' - follow the interpreter comments c. As QNial only flags the first error for each block, so this has to be done iteratively d. Use 'Symbol_list.txt' to refer to the source and application of global data and operations (but not local variables within blocks) % ; 3. When errors are down to one file (or even before), you can focus on debugging it by typing 'make f3' in the interpreter, for example (look at the list of files above for their designations). # Progressive tesing of operations & data - once the 'make' errors are resolved This should eventually be converted to an automated check file that tests the results against standard results and puts out error diagnostics. % ; Note: 'command' means type the indicated string into the cQNial interpreter, (top level) % ; 1. 'Make all results.txt' Raw data checks a. type ' Milancovic_rows Milankovic_cols ' then 'Milankovc ' - are they correct? All 'raw' data can be checked by looking through the saved file 'Make all results.txt' b. Do the same with 'Solanki' 'Solanki_rows' 'Solanki_cols' # 2. 'complete_inputs verification.txt' Type 'complete_inputs' in the QNial interpreter. messages are primarily in the file 'Main.ndf' which hosts the 'complete_inputs' operation % ; Type & check results in file 'complete_inputs verification.txt' of: a. ' Milankovic_rows Milankovic_cols ' then ' Milankovic ' b. ' Solanki_rows Solanki_cols ' (but NOT Solanki - there are no transformations) c. ' datedebut datefin date_conversion ' d. ' Milankovic_delta_t Solanki_delta_t civilisation_period ' e. ' n_intrpsteps n_poly ' e. ' intrp_tdata ' BUT don't type ' intrp_tseries ' yet, this is long!!! # 3. Check interpolations - Verify the Interpolation routine on toy problems. Make sure that steps 1 and 2 have been completed, or re-load and run complete_inputs a. Simply load the interpolations file ('make f2') Test using the example in the file 'Check interpolations.ndf'. b. ' make "all ', command ' complete_inputs ', and command ' setdeftrace "interpolation_for_interval ' and ' interpolation_for_interval -3000 ' -> compare to ' Check interpolate_for_interval.ndf ' Note that the interpolation errors are too high!! # 4. Eventually, convert all of the above to a special header and verification file system # Current problems: 1. Not robust with multiple makes without 'clearws' - initialization not properly set up #Copy the following to a separate QNial file window, so that you can rapidly get to an advanced point in the verification process. make "all civic #**************************** Lessons learned # All global variable definitions should be declared "NONLOCAL" in each operation that uses them (including 'EXTERNAL' declarations # arctan provides wrong answers for some problems, but the sine & cosine, if available, can be used to select the right angle that yields the right tan #****************************** Run the program IF run_mode THEN Complete_inputs ; fout_start := open (link results_dir '_1_Start calculations.txt') "w ; writefile fout_start 'Look at this files timestamp to see when calculations started' ; close fout_start ; % ; interpolation_setup index_Milankovic_month ; calc_insolation_all_months_all_latitudes (solitary 45) ; % (-90 + tell 181) ; % ; fout_end := open (link results_dir '_2_End calculations.txt') "w ; writefile fout_end 'Look at this files timestamp to see when calculations ended' ; close fout_end ; ENDIF ; # set old_logmode ; # enddoc