diff --git a/src/dfp200.f90 b/src/dfp200.f90
index 2015b3b6..7c73253c 100644
--- a/src/dfp200.f90
+++ b/src/dfp200.f90
@@ -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)
diff --git a/src/global.f90 b/src/global.f90
index 1429473f..503963c8 100644
--- a/src/global.f90
+++ b/src/global.f90
@@ -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
diff --git a/src/hesian.f90 b/src/hesian.f90
index 2ea18d90..dd49506f 100644
--- a/src/hesian.f90
+++ b/src/hesian.f90
@@ -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, &
@@ -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;
@@ -402,7 +402,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof )
!>
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;
@@ -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)
@@ -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
diff --git a/src/newton.f90 b/src/newton.f90
index 7bd26216..77573670 100644
--- a/src/newton.f90
+++ b/src/newton.f90
@@ -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, &
@@ -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
@@ -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;
@@ -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;
@@ -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, &
diff --git a/src/pp00aa.f90 b/src/pp00aa.f90
index dc91ff31..6c0fb2f2 100644
--- a/src/pp00aa.f90
+++ b/src/pp00aa.f90
@@ -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
@@ -55,7 +55,7 @@
!> 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
diff --git a/src/ra00aa.f90 b/src/ra00aa.f90
index 81553e76..15ccaf82 100644
--- a/src/ra00aa.f90
+++ b/src/ra00aa.f90
@@ -24,7 +24,7 @@
!>
!> - 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;
@@ -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
@@ -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
diff --git a/src/xspech.f90 b/src/xspech.f90
index 0ceb417c..26f0e1ee 100644
--- a/src/xspech.f90
+++ b/src/xspech.f90
@@ -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
@@ -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