Previous Thread
Next Thread
Print Thread
Page 1 of 2 1 2
passing variables or file names from bash script to charmm
#37048 07/17/18 11:33 AM
Joined: Oct 2017
Posts: 42
R
Rohit Offline OP
Forum Member
OP Offline
Forum Member
R
Joined: Oct 2017
Posts: 42
Hi,

I wanted to know if there is any other way of passing variables to charmm from bash script. below script does not work.

Code:
fdcd="../output/0/unfold_1le0.job0.0.sort.dcd"
export $fdcd
charmm < recenter_orient.inp

I want to use filepath stored in fdcd in charmm.

I am having 48 dcd in different directories. directories are named as 0 to 47.
right now i have created a loop in charmm to read different dcds but i am unable to store different log file for each dcd recenter. so wanted to put loop in bash and run charmm 48 times instead of putting loop in charmm script which ends up creating single log file.

thank-you
Rohit

Re: passing variables or file names from bash script to charmm
Rohit #37050 07/17/18 03:14 PM
Joined: Sep 2003
Posts: 8,499
rmv Online Content
Forum Member
Online Content
Forum Member
Joined: Sep 2003
Posts: 8,499
You've omitted how you've referenced the env var in the script; you probably need to use e.g.

open read file unit 101 name "$fdcd"


Rick Venable
computational chemist

Re: passing variables or file names from bash script to charmm
rmv #37056 07/19/18 05:27 AM
Joined: Oct 2017
Posts: 42
R
Rohit Offline OP
Forum Member
OP Offline
Forum Member
R
Joined: Oct 2017
Posts: 42
yes that is how i used it in the script "$fdcd" it doesn't work.

Re: passing variables or file names from bash script to charmm
Rohit #37057 07/19/18 08:53 AM
Joined: Sep 2003
Posts: 4,794
Likes: 2
Forum Member
Online Content
Forum Member
Joined: Sep 2003
Posts: 4,794
Likes: 2
Three alternatives:
1/ keep your current setup with a CHARMM loop and change the output for each part with the CHARMM "OUTU" command

2/ send the filepath to CHARMM as an argument on the command line:
charmm fdcd=../output/ -i recenter-orient.inp, then use it in the script as @fdcd

3/ use export fdcd instead of export $fdcd


Lennart Nilsson
Karolinska Institutet
Stockholm, Sweden
Re: passing variables or file names from bash script to charmm
Rohit #37059 07/19/18 03:03 PM
Joined: Sep 2003
Posts: 8,499
rmv Online Content
Forum Member
Online Content
Forum Member
Joined: Sep 2003
Posts: 8,499
(I missed that dollar sign in the export.)

I often see the one line construct

export fdcd="../output/0/unfold_1le0.job0.0.sort.dcd"


Rick Venable
computational chemist

Re: passing variables or file names from bash script to charmm
rmv #37062 07/20/18 09:05 AM
Joined: Oct 2017
Posts: 42
R
Rohit Offline OP
Forum Member
OP Offline
Forum Member
R
Joined: Oct 2017
Posts: 42
1/ didn't work after adding 3rd line from the end in below code
Code:
set i = 0
label beginloop

!open read unit 51 file name @fdcd
open read unit 51 file name ../output/@i/unfold_1le0.job0.@i.sort.dcd
TRAJECTORY FIRSTU 51 NUNIT 1 IREAD BEGIN 0 STOP 10000000 SKIP 2500
TRAJ READ

!open unit 61 write file name @odcd
open unit 61 write file name ./../anal/recen/@i/unfold_1le0.job0.@i.recen.dcd

! Here you need the same set of image or crystal definitions as were used 
! when the trajectory was created	
crystal define CUBIc  50. 50. 50. 90.0 90.0 90.0
crystal build noper 0

! Image statemnts for those molecules that should be recentered
image byresidue sele all end
 
merge firstu 51 nunit 1 skip 0 output 61 begin 0 stop 10000000 -
  orient recenter sele all end sele segid PRT .and. .not. hydrogen end

outu 63 write file name recenter@i.out

incr i by 1
if @i .lt. 48 then goto beginloop

only single fort.63 output file is created which is attached with this post.

2/ doen't work the path come in all capital letters even after using double quotes

Code:
charmm fdcd="../output/0/unfold_1le0.job0.0.sort.dcd" -i recenter_orient.inp > recenter_orient.out

error 1 try 1
FDCD -> "../OUTPUT/0/UNFOLD_1LE0.JOB0.0.SORT.DCD"

try 2
open read unit 51 file name "@fdcd"
  * WARNING * <PARSUB> Command ignored. Token not found: >fdcd<



3/ export doesn't pass fdcd variable/parameter.

try 1
Code:
CHARMM>    open read unit 51 file name @fdcd
 CHARMM>     
  * WARNING * <PARSUB> Command ignored. Token not found: >FDCD<

      ***** LEVEL  0 WARNING FROM <PARSE1> *****
      ***** Error in parameter substitution.
      ******************************************


try2
Code:
CHARMM>    open read unit 51 file name "@fdcd"
      ***** LEVEL  0 WARNING FROM <PARSE1> *****
      ***** Error in parameter substitution.

Attached Files
fort.63.txt (303.69 KB, 186 downloads)
Re: passing variables or file names from bash script to charmm
Rohit #37064 07/20/18 09:45 AM
Joined: Sep 2003
Posts: 4,794
Likes: 2
Forum Member
Online Content
Forum Member
Joined: Sep 2003
Posts: 4,794
Likes: 2
1/ This is what you should do:
open unit 63 write form recenter@i.out
outu 63

2/ Works for me, but skip the double quotes.

3/ To access an environment variable you use $fdcd in the CHARMM script


Lennart Nilsson
Karolinska Institutet
Stockholm, Sweden
Re: passing variables or file names from bash script to charmm
Rohit #37065 07/20/18 10:43 AM
Joined: Oct 2017
Posts: 42
R
Rohit Offline OP
Forum Member
OP Offline
Forum Member
R
Joined: Oct 2017
Posts: 42
3/ passing env var $fdcd = path to charmm

CHARMM> open read unit 51 file name $"fdcd"
VOPEN> Attempting to open::../output/0/unfold_1le0.job0.0.sort.dcd/::
OPNLGU> Unit 51 cannot be opened as $fdcd

Re: passing variables or file names from bash script to charmm
Rohit #37067 07/20/18 02:57 PM
Joined: Sep 2003
Posts: 8,499
rmv Online Content
Forum Member
Online Content
Forum Member
Joined: Sep 2003
Posts: 8,499
It probably should be "$fdcd" not $"fdcd"

I've always used all upper case for env vars, e.g. FDCD, and it seems to work for me.


Rick Venable
computational chemist

Re: passing variables or file names from bash script to charmm
Rohit #37069 07/20/18 08:04 PM
Joined: Sep 2003
Posts: 4,794
Likes: 2
Forum Member
Online Content
Forum Member
Joined: Sep 2003
Posts: 4,794
Likes: 2
It seems that the file ../output/0/unfold_1le0.job0.0.sort.dcd does not exist, or is not accessible.


Lennart Nilsson
Karolinska Institutet
Stockholm, Sweden
Page 1 of 2 1 2

Moderated by  lennart, rmv 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 5.6.33-0+deb8u1 Page Time: 0.017s Queries: 36 (0.008s) Memory: 0.9876 MB (Peak: 1.1238 MB) Data Comp: Off Server Time: 2020-09-30 21:54:41 UTC
Valid HTML 5 and Valid CSS