diff -u ORG/anamx/aimgn.f90 anamx/aimgn.f90
--- ORG/anamx/aimgn.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/aimgn.f90	2018-05-15 18:47:28.000000000 +0900
@@ -343,6 +343,7 @@
     ' loop', klp, 'rms.Step :', rs, 'rms.Residual :', dv
   open(9,status='scratch')
   write(9,*) klp, rs, dv
+  flush(6)        !--- or  call flush(6)
   call conv2(g,nfx,nfy, r, mx,my, u, mxm,mym,nds)
   p1 = 0.
   do l=1,nds; do j=1,mym; do i=1,mxm
@@ -377,6 +378,7 @@
     write(6,'(a5,i4,3x,a10,f8.2,3x,a14,f7.2)')   &
       ' loop', klp, 'rms.Step :', rs, 'rms.Residual :', dv
     write(9,*) klp, rs, dv
+    flush(6)        !--- or  call flush(6)
 
     p1p = p1
     call conv2(g,nfx,nfy, q, mx,my, v, mxm,mym,nds)
@@ -474,7 +476,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/aimgnc.f90 anamx/aimgnc.f90
--- ORG/anamx/aimgnc.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/aimgnc.f90	2018-05-15 18:47:28.000000000 +0900
@@ -336,6 +336,7 @@
     ' loop', klp, kc, 'rms.Step :', rs, 'rms.Residual :', dv
   open(9,status='scratch')
   write(9,*) klp, kc, rs, dv
+  flush(6)        !--- or  call flush(6)
   call conv2(g,nfx,nfy, r, mx,my, u, mxm,mym,nds)
   p1 = 0.
   do l=1,nds; do j=1,mym; do i=1,mxm
@@ -375,6 +376,7 @@
     write(6,'(a5,i4,i3,3x,a10,f8.2,3x,a14,f7.2)')   &
       ' loop', klp, kc, 'rms.Step :', rs, 'rms.Residual :', dv
     write(9,*) klp, kc, rs, dv
+    flush(6)        !--- or  call flush(6)
     if ((kc == 5) .or. (dv < 0.1) .or. (ilp >= nloop)) exit
     p1p = p1
     call conv2(g,nfx,nfy, q, mx,my, v, mxm,mym,nds)
@@ -472,7 +474,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/aimgs.f90 anamx/aimgs.f90
--- ORG/anamx/aimgs.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/aimgs.f90	2018-05-15 18:47:28.000000000 +0900
@@ -341,6 +341,7 @@
     ' loop', klp, 'rms.Step :', rs, 'rms.Residual :', dv
   open(9,status='scratch')
   write(9,*) klp, rs, dv
+  flush(6)        !--- or  call flush(6)
 
   call conv2(g,nfx,nfy, r, mx,my, u, mxm,mym,nds)
   p1 = 0.
@@ -376,6 +377,7 @@
     write(6,'(a5,i4,3x,a10,f8.2,3x,a14,f7.2)')   &
       ' loop', klp, 'rms.Step :', rs, 'rms.Residual :', dv
     write(9,*) klp, rs, dv
+    flush(6)        !--- or  call flush(6)
 
     p1p = p1
     call conv2(g,nfx,nfy, q, mx,my, v, mxm,mym,nds)
@@ -472,7 +474,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/aimgsc.f90 anamx/aimgsc.f90
--- ORG/anamx/aimgsc.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/aimgsc.f90	2018-05-15 18:47:28.000000000 +0900
@@ -335,6 +335,7 @@
     ' loop', klp, kc, 'rms.Step :', rs, 'rms.Residual :', dv
   open(9,status='scratch')
   write(9,*) klp, kc, rs, dv
+  flush(6)        !--- or  call flush(6)
 
   call conv2(g,nfx,nfy, r, mx,my, u, mxm,mym,nds)
   p1 = 0.
@@ -375,6 +376,7 @@
     write(6,'(a5,i4,i3,3x,a10,f8.2,3x,a14,f7.2)')   &
       ' loop', klp, kc, 'rms.Step :', rs, 'rms.Residual :', dv
     write(9,*) klp, kc, rs, dv
+    flush(6)        !--- or  call flush(6)
     if ((kc == 5) .or. (dv < 0.1) .or. (ilp >= nloop)) exit
 
     p1p = p1
@@ -472,7 +474,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/axdeq.f90 anamx/axdeq.f90
--- ORG/anamx/axdeq.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/axdeq.f90	2018-06-17 17:09:08.000000000 +0900
@@ -230,6 +230,7 @@
   dv = sqrt(ss / float(ndpt))
   write(6,'(a5,i4,3x,a10,f8.2,3x,a14,f7.2)')   &
     ' loop', klp, 'rms.Step :', ds, 'rms.Residual :', dv
+  flush(6)        !--- or  call flush(6)
   open(9,status='scratch')
   write(9,*) klp, ds, dv
 
@@ -261,6 +262,7 @@
     dv = sqrt(ss / float(ndpt))
     write(6,'(a5,i4,3x,a10,f8.2,3x,a14,f7.2)')   &
       ' loop', klp, 'rms.Step :', ds, 'rms.Residual :', dv
+    flush(6)        !--- or  call flush(6)
     write(9,*) klp, ds, dv
   enddo
   close(20)
diff -u ORG/anamx/axdeqc.f90 anamx/axdeqc.f90
--- ORG/anamx/axdeqc.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/axdeqc.f90	2018-06-17 17:09:08.000000000 +0900
@@ -233,6 +233,7 @@
   lp = 0
   write(6,'(a5,i4,i3,3x,a10,f8.2,3x,a14,f7.2)')   &
     ' loop', klp, lp, 'rms.Step :', ds, 'rms.Residual :', dv
+  flush(6)        !--- or  call flush(6)
   open(9,status='scratch')
   write(9,*) klp, lp, ds, dv
 
@@ -269,6 +270,7 @@
     endif
     write(6,'(a5,i4,i3,3x,a10,f8.2,3x,a14,f7.2)')   &
       ' loop', klp, lp, 'rms.Step :', ds, 'rms.Residual :', dv
+    flush(6)        !--- or  call flush(6)
     write(9,*) klp, lp, ds, dv
     if ((lp >= 5) .or. (dv < 0.1)) exit
   enddo
diff -u ORG/anamx/cimgn.f90 anamx/cimgn.f90
--- ORG/anamx/cimgn.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/cimgn.f90	2018-05-15 18:47:28.000000000 +0900
@@ -361,6 +361,7 @@
   write(6,'(a5,i4,3x,a13,f7.3,a2,f7.4,3x,a6,f7.2,3x,a6,f7.2)')   &
       ' loop', klp, 'rms.Step/Src.', 0., ' /', rv, 'Misfit', dv, 'T.Res.', dv
   write(9,*) klp, 0., 0., rv, dv, dv
+  flush(6)        !--- or  call flush(6)
 
   if (nloop /= 0) then
     ilp = 1;  klp = klp + 1
@@ -404,6 +405,7 @@
       ' loop', klp, 'Updated hyper-parameter =', ee, 'T.Res.', tr
     write(9,*) klp, ee, rs, rv, dv, tr
     kc = 0;  trp = tr
+    flush(6)        !--- or  call flush(6)
   endif
 
   do while ((kc < 5) .and. (dv >= 0.1) .and. (ilp < nloop))
@@ -563,7 +565,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/cimgnc.f90 anamx/cimgnc.f90
--- ORG/anamx/cimgnc.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/cimgnc.f90	2018-05-15 18:47:28.000000000 +0900
@@ -394,6 +394,7 @@
     ' loop', klp, 'Updated hyper-parameter =', ee, 'T.Res.', tr
   write(9,*) klp, ee, rs, rv, dv, tr
   kc = 0;  trp = tr
+  flush(6)        !--- or  call flush(6)
 
   do while ((kc < 5) .and. (dv >= 0.1) .and. (ilp < nloop))
     ilp = ilp + 1;  klp = klp + 1
@@ -466,6 +467,7 @@
       write(9,*) klp, ee, rs, rv, dv, tr
     endif
     trp = tr
+    flush(6)        !--- or  call flush(6)
   enddo
 
   write(6,'(1x)')
@@ -551,7 +553,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/cimgs.f90 anamx/cimgs.f90
--- ORG/anamx/cimgs.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/cimgs.f90	2018-05-15 18:47:28.000000000 +0900
@@ -361,6 +361,7 @@
   write(6,'(a5,i4,3x,a13,f7.3,a2,f7.4,3x,a6,f7.2,3x,a6,f7.2)')   &
       ' loop', klp, 'rms.Step/Src.', 0., ' /', rv, 'Misfit', dv, 'T.Res.', dv
   write(9,*) klp, 0., 0., rv, dv, dv
+  flush(6)        !--- or  call flush(6)
 
   if (nloop /= 0) then
     ilp = 1;  klp = klp + 1
@@ -475,8 +476,9 @@
       write(6,'(a5,i4,6x,a25,e10.3,10x,a6,f7.2)')   &
         ' loop', klp, 'Updated hyper-parameter =', ee, 'T.Res.', tr
       write(9,*) klp, ee, rs, rv, dv, tr
-     endif
-   trp = tr
+    endif
+    trp = tr
+    flush(6)        !--- or  call flush(6)
   enddo
 
   write(6,'(1x)')
@@ -563,7 +565,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/cimgsc.f90 anamx/cimgsc.f90
--- ORG/anamx/cimgsc.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/cimgsc.f90	2018-05-15 18:47:28.000000000 +0900
@@ -394,6 +394,7 @@
     ' loop', klp, 'Updated hyper-parameter =', ee, 'T.Res.', tr
   write(9,*) klp, ee, rs, rv, dv, tr
   kc = 0;  trp = tr
+  flush(6)        !--- or  call flush(6)
 
   do while ((kc < 5) .and. (dv >= 0.1) .and. (ilp < nloop))
     ilp = ilp + 1;  klp = klp + 1
@@ -466,6 +467,7 @@
       write(9,*) klp, ee, rs, rv, dv, tr
     endif
     trp = tr
+    flush(6)        !--- or  call flush(6)
   enddo
 
   write(6,'(1x)')
@@ -551,7 +553,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/fimgs.f90 anamx/fimgs.f90
--- ORG/anamx/fimgs.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/fimgs.f90	2018-05-15 18:47:28.000000000 +0900
@@ -376,6 +376,7 @@
   write(6,'(a5,i4,3x,a13,f7.3,a2,f7.4,3x,a6,f7.2,3x,a6,f7.2)')   &
       ' loop', klp, 'rms.Step/Src.', 0., ' /', rv, 'Misfit', dv, 'T.Res.', dv
   write(9,*) klp, 0., 0., rv, dv, dv
+  flush(6)        !--- or  call flush(6)
 
   if (nloop /= 0) then
     ilp = 1;  klp = klp + 1
@@ -426,6 +427,7 @@
       ' loop', klp, 'Updated hyper-parameter =', ee, 'T.Res.', tr
     write(9,*) klp, ee, rs, rv, dv, tr
     kc = 0;  trp = tr
+    flush(6)        !--- or  call flush(6)
   endif
 
   do while ((kc < 5) .and. (dv >= 0.1) .and. (ilp < nloop))
@@ -592,7 +594,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/fimgsc.f90 anamx/fimgsc.f90
--- ORG/anamx/fimgsc.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/fimgsc.f90	2018-05-15 18:47:28.000000000 +0900
@@ -416,6 +416,7 @@
     ' loop', klp, 'Updated hyper-parameter =', ee, 'T.Res.', tr
   write(9,*) klp, ee, rs, rv, dv, tr
   kc = 0;  trp = tr
+  flush(6)        !--- or  call flush(6)
 
   do while ((kc < 5) .and. (dv >= 0.1) .and. (ilp < nloop))
     ilp = ilp + 1;  klp = klp + 1
@@ -495,6 +496,7 @@
       write(9,*) klp, ee, rs, rv, dv, tr
     endif
     trp = tr
+    flush(6)        !--- or  call flush(6)
   enddo
 
   write(6,'(1x)')
@@ -582,7 +584,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/nimgn.f90 anamx/nimgn.f90
--- ORG/anamx/nimgn.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/nimgn.f90	2018-05-15 18:47:28.000000000 +0900
@@ -401,6 +401,7 @@
     write(9,*) klp, ee, rs, rv, dv, tr
     kc = 0;  trp = tr
   endif
+  flush(6)        !--- or  call flush(6)
 
   do while ((kc < 5) .and. (dv >= 0.1) .and. (ilp < nloop))
     ilp = ilp + 1;  klp = klp + 1
@@ -471,6 +472,7 @@
       write(9,*) klp, ee, rs, rv, dv, tr
     endif
     trp = tr
+    flush(6)        !--- or  call flush(6)
   enddo
 
   write(6,'(1x)')
@@ -558,7 +560,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/nimgnc.f90 anamx/nimgnc.f90
--- ORG/anamx/nimgnc.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/nimgnc.f90	2018-05-15 18:47:28.000000000 +0900
@@ -391,6 +391,7 @@
     ' loop', klp, 'Updated hyper-parameter =', ee, 'T.Res.', tr
   write(9,*) klp, ee, rs, rv, dv, tr
   kc = 0;  trp = tr
+  flush(6)        !--- or  call flush(6)
 
   do while ((kc < 5) .and. (dv >= 0.1) .and. (ilp < nloop))
     ilp = ilp + 1;  klp = klp + 1
@@ -461,6 +462,7 @@
       write(9,*) klp, ee, rs, rv, dv, tr
     endif
     trp = tr
+    flush(6)        !--- or  call flush(6)
   enddo
 
   write(6,'(1x)')
@@ -548,7 +550,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/nimgs.f90 anamx/nimgs.f90
--- ORG/anamx/nimgs.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/nimgs.f90	2018-05-15 18:47:26.000000000 +0900
@@ -398,6 +398,7 @@
     write(9,*) klp, ee, rs, rv, dv, tr
     kc = 0;  trp = tr
   endif
+  flush(6)        !--- or  call flush(6)
 
   do while ((kc < 5) .and. (dv >= 0.1) .and. (ilp < nloop))
     ilp = ilp + 1;  klp = klp + 1
@@ -468,6 +469,7 @@
       write(9,*) klp, ee, rs, rv, dv, tr
     endif
     trp = tr
+    flush(6)        !--- or  call flush(6)
   enddo
 
   write(6,'(1x)')
@@ -554,7 +556,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/nimgsc.f90 anamx/nimgsc.f90
--- ORG/anamx/nimgsc.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/nimgsc.f90	2018-05-15 18:47:28.000000000 +0900
@@ -388,6 +388,7 @@
     ' loop', klp, 'Updated hyper-parameter =', ee, 'T.Res.', tr
   write(9,*) klp, ee, rs, rv, dv, tr
   kc = 0;  trp = tr
+  flush(6)        !--- or  call flush(6)
 
   do while ((kc < 5) .and. (dv >= 0.1) .and. (ilp < nloop))
     ilp = ilp + 1;  klp = klp + 1
@@ -458,6 +459,7 @@
       write(9,*) klp, ee, rs, rv, dv, tr
     endif
     trp = tr
+    flush(6)        !--- or  call flush(6)
   enddo
 
   write(6,'(1x)')
@@ -544,7 +546,7 @@
       write(99,'(22x,a)') 'Linear trend removed'
       write(99,'(a,f8.2,a,f7.3,a,f7.3,a)')   &
         ' Trend surface in nT :', cf, ' + (', af, ' * x) + (', bf, ' * y)'
-      write(6,'(5x,a)')   &
+      write(99,'(5x,a)')   &
         '( x/y : N/E coord. in mesh unit referred to the center of area )'
     else
       write(99,'(22x,a)') 'without removal of Linear trend'
diff -u ORG/anamx/plsim.f90 anamx/plsim.f90
--- ORG/anamx/plsim.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/plsim.f90	2018-05-06 00:29:18.000000000 +0900
@@ -114,7 +114,7 @@
     if ((1+nkw) >= (my-nke)) call abendm('no range')
     np = my - nke - nkw;  hlen = float(mszy * (np-1))
     write(str1,'(a,i4)') 'W-E  ix#', nsec
-    write(str2,'(a,i3,2x,a,i3,a)') '(LmW=', nks, 'LmE=', nkn, ')'
+    write(str2,'(a,i3,2x,a,i3,a)') '(LmW=', nkw, 'LmE=', nke, ')'
 
     allocate(z(np));  allocate(v(np,nly))
 
diff -u ORG/anamx/plsimc.f90 anamx/plsimc.f90
--- ORG/anamx/plsimc.f90	2017-12-23 18:00:00.000000000 +0900
+++ anamx/plsimc.f90	2018-05-06 00:29:20.000000000 +0900
@@ -114,7 +114,7 @@
     if ((1+nkw) >= (my-nke)) call abendm('no range')
     np = my - nke - nkw;  hlen = float(mszy * (np-1))
     write(str1,'(a,i4)') 'W-E  ix#', nsec
-    write(str2,'(a,i3,2x,a,i3,a)') '(LmW=', nks, 'LmE=', nkn, ')'
+    write(str2,'(a,i3,2x,a,i3,a)') '(LmW=', nkw, 'LmE=', nke, ')'
 
     allocate(z(np));  allocate(v(np,nly))
 
