From 0821fd8aa55a218a605a151ddb46cbd05c16e83c Mon Sep 17 00:00:00 2001 From: Mads Bertelsen Date: Thu, 7 Dec 2023 13:48:51 +0100 Subject: [PATCH 1/3] Small fixes in monitors: Monitor_4PI Wrong use of NAME_CURRENT_COMPONENT in save section fixed TOFlog_monitor Used static memory, moved to dynamic and removed static limit on memory PSD_monitor_psf Still had state and polarization parameters that would not compile --- mcstas-comps/monitors/Monitor_4PI.comp | 4 ++- mcstas-comps/monitors/PSD_monitor_psf.comp | 4 --- mcstas-comps/monitors/TOFlog_monitor.comp | 33 ++++++++++++++++++---- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/mcstas-comps/monitors/Monitor_4PI.comp b/mcstas-comps/monitors/Monitor_4PI.comp index d8b42d0bd7..9a2c05ef93 100644 --- a/mcstas-comps/monitors/Monitor_4PI.comp +++ b/mcstas-comps/monitors/Monitor_4PI.comp @@ -71,7 +71,9 @@ TRACE SAVE %{ - DETECTOR_OUT_0D("4PI monitor " NAME_CURRENT_COMP, Nsum, psum, p2sum); + char full_name[1024]; + sprintf(full_name, "4PI monitor %s", NAME_CURRENT_COMP); + DETECTOR_OUT_0D(full_name, Nsum, psum, p2sum); %} MCDISPLAY diff --git a/mcstas-comps/monitors/PSD_monitor_psf.comp b/mcstas-comps/monitors/PSD_monitor_psf.comp index 656d6046de..2bc0f71d83 100644 --- a/mcstas-comps/monitors/PSD_monitor_psf.comp +++ b/mcstas-comps/monitors/PSD_monitor_psf.comp @@ -58,10 +58,6 @@ SETTING PARAMETERS ( OUTPUT PARAMETERS () -STATE PARAMETERS (x, y, z, vx, vy, vz, t, s1, s2, p) - -POLARISATION PARAMETERS (sx, sy, sz) - DECLARE %{ DArray2d PSD_N; diff --git a/mcstas-comps/monitors/TOFlog_monitor.comp b/mcstas-comps/monitors/TOFlog_monitor.comp index 5d7d04c5c9..b1aa734bea 100644 --- a/mcstas-comps/monitors/TOFlog_monitor.comp +++ b/mcstas-comps/monitors/TOFlog_monitor.comp @@ -57,11 +57,10 @@ OUTPUT PARAMETERS () DECLARE %{ - #define LARGENUMBER int nchan; - double TOF_N[LARGENUMBER]; - double TOF_p[LARGENUMBER]; - double TOF_p2[LARGENUMBER]; + DArray1d TOF_N; + DArray1d TOF_p; + DArray1d TOF_p2; %} INITIALIZE @@ -76,10 +75,23 @@ INITIALIZE NAME_CURRENT_COMP); exit(0); } + + if (tmin <= 0 || tmax <= 0) { + printf("TOFlog_mon: %s: Only supports positive tmin and tmax !\n" + "ERROR (tmin, tmax). Exiting", NAME_CURRENT_COMP); + exit(0); + } + + if (tmin >= tmax) { + printf("TOFlog_mon: %s: tmin should be smaller than tmax !\n" + "ERROR (tmin, tmax). Exiting", NAME_CURRENT_COMP); + exit(0); + } nchan=(int)ceil(ndec*log(tmax/tmin)/log(10.0)); - if (nchan>LARGENUMBER) - printf("FATAL ERROR, too many time channels \n"); + TOF_N = create_darr1d(nchan); + TOF_p = create_darr1d(nchan); + TOF_p2 = create_darr1d(nchan); for (i=0; i Date: Thu, 7 Dec 2023 15:07:38 +0100 Subject: [PATCH 2/3] Update TOFlog_monitor.comp Arrays defined via create_darr*() are in fact calloc()'ed and hence no longer need the classic for-loop for 0-init. --- mcstas-comps/monitors/TOFlog_monitor.comp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mcstas-comps/monitors/TOFlog_monitor.comp b/mcstas-comps/monitors/TOFlog_monitor.comp index b1aa734bea..605fe6a776 100644 --- a/mcstas-comps/monitors/TOFlog_monitor.comp +++ b/mcstas-comps/monitors/TOFlog_monitor.comp @@ -93,13 +93,6 @@ INITIALIZE TOF_p = create_darr1d(nchan); TOF_p2 = create_darr1d(nchan); - for (i=0; i Date: Thu, 7 Dec 2023 15:09:46 +0100 Subject: [PATCH 3/3] Update PSD_monitor_psf.comp This for-loop structure init is no longer needed as create_darr*() return calloc'ed arrays. --- mcstas-comps/monitors/PSD_monitor_psf.comp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/mcstas-comps/monitors/PSD_monitor_psf.comp b/mcstas-comps/monitors/PSD_monitor_psf.comp index 2bc0f71d83..3beb4e9b01 100644 --- a/mcstas-comps/monitors/PSD_monitor_psf.comp +++ b/mcstas-comps/monitors/PSD_monitor_psf.comp @@ -83,14 +83,6 @@ INITIALIZE PSD_p = create_darr2d(nx, ny); PSD_p2 = create_darr2d(nx, ny); - for (i=0; i