! Read parameters using xml file , version civ1 & civ2
! Copyright (C) 1999,2010 Gauthier Delerce
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2, or (at your option)
! any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software Foundation,
! Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
!
! Gauthier Delerce <Gauthier.Delerce@civx.org>
subroutine read_xml(code,parameterFileName)
! use libxml2f90 library, http://sourceforge.net/projects/libxml2f90/
! developped by alexander.poddey@tu-clausthal.de
use libxml2f90_interface_module
use libxml2f90_module
use libxml2f90_strings_module
use ll_module
use modvsv
use modnetcdf
use modgrille
use modcorr
implicit none
character(256),intent(in),optional::parameterFileName
integer::code,index_i
integer::tmp1,tmp2
integer::sqm,q1,q2,pp,ha,de,pa,cd,rs,p4,p4d,ttt
character(120)::anul
character(256)::string(1)
integer::entier(1)
real(8)::reel(1)
character(5)::ch1,ch2
character(1)::char1
integer::i,j
real::f1,f2
logical::back
print*,"read_xml*",trim(adjustl(configfilename)),"*"
print*,"*",trim(adjustl(parameterFileName)),"*"
index_i=index(parameterFileName,'.xml',back=.true.)
if(index_i/=0) then
print*,"*",trim(adjustl(parameterFileName(1:index_i+4))),"*"
call libxml2f90__readin_file(trim(adjustl(parameterFileName(1:index_i+4))),'LIST1')
configfilename=trim(adjustl(parameterFileName))
else
call libxml2f90__readin_file(trim(adjustl(configfilename)),'LIST1')
endif
if(code==1) then ! civ1
call libxml2f90__ll_selectlist('LIST1')
call libxml2f90__ll_selecttag('ACT','civ1',1)
call libxml2f90__ll_exist('DOWN','image1',i)
if(i.lt.1) then
print*,'Name of First image must be given'
stop'read_input'
end if
call libxml2f90__ll_selecttag('DOWN','image1',1) !the 1 at the end means select the first tag
call libxml2f90__ll_getstring('image1',size(string),string) !OLD
namea=trim(adjustl(string(1)))
print*,trim(adjustl("Image1:"//namea))
call libxml2f90__ll_selecttag('UP','civ1',1)
call libxml2f90__ll_exist('DOWN','image2',i)
if(i.lt.1) then
print*,'Name of second image must be given'
stop'read_input'
end if
call libxml2f90__ll_selecttag('DOWN','image2',1)
call libxml2f90__ll_getstring('image2',size(string),string)
nameb=trim(adjustl(string(1)))
print*,trim(adjustl("Image2:"//nameb))
call libxml2f90__ll_selecttag('UP','civ1',1)
call libxml2f90__ll_exist('DOWN','outputFileName',i)
if(i.lt.1) then
print*,'Name of outputFileName must be given'
stop'read_input'
end if
call libxml2f90__ll_selecttag('DOWN','outputFileName',1)
call libxml2f90__ll_getstring('outputFileName',size(string),string)
outputFileName=trim(adjustl(string(1)))
print*,trim(adjustl("outputFileName:"//outputFileName))
call libxml2f90__ll_selecttag('UP','civ1',1)
call libxml2f90__ll_exist('DOWN','mask',i)
if(i.lt.1) then
print*,'no mask defined, using default grid'
yorn="n"
goto 11
else
call libxml2f90__ll_selecttag('DOWN','mask',1)
call libxml2f90__ll_getstring('mask',size(string),string)
maskname=trim(adjustl(string(1)))
print*,trim(adjustl("maskName:"//maskname))
if(maskname=="n") then
yorn="n"
else
yorn="y"
endif
call libxml2f90__ll_selecttag('UP','civ1',1)
endif
11 continue
call libxml2f90__ll_exist('DOWN','imageSize_X',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','imageSize_X',1)
call libxml2f90__ll_geti4('imageSize_X',size(entier),entier)
print*,trim(adjustl("imageSize_X :")),entier(1)
nx=entier(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
endif
call libxml2f90__ll_exist('DOWN','imageSize_Y',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','imageSize_Y',1)
call libxml2f90__ll_geti4('imageSize_Y',size(entier),entier)
print*,trim(adjustl("imageSize_Y :")),entier(1)
ny=entier(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
endif
call libxml2f90__ll_exist('DOWN','correlationBoxesSize_X',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','correlationBoxesSize_X',1)
call libxml2f90__ll_geti4('correlationBoxesSize_X',size(entier),entier)
print*,trim(adjustl("correlationBoxesSize_X :")),entier(1)
ibsx=entier(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
else
print*,"No correlation box size defined, using default 31 pixels"
ibsx=31
endif
call libxml2f90__ll_exist('DOWN','correlationBoxesSize_Y',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','correlationBoxesSize_Y',1)
call libxml2f90__ll_geti4('correlationBoxesSize_Y',size(entier),entier)
print*,trim(adjustl("correlationBoxesSize_Y :")),entier(1)
ibsy=entier(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
else
print*,"No correlation box size defined, using default 31 pixels"
ibsy=31
endif
call libxml2f90__ll_exist('DOWN','searchBoxesSize_X',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','searchBoxesSize_X',1)
call libxml2f90__ll_geti4('searchBoxesSize_X',size(entier),entier)
print*,trim(adjustl("searchBoxesSize_X :")),entier(1)
isrx=entier(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
else
print*,"No search box, using default 63 pixels"
isrx=63
endif
call libxml2f90__ll_exist('DOWN','searchBoxesSize_Y',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','searchBoxesSize_Y',1)
call libxml2f90__ll_geti4('searchBoxesSize_Y',size(entier),entier)
print*,trim(adjustl("searchBoxesSize_Y :")),entier(1)
isry=entier(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
else
print*,"No search box, using default 63 pixels"
isry=63
endif
call libxml2f90__ll_exist('DOWN','ro',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','ro',1)
call libxml2f90__ll_getr8('ro',size(reel),reel)
print*,trim(adjustl("ro :")),reel(1)
roi=reel(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
else
print*,"No smooth coeff defined, using default 1.0"
roi=1.0
endif
call libxml2f90__ll_exist('DOWN','globalShift_X',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','globalShift_X',1)
call libxml2f90__ll_getr8('globalShift_X',size(reel),reel)
print*,trim(adjustl("globalShift_X :")),reel(1)
xoffset=nint(reel(1))
call libxml2f90__ll_selecttag('UP','civ1',1)
endif
call libxml2f90__ll_exist('DOWN','globalShift_Y',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','globalShift_Y',1)
call libxml2f90__ll_getr8('globalShift_Y',size(reel),reel)
print*,trim(adjustl("globalShift_Y :")),reel(1)
yoffset=-nint(reel(1))
call libxml2f90__ll_selecttag('UP','civ1',1)
endif
call libxml2f90__ll_exist('DOWN','gridSpacing_X',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','gridSpacing_X',1)
call libxml2f90__ll_geti4('gridSpacing_X',size(entier),entier)
print*,trim(adjustl("gridSpacing_X :")),entier(1)
dxshift=entier(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
else
dxshift=15
endif
call libxml2f90__ll_exist('DOWN','gridSpacing_Y',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','gridSpacing_Y',1)
call libxml2f90__ll_geti4('gridSpacing_Y',size(entier),entier)
print*,trim(adjustl("gridSpacing_Y :")),entier(1)
dyshift=entier(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
else
dyshift=15
endif
call libxml2f90__ll_exist('DOWN','dt',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','dt',1)
call libxml2f90__ll_getr8('dt',size(reel),reel)
print*,trim(adjustl("dt :")),reel(1)
dt=reel(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
else
print*,"No delta time defined between image paire, using default 1.0"
dt=1.0
endif
call libxml2f90__ll_exist('DOWN','absolut_time_T0',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','absolut_time_T0',1)
call libxml2f90__ll_getr8('absolut_time_T0',size(reel),reel)
print*,trim(adjustl("absolut_time_T0 :")),reel(1)
T0=reel(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
else
print*,"No absolut time defined , using default 0.0"
dt=0.0
endif
T02=T0
dt2=dt
call libxml2f90__ll_exist('DOWN','pixcmx',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','pixcmx',1)
call libxml2f90__ll_getr8('pixcmx',size(reel),reel)
print*,trim(adjustl("pixcmx :")),reel(1)
pixcmx=reel(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
else
print*,"No pixcmx defined , using default 1.0"
pixcmx=1.0
endif
call libxml2f90__ll_exist('DOWN','pixcmy',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','pixcmy',1)
call libxml2f90__ll_getr8('pixcmy',size(reel),reel)
print*,trim(adjustl("pixcmy :")),reel(1)
pixcmy=reel(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
else
print*,"No pixcmy defined , using default 1.0"
pixcmy=1.0
endif
call libxml2f90__ll_exist('DOWN','grid',i)
if(i.lt.1) then
print*,'No grid are defined, creating a regular one'
fgrille="n"
goto 12
else
call libxml2f90__ll_selecttag('DOWN','grid',1)
call libxml2f90__ll_getstring('grid',size(string),string)
call libxml2f90__ll_selecttag('UP','civ1',1)
fgrille=trim(adjustl(string(1)))
endif
12 continue
if(fgrille=="n") then
new_default=.true.
else
print*,trim(adjustl("Grid file :"//fgrille))
endif
call libxml2f90__ll_exist('DOWN','convectFlow',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','convectFlow',1)
call libxml2f90__ll_getstring('convectFlow',size(string),string)
if((string(1)=="y").or.(string(1)=="1").or.(string(1)=="o")) convect_flow=1
if((string(1)=="n").or.(string(1)=="0")) convect_flow=0
call libxml2f90__ll_selecttag('UP','civ1',1)
endif
call libxml2f90__ll_exist('DOWN','corrMod',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','corrMod',1)
call libxml2f90__ll_geti4('corrMod',size(entier),entier)
print*,trim(adjustl("corrMod :")),entier(1)
corrMod=entier(1)
call libxml2f90__ll_selecttag('UP','civ1',1)
else
corrmod=0 ! default value, use Xcorr
endif
call libxml2f90__ll_exist('DOWN','hart',i)
hart=0
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','hart',1)
call libxml2f90__ll_getstring('hart',size(string),string)
call libxml2f90__ll_selecttag('UP','civ1',1)
if(string(1)=="y") then
hart=1
else
hart=0
endif
endif
correlation_min=0
intensity_min=0
char1="n"
if(char1=='y') then
call extract_char_real_real(anul,f1,f2)
level1=int(f1)
level2=int(f2)
!call extract_char_int_int(anul,level1,level2)
Print*,'SEUILLAGE ACTIF ENTRE ',level1,' ET ',level2
else
level1=0;level2=0;test_seuil=.false.
endif
!ImageToUse a c
!read(9,'(a120)') anul
img1="Z"
img2="Z"
img3="Z"
img4="Z"
if((ibsx/2*2)==ibsx) then
if(verbose) Print*,' Ibsx is even, Ibsx->Ibsx-1 '
ibsx=ibsx-1
endif
if((ibsy/2*2)==ibsy) then
if(verbose) Print*,' Ibsy is even, Ibsy->Ibsy-1 '
ibsy=ibsy-1
endif
if((isrx/2*2)==isrx) then
if (verbose) Print*,' Isrx is even, Isrx->Isrx-1 '
isrx=isrx-1
endif
if((isry/2*2)==isry) then
if (verbose) Print*,' Isry is even, Isry->Isry-1 '
isry=isry-1
endif
!print*,ibsx,ibsy,isrx,isry
if(intensity_min/=0) print*,' INTENSITY MINIMAL SET TO: ',intensity_min
ratio=1
hole=.false.
!*******************************************************************
!*******************************************************************
!*******************************************************************
!*******************************************************************
!*******************************************************************
!*******************************************************************
else ! civ 2
call libxml2f90__ll_selectlist('LIST1')
call libxml2f90__ll_selecttag('ACT','civ2',1)
call libxml2f90__ll_exist('DOWN','image1',i)
if(i.lt.1) then
print*,'Name of First image must be given'
stop'read_input'
end if
call libxml2f90__ll_selecttag('DOWN','image1',1) !the 1 at the end means select the first tag
call libxml2f90__ll_getstring('image1',size(string),string) !OLD
namea=trim(adjustl(string(1)))
print*,trim(adjustl("Image1:"//namea))
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','image2',i)
if(i.lt.1) then
print*,'Name of second image must be given'
stop'read_input'
end if
call libxml2f90__ll_selecttag('DOWN','image2',1)
call libxml2f90__ll_getstring('image2',size(string),string)
nameb=trim(adjustl(string(1)))
print*,trim(adjustl("Image2:"//nameb))
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','inputFileName',i)
if(i.lt.1) then
print*,'Name of input fileName must be given'
stop'read_input'
end if
call libxml2f90__ll_selecttag('DOWN','inputFileName',1)
call libxml2f90__ll_getstring('inputFileName',size(string),string)
inputFileName=trim(adjustl(string(1)))
print*,trim(adjustl("inputFileName:"//inputFileName))
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','outputFileName',i)
if(i.lt.1) then
print*,'Name of output fileName must be given'
stop'read_input'
end if
call libxml2f90__ll_selecttag('DOWN','outputFileName',1)
call libxml2f90__ll_getstring('outputFileName',size(string),string)
outputFileName=trim(adjustl(string(1)))
print*,trim(adjustl("outputFileName:"//outputFileName))
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','mask',i)
if(i.lt.1) then
print*,'no mask defined, using default grid'
yorn="n"
goto 16
end if
call libxml2f90__ll_selecttag('DOWN','mask',1)
call libxml2f90__ll_getstring('mask',size(string),string)
maskname=trim(adjustl(string(1)))
print*,trim(adjustl("maskName:"//maskname))
if(maskname=="n") then
yorn="n"
else
yorn="y"
endif
16 continue
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','imageSize_X',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','imageSize_X',1)
call libxml2f90__ll_geti4('imageSize_X',size(entier),entier)
print*,trim(adjustl("imageSize_X :")),entier(1)
nx=entier(1)
endif
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','imageSize_Y',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','imageSize_Y',1)
call libxml2f90__ll_geti4('imageSize_Y',size(entier),entier)
print*,trim(adjustl("imageSize_Y :")),entier(1)
ny=entier(1)
endif
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','correlationBoxesSize_X',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','correlationBoxesSize_X',1)
call libxml2f90__ll_geti4('correlationBoxesSize_X',size(entier),entier)
print*,trim(adjustl("correlationBoxesSize_X :")),entier(1)
ibsx=entier(1)
else
print*,"No correlation box size defined, using default 31 pixels"
ibsx=31
endif
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','correlationBoxesSize_Y',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','correlationBoxesSize_Y',1)
call libxml2f90__ll_geti4('correlationBoxesSize_Y',size(entier),entier)
print*,trim(adjustl("correlationBoxesSize_Y :")),entier(1)
ibsy=entier(1)
else
print*,"No correlation box size defined, using default 31 pixels"
ibsy=31
endif
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','ro',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','ro',1)
call libxml2f90__ll_getr8('ro',size(reel),reel)
print*,trim(adjustl("ro :")),reel(1)
roi=reel(1)
else
print*,"No smooth coeff defined, using default 1.0"
roi=1.0
endif
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','gridSpacing_X',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','gridSpacing_X',1)
call libxml2f90__ll_geti4('gridSpacing_X',size(entier),entier)
print*,trim(adjustl("gridSpacing_X :")),entier(1)
dxshift=entier(1)
else
dxshift=15
endif
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','gridSpacing_Y',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','gridSpacing_Y',1)
call libxml2f90__ll_geti4('gridSpacing_Y',size(entier),entier)
print*,trim(adjustl("gridSpacing_Y :")),entier(1)
dyshift=entier(1)
else
dyshift=15
endif
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','dt',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','dt',1)
call libxml2f90__ll_getr8('dt',size(reel),reel)
print*,trim(adjustl("dt :")),reel(1)
dt=reel(1)
else
print*,"No delta time defined between image paire, using default 1.0"
dt=1.0
endif
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','absolut_time_T0',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','absolut_time_T0',1)
call libxml2f90__ll_getr8('absolut_time_T0',size(reel),reel)
print*,trim(adjustl("absolut_time_T0 :")),reel(1)
T0=reel(1)
else
print*,"No absolut time defined , using default 0.0"
dt=0.0
endif
T02=T0
dt2=dt
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','pixcmx',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','pixcmx',1)
call libxml2f90__ll_getr8('pixcmx',size(reel),reel)
print*,trim(adjustl("pixcmx :")),reel(1)
pixcmx_out=reel(1)
else
print*,"No pixcmx defined , using default 1.0"
pixcmx_out=1.0
endif
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','pixcmy',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','pixcmy',1)
call libxml2f90__ll_getr8('pixcmy',size(reel),reel)
print*,trim(adjustl("pixcmy :")),reel(1)
pixcmy_out=reel(1)
else
print*,"No pixcmy defined , using default 1.0"
pixcmy_out=1.0
endif
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','grid',i)
if(i.lt.1) then
print*,'No grid are defined, creating a regular one'
fgrille="n"
goto 17
end if
call libxml2f90__ll_selecttag('DOWN','grid',1)
call libxml2f90__ll_getstring('grid',size(string),string)
fgrille=trim(adjustl(string(1)))
17 continue
if(fgrille=="n") then
new_default=.true.
else
print*,trim(adjustl("Grid file :"//fgrille))
endif
call defaultmesh
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','decimalShift',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','decimalShift',1)
call libxml2f90__ll_getstring('decimalShift',size(string),string)
if(string(1)=="y") then
corrdec=.true.
else
corrdec=.false.
endif
endif
call libxml2f90__ll_selecttag('UP','civ2',1)
call libxml2f90__ll_exist('DOWN','deformation',i)
if(i>=1) then
call libxml2f90__ll_selecttag('DOWN','deformation',1)
call libxml2f90__ll_getstring('deformation',size(string),string)
if(string(1)=="y") then
deform=.true.
else
deform=.false.
endif
endif
correlation_min=0
intensity_min=0
char1="n"
if(char1=='y') then
call extract_char_real_real(anul,f1,f2)
level1=int(f1)
level2=int(f2)
!call extract_char_int_int(anul,level1,level2)
Print*,'SEUILLAGE ACTIF ENTRE ',level1,' ET ',level2
else
level1=0;level2=0;test_seuil=.false.
endif
!ImageToUse a c
!read(9,'(a120)') anul
img1="Z"
img2="Z"
img3="Z"
img4="Z"
if((ibsx/2*2)==ibsx) then
if(verbose) Print*,' Ibsx is even, Ibsx->Ibsx-1 '
ibsx=ibsx-1
endif
if((ibsy/2*2)==ibsy) then
if(verbose) Print*,' Ibsy is even, Ibsy->Ibsy-1 '
ibsy=ibsy-1
endif
if((isrx/2*2)==isrx) then
if (verbose) Print*,' Isrx is even, Isrx->Isrx-1 '
isrx=isrx-1
endif
if((isry/2*2)==isry) then
if (verbose) Print*,' Isry is even, Isry->Isry-1 '
isry=isry-1
endif
!print*,ibsx,ibsy,isrx,isry
if(intensity_min/=0) print*,' INTENSITY MINIMAL SET TO: ',intensity_min
ratio=1
hole=.false.
endif
print*,'End of read_xml'
return
end