Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filepath handling #208

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/dfp200.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2110,12 +2110,12 @@ subroutine hessian3D_dFFdRZ(lvol, idof, innout, issym, irz, ii, dBB, XX, YY, len
!write(ounit,1000) 'values are:' Mvol, efcol1mn(1:mn)
!write(90,1000) efcol1mn(1:mn)
!1000 format(" "10x" "es23.15" ")
!open(nm1unit, file="."//trim(ext)//".GF.hcol1", status="unknown", form="unformatted")
!open(nm1unit, file=trim(hidden_ext)//".GF.hcol1", status="unknown", form="unformatted")
!write(nm1unit) NGdof, Mvol
!write(nm1unit) efcol1mn(1:Ntz)
!close(nm1unit)

!open(nm2unit, file="."//trim(ext)//".GF.hcol2", status="unknown", form="unformatted")
!open(nm2unit, file=trim(hidden_ext)//".GF.hcol2", status="unknown", form="unformatted")
!!write(nm2unit) NGdof, Mvol
!write(nm2unit) efcol2mn(1:Ntz)
!close(nm2unit)
Expand Down
3 changes: 2 additions & 1 deletion src/global.f90
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ module allglobal

!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!

CHARACTER(LEN=1000) :: ext ! extension of input filename, i.e., "G3V01L1Fi.001" for an input file G3V01L1Fi.001.sp
CHARACTER(LEN=1000) :: ext ! extension of input filename, i.e., "path/G3V01L1Fi.001" for an input file path/G3V01L1Fi.001.sp
CHARACTER(LEN=1000) :: hidden_ext ! ext with a "." prefix added to the basename "path/.G3V01L1Fi.001" for an input file path/G3V01L1Fi.001.sp

REAL :: ForceErr !< total force-imbalance
REAL :: Energy !< MHD energy
Expand Down
10 changes: 5 additions & 5 deletions src/hesian.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof )

use cputiming, only : Thesian

use allglobal, only : ncpu, myid, cpus, MPI_COMM_SPEC, ext, &
use allglobal, only : ncpu, myid, cpus, MPI_COMM_SPEC, ext, hidden_ext, &
im, in, &
iRbc, iZbs, iRbs, iZbc, &
dRbc, dZbs, dRbs, dZbc, &
Expand Down Expand Up @@ -260,7 +260,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof )
xx(0,-2:2)= zero ; dRZ = 1.0E-04

write(svol,'(i3.3)')myid
! open(lunit+myid,file="."//trim(ext)//".hessian."//svol,status="unknown")
! open(lunit+myid,file=trim(hidden_ext)//".hessian."//svol,status="unknown")

! lmu(1:Nvol) = mu(1:Nvol) ; lpflux(1:Nvol) = pflux(1:Nvol) ; lhelicity(1:Nvol) = helicity(1:Nvol) ! save original profile information; 20 Jun 14;

Expand Down Expand Up @@ -402,7 +402,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof )
!> <li> The eigenvalues and eigenvectors (if required) are written to the file \c .ext.GF.ev as follows:
!>
!> ```
!> open(hunit,file="."//trim(ext)//".GF.ev",status="unknown",form="unformatted")
!> open(hunit,file=trim(hidden_ext)//".GF.ev",status="unknown",form="unformatted")
!> write(hunit)NGdof,Ldvr,Ldvi ! integers; if only the eigenvalues were computed then Ldvr=Ldvi=1;
!> write(hunit)evalr(1:NGdof) ! reals ; real part of eigenvalues;
!> write(hunit)evali(1:NGdof) ! reals ; imaginary part of eigenvalues;
Expand All @@ -419,7 +419,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof )
if( LHmatrix ) then

if( myid.eq.0 ) then ; cput = GETTIME ; write(ounit,'("hesian : ",f10.2," : LHmatrix="L2" ;")')cput-cpus, LHmatrix ;
open(munit, file="."//trim(ext)//".GF.ma", status="unknown", form="unformatted")
open(munit, file=trim(hidden_ext)//".GF.ma", status="unknown", form="unformatted")
write(munit) NGdof
write(munit) ohessian(1:NGdof,1:NGdof)
close(munit)
Expand Down Expand Up @@ -574,7 +574,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof )


if( myid.eq.0 ) then ! write to file; 04 Dec 14;
open(hunit, file="."//trim(ext)//".GF.ev", status="unknown", form="unformatted")
open(hunit, file=trim(hidden_ext)//".GF.ev", status="unknown", form="unformatted")
write(hunit) NGdof, Ldvr, Ldvi
write(hunit) evalr
write(hunit) evali
Expand Down
12 changes: 6 additions & 6 deletions src/newton.f90
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ subroutine newton( NGdof, position, ihybrd )

use cputiming, only : Tnewton

use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, &
use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, hidden_ext, &
NOTstellsym, &
ForceErr, Energy, &
mn, im, in, iRbc, iZbs, iRbs, iZbc, Mvol, &
Expand Down Expand Up @@ -313,7 +313,7 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian )

use cputiming, only : Tnewton

use allglobal, only : myid, cpus, MPI_COMM_SPEC, ext, &
use allglobal, only : myid, cpus, MPI_COMM_SPEC, ext, hidden_ext, &
mn, im, in, hessian, Lhessianallocated

LOCALS
Expand All @@ -336,7 +336,7 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian )
! reset I/O state
ios = 0

open( dunit, file="."//trim(ext)//".sp.DF", status="replace", form="unformatted", iostat=ios ) ! save derivative matrix to file;
open( dunit, file=trim(hidden_ext)//".sp.DF", status="replace", form="unformatted", iostat=ios ) ! save derivative matrix to file;
FATAL( newton, ios.ne.0, error opening derivative matrix file )

write( dunit, iostat=ios ) Igeometry, Istellsym, Lfreebound, Nvol, Mpol, Ntor, NGdof ! enable resolution consistency check;
Expand All @@ -352,11 +352,11 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian )

cput = GETTIME

inquire( file="."//trim(ext)//".sp.DF", exist=exist ) ! the derivative matrix;
inquire( file=trim(hidden_ext)//".sp.DF", exist=exist ) ! the derivative matrix;

if( exist ) then ! 01234567890123456789012345678901
write(ounit,2000) cput-cpus, myid, "reading .ext.sp.DF ; "
open( dunit, file="."//trim(ext)//".sp.DF", status="old", form="unformatted", iostat=ios )
open( dunit, file=trim(hidden_ext)//".sp.DF", status="old", form="unformatted", iostat=ios )
else ! 01234567890123456789012345678901
write(ounit,2000) cput-cpus, myid, ".ext.sp.DF does not exist ; "
inquire( file=".sp.DF", exist=exist ) ! the derivative matrix;
Expand Down Expand Up @@ -442,7 +442,7 @@ subroutine fcn1( NGdof, xx, fvec, irevcm )

use cputiming, only : Tnewton

use allglobal, only : wrtend, myid, ncpu, cpus, MPI_COMM_SPEC, ext, &
use allglobal, only : wrtend, myid, ncpu, cpus, MPI_COMM_SPEC, ext, hidden_ext, &
NOTstellsym, &
ForceErr, Energy, &
mn, im, in, iRbc, iZbs, iRbs, iZbc, Mvol, &
Expand Down
4 changes: 2 additions & 2 deletions src/pp00aa.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
!>
!>~~~~~~~~~~~~
!> write(svol,'(i4.4)')lvol ! lvol labels volume;
!> open(lunit+myid,file="."//trim(ext)//".poincare."//svol,status="unknown",form="unformatted")
!> open(lunit+myid,file=trim(hidden_ext)//".poincare."//svol,status="unknown",form="unformatted")
!> do until end of file
!> write(lunit+myid) Nz, nPpts ! integers
!> write(lunit+myid) data(1:4,0:Nz-1,1:nPpts) ! doubles
Expand Down Expand Up @@ -55,7 +55,7 @@
!> <li> The rotational-transform data is written to \c .ext.transform:xxxx , where \c xxxx is an integer indicating the volume.
!> The format of this file is as follows:
!> ```
!> open(lunit+myid,file="."//trim(ext)//".sp.t."//svol,status="unknown",form="unformatted")
!> open(lunit+myid,file=trim(hidden_ext)//".sp.t."//svol,status="unknown",form="unformatted")
!> write(lunit+myid) lnPtrj-ioff+1 ! integer
!> write(lunit+myid) diotadxup(0:1,0,lvol) ! doubles
!> write(lunit+myid) ( fiota(itrj,1:2), itrj = ioff, lnPtrj ) ! doubles
Expand Down
8 changes: 4 additions & 4 deletions src/ra00aa.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
!> <ul>
!> <li> The format of the files containing the vector potential is as follows:
!> ```
!> open(aunit, file="."//trim(ext)//".sp.A", status="replace", form="unformatted" )
!> open(aunit, file=trim(hidden_ext)//".sp.A", status="replace", form="unformatted" )
!> write(aunit) Mvol, Mpol, Ntor, mn, Nfp ! integers;
!> write(aunit) im(1:mn) ! integers; poloidal modes;
!> write(aunit) in(1:mn) ! integers; toroidal modes;
Expand Down Expand Up @@ -57,7 +57,7 @@ subroutine ra00aa( writeorread )

use cputiming, only : Tra00aa

use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, Mvol, mn, im, in, Ate, Aze, Ato, Azo
use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, hidden_ext, Mvol, mn, im, in, Ate, Aze, Ato, Azo

use sphdf5, only : write_vector_potential

Expand Down Expand Up @@ -148,12 +148,12 @@ subroutine ra00aa( writeorread )

if( myid.eq.0 ) then

inquire(file="."//trim(ext)//".sp.A",exist=exist)
inquire(file=trim(hidden_ext)//".sp.A",exist=exist)

if( .not.exist ) then ; write(ounit,'("ra00aa : ",f10.2," : myid=",i3," ; error ; .ext.sp.A does not exist ;")') cput-cpus, myid ; goto 9998
endif

open(aunit,file="."//trim(ext)//".sp.A",status="old",form="unformatted",iostat=ios) ! this will contain initial guess for vector potential;
open(aunit,file=trim(hidden_ext)//".sp.A",status="old",form="unformatted",iostat=ios) ! this will contain initial guess for vector potential;

if( ios.ne.0 ) then ; write(ounit,'("ra00aa : ",f10.2," : myid=",i3," ; error ; opening .ext.sp.A ;")') cput-cpus, myid ; goto 9997
endif
Expand Down
14 changes: 12 additions & 2 deletions src/xspech.f90
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ subroutine read_command_args

use fileunits, only: ounit
use inputlist, only: Wreadin
use allglobal, only: cpus, myid, ext, MPI_COMM_SPEC, write_spec_namelist
use allglobal, only: cpus, myid, ext, hidden_ext, MPI_COMM_SPEC, write_spec_namelist

LOCALS

LOGICAL :: Lspexist
INTEGER :: iargc, iarg, numargs, extlen, sppos
INTEGER :: iargc, iarg, numargs, extlen, sppos, basename_start_index

CHARACTER(len=100) :: arg

Expand Down Expand Up @@ -243,6 +243,16 @@ subroutine read_command_args
endif
ext = trim(arg)

! Prepare the "hidden" ext filepath that has a "." prefix.
! Split ext into directory path and basename using INDEX function, then concatenate them again with a "." inbetween
#ifdef _WIN32
basename_start_index = INDEX(ext, '\', .TRUE.)
#else
basename_start_index = INDEX(ext, '/', .TRUE.)
#endif
! folder + . + filename
hidden_ext = trim(ext(1:basename_start_index))//"."//trim(ext(basename_start_index+1:))

write(ounit,'("rdcmdl : ", 10x ," : ")')
write(ounit,'("rdcmdl : ",f10.2," : ext = ",a100)') cput-cpus, ext
end select
Expand Down
Loading